aboutsummaryrefslogtreecommitdiff
path: root/src/IconbarTool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r--src/IconbarTool.cc29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 294d17a..4e2114d 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -292,7 +292,9 @@ void IconbarTool::move(int x, int y) {
292 292
293void IconbarTool::resize(unsigned int width, unsigned int height) { 293void IconbarTool::resize(unsigned int width, unsigned int height) {
294 m_icon_container.resize(width, height); 294 m_icon_container.resize(width, height);
295 m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() == FbTk::ROT180 ? width : height); 295 const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width;
296 m_icon_container.setMaxTotalSize(maxsize);
297 m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size()));
296 renderTheme(); 298 renderTheme();
297} 299}
298 300
@@ -300,7 +302,9 @@ void IconbarTool::moveResize(int x, int y,
300 unsigned int width, unsigned int height) { 302 unsigned int width, unsigned int height) {
301 303
302 m_icon_container.moveResize(x, y, width, height); 304 m_icon_container.moveResize(x, y, width, height);
303 m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() == FbTk::ROT180 ? width : height); 305 const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height : width;
306 m_icon_container.setMaxTotalSize(maxsize);
307 m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size()));
304 renderTheme(); 308 renderTheme();
305} 309}
306 310
@@ -362,6 +366,18 @@ unsigned int IconbarTool::width() const {
362 return m_icon_container.width(); 366 return m_icon_container.width();
363} 367}
364 368
369unsigned int IconbarTool::preferredWidth() const {
370 // border and paddings
371 unsigned int w = 2*borderWidth() + *m_rc_client_padding * m_icons.size();
372
373 // the buttons
374 for (IconMap::const_iterator it = m_icons.begin(), end = m_icons.end(); it != end; ++it) {
375 w += it->second->preferredWidth();
376 }
377
378 return w;
379}
380
365unsigned int IconbarTool::height() const { 381unsigned int IconbarTool::height() const {
366 return m_icon_container.height(); 382 return m_icon_container.height();
367} 383}
@@ -384,9 +400,6 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) {
384 400
385 m_icon_container.setAlignment(*m_rc_alignment); 401 m_icon_container.setAlignment(*m_rc_alignment);
386 402
387 *m_rc_client_width = FbTk::Util::clamp(*m_rc_client_width, 10, 400);
388 m_icon_container.setMaxSizePerClient(*m_rc_client_width);
389
390 // lock graphic update 403 // lock graphic update
391 m_icon_container.setUpdateLock(true); 404 m_icon_container.setUpdateLock(true);
392 405
@@ -404,6 +417,11 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) {
404 break; 417 break;
405 } 418 }
406 419
420 resizeSig().emit();
421 const unsigned int maxsize = (m_icon_container.orientation() & 1) ? height() : width();
422 m_icon_container.setMaxTotalSize(maxsize);
423 m_icon_container.setMaxSizePerClient(maxsize/std::max(1, m_icon_container.size()));
424
407 // unlock container and update graphics 425 // unlock container and update graphics
408 m_icon_container.setUpdateLock(false); 426 m_icon_container.setUpdateLock(false);
409 m_icon_container.update(); 427 m_icon_container.update();
@@ -441,6 +459,7 @@ void IconbarTool::insertWindow(Focusable &win, int pos) {
441 } 459 }
442 460
443 m_icon_container.insertItem(button, pos); 461 m_icon_container.insertItem(button, pos);
462 m_tracker.join(button->titleChanged(), FbTk::MemFun(resizeSig(), &FbTk::Signal<>::emit));
444} 463}
445 464
446void IconbarTool::reset() { 465void IconbarTool::reset() {