[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20814] branches/soc-2009-kazanbas: Started operator registration with python.

Arystanbek Dyussenov arystan.d at gmail.com
Thu Jun 11 20:15:05 CEST 2009


Revision: 20814
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20814
Author:   kazanbas
Date:     2009-06-11 20:15:04 +0200 (Thu, 11 Jun 2009)

Log Message:
-----------
Started operator registration with python. This is a piece of cake!
Made space_script header area customizable with python - need Brecht to 
check this.
Added a base for operator registration: a menu in Scripts Window with 
two items "Reload Scripts" and "Export". The former will do guess what?
The latter will be populated with submenu items each corresponding to 
an exporter :)

Modified Paths:
--------------
    branches/soc-2009-kazanbas/source/blender/editors/space_script/space_script.c

Added Paths:
-----------
    branches/soc-2009-kazanbas/release/ui/space_script.py

Added: branches/soc-2009-kazanbas/release/ui/space_script.py
===================================================================
--- branches/soc-2009-kazanbas/release/ui/space_script.py	                        (rev 0)
+++ branches/soc-2009-kazanbas/release/ui/space_script.py	2009-06-11 18:15:04 UTC (rev 20814)
@@ -0,0 +1,73 @@
+import bpy
+
+class SCRIPT_HT_header(bpy.types.Header):
+	__space_type__ = "SCRIPTS_WINDOW"
+	__idname__ = "SCRIPT_HT_header"
+
+	def draw(self, context):
+		st = context.space_data
+		layout = self.layout
+
+		layout.template_header(context)
+
+		if context.area.show_menus:
+			row = layout.row(align=True)
+			row.itemM(context, "SCRIPT_MT_scripts")
+
+        # draw menu item to reload scripts from
+        # release/io
+        #
+        # it should call operator or
+        # a func that will:
+        # for each .py file in the dir,
+        # import/reload module, in the module:
+        # find subclasses of bpy.types.Operator,
+        # for each subclass create menus under "Export"
+        # with (row.)itemO
+        #
+        # for interface api documentation, see
+        # see source/blender/editors/interface/interface_api.c
+        #
+        # hint: reloading ui scripts in scripts window is Shift+P
+
+
+class SCRIPT_MT_scripts(bpy.types.Menu):
+    __space_type__ = "SCRIPTS_WINDOW"
+    __label__ = "Scripts"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.column()
+        layout.itemM(context, "SCRIPT_MT_export")
+        layout.itemO("SCRIPT_OT_reload_scripts")
+
+class SCRIPT_MT_export(bpy.types.Menu):
+    __space_type__ = "SCRIPTS_WINDOW"
+    __label__ = "Export"
+
+    def draw(self, context):
+        pass
+
+class SCRIPT_OT_reload_scripts(bpy.types.Operator):
+    __label__ = 'Reload Scripts'
+
+    def exec(self, context):
+        print("SCRIPT_OT_reload_scripts: exec")
+        return 'FINISHED'
+
+    def invoke(self, context, event):
+        print("SCRIPT_OT_reload_scripts: invoke")
+        return self.exec(context)
+
+    def poll(self, context):
+        pass
+
+
+bpy.types.register(SCRIPT_HT_header)
+bpy.types.register(SCRIPT_MT_scripts)
+bpy.types.register(SCRIPT_MT_export)
+
+if (hasattr(bpy.ops, "SCRIPT_OT_reload_scripts")):
+    bpy.ops.remove(bpy.ops.SCRIPT_OT_reload_scripts)
+
+bpy.ops.add(SCRIPT_OT_reload_scripts)

Modified: branches/soc-2009-kazanbas/source/blender/editors/space_script/space_script.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/editors/space_script/space_script.c	2009-06-11 17:21:27 UTC (rev 20813)
+++ branches/soc-2009-kazanbas/source/blender/editors/space_script/space_script.c	2009-06-11 18:15:04 UTC (rev 20814)
@@ -175,29 +175,32 @@
 /* add handlers, stuff you only do once or on area/region changes */
 static void script_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
-	UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+	/* UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); */
+	ED_region_header_init(ar);
 }
 
 static void script_header_area_draw(const bContext *C, ARegion *ar)
 {
-	float col[3];
+	/* float col[3]; */
 	
-	/* clear */
-	if(ED_screen_area_active(C))
-		UI_GetThemeColor3fv(TH_HEADER, col);
-	else
-		UI_GetThemeColor3fv(TH_HEADERDESEL, col);
+	/* /\* clear *\/ */
+	/* if(ED_screen_area_active(C)) */
+	/* 	UI_GetThemeColor3fv(TH_HEADER, col); */
+	/* else */
+	/* 	UI_GetThemeColor3fv(TH_HEADERDESEL, col); */
 	
-	glClearColor(col[0], col[1], col[2], 0.0);
-	glClear(GL_COLOR_BUFFER_BIT);
+	/* glClearColor(col[0], col[1], col[2], 0.0); */
+	/* glClear(GL_COLOR_BUFFER_BIT); */
 	
-	/* set view2d view matrix for scrolling (without scrollers) */
-	UI_view2d_view_ortho(C, &ar->v2d);
+	/* /\* set view2d view matrix for scrolling (without scrollers) *\/ */
+	/* UI_view2d_view_ortho(C, &ar->v2d); */
 	
-	script_header_buttons(C, ar);
+	/* script_header_buttons(C, ar); */
 	
-	/* restore view matrix? */
-	UI_view2d_view_restore(C);
+	/* /\* restore view matrix? *\/ */
+	/* UI_view2d_view_restore(C); */
+
+	ED_region_header(C, ar);
 }
 
 static void script_main_area_listener(ARegion *ar, wmNotifier *wmn)





More information about the Bf-blender-cvs mailing list