diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-27 00:00:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-27 00:00:45 +0400 |
commit | f6eed88a7883e07f00949f3952f9214fa70cb996 (patch) | |
tree | d3c2dfd9a007eaabb3e553274e36a9e807ff0d1c /source | |
parent | ebde8a7ccc2b897b8f788fe8fb7266b638d4b22f (diff) |
- changed recent commit from William to have enum in user preferences as an expanded enum (like it was before)
- rename 'no_bg' argument to 'emboss' (and negated)
- added 'emboss' option for operator buttons.
- Addon UI Layout slight modifications, changed enable/disable buttons for checkbox, grey out text of disabled addons to make it obvious at a glance whats enabled.
- column expanded enums now align text to the left.
- renamed ui_item_enum_row to ui_item_enum_expand since its used for columns and rows.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 22 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 15 |
2 files changed, 25 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 35e813b1efc..eb96ca45ff8 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -436,8 +436,9 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon uiBlockSetCurLayout(block, layout); } -static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h, int icon_only) +static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h, int icon_only) { + uiBut *but; EnumPropertyItem *item; const char *identifier; char *name; @@ -457,11 +458,14 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, itemw= ui_text_icon_width(block->curlayout, name, icon, 0); if(icon && strcmp(name, "") != 0 && !icon_only) - uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + but= 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); + but= 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); + but= uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + + if(ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) + but->flag |= UI_TEXT_LEFT; } uiBlockSetCurLayout(block, layout); @@ -609,6 +613,9 @@ PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDP w= ui_text_icon_width(layout, name, icon, 0); + if (flag & UI_ITEM_R_NO_BG) + uiBlockSetEmboss(block, UI_EMBOSSN); + if(icon && strcmp(name, "") != 0) but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL); else if(icon) @@ -619,7 +626,10 @@ PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDP /* text alignment for toolbar buttons */ if((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) but->flag |= UI_TEXT_LEFT; - + + if (flag & UI_ITEM_R_NO_BG) + uiBlockSetEmboss(block, UI_EMBOSS); + /* assign properties */ if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) { PointerRNA *opptr= uiButGetOperatorPtrRNA(but); @@ -941,7 +951,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } /* expanded enum */ else if(type == PROP_ENUM && expand) - ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h, icon_only); + ui_item_enum_expand(layout, block, ptr, prop, name, 0, 0, w, h, icon_only); /* property with separate label */ else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index ccea5fbdf93..29d871dd66e 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -35,7 +35,7 @@ #ifdef RNA_RUNTIME -static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, char *name, int icon, int expand, int slider, int toggle, int icon_only, int event, int full_event, int no_bg, int index) +static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, char *name, int icon, int expand, int slider, int toggle, int icon_only, int event, int full_event, int emboss, int index) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); int flag= 0; @@ -51,14 +51,16 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, char flag |= (icon_only)? UI_ITEM_R_ICON_ONLY: 0; flag |= (event)? UI_ITEM_R_EVENT: 0; flag |= (full_event)? UI_ITEM_R_FULL_EVENT: 0; - flag |= (no_bg)? UI_ITEM_R_NO_BG: 0; + flag |= (emboss)? 0: UI_ITEM_R_NO_BG; uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon); } -static PointerRNA rna_uiItemO(uiLayout *layout, char *opname, char *name, int icon) +static PointerRNA rna_uiItemO(uiLayout *layout, char *opname, char *name, int icon, int emboss) { - return uiItemFullO(layout, opname, name, icon, NULL, uiLayoutGetOperatorContext(layout), UI_ITEM_O_RETURN_PROPS); + int flag= UI_ITEM_O_RETURN_PROPS; + flag |= (emboss)? 0: UI_ITEM_R_NO_BG; + return uiItemFullO(layout, opname, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag); } #else @@ -85,7 +87,7 @@ static void api_ui_item_op(FunctionRNA *func) { PropertyRNA *parm; parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED); } static void api_ui_item_op_common(FunctionRNA *func) @@ -160,7 +162,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_boolean(func, "icon_only", 0, "", "Draw only icons in buttons, no text."); RNA_def_boolean(func, "event", 0, "", "Use button to input key events."); RNA_def_boolean(func, "full_event", 0, "", "Use button to input full events including modifiers."); - RNA_def_boolean(func, "no_bg", 0, "", "Don't draw the button itself, just the icon/text."); + RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text."); RNA_def_int(func, "index", -1, -2, INT_MAX, "", "The index of this button, when set a single member of an array can be accessed, when set to -1 all array members are used.", -2, INT_MAX); /* RNA_NO_INDEX == -1 */ func= RNA_def_function(srna, "props_enum", "uiItemsEnumR"); @@ -186,6 +188,7 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "operator", "rna_uiItemO"); api_ui_item_op_common(func); + RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text."); parm= RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in, return when 'properties' is set to true."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); RNA_def_function_return(func, parm); |