Skip to content

Commit

Permalink
Widgets|libappfw: Setting a minimum content height for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 15, 2016
1 parent 78ff6ed commit 9eb2023
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doomsday/sdk/libappfw/include/de/widgets/labelwidget.h
Expand Up @@ -175,6 +175,8 @@ class LIBAPPFW_PUBLIC LabelWidget : public GuiWidget, public IAssetGroup

void setMaximumTextWidth(Rule const &pixels);

void setMinimumContentHeight(Rule const &minHeight);

/**
* Sets an alternative style for text. By default, the rich text styling comes
* from Style.
Expand Down
17 changes: 14 additions & 3 deletions doomsday/sdk/libappfw/src/widgets/labelwidget.cpp
Expand Up @@ -56,6 +56,8 @@ public Font::RichFormat::IStyle

ConstantRule *width;
ConstantRule *height;
IndirectRule *minHeight;
Rule const *outHeight;
AnimationRule *appearSize;
LabelWidget::AppearanceAnimation appearType;
TimeDelta appearSpan;
Expand Down Expand Up @@ -105,8 +107,10 @@ public Font::RichFormat::IStyle
, uMvpMatrix ("uMvpMatrix", GLUniform::Mat4)
, uColor ("uColor", GLUniform::Vec4)
{
width = new ConstantRule(0);
height = new ConstantRule(0);
width = new ConstantRule(0);
height = new ConstantRule(0);
minHeight = new IndirectRule;
outHeight = new OperatorRule(OperatorRule::Maximum, *height, *minHeight);

uColor = Vector4f(1, 1, 1, 1);
updateStyle();
Expand All @@ -119,6 +123,8 @@ public Font::RichFormat::IStyle
{
releaseRef(width);
releaseRef(height);
releaseRef(minHeight);
releaseRef(outHeight);
releaseRef(appearSize);
releaseRef(maxTextWidth);
}
Expand Down Expand Up @@ -568,7 +574,7 @@ public Font::RichFormat::IStyle
{
case AppearInstantly:
case AppearGrowHorizontally:
if (vertPolicy == Expand) return height;
if (vertPolicy == Expand) return outHeight;
break;

case AppearGrowVertically:
Expand Down Expand Up @@ -733,6 +739,11 @@ void LabelWidget::setMaximumTextWidth(Rule const &pixels)
requestGeometry();
}

void LabelWidget::setMinimumContentHeight(Rule const &minHeight)
{
d->minHeight->setSource(minHeight);
}

void LabelWidget::setTextStyle(Font::RichFormat::IStyle const *richStyle)
{
d->richStyle = richStyle;
Expand Down

0 comments on commit 9eb2023

Please sign in to comment.