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:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c18
-rw-r--r--source/blender/editors/interface/interface_layout.c17
-rw-r--r--source/blender/editors/interface/interface_region_popover.c10
3 files changed, 44 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 1e079835ec5..16c87b7a7d7 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -823,6 +823,24 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
return true;
}
+bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *ar, uiBlock *block)
+{
+ bool done = false;
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
+ if (!done && ui_but_is_editable(but)) {
+ if (but->flag & UI_BUT_ACTIVATE_ON_INIT) {
+ if (UI_but_active_only(C, ar, block, but)) {
+ done = true;
+ }
+ }
+ }
+ but->flag &= ~UI_BUT_ACTIVATE_ON_INIT;
+ }
+ return done;
+}
+
+
+
/* simulate button click */
void UI_but_execute(const bContext *C, uiBut *but)
{
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index a828c19be54..95791dc8811 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -160,6 +160,7 @@ struct uiLayout {
short space;
bool align;
bool active;
+ bool activate_init;
bool enabled;
bool redalert;
bool keepaspect;
@@ -1818,6 +1819,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (layout->redalert)
UI_but_flag_enable(but, UI_BUT_REDALERT);
+
+ if (layout->activate_init)
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
}
/* single button */
else {
@@ -1831,6 +1835,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (layout->redalert)
UI_but_flag_enable(but, UI_BUT_REDALERT);
+
+ if (layout->activate_init)
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
}
/* Mark non-embossed textfields inside a listbox. */
@@ -3949,6 +3956,11 @@ void uiLayoutSetActive(uiLayout *layout, bool active)
layout->active = active;
}
+void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
+{
+ layout->activate_init = activate_init;
+}
+
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
{
layout->enabled = enabled;
@@ -4019,6 +4031,11 @@ bool uiLayoutGetActive(uiLayout *layout)
return layout->active;
}
+bool uiLayoutGetActivateInit(uiLayout *layout)
+{
+ return layout->activate_init;
+}
+
bool uiLayoutGetEnabled(uiLayout *layout)
{
return layout->enabled;
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index d15eb7a3246..3176c7a454a 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -302,16 +302,24 @@ int UI_popover_panel_invoke(
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
+ uiBlock *block = NULL;
if (keep_open) {
- ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ uiPopupBlockHandle *handle = ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ uiPopover *pup = handle->popup_create_vars.arg;
+ block = pup->block;
+
}
else {
uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x);
layout = UI_popover_layout(pup);
UI_paneltype_draw(C, pt, layout);
UI_popover_end(C, pup, NULL);
+ block = pup->block;
}
+ if (block) {
+ UI_block_active_only_flagged_buttons(C, CTX_wm_region(C), block);
+ }
return OPERATOR_INTERFACE;
}