Revision: 21141
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21141
Author:   blendix
Date:     2009-06-24 23:27:10 +0200 (Wed, 24 Jun 2009)

Log Message:
-----------
2.5: File Selector: display operator properties in the side region,
check Save Image or Export PLY operator for example.

Also these code changes:

* Added some RNA collection iterator macros to simplify code.
* Fix bpy.props.BoolProperty not working correct.
* Merge uiDefAutoButsRNA/uiDefAutoButsRNA_single into one.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
    branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_define.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_operator_wrap.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: 
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h   
2009-06-24 21:03:37 UTC (rev 21140)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h   
2009-06-24 21:27:10 UTC (rev 21141)
@@ -417,7 +417,7 @@
 void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, 
struct rctf *butr, int event);
 
 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct 
PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int 
y2);
-void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct 
PointerRNA *ptr);
+void uiDefAutoButsRNA(const struct bContext *C, uiLayout *layout, struct 
PointerRNA *ptr, int columns);
 
 /* Links
  *

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-06-24 21:03:37 UTC (rev 21140)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-06-24 21:27:10 UTC (rev 21141)
@@ -1336,20 +1336,14 @@
 
 static void ui_rna_ID_collection(bContext *C, uiBut *but, PointerRNA *ptr, 
PropertyRNA **prop)
 {
-       CollectionPropertyIterator iter;
-       PropertyRNA *iterprop, *iprop;
        StructRNA *srna;
 
        /* look for collection property in Main */
        RNA_pointer_create(NULL, &RNA_Main, CTX_data_main(C), ptr);
 
-       iterprop= RNA_struct_iterator_property(ptr->type);
-       RNA_property_collection_begin(ptr, iterprop, &iter);
        *prop= NULL;
 
-       for(; iter.valid; RNA_property_collection_next(&iter)) {
-               iprop= iter.ptr.data;
-
+       RNA_STRUCT_BEGIN(ptr, iprop) {
                /* if it's a collection and has same pointer type, we've got it 
*/
                if(RNA_property_type(iprop) == PROP_COLLECTION) {
                        srna= RNA_property_pointer_type(ptr, iprop);
@@ -1360,8 +1354,7 @@
                        }
                }
        }
-
-       RNA_property_collection_end(&iter);
+       RNA_STRUCT_END;
 }
 
 /* autocomplete callback for RNA pointers */
@@ -1369,7 +1362,6 @@
 {
        uiBut *but= arg_but;
        AutoComplete *autocpl;
-       CollectionPropertyIterator iter;
        PointerRNA ptr;
        PropertyRNA *prop;
        char *name;
@@ -1381,11 +1373,10 @@
        if(prop==NULL) return;
 
        autocpl= autocomplete_begin(str, ui_get_but_string_max_length(but));
-       RNA_property_collection_begin(&ptr, prop, &iter);
 
        /* loop over items in collection */
-       for(; iter.valid; RNA_property_collection_next(&iter)) {
-               name= RNA_struct_name_get_alloc(&iter.ptr, NULL, 0);
+       RNA_PROP_BEGIN(&ptr, itemptr, prop) {
+               name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
 
                /* test item name */
                if(name) {
@@ -1393,8 +1384,8 @@
                        MEM_freeN(name);
                }
        }
+       RNA_PROP_END;
 
-       RNA_property_collection_end(&iter);
        autocomplete_end(autocpl, str);
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
  2009-06-24 21:03:37 UTC (rev 21140)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
  2009-06-24 21:27:10 UTC (rev 21141)
@@ -1620,7 +1620,7 @@
        scroll= MIN2(scroll, len-items+1);
        scroll= MAX2(scroll, 1);
 
-       RNA_BEGIN(ptr, itemptr, propname) {
+       RNA_PROP_BEGIN(ptr, itemptr, prop) {
                if(i >= scroll && i<scroll+items) {
                        name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
 
@@ -1634,13 +1634,13 @@
                                item->activei= i;
 
                                if(activetype == PROP_POINTER)
-                                       item->selected= (activeptr.data == 
itemptr.data);
+                                       item->selected= (activeptr.data == 
itemptr.data)? i: -1;
                                else if(activetype == PROP_INT)
-                                       item->selected= (activei == i);
+                                       item->selected= (activei == i)? i: -1;
                                else if(activetype == PROP_STRING)
-                                       item->selected= (strcmp(activename, 
name) == 0);
+                                       item->selected= (strcmp(activename, 
name) == 0)? i: -1;
 
-                               but= uiDefIconTextButI(block, TOG, 0, 
RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, 
&item->selected, 0, 0, 0, 0, "");
+                               but= uiDefIconTextButI(block, ROW, 0, 
RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, 
&item->selected, 0, i, 0, 0, "");
                                uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
                                uiButSetNFunc(but, list_item_cb, item, NULL);
 
@@ -1650,7 +1650,7 @@
 
                i++;
        }
-       RNA_END;
+       RNA_PROP_END;
 
        while(i < scroll+items) {
                if(i >= scroll)

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c  
    2009-06-24 21:03:37 UTC (rev 21140)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c  
    2009-06-24 21:27:10 UTC (rev 21141)
@@ -142,69 +142,39 @@
        return but;
 }
 
-void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr)
+void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, 
int columns)
 {
-       CollectionPropertyIterator iter;
-       PropertyRNA *iterprop, *prop;
-       uiLayout *split;
+       uiLayout *split, *col;
        char *name;
 
        uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
 
-       iterprop= RNA_struct_iterator_property(ptr->type);
-       RNA_property_collection_begin(ptr, iterprop, &iter);
-
-       for(; iter.valid; RNA_property_collection_next(&iter)) {
-               prop= iter.ptr.data;
-
+       RNA_STRUCT_BEGIN(ptr, prop) {
                if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
                        continue;
 
-               split = uiLayoutSplit(layout, 0.5f);
-
                name= (char*)RNA_property_ui_name(prop);
 
-               uiItemL(uiLayoutColumn(split, 0), name, 0);
-               uiItemFullR(uiLayoutColumn(split, 0), "", 0, ptr, prop, -1, 0, 
0, 0, 0);
-       }
+               if(columns == 1) {
+                       col= uiLayoutColumn(layout, 1);
+                       uiItemL(col, name, 0);
+               }
+               else if(columns == 2) {
+                       split = uiLayoutSplit(layout, 0.5f);
 
-       RNA_property_collection_end(&iter);
-}
+                       uiItemL(uiLayoutColumn(split, 0), name, 0);
+                       col= uiLayoutColumn(split, 0);
+               }
 
-/* temp call, single collumn, test for toolbar only */
-void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA 
*ptr)
-{
-       CollectionPropertyIterator iter;
-       PropertyRNA *iterprop, *prop;
-       uiLayout *col;
-       char *name;
-       
-       uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
-       
-       iterprop= RNA_struct_iterator_property(ptr->type);
-       RNA_property_collection_begin(ptr, iterprop, &iter);
-       
-       for(; iter.valid; RNA_property_collection_next(&iter)) {
-               prop= iter.ptr.data;
-               
-               if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
-                       continue;
-               
-               name= (char*)RNA_property_ui_name(prop);
-               col= uiLayoutColumn(layout, 1);
-               uiItemL(col, name, 0);
-               
                /* temp hack to show normal button for spin/screw */
                if(strcmp(name, "Axis")==0) {
-                       uiDefButR(uiLayoutGetBlock(layout), BUT_NORMAL, 0, 
name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
+                       uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 
0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
                }
                else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0);
        }
-       
-       RNA_property_collection_end(&iter);
+       RNA_STRUCT_END;
 }
 
-
 /***************************** ID Utilities *******************************/
 /* note, C code version, will be replaced with version in 
interface_templates.c */
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c   
2009-06-24 21:03:37 UTC (rev 21140)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c   
2009-06-24 21:27:10 UTC (rev 21141)
@@ -550,8 +550,25 @@
        }
 }
 
-static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, 
FSMenuCategory category, const char* category_name, short *starty)
+static void file_draw_fsmenu_category_name(ARegion *ar, const char 
*category_name, short *starty)
 {
+       short sx, sy;
+       int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X - 
ICON_DEFAULT_WIDTH - 4;
+       int fontsize = file_font_pointsize();
+
+       sx = ar->v2d.cur.xmin + TILE_BORDER_X;
+       sy = *starty;
+
+       UI_ThemeColor(TH_TEXT_HI);
+       file_draw_string(sx, sy, category_name, bmwidth, fontsize, 
FILE_SHORTEN_END);
+       
+       sy -= fontsize*2.0f;
+
+       *starty= sy;
+}
+
+static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, 
FSMenuCategory category, short *starty)
+{
        struct FSMenu* fsmenu = fsmenu_get();
        char bookmark[FILE_MAX];
        int nentries = fsmenu_get_nentries(fsmenu, category);
@@ -565,11 +582,6 @@
        sx = ar->v2d.cur.xmin + TILE_BORDER_X;
        sy = *starty;
 
-       UI_ThemeColor(TH_TEXT_HI);
-       file_draw_string(sx, sy, category_name, bmwidth, fontsize, 
FILE_SHORTEN_END);
-       
-       sy -= fontsize*2.0f;
-
        switch(category) {
                case FS_CATEGORY_SYSTEM:
                        cat_icon = ICON_DISK_DRIVE; break;
@@ -616,15 +628,54 @@
        *starty = sy;
 }
 
+void file_draw_fsmenu_operator(const bContext *C, ARegion *ar, wmOperator *op, 
short *starty)
+{
+       uiStyle *style= U.uistyles.first;
+       uiBlock *block;
+       uiLayout *layout;
+       int sy;
+
+       sy= *starty;
+       
+       block= uiBeginBlock(C, ar, "file_options", UI_EMBOSS);
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 
TILE_BORDER_X, sy, ar->winx-2*TILE_BORDER_X, 20, style);
+
+    RNA_STRUCT_BEGIN(op->ptr, prop) {
+        if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
+            continue;
+        if(strcmp(RNA_property_identifier(prop), "filename") == 0)
+            continue;
+
+        uiItemFullR(layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
+    }
+    RNA_STRUCT_END;
+
+       uiBlockLayoutResolve(C, block, NULL, &sy);
+       uiEndBlock(C, block);
+       uiDrawBlock(C, block);
+
+       *starty= sy;
+}
+
 void file_draw_fsmenu(const bContext *C, ARegion *ar)
 {
+       SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
        int linestep = file_font_pointsize()*2.0f;
        short sy= ar->v2d.cur.ymax-2*TILE_BORDER_Y;
 
-       file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, "SYSTEM", &sy);
+       file_draw_fsmenu_category_name(ar, "SYSTEM", &sy);
+       file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, &sy);
        sy -= linestep;
-       file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, "BOOKMARKS", 
&sy);
+       file_draw_fsmenu_category_name(ar, "BOOKMARKS", &sy);
+       file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, &sy);
        sy -= linestep;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to