[Bf-blender-cvs] [42aa190] master: Text3d: add select all operator
Campbell Barton
noreply at git.blender.org
Sun Dec 29 13:57:03 CET 2013
Commit: 42aa19088e02e296b4cc19b7171de2840e111539
Author: Campbell Barton
Date: Sun Dec 29 23:43:19 2013 +1100
https://developer.blender.org/rB42aa19088e02e296b4cc19b7171de2840e111539
Text3d: add select all operator
also add Edit menu for 3d text and move cut/copy/paste there.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/curve/curve_intern.h
M source/blender/editors/curve/curve_ops.c
M source/blender/editors/curve/editfont.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 041accb..4722146 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -51,7 +51,7 @@ class VIEW3D_HT_header(Header):
sub.menu("VIEW3D_MT_select_paint_mask")
elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
sub.menu("VIEW3D_MT_select_paint_mask_vertex")
- elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
+ elif mode_string not in {'SCULPT'}:
sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
if mode_string == 'OBJECT':
@@ -714,6 +714,23 @@ class VIEW3D_MT_select_edit_surface(Menu):
layout.operator("curve.select_less")
+class VIEW3D_MT_select_edit_text(Menu):
+ # intentional name mis-match
+ # select menu for 3d-text doesn't make sense
+ bl_label = "Edit"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("font.text_copy", text="Copy")
+ layout.operator("font.text_cut", text="Cut")
+ layout.operator("font.text_paste", text="Paste")
+
+ layout.separator()
+
+ layout.operator("font.select_all")
+
+
class VIEW3D_MT_select_edit_metaball(Menu):
bl_label = "Select"
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 034ad19..9a56cc5 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -347,12 +347,6 @@ class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
layout = self.layout
col = layout.column(align=True)
- col.label(text="Text Edit:")
- col.operator("font.text_copy", text="Copy")
- col.operator("font.text_cut", text="Cut")
- col.operator("font.text_paste", text="Paste")
-
- col = layout.column(align=True)
col.label(text="Set Case:")
col.operator("font.case_set", text="To Upper").case = 'UPPER'
col.operator("font.case_set", text="To Lower").case = 'LOWER'
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index ecadb57..878e024 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -56,6 +56,8 @@ void FONT_OT_case_set(struct wmOperatorType *ot);
void FONT_OT_style_toggle(struct wmOperatorType *ot);
void FONT_OT_style_set(struct wmOperatorType *ot);
+void FONT_OT_select_all(struct wmOperatorType *ot);
+
void FONT_OT_text_copy(struct wmOperatorType *ot);
void FONT_OT_text_cut(struct wmOperatorType *ot);
void FONT_OT_text_paste(struct wmOperatorType *ot);
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index c2fe879..6186440 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -65,6 +65,8 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(FONT_OT_style_toggle);
WM_operatortype_append(FONT_OT_style_set);
+ WM_operatortype_append(FONT_OT_select_all);
+
WM_operatortype_append(FONT_OT_text_copy);
WM_operatortype_append(FONT_OT_text_cut);
WM_operatortype_append(FONT_OT_text_paste);
@@ -208,6 +210,8 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", UPARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", DOWNARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1);
+ WM_keymap_add_item(keymap, "FONT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0);
+
WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 1ca97da..59075d4 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -675,6 +675,47 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to");
}
+
+/* -------------------------------------------------------------------- */
+/* Select All */
+
+static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
+ Curve *cu = obedit->data;
+
+ if (cu->len) {
+ cu->selstart = 1;
+ cu->selend = cu->len;
+ cu->pos = cu->len;
+
+ text_update_edited(C, scene, obedit, true, FO_SELCHANGE);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+
+}
+
+void FONT_OT_select_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select All";
+ ot->description = "Select all text";
+ ot->idname = "FONT_OT_select_all";
+
+ /* api callbacks */
+ ot->exec = font_select_all_exec;
+ ot->poll = ED_operator_editfont;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
/******************* copy text operator ********************/
static void copy_selection(Object *obedit)
More information about the Bf-blender-cvs
mailing list