[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20912] branches/blender2.5/blender: 2.5: Text editor, port menu code to python.
Brecht Van Lommel
brecht at blender.org
Tue Jun 16 03:10:48 CEST 2009
Revision: 20912
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20912
Author: blendix
Date: 2009-06-16 03:10:47 +0200 (Tue, 16 Jun 2009)
Log Message:
-----------
2.5: Text editor, port menu code to python.
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/space_text.py
branches/blender2.5/blender/source/blender/editors/space_text/space_text.c
branches/blender2.5/blender/source/blender/editors/space_text/text_header.c
branches/blender2.5/blender/source/blender/editors/space_text/text_intern.h
Modified: branches/blender2.5/blender/release/ui/space_text.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_text.py 2009-06-16 01:08:39 UTC (rev 20911)
+++ branches/blender2.5/blender/release/ui/space_text.py 2009-06-16 01:10:47 UTC (rev 20912)
@@ -2,12 +2,8 @@
import bpy
# temporary
-ICON_LINENUMBERS_OFF = 588
-ICON_WORDWRAP_OFF = 584
-ICON_SYNTAX_OFF = 586
ICON_TEXT = 120
ICON_HELP = 1
-ICON_SCRIPTPLUGINS = 1
class TEXT_HT_header(bpy.types.Header):
__space_type__ = "TEXT_EDITOR"
@@ -21,7 +17,7 @@
layout.template_header(context)
if context.area.show_menus:
- row = layout.row(align=True)
+ row = layout.row()
row.itemM(context, "TEXT_MT_text")
if text:
row.itemM(context, "TEXT_MT_edit")
@@ -33,10 +29,9 @@
row.itemO("TEXT_OT_resolve_conflict", text="", icon='ICON_HELP')
row = layout.row(align=True)
- row.itemR(st, "line_numbers", text="", icon='ICON_LINENUMBERS_OFF')
- row.itemR(st, "word_wrap", text="", icon='ICON_WORDWRAP_OFF')
- row.itemR(st, "syntax_highlight", text="", icon='ICON_SYNTAX_OFF')
- # row.itemR(st, "do_python_plugins", text="", icon=ICON_SCRIPTPLUGINS)
+ row.itemR(st, "line_numbers", text="")
+ row.itemR(st, "word_wrap", text="")
+ row.itemR(st, "syntax_highlight", text="")
layout.template_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
@@ -63,9 +58,9 @@
layout = self.layout
flow = layout.column_flow()
- flow.itemR(st, "line_numbers", icon='ICON_LINENUMBERS_OFF')
- flow.itemR(st, "word_wrap", icon='ICON_WORDWRAP_OFF')
- flow.itemR(st, "syntax_highlight", icon='ICON_SYNTAX_OFF')
+ flow.itemR(st, "line_numbers")
+ flow.itemR(st, "word_wrap")
+ flow.itemR(st, "syntax_highlight")
flow.itemR(st, "live_edit")
flow = layout.column_flow()
@@ -140,8 +135,109 @@
# XXX uiDefIconTextBlockBut(block, text_plugin_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Text Plugins", 0, yco-=20, 120, 19, "");
#endif
+class TEXT_MT_edit_view(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "View"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_enumO("TEXT_OT_move", "type", "FILE_TOP", text="Top of File")
+ layout.item_enumO("TEXT_OT_move", "type", "FILE_BOTTOM", text="Bottom of File")
+
+class TEXT_MT_edit_select(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "Select"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("TEXT_OT_select_all")
+ layout.itemO("TEXT_OT_select_line")
+
+class TEXT_MT_edit_markers(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "Markers"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("TEXT_OT_markers_clear")
+ layout.itemO("TEXT_OT_next_marker")
+ layout.itemO("TEXT_OT_previous_marker")
+
+class TEXT_MT_format(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "Format"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("TEXT_OT_indent")
+ layout.itemO("TEXT_OT_unindent")
+
+ layout.itemS()
+
+ layout.itemO("TEXT_OT_comment")
+ layout.itemO("TEXT_OT_uncomment")
+
+ layout.itemS()
+
+ layout.item_menu_enumO("TEXT_OT_convert_whitespace", "type")
+
+class TEXT_MT_edit_to3d(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "Text To 3D Object"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_booleanO("TEXT_OT_to_3d_object", "split_lines", False, text="One Object");
+ layout.item_booleanO("TEXT_OT_to_3d_object", "split_lines", True, text="One Object Per Line");
+
+class TEXT_MT_edit(bpy.types.Menu):
+ __space_type__ = "TEXT_EDITOR"
+ __label__ = "Edit"
+
+ def poll(self, context):
+ st = context.space_data
+ return st.text != None
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("ED_OT_undo")
+ layout.itemO("ED_OT_redo")
+
+ layout.itemS()
+
+ layout.itemO("TEXT_OT_cut")
+ layout.itemO("TEXT_OT_copy")
+ layout.itemO("TEXT_OT_paste")
+
+ layout.itemS()
+
+ layout.itemM(context, "TEXT_MT_edit_view")
+ layout.itemM(context, "TEXT_MT_edit_select")
+ layout.itemM(context, "TEXT_MT_edit_markers")
+
+ layout.itemS()
+
+ layout.itemO("TEXT_OT_jump")
+ layout.itemO("TEXT_OT_properties")
+
+ layout.itemS()
+
+ layout.itemM(context, "TEXT_MT_edit_to3d")
+
bpy.types.register(TEXT_HT_header)
bpy.types.register(TEXT_PT_properties)
bpy.types.register(TEXT_PT_find)
bpy.types.register(TEXT_MT_text)
+bpy.types.register(TEXT_MT_format)
+bpy.types.register(TEXT_MT_edit)
+bpy.types.register(TEXT_MT_edit_view)
+bpy.types.register(TEXT_MT_edit_select)
+bpy.types.register(TEXT_MT_edit_markers)
+bpy.types.register(TEXT_MT_edit_to3d)
Modified: branches/blender2.5/blender/source/blender/editors/space_text/space_text.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_text/space_text.c 2009-06-16 01:08:39 UTC (rev 20911)
+++ branches/blender2.5/blender/source/blender/editors/space_text/space_text.c 2009-06-16 01:10:47 UTC (rev 20912)
@@ -415,8 +415,6 @@
art->init= text_header_area_init;
art->draw= text_header_area_draw;
-
- text_header_register(art);
BLI_addhead(&st->regiontypes, art);
Modified: branches/blender2.5/blender/source/blender/editors/space_text/text_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_text/text_header.c 2009-06-16 01:08:39 UTC (rev 20911)
+++ branches/blender2.5/blender/source/blender/editors/space_text/text_header.c 2009-06-16 01:10:47 UTC (rev 20912)
@@ -155,101 +155,6 @@
}
#endif
-static void text_editmenu_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
- uiItemEnumO(layout, "Top of File", 0, "TEXT_OT_move", "type", FILE_TOP);
- uiItemEnumO(layout, "Bottom of File", 0, "TEXT_OT_move", "type", FILE_BOTTOM);
-}
-
-static void text_editmenu_selectmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
- uiItemO(layout, NULL, 0, "TEXT_OT_select_all");
- uiItemO(layout, NULL, 0, "TEXT_OT_select_line");
-}
-
-static void text_editmenu_markermenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
- uiItemO(layout, NULL, 0, "TEXT_OT_markers_clear");
- uiItemO(layout, NULL, 0, "TEXT_OT_next_marker");
- uiItemO(layout, NULL, 0, "TEXT_OT_previous_marker");
-}
-
-static void text_formatmenu(const bContext *C, Menu *menu)
-{
- uiLayout *layout= menu->layout;
-
- uiItemO(layout, NULL, 0, "TEXT_OT_indent");
- uiItemO(layout, NULL, 0, "TEXT_OT_unindent");
-
- uiItemS(layout);
-
- uiItemO(layout, NULL, 0, "TEXT_OT_comment");
- uiItemO(layout, NULL, 0, "TEXT_OT_uncomment");
-
- uiItemS(layout);
-
- uiItemMenuEnumO(layout, NULL, 0, "TEXT_OT_convert_whitespace", "type");
-}
-
-static void text_editmenu_to3dmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
- uiItemBooleanO(layout, "One Object", 0, "TEXT_OT_to_3d_object", "split_lines", 0);
- uiItemBooleanO(layout, "One Object Per Line", 0, "TEXT_OT_to_3d_object", "split_lines", 1);
-}
-
-static int text_menu_edit_poll(bContext *C)
-{
- return (CTX_data_edit_text(C) != NULL);
-}
-
-static void text_editmenu(const bContext *C, Menu *menu)
-{
- uiLayout *layout= menu->layout;
-
- uiItemO(layout, NULL, 0, "ED_OT_undo");
- uiItemO(layout, NULL, 0, "ED_OT_redo");
-
- uiItemS(layout);
-
- uiItemO(layout, NULL, 0, "TEXT_OT_cut");
- uiItemO(layout, NULL, 0, "TEXT_OT_copy");
- uiItemO(layout, NULL, 0, "TEXT_OT_paste");
-
- uiItemS(layout);
-
- uiItemMenuF(layout, "View", 0, text_editmenu_viewmenu);
- uiItemMenuF(layout, "Select", 0, text_editmenu_selectmenu);
- uiItemMenuF(layout, "Markers", 0, text_editmenu_markermenu);
-
- uiItemS(layout);
-
- uiItemO(layout, NULL, 0, "TEXT_OT_jump");
- uiItemO(layout, NULL, 0, "TEXT_OT_properties");
-
- uiItemS(layout);
-
- uiItemMenuF(layout, "Text to 3D Object", 0, text_editmenu_to3dmenu);
-}
-
-/********************** header buttons ***********************/
-
-void text_header_register(ARegionType *art)
-{
- MenuType *mt;
-
- mt= MEM_callocN(sizeof(MenuType), "spacetype text menu edit");
- strcpy(mt->idname, "TEXT_MT_edit");
- strcpy(mt->label, "Edit");
- mt->draw= text_editmenu;
- BLI_addhead(&art->menutypes, mt);
-
- mt= MEM_callocN(sizeof(MenuType), "spacetype text menu format");
- strcpy(mt->idname, "TEXT_MT_format");
- strcpy(mt->label, "Format");
- mt->draw= text_formatmenu;
- BLI_addhead(&art->menutypes, mt);
-}
-
/************************** properties ******************************/
ARegion *text_has_properties_region(ScrArea *sa)
Modified: branches/blender2.5/blender/source/blender/editors/space_text/text_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_text/text_intern.h 2009-06-16 01:08:39 UTC (rev 20911)
+++ branches/blender2.5/blender/source/blender/editors/space_text/text_intern.h 2009-06-16 01:10:47 UTC (rev 20912)
@@ -41,9 +41,6 @@
struct wmOperatorType;
struct wmWindowManager;
-/* text_header.c */
-void text_header_register(struct ARegionType *art);
-
/* text_draw.c */
void draw_text_main(struct SpaceText *st, struct ARegion *ar);
More information about the Bf-blender-cvs
mailing list