diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2021-01-25 02:16:05 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2021-01-25 02:16:05 +0300 |
commit | cf6d17a6aa421e0038fc1f8e60e3f1f708887c3e (patch) | |
tree | 30eeb91c88f0c3c4552fcf2255582d439e69b899 /source/blender/editors/interface/interface_region_tooltip.c | |
parent | 2fec46c3e614c10cadef945855747d0f3f251fd4 (diff) |
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
Diffstat (limited to 'source/blender/editors/interface/interface_region_tooltip.c')
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 2bf63955855..91e5b61a16d 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -1456,15 +1456,23 @@ ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) { wmWindow *win = CTX_wm_window(C); const float aspect = 1.0f; - float init_position[2]; + float init_position[2] = {win->eventstate->x, win->eventstate->y}; uiTooltipData *data = ui_tooltip_data_from_gizmo(C, gz); if (data == NULL) { return NULL; } - init_position[0] = win->eventstate->x; - init_position[1] = win->eventstate->y; + /* TODO(harley): + * Julian preferred that the gizmo callback return the 3D bounding box + * which we then project to 2D here. Would make a nice improvement. + */ + if (gz->type->screen_bounds_get) { + rcti bounds; + gz->type->screen_bounds_get(C, gz, &bounds); + init_position[0] = bounds.xmin; + init_position[1] = bounds.ymin; + } return ui_tooltip_create_with_data(C, data, init_position, NULL, aspect); } |