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:
-rw-r--r--source/blender/editors/animation/drivers.c10
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_region_popover.c42
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
4 files changed, 34 insertions, 22 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 41a72e7b5fd..2c28ecfac5d 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -976,17 +976,17 @@ static int edit_driver_button_exec(bContext *C, wmOperator *op)
PropertyRNA *prop = NULL;
int index;
const bool all = 0; // RNA_boolean_get(op->ptr, "all");
-
+
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
if (all)
index = -1;
-
+
if (ptr.id.data && ptr.data && prop) {
- UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", op->reports);
+ UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
}
-
+
return OPERATOR_INTERFACE;
}
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 9d3ba1fe675..689fa850dea 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -431,7 +431,7 @@ typedef struct uiPopover uiPopover;
int UI_popover_panel_invoke(
struct bContext *C, int space_id, int region_id, const char *idname,
- struct ReportList *reports);
+ bool keep_open, struct ReportList *reports);
uiPopover *UI_popover_begin(struct bContext *C) ATTR_NONNULL(1);
void UI_popover_end(struct bContext *C, struct uiPopover *head, struct wmKeyMap *keymap);
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 169b3d43e80..1f9326ac204 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -189,17 +189,26 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
UI_block_flag_enable(block, UI_BLOCK_LOOP);
UI_block_direction_set(block, block->direction);
block->minbounds = UI_MENU_WIDTH_MIN;
+ bool use_place_under_active = false;
- uiBut *but = NULL;
- for (but = block->buttons.first; but; but = but->next) {
- if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
- break;
- }
+#ifdef USE_POPOVER_ONCE
+ if (pup->is_once) {
+ /* Weak, toolbars act like menus, so position with the cursor under the active button. */
+ use_place_under_active = true;
}
+#endif
+ if (use_place_under_active) {
+ uiBut *but = NULL;
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
+ break;
+ }
+ }
- if (but) {
- offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
- offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ if (but) {
+ offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
+ offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ }
}
UI_block_bounds_set_popup(block, block_margin, offset[0], offset[1]);
@@ -256,11 +265,15 @@ uiPopupBlockHandle *ui_popover_panel_create(
/** \name Standard Popover Panels
* \{ */
-
+static void ui_item_paneltype_func(bContext *C, uiLayout *layout, void *arg_pt)
+{
+ PanelType *pt = (PanelType *)arg_pt;
+ UI_paneltype_draw(C, pt, layout);
+}
int UI_popover_panel_invoke(
bContext *C, int space_id, int region_id, const char *idname,
- ReportList *reports)
+ bool keep_open, ReportList *reports)
{
uiLayout *layout;
PanelType *pt = UI_paneltype_find(space_id, region_id, idname);
@@ -277,7 +290,10 @@ int UI_popover_panel_invoke(
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
- {
+ if (keep_open) {
+ ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ }
+ else {
uiPopover *pup = UI_popover_begin(C);
layout = UI_popover_layout(pup);
UI_paneltype_draw(C, pt, layout);
@@ -366,7 +382,3 @@ void UI_popover_once_clear(uiPopover *pup)
#endif
/** \} */
-
-/* We may want to support this in future */
-/* Similar to UI_popup_menu_invoke */
-// int UI_popover_panel_invoke(bContext *C, const char *idname, ReportList *reports);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1fe0799d6c1..7cf1fe3bdfa 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2248,7 +2248,7 @@ static int wm_call_panel_exec(bContext *C, wmOperator *op)
const int space_type = RNA_enum_get(op->ptr, "space_type");
const int region_type = RNA_enum_get(op->ptr, "region_type");
- return UI_popover_panel_invoke(C, space_type, region_type, idname, op->reports);
+ return UI_popover_panel_invoke(C, space_type, region_type, idname, true, op->reports);
}
static void WM_OT_call_panel(wmOperatorType *ot)