UI: center floating popovers
Tweak placement so useful items are more likely to be nearby, centering horizontally and align vertically to the first button.
This commit is contained in:
parent
53f4fc7da9
commit
47ba487e05
Notes:
blender-bot
2023-02-14 03:17:59 +01:00
Referenced by issue #62768, Softbody cashe still not updated correctly in Blender 2.8
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue