void Label::LoadStyle(const std::string& nameStyle) { ResourceManager* rm = ResourceManager::Get(); StyleProperties& properties = rm->GetStyle(nameStyle); SetTextColor(rm->GetColorValue(properties["textColor"], GetTextColor())); Font* newFont = rm->GetFont(properties["font"], GetTextSize()); if (newFont) { SetFont(*newFont); } if (properties["textSize"] != "") { mCaption.SetSize(rm->GetValue(properties["textSize"], GetTextSize())); const Vector2f& strSize = mCaption.GetRect().GetSize(); if (properties["width"] == "") SetWidth(strSize.x); if (properties["height"] == "") SetHeight(strSize.y); } Widget::LoadStyle(nameStyle); }
void Widget::LoadStyle(const std::string& style) { ResourceManager* rm = ResourceManager::Get(); StyleProperties& properties = rm->GetStyle(style); if (properties["from"] != "") LoadStyle(properties["from"]); SetX(rm->GetValue(properties["x"], GetPosition().x)); SetY(rm->GetValue(properties["y"], GetPosition().y)); mAlignOffset.x = rm->GetValue(properties["x"], mAlignOffset.x); mAlignOffset.y = rm->GetValue(properties["y"], mAlignOffset.y); SetWidth(rm->GetValue(properties["width"], GetWidth())); SetHeight(rm->GetValue(properties["height"], GetHeight())); // Detect alignement if (properties["align"] != "") { std::string strA = properties["align"]; if (strA == "top_left") mAlign = Align::TOP_LEFT; else if (strA == "top_center") mAlign = Align::TOP_CENTER; else if (strA == "top_right") mAlign = Align::TOP_RIGHT; else if (strA == "left") mAlign = Align::LEFT; else if (strA == "center") mAlign = Align::CENTER; else if (strA == "right") mAlign = Align::RIGHT; else if (strA == "bottom_left") mAlign = Align::BOTTOM_LEFT; else if (strA == "bottom_center") mAlign = Align::BOTTOM_CENTER; else if (strA == "bottom_right") mAlign = Align::BOTTOM_RIGHT; else mAlign = Align::NONE; } SetColor(rm->GetColorValue(properties["color"], GetColor())); SetBorderColor(rm->GetColorValue(properties["borderColor"], GetBorderColor())); SetEnabled(rm->GetValue(properties["enabled"], IsEnabled())); SetVisible(rm->GetValue(properties["visible"], IsVisible())); SetFocusable(rm->GetValue(properties["focusable"], IsFocusable())); UpdatePosition(); }
void GridDecorator::LoadStyle(const std::string& nameStyle) { ResourceManager* rm = ResourceManager::Get(); StyleProperties& properties = rm->GetStyle(nameStyle); UseGrid(rm->GetValue(properties["useGrid"], IsGridUsed())); mIcons[Align::TOP_LEFT].LoadStyle(nameStyle + "->topLeft"); mIcons[Align::TOP_CENTER].LoadStyle(nameStyle + "->topCenter"); mIcons[Align::TOP_RIGHT].LoadStyle(nameStyle + "->topRight"); mIcons[Align::LEFT].LoadStyle(nameStyle + "->left"); mIcons[Align::CENTER].LoadStyle(nameStyle + "->center"); mIcons[Align::RIGHT].LoadStyle(nameStyle + "->right"); mIcons[Align::BOTTOM_LEFT].LoadStyle(nameStyle + "->bottomLeft"); mIcons[Align::BOTTOM_CENTER].LoadStyle(nameStyle + "->bottomCenter"); mIcons[Align::BOTTOM_RIGHT].LoadStyle(nameStyle + "->bottomRight"); Icon::LoadStyle(nameStyle); }