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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-11-01 21:00:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-11-01 21:02:56 +0300
commita6e1f7560fa4e6308a83d42d701a1b95d7db38a8 (patch)
tree7125f878cca661077b9e0bdd76c1c7ba953ccbdc /source
parent3ec4d0b51bf3a76725e39a57b0f30bec3edc6882 (diff)
UI: Option to draw button pressed
Needed to show the active tool
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface_layout.c4
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c15
3 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index a609a3b51fd..a0664f020bf 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -832,6 +832,7 @@ void UI_exit(void);
#define UI_ITEM_R_FULL_EVENT (1 << 6)
#define UI_ITEM_R_NO_BG (1 << 7)
#define UI_ITEM_R_IMMEDIATE (1 << 8)
+#define UI_ITEM_O_DEPRESS (1 << 9)
/* uiTemplateOperatorPropertyButs flags */
#define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 33dc74cbe23..936b4fd2bba 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -845,6 +845,10 @@ static uiBut *uiItemFullO_ptr_ex(
if (flag & UI_ITEM_R_NO_BG)
UI_block_emboss_set(block, UI_EMBOSS);
+ if (flag & UI_ITEM_O_DEPRESS) {
+ but->flag |= UI_SELECT;
+ }
+
if (layout->redalert)
UI_but_flag_enable(but, UI_BUT_REDALERT);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index eb95602010a..69636788493 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -175,11 +175,11 @@ static void rna_uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const c
uiItemPointerR(layout, ptr, propname, searchptr, searchpropname, name, icon);
}
-static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, const char *text_ctxt,
- int translate, int icon, int emboss, int icon_value)
+static PointerRNA rna_uiItemO(
+ uiLayout *layout, const char *opname, const char *name, const char *text_ctxt,
+ int translate, int icon, int emboss, int depress, int icon_value)
{
wmOperatorType *ot;
- int flag;
ot = WM_operatortype_find(opname, 0); /* print error next */
if (!ot || !ot->srna) {
@@ -193,9 +193,8 @@ static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *
if (icon_value && !icon) {
icon = icon_value;
}
-
- flag = 0;
- flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;
+ int flag = (emboss) ? 0 : UI_ITEM_R_NO_BG;
+ flag |= (depress) ? UI_ITEM_O_DEPRESS : 0;
PointerRNA opptr;
uiItemFullO_ptr(layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag, &opptr);
@@ -204,7 +203,7 @@ static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *
static PointerRNA rna_uiItemOMenuHold(
uiLayout *layout, const char *opname, const char *name, const char *text_ctxt,
- int translate, int icon, int emboss, int icon_value,
+ int translate, int icon, int emboss, int depress, int icon_value,
const char *menu)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
@@ -219,6 +218,7 @@ static PointerRNA rna_uiItemOMenuHold(
icon = icon_value;
}
int flag = (emboss) ? 0 : UI_ITEM_R_NO_BG;
+ flag |= (depress) ? UI_ITEM_O_DEPRESS : 0;
PointerRNA opptr;
uiItemFullOMenuHold_ptr(layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag, menu, &opptr);
@@ -583,6 +583,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function(srna, "operator", "rna_uiItemO");
api_ui_item_op_common(func);
RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, just the icon/text");
+ RNA_def_boolean(func, "depress", false, "", "Draw pressed in");
parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
if (is_menu_hold) {