Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-13 13:57:31 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-13 14:44:49 +0300
commit3469e623d3174ff4e82c430478640dfacd0e63ff (patch)
treeaa24812791b5e764c26cdd19da006372d6789eac /source/blender/editors/interface
parent343c2e94f531c9bfb5fd8a52391a553f48fa418c (diff)
UI/Python: layout API support for setting button emboss style.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_layout.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 6626693ebec..f0ea6466763 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -151,6 +151,7 @@ struct uiLayout {
bool redalert;
bool keepaspect;
char alignment;
+ char emboss;
};
typedef struct uiLayoutItemFlow {
@@ -844,8 +845,9 @@ static uiBut *uiItemFullO_ptr_ex(
w = ui_text_icon_width(layout, name, icon, 0);
+ int prev_emboss = layout->emboss;
if (flag & UI_ITEM_R_NO_BG)
- UI_block_emboss_set(block, UI_EMBOSS_NONE);
+ layout->emboss = UI_EMBOSS_NONE;
/* create the button */
if (icon) {
@@ -867,7 +869,9 @@ static uiBut *uiItemFullO_ptr_ex(
but->drawflag |= UI_BUT_TEXT_LEFT;
if (flag & UI_ITEM_R_NO_BG)
- UI_block_emboss_set(block, UI_EMBOSS);
+ layout->emboss = prev_emboss;
+
+ if (flag & UI_ITEM_R_NO_BG)
if (flag & UI_ITEM_O_DEPRESS) {
but->flag |= UI_SELECT_DRAW;
@@ -1496,8 +1500,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
/* get size */
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
- if (no_bg)
- UI_block_emboss_set(block, UI_EMBOSS_NONE);
+ int prev_emboss = layout->emboss;
+ if (flag & UI_ITEM_R_NO_BG)
+ layout->emboss = UI_EMBOSS_NONE;
/* array property */
if (index == RNA_NO_INDEX && is_array)
@@ -1543,8 +1548,8 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
UI_but_flag_enable(but, UI_BUT_LIST_ITEM);
}
- if (no_bg)
- UI_block_emboss_set(block, UI_EMBOSS);
+ if (flag & UI_ITEM_R_NO_BG)
+ layout->emboss = prev_emboss;
/* ensure text isn't added to icon_only buttons */
if (but && icon_only) {
@@ -1880,9 +1885,6 @@ static uiBut *ui_item_menu(
UI_block_layout_set_current(block, layout);
- if (layout->root->type == UI_LAYOUT_HEADER)
- UI_block_emboss_set(block, UI_EMBOSS);
-
if (!name)
name = "";
if (layout->root->type == UI_LAYOUT_MENU && !icon)
@@ -1914,9 +1916,6 @@ static uiBut *ui_item_menu(
but->func_argN = argN;
}
- if (layout->root->type == UI_LAYOUT_HEADER) {
- UI_block_emboss_set(block, UI_EMBOSS);
- }
if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR) ||
(force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */
{
@@ -2947,7 +2946,7 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali
litem->context = layout->context;
litem->redalert = layout->redalert;
litem->w = layout->w;
- litem->emboss = layout->root->block->dt;
+ litem->emboss = layout->emboss;
BLI_addtail(&layout->items, litem);
}
@@ -3177,6 +3176,11 @@ void uiLayoutSetScaleY(uiLayout *layout, float scale)
layout->scale[1] = scale;
}
+void uiLayoutSetEmboss(uiLayout *layout, char emboss)
+{
+ layout->emboss = emboss;
+}
+
bool uiLayoutGetActive(uiLayout *layout)
{
return layout->active;
@@ -3217,6 +3221,16 @@ float uiLayoutGetScaleY(uiLayout *layout)
return layout->scale[1];
}
+int uiLayoutGetEmboss(uiLayout *layout)
+{
+ if (layout->emboss == UI_EMBOSS_UNDEFINED) {
+ return layout->root->block->dt;
+ }
+ else {
+ return layout->emboss;
+ }
+}
+
/********************** Layout *******************/
static void ui_item_scale(uiLayout *litem, const float scale[2])
@@ -3470,6 +3484,7 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s
layout->active = 1;
layout->enabled = 1;
layout->context = NULL;
+ layout->emboss = UI_EMBOSS_UNDEFINED;
if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU)
layout->space = 0;
@@ -3534,6 +3549,10 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but)
but->context = layout->context;
but->context->used = true;
}
+
+ if (layout->emboss != UI_EMBOSS_UNDEFINED) {
+ but->dt = layout->emboss;
+ }
}
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)