Skip to content

Commit

Permalink
Ability to override theme font, size and spacing in UITextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansafrin committed Jun 23, 2015
1 parent 98174f5 commit 216caf5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Modules/Contents/UI/Include/PolyUITextInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace Polycode {
* @param width The width of the element.
* @param height The height of the element.
*/
UITextInput(bool multiLine, Number width, Number height);
UITextInput(bool multiLine, Number width, Number height, int customFontSize=-1, const String &customFont="", int customLineSpacing=-1);
virtual ~UITextInput();

void handleEvent(Event *event);
Expand Down
30 changes: 21 additions & 9 deletions Modules/Contents/UI/Source/PolyUITextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void UITextInput::setMenuSingleton(UIGlobalMenu *_globalMenu) {
globalMenuSingleton = _globalMenu;
}

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

if(customFont != "") {
fontName = customFont;
} else {
if(multiLine)
fontName = conf->getStringValue("Polycode", "uiTextInputFontNameMultiLine");
else
fontName = conf->getStringValue("Polycode", "uiTextInputFontName");

if(multiLine)
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSizeMultiline");
else
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSize");

}
if(customFontSize != -1) {
fontSize = customFontSize;
} else {
if(multiLine)
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSizeMultiline");
else
fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSize");
}

Number rectHeight = height;
if(!multiLine) {
rectHeight = fontSize+10;
Expand All @@ -90,8 +97,13 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
linesContainer = new Entity();
linesContainer->processInputEvents = true;
linesContainer->ownsChildren = true;
lineSpacing = conf->getNumericValue("Polycode", "textEditLineSpacing");


if(customLineSpacing != -1) {
lineSpacing = customLineSpacing;
} else {
lineSpacing = conf->getNumericValue("Polycode", "textEditLineSpacing");
}

st = conf->getNumericValue("Polycode", "textBgSkinT");
sr = conf->getNumericValue("Polycode", "textBgSkinR");
sb = conf->getNumericValue("Polycode", "textBgSkinB");
Expand Down

0 comments on commit 216caf5

Please sign in to comment.