diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-04 08:29:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-04 08:29:27 +0300 |
commit | 531183dfd8fc89419e779520073aa0a248caedd3 (patch) | |
tree | 066128d58c9fb918e478fef41009cabff7c98d40 | |
parent | 113c180902cb112091dbf997beaff29884735b96 (diff) | |
parent | 52f4531eeb577d11f2738cb5e3b0fc4c7cc48b80 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 6f78fb09ff1..6f4e48a9793 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -968,12 +968,12 @@ static ARegion *ui_tooltip_create_with_data( const float pad_px = UI_TIP_PADDING; wmWindow *win = CTX_wm_window(C); const int winx = WM_window_pixels_x(win); + const int winy = WM_window_pixels_y(win); uiStyle *style = UI_style_get(); static ARegionType type; ARegion *ar; int fonth, fontw; int h, i; - rctf rect_fl; rcti rect_i; int font_flag = 0; @@ -1053,35 +1053,32 @@ static ARegion *ui_tooltip_create_with_data( data->toth = fonth; data->lineh = h; - /* compute position */ - - rect_fl.xmin = init_position[0] - TIP_BORDER_X; - rect_fl.xmax = rect_fl.xmin + fontw + pad_px; - rect_fl.ymax = init_position[1] - TIP_BORDER_Y; - rect_fl.ymin = rect_fl.ymax - fonth - TIP_BORDER_Y; - - BLI_rcti_rctf_copy(&rect_i, &rect_fl); + /* Compute position. */ + { + rctf rect_fl; + rect_fl.xmin = init_position[0] - TIP_BORDER_X; + rect_fl.xmax = rect_fl.xmin + fontw + pad_px; + rect_fl.ymax = init_position[1] - TIP_BORDER_Y; + rect_fl.ymin = rect_fl.ymax - fonth - TIP_BORDER_Y; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); + } #undef TIP_BORDER_X #undef TIP_BORDER_Y - /* clip with window boundaries */ - if (rect_i.xmax > winx) { - /* super size */ - if (rect_i.xmax > winx + rect_i.xmin) { - rect_i.xmax = winx; - rect_i.xmin = 0; - } - else { - rect_i.xmin -= rect_i.xmax - winx; - rect_i.xmax = winx; - } - } - /* ensure at least 5 px above screen bounds - * 25 is just a guess to be above the menu item */ - if (rect_i.ymin < 5) { - rect_i.ymax += (-rect_i.ymin) + 30; - rect_i.ymin = 30; + /* Clamp to window bounds. */ + { + /* Ensure at least 5 px above screen bounds + * UI_UNIT_Y is just a guess to be above the menu item */ + const int pad = max_ff(1.0f, U.pixelsize) * 5; + const rcti rect_clamp = { + .xmin = pad, + .xmax = winx - pad, + .ymin = pad + (UI_UNIT_Y * 2), + .ymax = winy - pad, + }; + int offset_dummy[2]; + BLI_rcti_clamp(&rect_i, &rect_clamp, offset_dummy); } /* add padding */ |