diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2021-07-06 22:56:26 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2021-07-06 22:56:26 (GMT) |
commit | b0663bc167f34b9796f98406329317f7bee15b00 (patch) | |
tree | 24e59202b08ab96d7539f56d14aeb15617739658 /src/IconbarTool.cc | |
parent | f76720d918d1a2c72811a6ec5b3a1fc4b52f768c (diff) | |
download | fluxbox-b0663bc167f34b9796f98406329317f7bee15b00.zip fluxbox-b0663bc167f34b9796f98406329317f7bee15b00.tar.bz2 |
Patch from Bo Simonsen.
Max size per client (setMaxSizePerClient) was computed for
iconbar.alignment = Relative not taking into account that a fixed size
can be given when iconbar.alignment = Left/Right.
In a "recent" change, relative alignment was changed, to better handle
items with long titles. This is breaking existing behavior, the new
behavior is (with this commit) now denoted RelativeSmart.
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r-- | src/IconbarTool.cc | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 8f8f128..027ab1c 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -73,6 +73,8 @@ string FbTk::Resource<FbTk::Container::Alignment>::getString() const { | |||
73 | return string("Left"); | 73 | return string("Left"); |
74 | if (m_value == FbTk::Container::RIGHT) | 74 | if (m_value == FbTk::Container::RIGHT) |
75 | return string("Right"); | 75 | return string("Right"); |
76 | if (m_value == FbTk::Container::RELATIVE_SMART) | ||
77 | return string("RelativeSmart"); | ||
76 | return string("Relative"); | 78 | return string("Relative"); |
77 | } | 79 | } |
78 | 80 | ||
@@ -84,6 +86,8 @@ void FbTk::Resource<FbTk::Container::Alignment>::setFromString(const char *str) | |||
84 | m_value = FbTk::Container::RIGHT; | 86 | m_value = FbTk::Container::RIGHT; |
85 | else if (strcasecmp(str, "Relative") == 0) | 87 | else if (strcasecmp(str, "Relative") == 0) |
86 | m_value = FbTk::Container::RELATIVE; | 88 | m_value = FbTk::Container::RELATIVE; |
89 | else if (strcasecmp(str, "RelativeSmart") == 0) | ||
90 | m_value = FbTk::Container::RELATIVE_SMART; | ||
87 | else | 91 | else |
88 | setDefaultValue(); | 92 | setDefaultValue(); |
89 | } | 93 | } |
@@ -143,6 +147,7 @@ enum { | |||
143 | 147 | ||
144 | L_LEFT, | 148 | L_LEFT, |
145 | L_RELATIVE, | 149 | L_RELATIVE, |
150 | L_RELATIVE_SMART, | ||
146 | L_RIGHT, | 151 | L_RIGHT, |
147 | }; | 152 | }; |
148 | 153 | ||
@@ -163,6 +168,7 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { | |||
163 | 168 | ||
164 | _FB_XTEXT(Align, Left, "Left", "Align to the left"), | 169 | _FB_XTEXT(Align, Left, "Left", "Align to the left"), |
165 | _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"), | 170 | _FB_XTEXT(Align, Relative, "Relative", "Align relative to the width"), |
171 | _FB_XTEXT(Align, RelativeSmart, "Relative (Smart)", "Align relative to the width, but let elements vary according to size of title"), | ||
166 | _FB_XTEXT(Align, Right, "Right", "Align to the right"), | 172 | _FB_XTEXT(Align, Right, "Right", "Align to the right"), |
167 | }; | 173 | }; |
168 | 174 | ||
@@ -181,6 +187,7 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { | |||
181 | 187 | ||
182 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_LEFT], handler, FbTk::Container::LEFT, saverc_cmd)); | 188 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_LEFT], handler, FbTk::Container::LEFT, saverc_cmd)); |
183 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RELATIVE], handler, FbTk::Container::RELATIVE, saverc_cmd)); | 189 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RELATIVE], handler, FbTk::Container::RELATIVE, saverc_cmd)); |
190 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RELATIVE_SMART], handler, FbTk::Container::RELATIVE_SMART, saverc_cmd)); | ||
184 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RIGHT], handler, FbTk::Container::RIGHT, saverc_cmd)); | 191 | menu.insertItem(new ToolbarAlignMenuItem(_labels[L_RIGHT], handler, FbTk::Container::RIGHT, saverc_cmd)); |
185 | 192 | ||
186 | menu.insertItem(new FbTk::MenuSeparator()); | 193 | menu.insertItem(new FbTk::MenuSeparator()); |
@@ -304,11 +311,21 @@ void IconbarTool::move(int x, int y) { | |||
304 | m_icon_container.move(x, y); | 311 | m_icon_container.move(x, y); |
305 | } | 312 | } |
306 | 313 | ||
307 | void IconbarTool::resize(unsigned int width, unsigned int height) { | 314 | void IconbarTool::updateMaxSizes(unsigned int width, unsigned int height) { |
308 | m_icon_container.resize(width, height); | ||
309 | const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; | 315 | const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; |
310 | m_icon_container.setMaxTotalSize(maxsize); | 316 | m_icon_container.setMaxTotalSize(maxsize); |
311 | m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); | 317 | |
318 | if(*m_rc_alignment == FbTk::Container::LEFT || *m_rc_alignment == FbTk::Container::RIGHT) { | ||
319 | *m_rc_client_width = FbTk::Util::clamp(*m_rc_client_width, 10, 400); | ||
320 | m_icon_container.setMaxSizePerClient(*m_rc_client_width); | ||
321 | } else { | ||
322 | m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); | ||
323 | } | ||
324 | } | ||
325 | |||
326 | void IconbarTool::resize(unsigned int width, unsigned int height) { | ||
327 | m_icon_container.resize(width, height); | ||
328 | updateMaxSizes(width, height); | ||
312 | renderTheme(); | 329 | renderTheme(); |
313 | } | 330 | } |
314 | 331 | ||
@@ -316,9 +333,7 @@ void IconbarTool::moveResize(int x, int y, | |||
316 | unsigned int width, unsigned int height) { | 333 | unsigned int width, unsigned int height) { |
317 | 334 | ||
318 | m_icon_container.moveResize(x, y, width, height); | 335 | m_icon_container.moveResize(x, y, width, height); |
319 | const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width; | 336 | updateMaxSizes(width, height); |
320 | m_icon_container.setMaxTotalSize(maxsize); | ||
321 | m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); | ||
322 | renderTheme(); | 337 | renderTheme(); |
323 | } | 338 | } |
324 | 339 | ||
@@ -438,10 +453,8 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) { | |||
438 | } | 453 | } |
439 | 454 | ||
440 | m_resizeSig_timer.start(); | 455 | m_resizeSig_timer.start(); |
441 | const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height() : width(); | ||
442 | m_icon_container.setMaxTotalSize(maxsize); | ||
443 | m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size())); | ||
444 | 456 | ||
457 | updateMaxSizes(width(), height()); | ||
445 | // unlock container and update graphics | 458 | // unlock container and update graphics |
446 | m_icon_container.setUpdateLock(false); | 459 | m_icon_container.setUpdateLock(false); |
447 | m_icon_container.update(); | 460 | m_icon_container.update(); |