diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-10-14 16:24:41 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-10-14 16:24:41 +0300 |
commit | 5f2707075ff132a361e5b9694a0a4984feefd331 (patch) | |
tree | 59a36bb46c0d038ce95a43e00fedd0a8eca1b154 /source/blender/editors/interface/interface.c | |
parent | b884046e2a235a881c7a40e94642be55a02c6e6f (diff) | |
parent | 49f4ac17bf704614de59a4db7a65c205c085d694 (diff) |
Merge branch 'master' into id_override_static
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8b8122618bb..5560eb3c46d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -366,10 +366,10 @@ static void ui_block_bounds_calc_centered_pie(uiBlock *block) static void ui_block_bounds_calc_popup( wmWindow *window, uiBlock *block, - eBlockBoundsCalc bounds_calc, const int xy[2]) + eBlockBoundsCalc bounds_calc, const int xy[2], int r_xy[2]) { int width, height, oldwidth, oldheight; - int oldbounds, xmax, ymax; + int oldbounds, xmax, ymax, raw_x, raw_y; const int margin = UI_SCREEN_MARGIN; rcti rect, rect_bounds; int ofs_dummy[2]; @@ -407,8 +407,8 @@ static void ui_block_bounds_calc_popup( /* offset block based on mouse position, user offset is scaled * along in case we resized the block in ui_block_bounds_calc_text */ - rect.xmin = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth; - rect.ymin = xy[1] + block->rect.ymin + (block->my * height) / oldheight; + raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth; + raw_y = rect.ymin = xy[1] + block->rect.ymin + (block->my * height) / oldheight; rect.xmax = rect.xmin + width; rect.ymax = rect.ymin + height; @@ -422,6 +422,13 @@ static void ui_block_bounds_calc_popup( /* now recompute bounds and safety */ ui_block_bounds_calc(block); + + /* If given, adjust input coordinates such that they would generate real final popup position. + * Needed to handle correctly floating panels once they have been dragged around, see T52999. */ + if (r_xy) { + r_xy[0] = xy[0] + block->rect.xmin - raw_x; + r_xy[1] = xy[1] + block->rect.ymin - raw_y; + } } /* used for various cases */ @@ -1245,7 +1252,7 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block) block->oldblock = NULL; } -void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2]) +void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_xy[2]) { wmWindow *window = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); @@ -1314,7 +1321,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2]) /* fallback */ case UI_BLOCK_BOUNDS_POPUP_MOUSE: case UI_BLOCK_BOUNDS_POPUP_MENU: - ui_block_bounds_calc_popup(window, block, block->bounds_type, xy); + ui_block_bounds_calc_popup(window, block, block->bounds_type, xy, r_xy); break; } @@ -1332,7 +1339,7 @@ void UI_block_end(const bContext *C, uiBlock *block) { wmWindow *window = CTX_wm_window(C); - UI_block_end_ex(C, block, &window->eventstate->x); + UI_block_end_ex(C, block, &window->eventstate->x, NULL); } /* ************** BLOCK DRAWING FUNCTION ************* */ |