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:
authorCampbell Barton <ideasman42@gmail.com>2019-03-20 04:34:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-20 04:34:22 +0300
commit47ba487e05daf73018f7fd3af0a44d46228e9fd6 (patch)
treea6a45f1b3a0b5e43648f504fc9f338865519b7ca /source/blender
parent53f4fc7da9d4b7acd613430bfd0f97536cc164de (diff)
UI: center floating popovers
Tweak placement so useful items are more likely to be nearby, centering horizontally and align vertically to the first button.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface_region_popover.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 9fcf2a51652..d15eb7a3246 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -201,7 +201,11 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
if (!handle->refresh) {
uiBut *but = NULL;
+ uiBut *but_first = NULL;
for (but = block->buttons.first; but; but = but->next) {
+ if ((but_first == NULL) && ui_but_is_editable(but)) {
+ but_first = but;
+ }
if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
break;
}
@@ -209,7 +213,11 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
if (but) {
bounds_offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
- bounds_offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ bounds_offset[1] = -BLI_rctf_cent_y(&but->rect);
+ }
+ else {
+ bounds_offset[0] = -(pup->ui_size_x / 2);
+ bounds_offset[1] = but_first ? -BLI_rctf_cent_y(&but_first->rect) : (UI_UNIT_Y / 2);
}
copy_v2_v2_int(handle->prev_bounds_offset, bounds_offset);
}