diff --git a/data/skins/default/skin.xml b/data/skins/default/skin.xml
index 3303b5f0f..1f220163d 100644
--- a/data/skins/default/skin.xml
+++ b/data/skins/default/skin.xml
@@ -359,7 +359,7 @@
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index c04c4e7ad..429904538 100644
--- a/src/app/ui/skin/skin_theme.cpp
+++ b/src/app/ui/skin/skin_theme.cpp
@@ -606,6 +606,8 @@ void SkinTheme::onRegenerate()
PRINTF("- Rule '%s' for '%s'\n", ruleName.c_str(), style_id);
+ // TODO This code design to read styles could be improved.
+
const char* part_id = xmlRule->Attribute("part");
const char* color_id = xmlRule->Attribute("color");
@@ -635,6 +637,16 @@ void SkinTheme::onRegenerate()
else if (ruleName == "text") {
if (color_id) (*style)[StyleSheet::textColorRule()] = css::Value(color_id);
if (align) (*style)[StyleSheet::textAlignRule()] = css::Value(align);
+
+ const char* padding_left = xmlRule->Attribute("padding-left");
+ const char* padding_top = xmlRule->Attribute("padding-top");
+ const char* padding_right = xmlRule->Attribute("padding-right");
+ const char* padding_bottom = xmlRule->Attribute("padding-bottom");
+
+ if (padding_left) (*style)[StyleSheet::paddingLeftRule()] = css::Value(strtol(padding_left, NULL, 10));
+ if (padding_top) (*style)[StyleSheet::paddingTopRule()] = css::Value(strtol(padding_top, NULL, 10));
+ if (padding_right) (*style)[StyleSheet::paddingRightRule()] = css::Value(strtol(padding_right, NULL, 10));
+ if (padding_bottom) (*style)[StyleSheet::paddingBottomRule()] = css::Value(strtol(padding_bottom, NULL, 10));
}
xmlRule = xmlRule->NextSiblingElement();
diff --git a/src/app/ui/skin/style.cpp b/src/app/ui/skin/style.cpp
index 695a782be..11d175477 100644
--- a/src/app/ui/skin/style.cpp
+++ b/src/app/ui/skin/style.cpp
@@ -71,13 +71,14 @@ void TextRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* tex
{
SkinTheme* theme = static_cast(ui::CurrentTheme::get());
- if (text)
+ if (text) {
g->drawString(text,
(ui::is_transparent(m_color) ?
theme->getColor(ThemeColor::Text):
m_color),
ui::ColorNone,
- bounds, m_align);
+ gfx::Rect(bounds).shrink(m_padding), m_align);
+ }
}
void IconRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text)
@@ -113,6 +114,10 @@ Rules::Rules(const css::Query& query) :
css::Value iconPart = query[StyleSheet::iconPartRule()];
css::Value textAlign = query[StyleSheet::textAlignRule()];
css::Value textColor = query[StyleSheet::textColorRule()];
+ css::Value paddingLeft = query[StyleSheet::paddingLeftRule()];
+ css::Value paddingTop = query[StyleSheet::paddingTopRule()];
+ css::Value paddingRight = query[StyleSheet::paddingRightRule()];
+ css::Value paddingBottom = query[StyleSheet::paddingBottomRule()];
css::Value none;
if (backgroundColor != none
@@ -130,10 +135,17 @@ Rules::Rules(const css::Query& query) :
}
if (textAlign != none
- || textColor != none) {
+ || textColor != none
+ || paddingLeft != none
+ || paddingTop != none
+ || paddingRight != none
+ || paddingBottom != none) {
m_text = new TextRule();
m_text->setAlign((int)textAlign.number());
m_text->setColor(StyleSheet::convertColor(textColor));
+ m_text->setPadding(gfx::Border(
+ paddingLeft.number(), paddingTop.number(),
+ paddingRight.number(), paddingBottom.number())*ui::jguiscale());
}
}
diff --git a/src/app/ui/skin/style.h b/src/app/ui/skin/style.h
index fadab24ee..84f323805 100644
--- a/src/app/ui/skin/style.h
+++ b/src/app/ui/skin/style.h
@@ -25,6 +25,7 @@
#include "css/compound_style.h"
#include "css/state.h"
#include "css/stateful_style.h"
+#include "gfx/border.h"
#include "gfx/fwd.h"
#include "ui/color.h"
@@ -74,6 +75,7 @@ namespace app {
void setAlign(int align) { m_align = align; }
void setColor(ui::Color color) { m_color = color; }
+ void setPadding(const gfx::Border& padding) { m_padding = padding; }
protected:
void onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text) OVERRIDE;
@@ -81,6 +83,7 @@ namespace app {
private:
int m_align;
ui::Color m_color;
+ gfx::Border m_padding;
};
class IconRule : public Rule {
diff --git a/src/app/ui/skin/style_sheet.cpp b/src/app/ui/skin/style_sheet.cpp
index a57c73a35..026eb37dd 100644
--- a/src/app/ui/skin/style_sheet.cpp
+++ b/src/app/ui/skin/style_sheet.cpp
@@ -38,6 +38,10 @@ css::Rule StyleSheet::m_iconAlignRule("icon-align");
css::Rule StyleSheet::m_iconPartRule("icon-part");
css::Rule StyleSheet::m_textAlignRule("text-align");
css::Rule StyleSheet::m_textColorRule("text-color");
+css::Rule StyleSheet::m_paddingLeftRule("padding-left");
+css::Rule StyleSheet::m_paddingTopRule("padding-top");
+css::Rule StyleSheet::m_paddingRightRule("padding-right");
+css::Rule StyleSheet::m_paddingBottomRule("padding-bottom");
StyleSheet::StyleSheet()
{
@@ -48,6 +52,10 @@ StyleSheet::StyleSheet()
m_sheet->addRule(&m_iconPartRule);
m_sheet->addRule(&m_textAlignRule);
m_sheet->addRule(&m_textColorRule);
+ m_sheet->addRule(&m_paddingLeftRule);
+ m_sheet->addRule(&m_paddingTopRule);
+ m_sheet->addRule(&m_paddingRightRule);
+ m_sheet->addRule(&m_paddingBottomRule);
}
StyleSheet::~StyleSheet()
diff --git a/src/app/ui/skin/style_sheet.h b/src/app/ui/skin/style_sheet.h
index 1b956114c..04b8ae2d0 100644
--- a/src/app/ui/skin/style_sheet.h
+++ b/src/app/ui/skin/style_sheet.h
@@ -50,6 +50,10 @@ namespace app {
static css::Rule& iconPartRule() { return m_iconPartRule; }
static css::Rule& textAlignRule() { return m_textAlignRule; }
static css::Rule& textColorRule() { return m_textColorRule; }
+ static css::Rule& paddingLeftRule() { return m_paddingLeftRule; }
+ static css::Rule& paddingTopRule() { return m_paddingTopRule; }
+ static css::Rule& paddingRightRule() { return m_paddingRightRule; }
+ static css::Rule& paddingBottomRule() { return m_paddingBottomRule; }
css::Sheet& sheet() { return *m_sheet; }
@@ -69,6 +73,11 @@ namespace app {
static css::Rule m_iconPartRule;
static css::Rule m_textAlignRule;
static css::Rule m_textColorRule;
+ static css::Rule m_paddingLeftRule;
+ static css::Rule m_paddingTopRule;
+ static css::Rule m_paddingRightRule;
+ static css::Rule m_paddingBottomRule;
+
css::Sheet* m_sheet;
StyleMap m_styles;
};