diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-04 01:54:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-04 02:37:22 +0300 |
commit | 3c8c1841d72d8b9b13799c9a12cd8637b38be51d (patch) | |
tree | 08c0a06d79ab98d5a878051246645931d6eb6faf /source/blender/editors/space_view3d/space_view3d.c | |
parent | 55f62b94f861b3284ae813fd4d0ca9f1458f7ae5 (diff) |
UI: use shared toolbar region callbacks
Image toolbar now starts with a single column width
and snaps to button increments.
Diffstat (limited to 'source/blender/editors/space_view3d/space_view3d.c')
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 6f6b94e000c..c7f02f3c74c 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1103,20 +1103,6 @@ static void view3d_main_region_message_subscribe( } } -static void view3d_tools_region_message_subscribe( - const struct bContext *UNUSED(C), - struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), - struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar, - struct wmMsgBus *mbus) -{ - wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { - .owner = ar, - .user_data = ar, - .notify = ED_region_do_msg_notify_tag_redraw, - }; - WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw); -} - /* concept is to retrieve cursor type context-less */ static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) { @@ -1319,27 +1305,6 @@ static void view3d_buttons_region_listener( } } -static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis) -{ - if (axis == 0) { - /* Note, this depends on the icon size: see #ICON_DEFAULT_HEIGHT_TOOLBAR. */ - const float snap_units[] = {2 + 0.8f, 4 + 0.8f}; - const float aspect = BLI_rctf_size_x(&ar->v2d.cur) / (BLI_rcti_size_x(&ar->v2d.mask) + 1); - int best_diff = INT_MAX; - int best_size = size; - for (uint i = 0; i < ARRAY_SIZE(snap_units); i += 1) { - const int test_size = (snap_units[i] * U.widget_unit) / (UI_DPI_FAC * aspect); - const int test_diff = ABS(test_size - size); - if (test_diff < best_diff) { - best_size = test_size; - best_diff = test_diff; - } - } - return best_size; - } - return size; -} - /* add handlers, stuff you only do once or on area/region changes */ static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar) { @@ -1546,8 +1511,8 @@ void ED_spacetype_view3d(void) art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_region_listener; - art->message_subscribe = view3d_tools_region_message_subscribe; - art->snap_size = view3d_tools_region_snap_size; + art->message_subscribe = ED_region_generic_tools_region_message_subscribe; + art->snap_size = ED_region_generic_tools_region_snap_size; art->init = view3d_tools_region_init; art->draw = view3d_tools_region_draw; BLI_addhead(&st->regiontypes, art); |