Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 4,199 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Events for Various Button Types | /** \name Events for Various Button Types | ||||
| * \{ */ | * \{ */ | ||||
| static uiButExtraOpIcon *ui_but_extra_operator_icon_mouse_over_get(uiBut *but, | static uiButExtraOpIcon *ui_but_extra_operator_icon_mouse_over_get(uiBut *but, | ||||
| uiHandleButtonData *data, | uiHandleButtonData *data, | ||||
| const wmEvent *event) | const wmEvent *event) | ||||
| { | { | ||||
| float xmax = but->rect.xmax; | /* WARNING: Icon rect calculation should be in sync with widget_draw_extra_icons. */ | ||||
| const float icon_size = 0.8f * BLI_rctf_size_y(&but->rect); /* ICON_SIZE_FROM_BUTRECT */ | |||||
| int x = event->x, y = event->y; | int x = event->x, y = event->y; | ||||
| ui_window_to_block(data->region, but->block, &x, &y); | ui_window_to_block(data->region, but->block, &x, &y); | ||||
| if (!BLI_rctf_isect_pt(&but->rect, x, y)) { | if (!BLI_rctf_isect_pt(&but->rect, x, y)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| rcti icon_rect; | |||||
| BLI_rcti_rctf_copy_round(&icon_rect, &but->rect); | |||||
| const int icon_size = (0.8f * BLI_rcti_size_y(&icon_rect)); /* ICON_SIZE_FROM_BUTRECT */ | |||||
vvv: `ICON_SIZE_FROM_BUTRECT` is `interface_widgets.c` and unavailable here. | |||||
| /* Inverse order, from right to left. */ | /* Inverse order, from right to left. */ | ||||
| LISTBASE_FOREACH_BACKWARD (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) { | LISTBASE_FOREACH_BACKWARD (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) { | ||||
| if ((x > (xmax - icon_size)) && x < xmax) { | icon_rect.xmin = icon_rect.xmax - BLI_rcti_size_y(&icon_rect); | ||||
| /* Detect mouse over the actual icon inside the rect. */ | |||||
| rcti inner_rect = icon_rect; | |||||
| BLI_rcti_resize(&inner_rect, icon_size, icon_size); | |||||
| if (BLI_rcti_isect_pt(&inner_rect, x, y)) { | |||||
| return op_icon; | return op_icon; | ||||
| } | } | ||||
| xmax -= icon_size; | |||||
| icon_rect.xmax -= icon_size; | |||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| static bool ui_do_but_extra_operator_icon(bContext *C, | static bool ui_do_but_extra_operator_icon(bContext *C, | ||||
| uiBut *but, | uiBut *but, | ||||
| uiHandleButtonData *data, | uiHandleButtonData *data, | ||||
| ▲ Show 20 Lines • Show All 6,902 Lines • Show Last 20 Lines | |||||
ICON_SIZE_FROM_BUTRECT is interface_widgets.c and unavailable here.