Skip to content

Commit

Permalink
Fixed|libappfw|LabelWidget: Updating label's margins
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 9, 2014
1 parent 83f1a78 commit 619ce3e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions doomsday/libappfw/src/widgets/labelwidget.cpp
Expand Up @@ -55,7 +55,6 @@ public Font::RichFormat::IStyle
TimeDelta appearSpan;

// Style.
Vector4i margin;
DotPath gapId;
int gap;
ColorBank::Color highlightColor;
Expand Down Expand Up @@ -114,8 +113,7 @@ public Font::RichFormat::IStyle
{
Style const &st = self.style();

margin = self.margins().toVector();
gap = st.rules().rule(gapId).valuei();
gap = st.rules().rule(gapId).valuei();

// Colors.
highlightColor = st.colors().color("label.highlight");
Expand All @@ -129,6 +127,11 @@ public Font::RichFormat::IStyle
self.requestGeometry();
}

Vector4i margin() const
{
return self.margins().toVector();
}

Color richStyleColor(int index) const
{
switch(index)
Expand Down Expand Up @@ -239,7 +242,7 @@ public Font::RichFormat::IStyle

Rectanglei contentArea() const
{
return self.rule().recti().adjusted(margin.xy(), -margin.zw());
return self.rule().recti().adjusted(margin().xy(), -margin().zw());
}

/**
Expand Down Expand Up @@ -411,15 +414,15 @@ public Font::RichFormat::IStyle
if(horizPolicy == Expand)
{
// Expansion can occur to full view width.
w = root().viewSize().x - (margin.x + margin.z);
w = root().viewSize().x - (margin().x + margin().z);
}
else
{
w = self.rule().width().valuei() - (margin.x + margin.z);
w = self.rule().width().valuei() - (margin().x + margin().z);
}
if(vertPolicy != Expand)
{
h = self.rule().height().valuei() - (margin.y + margin.w);
h = self.rule().height().valuei() - (margin().y + margin().w);
}

if(hasImage())
Expand Down Expand Up @@ -456,8 +459,8 @@ public Font::RichFormat::IStyle
ContentLayout layout;
contentPlacement(layout);
Rectanglef combined = layout.image | layout.text;
width->set (combined.width() + margin.x + margin.z);
height->set(combined.height() + margin.y + margin.w);
width->set (combined.width() + self.margins().width().valuei());
height->set(combined.height() + self.margins().height().valuei());
}

void updateAppearanceAnimation()
Expand Down

0 comments on commit 619ce3e

Please sign in to comment.