From 9eb202348d5ecbaa1d598f7122b2bab21ffabd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 15 Oct 2016 15:50:13 +0300 Subject: [PATCH] Widgets|libappfw: Setting a minimum content height for labels --- .../libappfw/include/de/widgets/labelwidget.h | 2 ++ .../sdk/libappfw/src/widgets/labelwidget.cpp | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doomsday/sdk/libappfw/include/de/widgets/labelwidget.h b/doomsday/sdk/libappfw/include/de/widgets/labelwidget.h index 4cfe25bf0f..8b08dbb15d 100644 --- a/doomsday/sdk/libappfw/include/de/widgets/labelwidget.h +++ b/doomsday/sdk/libappfw/include/de/widgets/labelwidget.h @@ -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. diff --git a/doomsday/sdk/libappfw/src/widgets/labelwidget.cpp b/doomsday/sdk/libappfw/src/widgets/labelwidget.cpp index 9650886834..936a25241d 100644 --- a/doomsday/sdk/libappfw/src/widgets/labelwidget.cpp +++ b/doomsday/sdk/libappfw/src/widgets/labelwidget.cpp @@ -56,6 +56,8 @@ public Font::RichFormat::IStyle ConstantRule *width; ConstantRule *height; + IndirectRule *minHeight; + Rule const *outHeight; AnimationRule *appearSize; LabelWidget::AppearanceAnimation appearType; TimeDelta appearSpan; @@ -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(); @@ -119,6 +123,8 @@ public Font::RichFormat::IStyle { releaseRef(width); releaseRef(height); + releaseRef(minHeight); + releaseRef(outHeight); releaseRef(appearSize); releaseRef(maxTextWidth); } @@ -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: @@ -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;