[Libreoffice-commits] .: Branch 'feature/layout' - vcl/source
Ricardo Cruz
rpmcruz at kemper.freedesktop.org
Fri Dec 17 20:28:50 PST 2010
vcl/source/layout/buttonbox.cxx | 30 +++++++++++++++---------------
vcl/source/layout/layout.cxx | 2 +-
2 files changed, 16 insertions(+), 16 deletions(-)
New commits:
commit d4237264d141849cb17ef183d91f4706b16ad198
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date: Sat Dec 18 04:28:23 2010 +0000
ButtonBox code more legible. Reduced QueueResize timeout.
diff --git a/vcl/source/layout/buttonbox.cxx b/vcl/source/layout/buttonbox.cxx
index 48b8e6d..7b938b7 100644
--- a/vcl/source/layout/buttonbox.cxx
+++ b/vcl/source/layout/buttonbox.cxx
@@ -43,10 +43,10 @@ struct DefaultButtonOrder : public ButtonOrder {
virtual int RoleOrder (ButtonRole role) {
switch (role) {
// right align
- case OK_BUTTON: return 3;
- case CANCEL_BUTTON: return 2;
- case APPLY_BUTTON: return 1;
- case CUSTOM_BUTTON: return 0;
+ case OK_BUTTON: return 0;
+ case CANCEL_BUTTON: return 1;
+ case APPLY_BUTTON: return 2;
+ case CUSTOM_BUTTON: return 3;
// left align
case HELP_BUTTON: return 0;
case REVERT_BUTTON: return 1;
@@ -170,7 +170,7 @@ void ButtonBox::SizeAllocate (long x, long y, long width, long height)
for (int align = -1; align <= +1; align++) {
std::vector <ChildData *> buttons;
buttons.reserve (m_children.size());
- long childrenWidth = 0; // required for align=0
+ long childrenWidth = 0;
// 1. filter buttons belonging to this alignment
for (std::list <ChildData>::iterator it = m_children.begin();
@@ -179,14 +179,17 @@ void ButtonBox::SizeAllocate (long x, long y, long width, long height)
if (button.IsVisible())
if (m_buttonOrder->RoleAlign (it->role) == align) {
buttons.push_back (&(*it));
- if (align == 0)
+
+ if (!m_buttonOrder->UseSameSize())
childrenWidth += it->requisition.Width();
}
}
- if (align == 0)
- childrenWidth += SPACING * (buttons.size()-1);
- // 2. sort buttons by order
+ if (m_buttonOrder->UseSameSize())
+ childrenWidth += m_maxButtonWidth * buttons.size();
+ childrenWidth += SPACING * (buttons.size()-1);
+
+ // 2. sort buttons by role
std::sort (buttons.begin(), buttons.end(), cmp);
// 3. allocate buttons
@@ -194,8 +197,9 @@ void ButtonBox::SizeAllocate (long x, long y, long width, long height)
switch (align) {
case -1: childX = 0; break;
case 0: childX = (width - childrenWidth) / 2; break;
- case +1: childX = width; break;
+ case +1: childX = width - childrenWidth; break;
}
+
for (std::vector <ChildData *>::iterator it = buttons.begin();
it != buttons.end(); it++) {
long childWidth;
@@ -203,13 +207,9 @@ void ButtonBox::SizeAllocate (long x, long y, long width, long height)
childWidth = m_maxButtonWidth;
else
childWidth = (*it)->requisition.Width();
- if (align == +1)
- childX -= childWidth;
(*it)->button.SizeAllocate (x + childX, y, childWidth, height);
- if (align <= 0)
- childX += childWidth;
- childX += SPACING * (align <= 0 ? +1 : -1);
+ childX += childWidth + SPACING;
}
}
}
diff --git a/vcl/source/layout/layout.cxx b/vcl/source/layout/layout.cxx
index 61e25e6..1b13931 100644
--- a/vcl/source/layout/layout.cxx
+++ b/vcl/source/layout/layout.cxx
@@ -42,7 +42,7 @@ struct LayoutProscratinator : public Timer
LayoutProscratinator() : Timer()
{
- SetTimeout (500);
+ SetTimeout (20);
}
void Add (Widget &widget)
More information about the Libreoffice-commits
mailing list