void DataGraph::FillCell(UIHierarchyCell *cell, void *node) { //Temporary fix for loading of UI Interface to avoid reloading of texrures to different formates. // 1. Reset default format before loading of UI // 2. Restore default format after loading of UI from stored settings. Texture::SetDefaultGPU(GPU_UNKNOWN); DataNode *n = (DataNode *)node; UIStaticText *text = (UIStaticText *)cell->FindByName("_Text_"); text->SetText(StringToWString(n->GetName())); UIControl *icon = cell->FindByName("_Icon_"); icon->SetSprite("~res:/Gfx/UI/SceneNode/datanode", 0); UIControl *marker = cell->FindByName("_Marker_"); marker->SetVisible(false); if(n == workingNode) { cell->SetSelected(true, false); } else { cell->SetSelected(false, false); } Texture::SetDefaultGPU(EditorSettings::Instance()->GetTextureViewGPU()); }
void UIButtonMetadata::SetFontSize(float fontSize) { if (!VerifyActiveParamID()) { return; } for (uint32 i = 0; i < this->GetStatesCount(); ++i) { UIStaticText *buttonText = GetActiveUIButton()->GetStateTextControl(this->uiControlStates[i]); if (!buttonText) { return; } Font *font = buttonText->GetFont(); if (!font) { return; } font->SetSize(fontSize); buttonText->SetFont(font); } UpdatePropertyDirtyFlagForFontSize(); }
bool AutotestingSystemLua::CheckMsgText(UIControl *control, const String &key) { WideString expectedText = StringToWString(key); //TODO: check key in localized strings for Lua expectedText = autotestingLocalizationSystem->GetLocalizedString(expectedText); UIStaticText *uiStaticText = dynamic_cast<UIStaticText*>(control); if(uiStaticText) { WideString actualText = uiStaticText->GetText(); Log("DEBUG", Format("Compare text in control %s with text by key %s", uiStaticText->GetName().c_str(), key.c_str())); Log("DEBUG", WStringToString(actualText)); Log("DEBUG", WStringToString(expectedText)); return (actualText == expectedText); } UITextField *uiTextField = dynamic_cast<UITextField*>(control); if(uiTextField) { WideString actualText = uiTextField->GetText(); Log("DEBUG", Format("Compare text in control %s with text by key %s", uiTextField->GetName().c_str(), key.c_str())); Log("DEBUG", WStringToString(actualText)); Log("DEBUG", WStringToString(expectedText)); return (actualText == expectedText); } return false; }
UIHierarchyCell * GraphBase::CellForNode(UIHierarchy *forHierarchy, void *node) { UIHierarchyCell *c= forHierarchy->GetReusableCell("Graph cell"); //try to get cell from the reusable cells store if(!c) { //if cell of requested type isn't find in the store create new cell int32 leftSideWidth = EditorSettings::Instance()->GetLeftPanelWidth(); c = new UIHierarchyCell(Rect(0, 0, leftSideWidth, ControlsFactory::CELL_HEIGHT), "Graph cell"); UIControl *icon = new UIControl(Rect(0, 0, ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); icon->SetName("_Icon_"); icon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); c->text->AddControl(icon); UIControl *marker = new UIControl(Rect(0, 0, ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); marker->SetName("_Marker_"); marker->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); c->text->AddControl(marker); UIStaticText *text = new UIStaticText(Rect(ControlsFactory::CELL_HEIGHT, 0, leftSideWidth - ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); Font *font = ControlsFactory::GetFont12(); text->SetFont(font); text->SetAlign(ALIGN_LEFT|ALIGN_VCENTER); text->SetName("_Text_"); text->SetTextColor(ControlsFactory::GetColorDark()); c->text->AddControl(text); } FillCell(c, node); ControlsFactory::CustomizeExpandButton(c->openButton); ControlsFactory::CustomizeSceneGraphCell(c); return c; }
Font * UIButtonMetadata::GetFontForState(UIControl::eControlState state) const { UIStaticText *buttonText = GetActiveUIButton()->GetStateTextControl(state); if (buttonText) { return buttonText->GetFont(); } return EditorFontManager::Instance()->GetDefaultFont(); }
void TextinputTestScreen::CreateHeader() { UIStaticText * header = new UIStaticText(Rect(5.f, 5.f, 300.f, 50.f)); AddControl(header); header->Release(); header->SetFont(font); header->SetTextColor(Color::White()); header->SetText(headerText); }
QColor UIButtonMetadata::GetFontColorForState(UIControl::eControlState state) const { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(state); if (referenceButtonText) { return DAVAColorToQTColor(referenceButtonText->GetTextColor()); } return QColor(); }
void LandscapeToolsPanel::SetSliderHeaderPoition(UISlider *slider, const WideString &headerText) { UIStaticText *textControl = static_cast<UIStaticText *>(this->FindByName(WStringToString(headerText))); if(textControl) { Rect sliderRect = slider->GetRect(); Vector2 textPosition = textControl->GetPosition(); textControl->SetPosition(Vector2(sliderRect.x - OFFSET - sliderRect.dx, textPosition.y)); } }
CreatePropertyControl::CreatePropertyControl(const Rect & rect, CreatePropertyControlDelegate *newDelegate) : UIControl(rect) { ControlsFactory::CustomizeDialog(this); delegate = newDelegate; Vector<String> types; types.push_back("String"); types.push_back("Integer"); types.push_back("Float"); types.push_back("Bool"); Rect buttonRect(0, rect.dy - ControlsFactory::BUTTON_HEIGHT, rect.dx / 2, ControlsFactory::BUTTON_HEIGHT); UIButton *btnCancel = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.cancel")); btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreatePropertyControl::OnCancel)); AddControl(btnCancel); SafeRelease(btnCancel); buttonRect.x = rect.dx - buttonRect.dx; UIButton *btnCreate = ControlsFactory::CreateButton(buttonRect, LocalizedString(L"dialog.create")); btnCreate->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &CreatePropertyControl::OnCreate)); AddControl(btnCreate); SafeRelease(btnCreate); Rect textRect(0, 0, rect.dx / 3, (rect.dy - buttonRect.dy) / 2); Rect controlRect(textRect.dx, 0, rect.dx - textRect.dx, textRect.dy); UIStaticText *t = new UIStaticText(textRect); t->SetText(LocalizedString(L"createproperty.type")); t->SetFont(ControlsFactory::GetFontLight()); AddControl(t); SafeRelease(t); typeCombo = new ComboBox(controlRect, NULL, types); AddControl(typeCombo); textRect.y = textRect.dy; controlRect.y = controlRect.dy; t = new UIStaticText(textRect); t->SetText(LocalizedString(L"createproperty.name")); t->SetFont(ControlsFactory::GetFontLight()); AddControl(t); SafeRelease(t); nameField = new UITextField(controlRect); ControlsFactory::CustomizeEditablePropertyCell(nameField); nameField->SetDelegate(this); nameField->SetFont(ControlsFactory::GetFontLight()); AddControl(nameField); }
SettingsDialog::SettingsDialog(const Rect & rect, SettingsDialogDelegate *newDelegate) : UIControl(rect) , delegate(newDelegate) { ControlsFactory::CustomizeDialogFreeSpace(this); Rect dialogRect(rect.dx/4, rect.dy/8, rect.dx / 2, rect.dy * 3 /4); dialogPanel = new DraggableDialog(dialogRect); ControlsFactory::CustomizeDialog(dialogPanel); AddControl(dialogPanel); UIStaticText * header = new UIStaticText(Rect(0, 0, dialogRect.dx, ControlsFactory::BUTTON_HEIGHT)); header->SetFont(ControlsFactory::GetFontLight()); header->SetText(LocalizedString(L"settings.header")); header->SetAlign(ALIGN_HCENTER | ALIGN_VCENTER); dialogPanel->AddControl(header); SafeRelease(header); propertyList = new PropertyList( Rect(0, ControlsFactory::BUTTON_HEIGHT, dialogRect.dx, dialogRect.dy - ControlsFactory::BUTTON_HEIGHT * 2), this); dialogPanel->AddControl(propertyList); float32 buttonY = dialogRect.dy - ControlsFactory::BUTTON_HEIGHT; float32 buttonX = (dialogRect.dx - ControlsFactory::BUTTON_WIDTH) / 2.f; UIButton *btnClose = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.close")); btnClose->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SettingsDialog::OnClose)); dialogPanel->AddControl(btnClose); SafeRelease(btnClose); propertyList->AddIntProperty("settingsdialog.screenwidth", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddIntProperty("settingsdialog.screenheight", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("settingsdialog.autosave", PropertyList::PROPERTY_IS_EDITABLE); languages.push_back("en"); languages.push_back("ru"); propertyList->AddComboProperty("settingsdialog.language", languages); propertyList->AddBoolProperty("settingsdialog.output", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("settingsdialog.cameraspeed1", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("settingsdialog.cameraspeed2", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("settingsdialog.cameraspeed3", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddFloatProperty("settingsdialog.cameraspeed4", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddIntProperty("settingsdialog.leftpanelwidth", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddIntProperty("settingsdialog.rightpanelwidth", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddBoolProperty("settingsdialog.drawgrid", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddBoolProperty("settingsdialog.imposters", PropertyList::PROPERTY_IS_EDITABLE); }
QColor UIButtonMetadata::GetShadowColor() const { if (VerifyActiveParamID()) { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(this->uiControlStates[GetActiveStateIndex()]); if (referenceButtonText) { return DAVAColorToQTColor(referenceButtonText->GetShadowColor()); } } return QColor(); }
float UIButtonMetadata::GetShadowOffsetY() const { if (VerifyActiveParamID()) { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(this->uiControlStates[GetActiveStateIndex()]); if (referenceButtonText) { return referenceButtonText->GetShadowOffset().y; } } return -1.0f; }
float UIButtonMetadata::GetFontSizeForState(UIControl::eControlState state) const { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(state); if (referenceButtonText) { Font* referenceFont = referenceButtonText->GetFont(); if (referenceFont) { return referenceFont->GetSize(); } } return -1.0f; }
String AutotestingSystemLua::GetText(UIControl *control) { Logger::Debug("AutotestingSystemLua::GetText =%s", control->GetName().c_str()); UIStaticText *uiStaticText = dynamic_cast<UIStaticText*>(control); if(uiStaticText) { return UTF8Utils::EncodeToUTF8(uiStaticText->GetText()); } UITextField *uiTextField = dynamic_cast<UITextField*>(control); if(uiTextField) { return UTF8Utils::EncodeToUTF8(uiTextField->GetText()); } return ""; }
UIStaticText * PropertyPanel::AddHeader(const WideString & string, float32 fontSize) { FTFont * font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf"); font->SetSize(fontSize); font->SetColor(Color(0.2f, 0.2f, 0.2f, 1.0f)); UIStaticText * text = new UIStaticText(Rect(10, 0, GetRect().dx - 20, 20)); text->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); text->SetFont(font); text->SetText(string); SafeRelease(font); AddPropertyControl(text); text->Release(); return text; }
void UIButtonMetadata::SetShadowColor(const QColor& value) { if (!VerifyActiveParamID()) { return; } for (uint32 i = 0; i < this->GetStatesCount(); ++i) { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(this->uiControlStates[i]); if (referenceButtonText) { referenceButtonText->SetShadowColor(QTColorToDAVAColor(value)); } } }
void UIButtonMetadata::SetShadowOffsetY(float offset) { if (!VerifyActiveParamID()) { return; } for (uint32 i = 0; i < this->GetStatesCount(); ++i) { UIStaticText* referenceButtonText = GetActiveUIButton()->GetStateTextControl(this->uiControlStates[i]); if (referenceButtonText) { Vector2 shadowOffset = GetOffsetY(referenceButtonText->GetShadowOffset(), offset); referenceButtonText->SetShadowOffset(shadowOffset); } } }
void FormatsTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); int32 columnCount = 6; int32 rowCount = (FORMAT_COUNT-1) / columnCount; if(0 != FORMAT_COUNT % columnCount) { ++rowCount; } float32 size = Min(GetSize().x / columnCount, GetSize().y / rowCount); Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); for(int32 i = FORMAT_RGBA8888; i < FORMAT_COUNT; ++i) { int32 y = (i-1) / columnCount; int32 x = (i-1) % columnCount; String formatName = Texture::GetPixelFormatString((PixelFormat)i); UIControl *c = new UIControl(Rect(x*size, y*size, size - 2, size - 2)); c->SetSprite(Format("~res:/TestData/FormatTest/%s/number_0", formatName.c_str()), 0); c->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); UIStaticText *text = new UIStaticText(Rect(0, c->GetSize().y - 30, c->GetSize().x, 30)); text->SetText(StringToWString(formatName)); text->SetFont(font); text->SetTextColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); c->AddControl(text); AddControl(c); SafeRelease(text); SafeRelease(c); } SafeRelease(font); }
UIListCell *MainScreen::CellAtIndex(UIList *list, int32 index) { UIListCell *c = list->GetReusableCell("UI info cell"); //try to get cell from the reusable cells store if(!c) { c = new UIListCell(Rect(0.0f, 0.0f, 2*buttonW, cellH), "UI info cell"); } c->RemoveAllControls(); WideString keyStr = (selectedControl ? selectedControl->GetSpecificInfoKeyText(index) : L""); WideString valueStr = (selectedControl ? selectedControl->GetSpecificInfoValueText(index) : L""); FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf"); font->SetSize(20.0f); font->SetColor(0.8f, 0.8f, 0.8f, 1.0f); c->SetStateFont(UIControl::STATE_NORMAL, font); UIStaticText* cellKeyText = new UIStaticText(Rect(0.0f, 0.0f, buttonW, cellH)); cellKeyText->SetFont(font); cellKeyText->SetText(keyStr); c->AddControl(cellKeyText); UIStaticText* cellValueText = new UIStaticText(Rect(buttonW, 0.0f, buttonW, cellH)); cellValueText->SetFont(font); cellValueText->SetText(valueStr); c->AddControl(cellValueText); SafeRelease(font); return c;//returns cell }
UIStaticText * ParseTextTest::CreateTextControl(const Rect &rect, const WideString & text, bool wrapBySymbol, const Vector2 &requestedSize /*= Vector2(0, 0)*/) { UIStaticText* textControl = new UIStaticText(rect); textControl->SetText(text, requestedSize); textControl->SetDebugDraw(true); textControl->SetTextAlign(ALIGN_VCENTER | ALIGN_LEFT); textControl->SetMultiline(true, wrapBySymbol); Font *font = NULL; switch(requestedFontType) { case Font::TYPE_FT: font = FTFont::Create("~res:/Fonts/korinna.ttf"); font->SetSize(14.f); break; case Font::TYPE_GRAPHICAL: font = GraphicsFont::Create("~res:/Fonts/korinna.def", "~res:/Gfx/Fonts/korinna"); break; default: break; } DVASSERT(font); if(font) { textControl->SetFont(font); font->Release(); } return textControl; }
UICheckBox *LandscapeToolsPanel::CreateCkeckbox(const Rect &rect, const WideString &text) { UICheckBox *checkbox = new UICheckBox("~res:/Gfx/UI/chekBox", rect); checkbox->SetDelegate(this); AddControl(checkbox); Rect textRect; textRect.x = rect.x + rect.dx + OFFSET; textRect.y = rect.y; textRect.dx = TEXT_WIDTH; textRect.dy = rect.dy; UIStaticText *textControl = new UIStaticText(textRect); textControl->SetText(text); textControl->SetFont(ControlsFactory::GetFont12()); textControl->SetTextColor(ControlsFactory::GetColorLight()); textControl->SetAlign(ALIGN_VCENTER | ALIGN_LEFT); AddControl(textControl); SafeRelease(textControl); return checkbox; }
bool AutotestingSystemLua::CheckText(UIControl *control, const String &expectedText) { UIStaticText *uiStaticText = dynamic_cast<UIStaticText*>(control); if(uiStaticText) { String actualText = WStringToString(uiStaticText->GetText()); Log("DEBUG", Format("Compare text in control %s with expected text", uiStaticText->GetName().c_str())); Log("DEBUG", actualText); Log("DEBUG", expectedText); return (actualText == expectedText); } UITextField *uiTextField = dynamic_cast<UITextField*>(control); if(uiTextField) { String actualText = WStringToString(uiTextField->GetText()); Log("DEBUG", Format("Compare text in control %s with expected text", uiTextField->GetName().c_str())); Log("DEBUG", actualText); Log("DEBUG", expectedText); return (actualText == expectedText); } return false; }
ModificationPopUp::ModificationPopUp() : DraggableDialog(Rect(100, 100, 150, 150)) { ControlsFactory::CustomizeDialog(this); selection = 0; UIStaticText *text = new UIStaticText(Rect(0, 0, 80, 20)); text->SetFont(ControlsFactory::GetFontLight()); text->SetText(LocalizedString(L"modificationpanel.modification")); AddControl(text); SafeRelease(text); parameters = new PropertyList(Rect(0.0f, 20.0f, 100.0f, 100.0f), this); parameters->AddFloatProperty("x"); parameters->AddFloatProperty("y"); parameters->AddFloatProperty("z"); AddControl(parameters); btnReset = ControlsFactory::CreateButton(Rect(0, 130, 80, 20), L"Reset"); btnReset->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ModificationPopUp::OnReset)); AddControl(btnReset); }
void LandscapeToolsPanel::AddSliderHeader(UISlider *slider, const WideString &text) { Rect rect = slider->GetRect(); rect.x -= rect.dx - OFFSET; UIStaticText *textControl = new UIStaticText(rect); textControl->SetName(WStringToString(text)); textControl->SetText(text); textControl->SetFont(ControlsFactory::GetFont12()); textControl->SetTextColor(ControlsFactory::GetColorLight()); textControl->SetAlign(ALIGN_VCENTER | ALIGN_RIGHT); AddControl(textControl); SafeRelease(textControl); }
// Initialize the control(s) attached. void UIStaticTextMetadata::InitializeControl(const String& controlName, const Vector2& position) { BaseMetadata::InitializeControl(controlName, position); int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { UIStaticText* staticText = dynamic_cast<UIStaticText*>(this->treeNodeParams[i].GetUIControl()); staticText->SetFont(EditorFontManager::Instance()->GetDefaultFont()); staticText->SetMultiline(true); staticText->GetBackground()->SetDrawType(UIControlBackground::DRAW_ALIGNED); // Initialize both control text and localization key. WideString controlText = StringToWString(staticText->GetName()); HierarchyTreeNode* activeNode = GetTreeNode(i); staticText->SetText(controlText); // Static text is not state-aware. activeNode->GetExtraData().SetLocalizationKey(controlText, this->GetReferenceState()); } }
void DFFontTest::LoadResources() { Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); WideString testText = L"Distance font test"; { DFFont* dfFont = DFFont::Create("~res:/DFFont/testFont.df"); dfFont->SetSize(20); UIStaticText* staticText = new UIStaticText(); staticText->SetFont(dfFont); staticText->SetRect(Rect(100, 15, 1000, 100)); staticText->SetText(testText); AddControl(staticText); SafeRelease(dfFont); SafeRelease(staticText); } { DFFont* dfFont = DFFont::Create("~res:/DFFont/testFont.df"); dfFont->SetSize(48); UIStaticText* staticText = new UIStaticText(); staticText->SetFont(dfFont); staticText->SetRect(Rect(100, 250, 1000, 100)); staticText->SetText(testText); AddControl(staticText); SafeRelease(dfFont); SafeRelease(staticText); } { DFFont* dfFont = DFFont::Create("~res:/DFFont/testFont.df"); dfFont->SetSize(65); UIStaticText* staticText = new UIStaticText(); staticText->SetFont(dfFont); staticText->SetRect(Rect(100, 450, 1000, 100)); staticText->SetText(testText); AddControl(staticText); SafeRelease(dfFont); SafeRelease(staticText); } { UIStaticText* staticText1 = new UIStaticText(); staticText1->SetFont(font); staticText1->SetRect(Rect(10, 15, 300, 30)); staticText1->SetText(L"FTFont test"); AddControl(staticText1); SafeRelease(staticText1); } testButton = new UIButton(Rect(0, 600, 300, 30)); testButton->SetStateFont(0xFF, font); //testButton->SetStateFontColor(0xFF, Color::White()); testButton->SetStateText(0xFF, L"Finish Test"); testButton->SetDebugDraw(true); testButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &DFFontTest::ButtonPressed)); AddControl(testButton); SafeRelease(font); }
void EntitiesGraph::FillCell(UIHierarchyCell *cell, void *node) { Entity *n = (Entity *)node; UIStaticText *text = (UIStaticText *)cell->FindByName("_Text_"); text->SetText(Format(L"Entity %d", n->GetIndexInFamily())); }
YamlNode * UIStaticText::SaveToYamlNode(UIYamlLoader * loader) { YamlNode *node = UIControl::SaveToYamlNode(loader); UIStaticText *baseControl = new UIStaticText(); //Temp variable VariantType *nodeValue = new VariantType(); //Font //Get font name and put it here nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont())); node->Set("font", nodeValue); //TextColor const Color &textColor = GetTextColor(); if (baseControl->GetTextColor() != textColor) { nodeValue->SetColor(textColor); node->Set("textcolor", nodeValue); } // Text Color Inherit Type. int32 colorInheritType = (int32)GetTextBackground()->GetColorInheritType(); if (baseControl->GetTextBackground()->GetColorInheritType() != colorInheritType) { node->Set("textcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType)); } // ShadowColor const Color &shadowColor = GetShadowColor(); if (baseControl->GetShadowColor() != shadowColor) { nodeValue->SetColor(shadowColor); node->Set("shadowcolor", nodeValue); } // Shadow Color Inherit Type. colorInheritType = (int32)GetShadowBackground()->GetColorInheritType(); if (baseControl->GetShadowBackground()->GetColorInheritType() != colorInheritType) { node->Set("shadowcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType)); } // ShadowOffset const Vector2 &shadowOffset = GetShadowOffset(); if (baseControl->GetShadowOffset() != shadowOffset) { nodeValue->SetVector2(shadowOffset); node->Set("shadowoffset", nodeValue); } //Text const WideString &text = GetText(); if (baseControl->GetText() != text) { node->Set("text", text); } //Multiline if (baseControl->textBlock->GetMultiline() != this->textBlock->GetMultiline()) { node->Set("multiline", this->textBlock->GetMultiline()); } //multilineBySymbol if (baseControl->textBlock->GetMultilineBySymbol() != this->textBlock->GetMultilineBySymbol()) { node->Set("multilineBySymbol", this->textBlock->GetMultilineBySymbol()); } //fitting - Array of strings if (baseControl->textBlock->GetFittingOption() != this->textBlock->GetFittingOption()) { node->SetNodeToMap("fitting", loader->GetFittingOptionNodeValue(textBlock->GetFittingOption())); } // Text Align if (baseControl->GetTextAlign() != this->GetTextAlign()) { node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign())); } // Draw type. Must be overriden for UITextControls. if (baseControl->GetBackground()->GetDrawType() != this->GetBackground()->GetDrawType()) { node->Set("drawType", loader->GetDrawTypeNodeValue(this->GetBackground()->GetDrawType())); } SafeDelete(nodeValue); SafeRelease(baseControl); return node; }
UIControl *UIStaticText::Clone() { UIStaticText *t = new UIStaticText(GetRect()); t->CopyDataFrom(this); return t; }
void StaticTextScreen::LoadResources() { Font::SetDPI(160); Font *fnt; fnt = FTFont::Create(FilePath("~res:/Fonts/yikes.ttf")); // fnt = GraphicsFont::Create("~res:/Fonts/korinna.def", "~res:/Gfx/Fonts2/korinna"); fnt->SetSize(7.5f); // fnt->SetSize(12); // fnt->SetVerticalSpacing(-1); // fnt->SetColor(.82f, .81f, 0.73f, 1.0f); float32 sizeX = 50; float32 sizeY = 80; UIControl *tc = new UIControl(Rect(0, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); UIStaticText *tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); // tx->SetMultiline(true); // tx->SetAlign(ALIGN_LEFT|ALIGN_TOP); tx->SetText(L"Management"); // tx->SetText(L"This text is aligned by the Left and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_TOP); // tx->SetText(L"abab."); tx->SetText(L"This text is aligned byyyi the Center and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_TOP); // tx->SetText(L"apap."); tx->SetText(L"This text is aligned by the Right and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(0, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_LEFT|ALIGN_VCENTER); // tx->SetText(L"apap."); tx->SetText(L"This text is aligned by the Left and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_VCENTER); // tx->SetText(L"abpbs"); tx->SetText(L"This text is aligned by the Center and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_VCENTER); // tx->SetText(L"aaaa."); tx->SetText(L"This text is aligned by the Right and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(0, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_LEFT|ALIGN_BOTTOM); tx->SetText(L"This text is aligned by the Left and Bottom borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_BOTTOM); tx->SetText(L"This text is aligned by the Center and Bottom borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_BOTTOM); tx->SetText(L"No desc elems.uj"); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, (size.y - sizeY)/2 - 70, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HJUSTIFY|ALIGN_TOP); tx->SetText(L"This text is Justify and it's looks little better than the others. aja. AVA."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); //fnt->SetColor(1.0f, 0.3f, 0.3f, 1.0f); fnt->SetVerticalSpacing(5); tc = new UIControl(Rect(100, 100, 600, 400)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); tc->GetBackground()->color = Color(0.5f,0.5,0.5f,1.0f); tx = new UIStaticText(Rect(10, 10, 400, 200)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HJUSTIFY|ALIGN_TOP); tx->SetText(L"Test test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ\nTest test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ\nTest test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ"); tx->SetTextColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); tx->SetShadowColor(Color(0.0f, 0.0f, 0.0f, 0.25f)); tx->SetShadowOffset(Vector2(2.0f, 2.0f)); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); SafeRelease(fnt); }