Skip to content

Commit 216caf5

Browse files
committed
Ability to override theme font, size and spacing in UITextInput
1 parent 98174f5 commit 216caf5

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

Modules/Contents/UI/Include/PolyUITextInput.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ namespace Polycode {
146146
* @param width The width of the element.
147147
* @param height The height of the element.
148148
*/
149-
UITextInput(bool multiLine, Number width, Number height);
149+
UITextInput(bool multiLine, Number width, Number height, int customFontSize=-1, const String &customFont="", int customLineSpacing=-1);
150150
virtual ~UITextInput();
151151

152152
void handleEvent(Event *event);

Modules/Contents/UI/Source/PolyUITextInput.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void UITextInput::setMenuSingleton(UIGlobalMenu *_globalMenu) {
3737
globalMenuSingleton = _globalMenu;
3838
}
3939

40-
UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElement(width, height) {
40+
UITextInput::UITextInput(bool multiLine, Number width, Number height, int customFontSize, const String &customFont, int customLineSpacing) : UIElement(width, height) {
4141
this->multiLine = multiLine;
4242
processInputEvents = true;
4343
isNumberOnly = false;
@@ -72,16 +72,23 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
7272
setAnchorPoint(0.0, 0.0, 0.0);
7373
Config *conf = CoreServices::getInstance()->getConfig();
7474

75+
if(customFont != "") {
76+
fontName = customFont;
77+
} else {
7578
if(multiLine)
7679
fontName = conf->getStringValue("Polycode", "uiTextInputFontNameMultiLine");
7780
else
7881
fontName = conf->getStringValue("Polycode", "uiTextInputFontName");
79-
80-
if(multiLine)
81-
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSizeMultiline");
82-
else
83-
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSize");
84-
82+
}
83+
if(customFontSize != -1) {
84+
fontSize = customFontSize;
85+
} else {
86+
if(multiLine)
87+
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSizeMultiline");
88+
else
89+
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSize");
90+
}
91+
8592
Number rectHeight = height;
8693
if(!multiLine) {
8794
rectHeight = fontSize+10;
@@ -90,8 +97,13 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
9097
linesContainer = new Entity();
9198
linesContainer->processInputEvents = true;
9299
linesContainer->ownsChildren = true;
93-
lineSpacing = conf->getNumericValue("Polycode", "textEditLineSpacing");
94-
100+
101+
if(customLineSpacing != -1) {
102+
lineSpacing = customLineSpacing;
103+
} else {
104+
lineSpacing = conf->getNumericValue("Polycode", "textEditLineSpacing");
105+
}
106+
95107
st = conf->getNumericValue("Polycode", "textBgSkinT");
96108
sr = conf->getNumericValue("Polycode", "textBgSkinR");
97109
sb = conf->getNumericValue("Polycode", "textBgSkinB");

0 commit comments

Comments
 (0)