From d24f6f79164699be21823d69f499c41a152be5c6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Mar 2019 14:20:48 +0100 Subject: [PATCH] Reduce the margins around toolbar controls by half This wastes less space in the toolbar and looks better and is more compatible with 3.0 (although not totally so, but this is intentional as 3.0 didn't use any margins at all, which looked bad). --- src/msw/toolbar.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 1c792f209e..5044242339 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -553,8 +553,11 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const } } - // Also account for the tool padding value. - size.x += m_toolPacking; + // Also account for the tool padding value: note that we only have to add + // half of it to each tool, as the total amount of packing is the sum of + // the right margin of the previous tool and the left margin of the next + // one. + size.x += m_toolPacking / 2; return size; } @@ -603,7 +606,9 @@ wxSize wxToolBar::DoGetBestSize() const sizeBest.x += sizeTool.x; } - sizeBest.x += m_toolPacking; + // As explained in MSWGetFittingtSizeForControl() above, the actual + // margin used for a single tool is one half of the total packing. + sizeBest.x += m_toolPacking / 2; } } @@ -1271,8 +1276,10 @@ bool wxToolBar::Realize() const wxSize controlSize = control->GetSize(); - // Take also into account tool padding value. - const int x = r.left + m_toolPacking/2; + // Take also into account tool padding value: the amount of padding + // used for each tool is half of m_toolPacking, so the margin on each + // side is a half of that. + const int x = r.left + m_toolPacking / 4; // Greater of control and its label widths. int totalWidth = controlSize.x;