diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5fba42fe921..6d2013688f5 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -262,6 +262,13 @@ enum { #define UI_NAVIGATION_REGION_WIDTH UI_COMPACT_PANEL_WIDTH #define UI_NARROW_NAVIGATION_REGION_WIDTH 100 +/* The width of one icon column of the Toolbar. */ +#define UI_TOOLBAR_COLUMN (1.25f * ICON_DEFAULT_HEIGHT_TOOLBAR) +/* The space between the Toolbar and the area's edge. */ +#define UI_TOOLBAR_MARGIN (0.5f * ICON_DEFAULT_HEIGHT_TOOLBAR) +/* Total width of Toolbar showing one icon column. */ +#define UI_TOOLBAR_WIDTH UI_TOOLBAR_MARGIN + UI_TOOLBAR_COLUMN + #define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f) /* Both these margins should be ignored if the panel doesn't show a background (check diff --git a/source/blender/editors/screen/area_utils.c b/source/blender/editors/screen/area_utils.c index 966a68faa2d..cabebfbc955 100644 --- a/source/blender/editors/screen/area_utils.c +++ b/source/blender/editors/screen/area_utils.c @@ -20,6 +20,7 @@ #include "ED_screen.h" +#include "UI_interface.h" #include "UI_interface_icons.h" /* -------------------------------------------------------------------- */ @@ -45,9 +46,8 @@ int ED_region_generic_tools_region_snap_size(const ARegion *region, int size, in /* Using Y axis avoids slight feedback loop when adjusting X. */ const float aspect = BLI_rctf_size_y(®ion->v2d.cur) / (BLI_rcti_size_y(®ion->v2d.mask) + 1); - const float icon_size = ICON_DEFAULT_HEIGHT_TOOLBAR / aspect; - const float column = 1.25f * icon_size; - const float margin = 0.5f * icon_size; + const float column = UI_TOOLBAR_COLUMN / aspect; + const float margin = UI_TOOLBAR_MARGIN / aspect; const float snap_units[] = { column + margin, (2.0f * column) + margin, diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 68fc6e360f8..ae1e9600e37 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -1134,7 +1134,7 @@ void ED_spacetype_image(void) /* regions: tool(bar) */ art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 58; /* XXX */ + art->prefsizex = (int)UI_TOOLBAR_WIDTH; art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = image_tools_region_listener; diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 863cc599854..03e94bed55a 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -1184,7 +1184,7 @@ void ED_spacetype_node() /* regions: toolbar */ art = MEM_cnew("spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 58; /* XXX */ + art->prefsizex = int(UI_TOOLBAR_WIDTH); art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = node_region_listener; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 15d2e557957..0d1422050cd 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -1063,7 +1063,7 @@ void ED_spacetype_sequencer(void) /* Toolbar. */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 58; /* XXX */ + art->prefsizex = (int)UI_TOOLBAR_WIDTH; art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->message_subscribe = ED_region_generic_tools_region_message_subscribe; diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 3f639b7473e..32a5600541f 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -2167,7 +2167,7 @@ void ED_spacetype_view3d() /* regions: tool(bar) */ art = MEM_cnew("spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 58; /* XXX */ + art->prefsizex = int(UI_TOOLBAR_WIDTH); art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_region_listener;