Revision: 20911
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20911
Author:   blendix
Date:     2009-06-16 03:08:39 +0200 (Tue, 16 Jun 2009)

Log Message:
-----------
UI

* Added option for panel to be closed by default.
* Added support for RNA property and enum icons in buttons.
* Remove some deprecated RNA menu code.
* Fix issue with newly created panels not being inserted in the
  right place.
* Fix issue with 3-split layout not being divided correctly.
* FIx issue with menu items not drawing correct using python UI.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h
    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_layout.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
    
branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h  
2009-06-16 01:04:17 UTC (rev 20910)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h  
2009-06-16 01:08:39 UTC (rev 20911)
@@ -157,6 +157,8 @@
        int                     space_type;
        int                     region_type;
 
+       int             flag;
+
        /* verify if the panel should draw or not */
        int                     (*poll)(const struct bContext *, struct 
PanelType *);
        /* draw header (optional) */

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-16 01:04:17 UTC (rev 20910)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h   
2009-06-16 01:08:39 UTC (rev 20911)
@@ -491,7 +491,7 @@
 void uiBeginPanels(const struct bContext *C, struct ARegion *ar);
 void uiEndPanels(const struct bContext *C, struct ARegion *ar);
 
-struct Panel *uiBeginPanel(struct ARegion *ar, uiBlock *block, struct 
PanelType *pt, int *open);
+struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock 
*block, struct PanelType *pt, int *open);
 void uiEndPanel(uiBlock *block, int width, int height);
 
 /* Handlers
@@ -539,8 +539,6 @@
 
 uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
 uiBut *uiDefMenuSep(uiBlock *block);
-uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name);
-uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, 
char *propvalue, char *name);
 
 /* Layout
  *

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-06-16 01:04:17 UTC (rev 20910)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c    
2009-06-16 01:08:39 UTC (rev 20911)
@@ -1859,18 +1859,24 @@
                        
                case ICONTOG: 
                case ICONTOGN:
-                       if(but->flag & UI_SELECT) but->iconadd= 1;
-                       else but->iconadd= 0;
+                       if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & 
PROP_ICONS_CONSECUTIVE)) {
+                               if(but->flag & UI_SELECT) but->iconadd= 1;
+                               else but->iconadd= 0;
+                       }
                        break;
                        
                case ICONROW:
-                       value= ui_get_but_val(but);
-                       but->iconadd= (int)value- (int)(but->hardmin);
+                       if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & 
PROP_ICONS_CONSECUTIVE)) {
+                               value= ui_get_but_val(but);
+                               but->iconadd= (int)value- (int)(but->hardmin);
+                       }
                        break;
                        
                case ICONTEXTROW:
-                       value= ui_get_but_val(but);
-                       but->iconadd= (int)value- (int)(but->hardmin);
+                       if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & 
PROP_ICONS_CONSECUTIVE)) {
+                               value= ui_get_but_val(but);
+                               but->iconadd= (int)value- (int)(but->hardmin);
+                       }
                        break;
        }
        
@@ -2267,7 +2273,7 @@
        uiBut *but;
        PropertyRNA *prop;
        PropertyType proptype;
-       int freestr= 0;
+       int freestr= 0, icon= 0;
 
        prop= RNA_struct_find_property(ptr, propname);
 
@@ -2279,14 +2285,22 @@
                        if(type == MENU && proptype == PROP_ENUM) {
                                const EnumPropertyItem *item;
                                DynStr *dynstr;
-                               int i, totitem;
+                               int i, totitem, value;
 
                                RNA_property_enum_items(ptr, prop, &item, 
&totitem);
+                               value= RNA_property_enum_get(ptr, prop);
 
                                dynstr= BLI_dynstr_new();
                                BLI_dynstr_appendf(dynstr, "%s%%t", 
RNA_property_ui_name(prop));
-                               for(i=0; i<totitem; i++)
-                                       BLI_dynstr_appendf(dynstr, "|%s %%x%d", 
item[i].name, item[i].value);
+                               for(i=0; i<totitem; i++) {
+                                       if(item[i].icon)
+                                               BLI_dynstr_appendf(dynstr, "|%s 
%%i%d %%x%d", item[i].name, item[i].icon, item[i].value);
+                                       else
+                                               BLI_dynstr_appendf(dynstr, "|%s 
%%x%d", item[i].name, item[i].value);
+
+                                       if(value == item[i].value)
+                                               icon= item[i].icon;
+                               }
                                str= BLI_dynstr_get_cstring(dynstr);
                                BLI_dynstr_free(dynstr);
 
@@ -2297,15 +2311,20 @@
                                int i, totitem;
 
                                RNA_property_enum_items(ptr, prop, &item, 
&totitem);
-                               for(i=0; i<totitem; i++)
-                                       if(item[i].value == (int)max)
+                               for(i=0; i<totitem; i++) {
+                                       if(item[i].value == (int)max) {
                                                str= (char*)item[i].name;
+                                               icon= item[i].icon;
+                                       }
+                               }
 
                                if(!str)
                                        str= (char*)RNA_property_ui_name(prop);
                        }
-                       else
+                       else {
                                str= (char*)RNA_property_ui_name(prop);
+                               icon= RNA_property_ui_icon(prop);
+                       }
                }
 
                if(!tip) {
@@ -2384,7 +2403,14 @@
 
                if(type == IDPOIN)
                        uiButSetCompleteFunc(but, ui_rna_ID_autocomplete, but);
+
        }
+
+       if(icon) {
+               but->icon= (BIFIconID)icon;
+               but->flag |= UI_HAS_ICON;
+               but->flag|= UI_ICON_LEFT;
+       }
        
        if (!prop || !RNA_property_editable(&but->rnapoin, prop)) {
                but->flag |= UI_BUT_DISABLED;
@@ -2653,8 +2679,10 @@
 
        but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, 
propname, index, min, max, a1, a2, tip);
        if(but) {
-               but->icon= (BIFIconID) icon;
-               but->flag|= UI_HAS_ICON;
+               if(icon) {
+                       but->icon= (BIFIconID) icon;
+                       but->flag|= UI_HAS_ICON;
+               }
                ui_check_but(but);
        }
 
@@ -2736,8 +2764,10 @@
 
        but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, 
propname, index, min, max, a1, a2, tip);
        if(but) {
-               but->icon= (BIFIconID) icon;
-               but->flag|= UI_HAS_ICON;
+               if(icon) {
+                       but->icon= (BIFIconID) icon;
+                       but->flag|= UI_HAS_ICON;
+               }
                but->flag|= UI_ICON_LEFT;
                ui_check_but(but);
        }
@@ -2779,60 +2809,6 @@
        return uiDefBut(block, SEPR, 0, "", 0, y, MENU_WIDTH, MENU_SEP_HEIGHT, 
NULL, 0.0, 0.0, 0, 0, "");
 }
 
-uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name)
-{
-       int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
-       return uiDefIconTextBlockBut(block, func, NULL, ICON_BLANK1, name, 0, 
y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, "");
-}
-
-uiBut *uiDefMenuTogR(uiBlock *block, PointerRNA *ptr, char *propname, char 
*propvalue, char *name)
-{
-       uiBut *but;
-       PropertyRNA *prop;
-       PropertyType type;
-       const EnumPropertyItem *item;
-       int a, value, totitem, icon= ICON_CHECKBOX_DEHLT;
-       int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
-
-       prop= RNA_struct_find_property(ptr, propname);
-       if(prop) {
-               type= RNA_property_type(prop);
-
-               if(type == PROP_BOOLEAN) {
-                       if(RNA_property_boolean_get(ptr, prop))
-                               icon= ICON_CHECKBOX_HLT;
-
-                       return uiDefIconTextButR(block, TOG, 0, icon, name, 0, 
y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, 0, 0, 0, NULL);
-               }
-               else if(type == PROP_ENUM) {
-                       RNA_property_enum_items(ptr, prop, &item, &totitem);
-
-                       value= 0;
-                       for(a=0; a<totitem; a++) {
-                               if(propvalue && strcmp(propvalue, 
item[a].identifier) == 0) {
-                                       value= item[a].value;
-                                       if(!name)
-                                               name= (char*)item[a].name;
-
-                                       if(RNA_property_enum_get(ptr, prop) == 
value)
-                                               icon= ICON_CHECKBOX_HLT;
-                                       break;
-                               }
-                       }
-
-                       if(a != totitem)
-                               return uiDefIconTextButR(block, ROW, 0, icon, 
name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, value, 0, 0, 
NULL);
-               }
-       }
-
-       /* not found */
-       uiBlockSetButLock(block, 1, "");
-       but= uiDefIconTextBut(block, BUT, 0, ICON_BLANK1, propname, 0, y, 
MENU_WIDTH, MENU_ITEM_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
-       uiBlockClearButLock(block);
-
-       return but;
-} 
-
 /* END Button containing both string label and icon */
 
 void uiSetButLink(uiBut *but, void **poin, void ***ppoin, short *tot, int 
from, int to)

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 
    2009-06-16 01:04:17 UTC (rev 20910)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 
    2009-06-16 01:08:39 UTC (rev 20911)
@@ -427,19 +427,29 @@
        uiBlockSetCurLayout(block, layout);
 }
 
-static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA 
*ptr, PropertyRNA *prop, int x, int y, int w, int h)
+static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA 
*ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h)
 {
        const EnumPropertyItem *item;
-       int a, totitem, itemw;
-       const char *propname;
+       const char *identifier;
+       char *name;
+       int a, totitem, itemw, icon, value;
 
-       propname= RNA_property_identifier(prop);
+       identifier= RNA_property_identifier(prop);
        RNA_property_enum_items(ptr, prop, &item, &totitem);
 
        uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
        for(a=0; a<totitem; a++) {
-               itemw= ui_text_icon_width(block->curlayout, 
(char*)item[a].name, 0);
-               uiDefButR(block, ROW, 0, NULL, 0, 0, itemw, h, ptr, propname, 
-1, 0, item[a].value, -1, -1, NULL);
+               name= (!uiname || uiname[0])? (char*)item[a].name: "";
+               icon= item[a].icon;
+               value= item[a].value;
+               itemw= ui_text_icon_width(block->curlayout, name, icon);
+
+               if(icon && strcmp(name, "") != 0)
+                       uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, 
itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+               else if(icon)
+                       uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, 
identifier, -1, 0, value, -1, -1, NULL);
+               else
+                       uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, 
identifier, -1, 0, value, -1, -1, NULL);
        }
        uiBlockSetCurLayout(block, layout);
 }
@@ -732,6 +742,8 @@
        /* set name and icon */
        if(!name)
                name= (char*)RNA_property_ui_name(prop);
+       if(!icon)
+               icon= RNA_property_ui_icon(prop);
 
        if(ELEM5(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_ENUM, 
PROP_POINTER))
                name= ui_item_name_add_colon(name, namestr);
@@ -764,7 +776,7 @@
        }
        /* expanded enum */
        else if(type == PROP_ENUM && expand)
-               ui_item_enum_row(layout, block, ptr, prop, 0, 0, w, h);
+               ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h);
        /* property with separate label */
        else if(type == PROP_ENUM || type == PROP_STRING || type == 
PROP_POINTER)
                ui_item_with_label(layout, block, name, icon, ptr, prop, index, 
0, 0, w, h);
@@ -858,7 +870,7 @@
        uiBlockSetCurLayout(block, layout);
 
        if(layout->root->type == UI_LAYOUT_HEADER)
-               uiBlockSetEmboss(block, UI_EMBOSSP);
+               uiBlockSetEmboss(block, UI_EMBOSS);
 
        if(!name)
                name= "";
@@ -869,7 +881,7 @@
        h= UI_UNIT_Y;
 
        if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */
-               w -= 3;
+               w -= 10;
 
        if(icon)
                but= uiDefIconTextMenuBut(block, func, arg, icon, (char*)name, 
0, 0, w, h, "");
@@ -1484,6 +1496,7 @@
 {

@@ 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