From 4e586cc1729fc1c7115dfc6d2499d40db559b8e1 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sun, 28 Jun 2009 08:22:51 -0700 Subject: previous fix for reverting iconbar to relative broke external tabs --- src/FbTk/Container.cc | 46 +++++++++++++++++++++++++++------------------- src/FbTk/Container.hh | 4 ++-- src/IconbarTool.cc | 4 +++- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/FbTk/Container.cc b/src/FbTk/Container.cc index 6a8f2a3..bcb6b01 100644 --- a/src/FbTk/Container.cc +++ b/src/FbTk/Container.cc @@ -33,13 +33,14 @@ namespace FbTk { typedef CompareEqual_base CompareWindow; -Container::Container(const FbWindow &parent): +Container::Container(const FbWindow &parent, bool auto_resize): FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_orientation(ROT0), m_align(RELATIVE), m_max_size_per_client(60), m_max_total_size(0), - m_update_lock(false) { + m_update_lock(false), + m_auto_resize(auto_resize) { EventManager::instance()->add(*this, *this); } @@ -328,7 +329,7 @@ void Container::repositionItems() { } else max_width_per_client = 1; } - if (total_width != cur_width) { + if (m_auto_resize && total_width != cur_width) { // calling Container::resize here risks infinite loops unsigned int neww = total_width, newh = height; translateSize(m_orientation, neww, newh); @@ -410,24 +411,31 @@ void Container::repositionItems() { unsigned int Container::maxWidthPerClient() const { - unsigned int max_relative_size; - if (size() == 0) - max_relative_size = width(); - else { - unsigned int borderW = m_item_list.front()->borderWidth(); - // there're count-1 borders to fit in with the windows - // -> 1 per window plus end - unsigned int w = width(), h = height(); - translateSize(m_orientation, w, h); - max_relative_size = w < (size()-1)*borderW ? 1 : - (w - (size() - 1) * borderW) / size(); + switch (alignment()) { + case RIGHT: + case CENTER: + case LEFT: + return m_max_size_per_client; + break; + case RELATIVE: + if (size() == 0) + return width(); + else { + unsigned int borderW = m_item_list.front()->borderWidth(); + // there're count-1 borders to fit in with the windows + // -> 1 per window plus end + unsigned int w = width(), h = height(); + translateSize(m_orientation, w, h); + if (w < (size()-1)*borderW) + return 1; + else + return (w - (size() - 1) * borderW) / size(); + } + break; } - if (alignment() == RELATIVE) - return max_relative_size; - - return (m_max_size_per_client < max_relative_size ? - m_max_size_per_client : max_relative_size); + // this will never happen anyway + return 1; } void Container::for_each(std::mem_fun_t function) { diff --git a/src/FbTk/Container.hh b/src/FbTk/Container.hh index 00f2c88..e2614a8 100644 --- a/src/FbTk/Container.hh +++ b/src/FbTk/Container.hh @@ -43,7 +43,7 @@ public: typedef const Button * ConstItem; typedef std::list ItemList; - explicit Container(const FbWindow &parent); + explicit Container(const FbWindow &parent, bool auto_resize = true); virtual ~Container(); // manipulators @@ -106,7 +106,7 @@ private: unsigned int m_max_size_per_client; unsigned int m_max_total_size; ItemList m_item_list; - bool m_update_lock; + bool m_update_lock, m_auto_resize; }; } // end namespace FbTk diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 03cadec..c84372f 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -249,7 +249,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen, FbTk::Menu &menu): ToolbarItem(ToolbarItem::RELATIVE), m_screen(screen), - m_icon_container(parent), + m_icon_container(parent, false), m_theme(theme), m_focused_theme(focused_theme), m_unfocused_theme(unfocused_theme), @@ -307,6 +307,7 @@ void IconbarTool::move(int x, int y) { void IconbarTool::resize(unsigned int width, unsigned int height) { m_icon_container.resize(width, height); + m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() ? width : height); renderTheme(); } @@ -314,6 +315,7 @@ void IconbarTool::moveResize(int x, int y, unsigned int width, unsigned int height) { m_icon_container.moveResize(x, y, width, height); + m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() ? width : height); renderTheme(); } -- cgit v0.11.2