From cf6d17a6aa421e0038fc1f8e60e3f1f708887c3e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 24 Jan 2021 15:16:05 -0800 Subject: UI: Gizmo Tooltip Positioning Position Gizmo tooltips below their bounds so they do not obscure the content. Differential Revision: https://developer.blender.org/D9793 Reviewed by Julian Eisel --- .../editors/gizmo_library/gizmo_types/button2d_gizmo.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/editors/gizmo_library') diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index eb40500d011..cbca230da7e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -320,6 +320,16 @@ static int gizmo_button2d_cursor_get(wmGizmo *gz) return WM_CURSOR_DEFAULT; } +static void gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box) +{ + ScrArea *area = CTX_wm_area(C); + float rad = CIRCLE_RESOLUTION * U.dpi_fac / 2.0f; + r_bounding_box->xmin = gz->matrix_basis[3][0] + area->totrct.xmin - rad; + r_bounding_box->ymin = gz->matrix_basis[3][1] + area->totrct.ymin - rad; + r_bounding_box->xmax = r_bounding_box->xmin + rad; + r_bounding_box->ymax = r_bounding_box->ymin + rad; +} + static void gizmo_button2d_free(wmGizmo *gz) { ButtonGizmo2D *shape = (ButtonGizmo2D *)gz; @@ -346,6 +356,7 @@ static void GIZMO_GT_button_2d(wmGizmoType *gzt) gzt->draw_select = gizmo_button2d_draw_select; gzt->test_select = gizmo_button2d_test_select; gzt->cursor_get = gizmo_button2d_cursor_get; + gzt->screen_bounds_get = gizmo_button2d_bounds; gzt->free = gizmo_button2d_free; gzt->struct_size = sizeof(ButtonGizmo2D); -- cgit v1.2.3