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;
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;
switch (alignment()) {
case RIGHT:
case CENTER:
case LEFT:
return m_max_size_per_client;
break;
case RELATIVE:
if (size() == 0)
max_relative_size = width();
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);
max_relative_size = w < (size()-1)*borderW ? 1 :
(w - (size() - 1) * borderW) / size();
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<void, FbWindow> function) {

View file

@ -43,7 +43,7 @@ public:
typedef const Button * ConstItem;
typedef std::list<Item> 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

View file

@ -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();
}