2.5 Buttons Window:
authorThomas Dinges <blender@dingto.org>
Sun, 21 Jun 2009 10:26:39 +0000 (10:26 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 21 Jun 2009 10:26:39 +0000 (10:26 +0000)
* WIP Commit: Started wrapping the buttons header to python. Still disabled due to some display problems.

release/ui/space_buttons.py [new file with mode: 0644]
source/blender/editors/space_buttons/space_buttons.c
source/blender/makesrna/intern/rna_space.c

diff --git a/release/ui/space_buttons.py b/release/ui/space_buttons.py
new file mode 100644 (file)
index 0000000..7686304
--- /dev/null
@@ -0,0 +1,36 @@
+
+import bpy
+
+class Buttons_HT_header(bpy.types.Header):
+       __space_type__ = "BUTTONS_WINDOW"
+       __idname__ = "BUTTONS_HT_header"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               so = context.space_data
+               scene = context.scene
+
+               layout.template_header(context)
+
+               if context.area.show_menus:
+                       row = layout.row(align=True)
+                       row.itemM(context, "Buttons_MT_view", text="View")
+                       
+               row = layout.row()
+               row.itemR(so, "buttons_context", expand=True, text="")
+               row.itemR(scene, "current_frame")
+
+class Buttons_MT_view(bpy.types.Menu):
+       __space_type__ = "BUTTONS_WINDOW"
+       __label__ = "View"
+
+       def draw(self, context):
+               layout = self.layout
+               so = context.space_data
+
+               col = layout.column()
+               col.itemR(so, "panel_alignment", expand=True)
+
+bpy.types.register(Buttons_HT_header)
+bpy.types.register(Buttons_MT_view)
\ No newline at end of file
index 38ce88019ed7e332fb75a40de48a8b354c117aac..e5d2215be299dfdffadcdb8c81fa7c4a721069f3 100644 (file)
@@ -220,14 +220,23 @@ void buttons_keymap(struct wmWindowManager *wm)
        
 }
 
+//#define PY_HEADER
 /* add handlers, stuff you only do once or on area/region changes */
 static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
+#ifdef PY_HEADER
+       ED_region_header_init(ar);
+#else
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+#endif
 }
 
 static void buttons_header_area_draw(const bContext *C, ARegion *ar)
 {
+#ifdef PY_HEADER
+       ED_region_header(C, ar);
+#else
+
        float col[3];
        
        /* clear */
@@ -243,7 +252,8 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_ortho(C, &ar->v2d);
        
        buttons_header_buttons(C, ar);
-       
+#endif 
+
        /* restore view matrix? */
        UI_view2d_view_restore(C);
 }
index 41acc458cd95c036017931a4fa57a84a84e8a56e..66d98d98834e06a43f2cf10e9d7b533a024b6b27 100644 (file)
@@ -575,18 +575,17 @@ static void rna_def_space_buttons(BlenderRNA *brna)
        PropertyRNA *prop;
 
        static EnumPropertyItem buttons_context_items[] = {
-               {BCONTEXT_SCENE, "SCENE", 0, "Scene", ""},
-               {BCONTEXT_WORLD, "WORLD", 0, "World", ""},
-               {BCONTEXT_OBJECT, "OBJECT", 0, "Object", ""},
-               {BCONTEXT_DATA, "DATA", 0, "Data", ""},
-               {BCONTEXT_MATERIAL, "MATERIAL", 0, "Material", ""},
-               {BCONTEXT_TEXTURE, "TEXTURE", 0, "Texture", ""},
-               {BCONTEXT_PARTICLE, "PARTICLE", 0, "Particle", ""},
-               {BCONTEXT_PHYSICS, "PHYSICS", 0, "Physics", ""},
-               {BCONTEXT_GAME, "GAME", 0, "Game", ""},
-               {BCONTEXT_BONE, "BONE", 0, "Bone", ""},
-               {BCONTEXT_MODIFIER, "MODIFIER", 0, "Modifier", ""},
-               {BCONTEXT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""},
+               {BCONTEXT_SCENE, "SCENE", ICON_SCENE, "Scene", "Scene"},
+               {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
+               {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
+               {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraint", "Constraint"},
+               {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifier", "Modifier"},
+               {BCONTEXT_DATA, "DATA", 0, "Data", "Data"},
+               {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"},
+               {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
+               {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
+               {BCONTEXT_PARTICLE, "PARTICLE", ICON_PARTICLES, "Particle", "Particle"},
+               {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
                {0, NULL, 0, NULL, NULL}};
                
        static EnumPropertyItem panel_alignment_items[] = {
@@ -602,11 +601,13 @@ static void rna_def_space_buttons(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "mainb");
        RNA_def_property_enum_items(prop, buttons_context_items);
        RNA_def_property_ui_text(prop, "Buttons Context", "The type of active data to display and edit in the buttons window");
+       RNA_def_property_update(prop, NC_WINDOW, NULL);
        
        prop= RNA_def_property(srna, "panel_alignment", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "align");
        RNA_def_property_enum_items(prop, panel_alignment_items);
        RNA_def_property_ui_text(prop, "Panel Alignment", "Arrangement of the panels within the buttons window");
+       RNA_def_property_update(prop, NC_WINDOW, NULL);
 
        /* pinned data */
        prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);