2.5:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 11 Jul 2009 13:32:20 +0000 (13:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 11 Jul 2009 13:32:20 +0000 (13:32 +0000)
* Code to start moving 3D view header and panels to python, at
  the moment the View menu and one empty panel is in python. The
  C header code is wrapped in one template, so parts of that can
  be moved over while still keeping things working.
* Fix for mistake in RNA enum commit yesterday, and some warning
  fixes.

release/ui/space_view3d.py [new file with mode: 0644]
source/blender/editors/include/UI_interface.h
source/blender/editors/object/object_edit.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_ui_api.c

diff --git a/release/ui/space_view3d.py b/release/ui/space_view3d.py
new file mode 100644 (file)
index 0000000..c338241
--- /dev/null
@@ -0,0 +1,106 @@
+
+import bpy
+
+class VIEW3D_MT_view_navigation(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Navigation"
+
+       def draw(self, context):
+               layout = self.layout
+
+               # layout.itemO("VIEW3D_OT_view_fly_mode")
+               # layout.itemS()
+               
+               layout.items_enumO("VIEW3D_OT_view_orbit", "type")
+               
+               layout.itemS()
+               
+               layout.items_enumO("VIEW3D_OT_view_pan", "type")
+               
+               layout.itemS()
+               
+               layout.item_floatO("VIEW3D_OT_zoom", "delta", 1.0, text="Zoom In")
+               layout.item_floatO("VIEW3D_OT_zoom", "delta", -1.0, text="Zoom Out")
+
+class VIEW3D_MT_view(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "View"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.itemO("VIEW3D_OT_properties", icon="ICON_MENU_PANEL")
+               layout.itemO("VIEW3D_OT_toolbar", icon="ICON_MENU_PANEL")
+               
+               layout.itemS()
+               
+               layout.item_enumO("VIEW3D_OT_viewnumpad", "type", "CAMERA")
+               layout.item_enumO("VIEW3D_OT_viewnumpad", "type", "TOP")
+               layout.item_enumO("VIEW3D_OT_viewnumpad", "type", "FRONT")
+               layout.item_enumO("VIEW3D_OT_viewnumpad", "type", "RIGHT")
+               
+               # layout.itemM("VIEW3D_MT_view_cameras", text="Cameras")
+               
+               layout.itemS()
+
+               layout.itemO("VIEW3D_OT_view_persportho")
+               
+               layout.itemS()
+               
+               # layout.itemO("VIEW3D_OT_view_show_all_layers")
+               
+               # layout.itemS()
+               
+               # layout.itemO("VIEW3D_OT_view_local_view")
+               # layout.itemO("VIEW3D_OT_view_global_view")
+               
+               # layout.itemS()
+               
+               layout.itemM("VIEW3D_MT_view_navigation")
+               # layout.itemM("VIEW3D_MT_view_align", text="Align View")
+               
+               layout.itemS()
+
+               layout.operator_context = "INVOKE_REGION_WIN"
+
+               layout.itemO("VIEW3D_OT_clip_border")
+               layout.itemO("VIEW3D_OT_zoom_border")
+               
+               layout.itemS()
+               
+               layout.itemO("VIEW3D_OT_view_center")
+               layout.itemO("VIEW3D_OT_view_all")
+               
+               layout.itemS()
+               
+               layout.itemO("SCREEN_OT_screen_full_area")
+
+class VIEW3D_HT_header(bpy.types.Header):
+       __space_type__ = "VIEW_3D"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.template_header()
+
+               # menus
+               if context.area.show_menus:
+                       row = layout.row()
+                       row.itemM("VIEW3D_MT_view")
+
+               layout.template_header_3D()
+
+class VIEW3D_PT_random_panel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "UI"
+       __label__ = "Random Panel"
+
+       def draw(self, context):
+               layout = self.layout
+               layout.itemL(text="panel contents")
+
+bpy.types.register(VIEW3D_MT_view_navigation)
+bpy.types.register(VIEW3D_MT_view)
+bpy.types.register(VIEW3D_HT_header)
+bpy.types.register(VIEW3D_PT_random_panel)
+
index 67438120eeffc3f02068cf2589916153323ac1a2..66089272737d7282a392246c4478aada8d2ef541 100644 (file)
@@ -622,6 +622,7 @@ void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *i
 ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int columns, int compact);
 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
 void uiTemplateOperatorSearch(uiLayout *layout);
+void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
 
 /* items */
 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
index f122412fdd6c14507c6ec93e7b2923673ae0cdbe..e39ed800e0c7f1a455ac51f92458414b70847cb5 100644 (file)
@@ -1757,9 +1757,9 @@ static short select_grouped_group(bContext *C, Object *ob)        /* Select objects in
        short changed = 0;
        Base *base;
        Group *group, *ob_groups[GROUP_MENU_MAX];
-       char str[10 + (24*GROUP_MENU_MAX)];
-       char *p = str;
-       int group_count=0, menu, i;
+       //char str[10 + (24*GROUP_MENU_MAX)];
+       //char *p = str;
+       int group_count=0; //, menu, i;
 
        for (   group=G.main->group.first;
                        group && group_count < GROUP_MENU_MAX;
index 9b6b70eb396d577668db618e9939c055768886b4..718b74e5225b0020333549af69d3382985ff25f8 100644 (file)
@@ -490,30 +490,13 @@ static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
        ListBase *keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
-       
-       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+
+       ED_region_header_init(ar);
 }
 
 static void view3d_header_area_draw(const bContext *C, ARegion *ar)
 {
-       float col[3];
-       
-       /* 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);
-       
-       /* set view2d view matrix for scrolling (without scrollers) */
-       UI_view2d_view_ortho(C, &ar->v2d);
-       
-       view3d_header_buttons(C, ar);
-       
-       /* restore view matrix? */
-       UI_view2d_view_restore(C);
+       ED_region_header(C, ar);
 }
 
 static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn)
index 387c3c7626adc5db8f19dbbda207e0edc135b6d1..e68a1c8a10aaca5e5bee5c3e437ee098f0a5f761 100644 (file)
@@ -636,86 +636,6 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event)
 }
 #endif
 
-static void view3d_view_viewnavmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-//     uiItemO(layout, NULL, 0, "VIEW3D_OT_view_fly_mode");
-       
-//     uiItemS(layout);
-       
-       uiItemsEnumO(layout, "VIEW3D_OT_view_orbit", "type");
-       
-       uiItemS(layout);
-       
-       uiItemsEnumO(layout, "VIEW3D_OT_view_pan", "type");
-       
-       uiItemS(layout);
-       
-       uiItemFloatO(layout, "Zoom in", 0, "VIEW3D_OT_zoom", "delta", 1.0f);
-       uiItemFloatO(layout, "Zoom out", 0, "VIEW3D_OT_zoom", "delta", -1.0f);
-       
-}
-static void view3d_view_alignviewmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       
-}
-
-static void view3d_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       ScrArea *sa= CTX_wm_area(C);
-
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "VIEW3D_OT_properties");
-       uiItemO(layout, NULL, ICON_MENU_PANEL, "VIEW3D_OT_toolbar");
-       
-//     uiItemO(layout, ICON_MENU_PANEL, "VIEW3D_OT_toggle_transform_orientations_panel"); // Transform Orientations...
-//     uiItemO(layout, ICON_MENU_PANEL, "VIEW3D_OT_toggle_render_preview_panel"); // render preview...
-//     uiItemO(layout, ICON_MENU_PANEL, "VIEW3D_OT_toggle_view_properties_panel"); // View Properties....
-//     uiItemO(layout, ICON_MENU_PANEL, "VIEW3D_OT_toggle_background_image_panel"); // Background Image....
-//     uiItemO(layout, ICON_MENU_PANEL, "VIEW3D_OT_toggle_grease_pencil_panel"); // Grease Pencil....
-       
-       uiItemS(layout);
-       
-       uiItemEnumO(layout, NULL, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
-       uiItemEnumO(layout, NULL, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
-       uiItemEnumO(layout, NULL, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
-       uiItemEnumO(layout, NULL, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
-       
-       //uiItemMenuF(layout, "Cameras", view3d_view_camerasmenu);
-       
-       uiItemS(layout);
-
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_view_persportho");
-       
-       uiItemS(layout);
-       
-//     uiItemO(layout, NULL, 0, "VIEW3D_OT_view_show_all_layers");     
-       
-//     uiItemS(layout);
-       
-//     uiItemO(layout, NULL, 0, "VIEW3D_OT_view_local_view");
-//     uiItemO(layout, NULL, 0, "VIEW3D_OT_view_global_view");
-       
-//     uiItemS(layout);
-       
-       uiItemMenuF(layout, "View Navigation", 0, view3d_view_viewnavmenu);
-       uiItemMenuF(layout, "Align View", 0, view3d_view_alignviewmenu);
-       
-       uiItemS(layout);
-
-       uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);    
-
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_clip_border");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_zoom_border");
-       
-       uiItemS(layout);
-       
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_view_center");
-       uiItemO(layout, NULL, 0, "VIEW3D_OT_view_all");
-       
-       uiItemS(layout);
-       
-       if(sa->full) uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
-       else uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
-}
 #if 0
 static uiBlock *view3d_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
 {
@@ -4344,7 +4264,6 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
        RegionView3D *rv3d= wm_region_view3d(C);
        short xmax, xco= *xcoord;
        
-       
        /* compensate for local mode when setting up the viewing menu/iconrow values */
        if(rv3d->view==7) rv3d->viewbut= 1;
        else if(rv3d->view==1) rv3d->viewbut= 2;
@@ -4355,11 +4274,6 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
         * menu is drawn wider than it should be. The ypos of -2 is to make it properly fill the
         * height of the header */
        
-       xmax= GetButStringLength("View");
-       uiDefMenuBut(block, view3d_viewmenu, NULL, "View", xco, yco, xmax-3, 20, "");
-       //uiDefPulldownBut(block, view3d_viewmenu, NULL, "View", xco, yco, xmax-3, 20, "");
-       xco+= xmax;
-       
        xmax= GetButStringLength("Select");
        if (obedit) {
                if (ob && ob->type == OB_MESH) {
@@ -4495,8 +4409,9 @@ static void header_xco_step(ARegion *ar, int *xco, int *yco, int *maxco, int ste
        }
 }
 
-void view3d_header_buttons(const bContext *C, ARegion *ar)
+void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 {
+       ARegion *ar= CTX_wm_region(C);
        ScrArea *sa= CTX_wm_area(C);
        View3D *v3d= sa->spacedata.first;
        Scene *scene= CTX_data_scene(C);
@@ -4506,11 +4421,9 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
        uiBlock *block;
        int a, xco, maxco=0, yco= 3;
        
-       block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
+       block= uiLayoutFreeBlock(layout);
        uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
        
-       xco= ED_area_header_standardbuttons(C, block, yco);
-
        if((sa->flag & HEADER_NO_PULLDOWN)==0) 
                view3d_header_pulldowns(C, block, ob, &xco, yco);
 
index f20df81d6ad3842bfa78f394bf5b247593456b21..d6ca03c85a229ac4c5fcadb82dc6a96833122ff6 100644 (file)
@@ -650,9 +650,10 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En
        if(C && eprop->itemf) {
                *item= eprop->itemf(C, ptr, free);
 
-               if(totitem)
+               if(totitem) {
                        for(tot=0; (*item)[tot].identifier; tot++);
-                               *totitem= tot;
+                       *totitem= tot;
+               }
        }
        else {
                *item= eprop->item;
index 363891e0f24537741ae572f2b5c938382b9ad3b9..404befc9bb284ef67406840cb88b331d23ea5c00 100644 (file)
@@ -273,6 +273,9 @@ void RNA_api_ui_layout(StructRNA *srna)
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 
        func= RNA_def_function(srna, "template_operator_search", "uiTemplateOperatorSearch");
+
+       func= RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D");
+       RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 }
 
 #endif