previous fix for reverting iconbar to relative broke external tabs

This commit is contained in:
Mark Tiefenbruck 2009-06-28 08:22:51 -07:00
parent f3d61235f3
commit 4e586cc172
3 changed files with 32 additions and 22 deletions

View file

@ -33,13 +33,14 @@ namespace FbTk {
typedef CompareEqual_base<FbWindow, Window> CompareWindow; typedef CompareEqual_base<FbWindow, Window> CompareWindow;
Container::Container(const FbWindow &parent): Container::Container(const FbWindow &parent, bool auto_resize):
FbWindow(parent, 0, 0, 1, 1, ExposureMask), FbWindow(parent, 0, 0, 1, 1, ExposureMask),
m_orientation(ROT0), m_orientation(ROT0),
m_align(RELATIVE), m_align(RELATIVE),
m_max_size_per_client(60), m_max_size_per_client(60),
m_max_total_size(0), m_max_total_size(0),
m_update_lock(false) { m_update_lock(false),
m_auto_resize(auto_resize) {
EventManager::instance()->add(*this, *this); EventManager::instance()->add(*this, *this);
} }
@ -328,7 +329,7 @@ void Container::repositionItems() {
} else } else
max_width_per_client = 1; 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 // calling Container::resize here risks infinite loops
unsigned int neww = total_width, newh = height; unsigned int neww = total_width, newh = height;
translateSize(m_orientation, neww, newh); translateSize(m_orientation, neww, newh);
@ -410,24 +411,31 @@ void Container::repositionItems() {
unsigned int Container::maxWidthPerClient() const { unsigned int Container::maxWidthPerClient() const {
unsigned int max_relative_size; switch (alignment()) {
if (size() == 0) case RIGHT:
max_relative_size = width(); case CENTER:
else { case LEFT:
unsigned int borderW = m_item_list.front()->borderWidth(); return m_max_size_per_client;
// there're count-1 borders to fit in with the windows break;
// -> 1 per window plus end case RELATIVE:
unsigned int w = width(), h = height(); if (size() == 0)
translateSize(m_orientation, w, h); return width();
max_relative_size = w < (size()-1)*borderW ? 1 : else {
(w - (size() - 1) * borderW) / size(); 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) // this will never happen anyway
return max_relative_size; return 1;
return (m_max_size_per_client < max_relative_size ?
m_max_size_per_client : max_relative_size);
} }
void Container::for_each(std::mem_fun_t<void, FbWindow> function) { void Container::for_each(std::mem_fun_t<void, FbWindow> function) {

View file

@ -43,7 +43,7 @@ public:
typedef const Button * ConstItem; typedef const Button * ConstItem;
typedef std::list<Item> ItemList; typedef std::list<Item> ItemList;
explicit Container(const FbWindow &parent); explicit Container(const FbWindow &parent, bool auto_resize = true);
virtual ~Container(); virtual ~Container();
// manipulators // manipulators
@ -106,7 +106,7 @@ private:
unsigned int m_max_size_per_client; unsigned int m_max_size_per_client;
unsigned int m_max_total_size; unsigned int m_max_total_size;
ItemList m_item_list; ItemList m_item_list;
bool m_update_lock; bool m_update_lock, m_auto_resize;
}; };
} // end namespace FbTk } // end namespace FbTk

View file

@ -249,7 +249,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme,
BScreen &screen, FbTk::Menu &menu): BScreen &screen, FbTk::Menu &menu):
ToolbarItem(ToolbarItem::RELATIVE), ToolbarItem(ToolbarItem::RELATIVE),
m_screen(screen), m_screen(screen),
m_icon_container(parent), m_icon_container(parent, false),
m_theme(theme), m_theme(theme),
m_focused_theme(focused_theme), m_focused_theme(focused_theme),
m_unfocused_theme(unfocused_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) { void IconbarTool::resize(unsigned int width, unsigned int height) {
m_icon_container.resize(width, height); m_icon_container.resize(width, height);
m_icon_container.setMaxTotalSize(m_icon_container.orientation() == FbTk::ROT0 || m_icon_container.orientation() ? width : height);
renderTheme(); renderTheme();
} }
@ -314,6 +315,7 @@ void IconbarTool::moveResize(int x, int y,
unsigned int width, unsigned int height) { unsigned int width, unsigned int height) {
m_icon_container.moveResize(x, y, width, 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(); renderTheme();
} }