UI: Correct default width of toolbars

Correct default initial widths of toolbars

Pull Request: https://projects.blender.org/blender/blender/pulls/108292
This commit is contained in:
Leon Schittek
2023-06-08 18:27:59 +02:00
committed by Harley Acheson
parent 2387290e4f
commit 16c9eacf41
6 changed files with 14 additions and 7 deletions

View File

@@ -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

View File

@@ -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(&region->v2d.cur) /
(BLI_rcti_size_y(&region->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,

View File

@@ -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;

View File

@@ -1184,7 +1184,7 @@ void ED_spacetype_node()
/* regions: toolbar */
art = MEM_cnew<ARegionType>("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;

View File

@@ -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;

View File

@@ -2167,7 +2167,7 @@ void ED_spacetype_view3d()
/* regions: tool(bar) */
art = MEM_cnew<ARegionType>("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;