Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
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);
}