Start cleaning icon.
This commit is contained in:
parent
97afa782a0
commit
3915a40c96
10 changed files with 172 additions and 33 deletions
|
@ -21,6 +21,8 @@ Button::Button(ButtonData::Component component)
|
|||
{
|
||||
mStyle.mComponent = component;
|
||||
mName = "Button";
|
||||
setWidth(150);
|
||||
setMaxWidth(150);
|
||||
|
||||
setHeight(mStyle.getContainerHeight());
|
||||
setMaxHeight(mStyle.getContainerHeight());
|
||||
|
@ -95,6 +97,9 @@ void Button::updateState()
|
|||
setLabelTextColor(mStyle.getLabelTextColor());
|
||||
setLabelTextOpacity(mStyle.getLabelOpacity());
|
||||
setLabelTextTypescale(mStyle.getLabelTypescale());
|
||||
|
||||
setIconColor(mStyle.getIconColor());
|
||||
//setIconOpacity()
|
||||
}
|
||||
|
||||
void Button::setLabelTextColor(Theme::Sys::Color color)
|
||||
|
@ -124,6 +129,24 @@ void Button::setLabelTextTypescale(Theme::Sys::Typescale typescale)
|
|||
}
|
||||
}
|
||||
|
||||
void Button::setIconColor(Theme::Sys::Color color)
|
||||
{
|
||||
if (mIconColor != color)
|
||||
{
|
||||
mIconColor = color;
|
||||
mMaterialDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setIconOpacity(float opacity)
|
||||
{
|
||||
if (mIconOpacity!= opacity)
|
||||
{
|
||||
mIconOpacity = opacity;
|
||||
mMaterialDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Button::onMyMouseEvent(const MouseEvent* event)
|
||||
{
|
||||
if (!mEnabled)
|
||||
|
@ -237,6 +260,10 @@ void Button::updateIcon(const PaintEvent* event)
|
|||
mIconNode->setContent(IconNode::IconType::Svg, MediaResourceManager::getSvgIconNode(mIcon));
|
||||
mRootNode->addChild(mIconNode.get());
|
||||
}
|
||||
else if (mContentDirty && mIcon != Resource::Icon::Svg::NONE)
|
||||
{
|
||||
mIconNode->setContent(IconNode::IconType::Svg, MediaResourceManager::getSvgIconNode(mIcon));
|
||||
}
|
||||
|
||||
if (!mIconNode)
|
||||
{
|
||||
|
@ -252,11 +279,7 @@ void Button::updateIcon(const PaintEvent* event)
|
|||
{
|
||||
auto icon_fill = event->getThemesManager()->getColor(mIconColor);
|
||||
icon_fill.setAlpha(mIconOpacity);
|
||||
}
|
||||
|
||||
if (mContentDirty)
|
||||
{
|
||||
mIconNode->setContent(IconNode::IconType::Svg, MediaResourceManager::getSvgIconNode(mIcon));
|
||||
mIconNode->setFillColor(icon_fill);
|
||||
}
|
||||
|
||||
if (mVisibilityDirty)
|
||||
|
|
|
@ -43,6 +43,9 @@ protected:
|
|||
void setLabelTextOpacity(float opacity);
|
||||
void setLabelTextTypescale(Theme::Sys::Typescale typescale);
|
||||
|
||||
void setIconColor(Theme::Sys::Color color);
|
||||
void setIconOpacity(float opacity);
|
||||
|
||||
void updateLabel(const PaintEvent* event);
|
||||
void updateIcon(const PaintEvent* event);
|
||||
|
||||
|
|
|
@ -1,14 +1,55 @@
|
|||
#include "IconNode.h"
|
||||
|
||||
#include "SvgNode.h"
|
||||
|
||||
IconNode::IconNode(const Point& loc)
|
||||
: AbstractVisualNode(loc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IconNode::setContent(IconType type, std::unique_ptr<AbstractVisualNode> content)
|
||||
void IconNode::setSvgContent(std::unique_ptr<SvgNode> svg_node)
|
||||
{
|
||||
mType = type;
|
||||
mContent = std::move(content);
|
||||
mChildren.clear();
|
||||
|
||||
mType = IconType::Svg;
|
||||
|
||||
mSvgContent = std::move(svg_node);
|
||||
mContentDirty = true;
|
||||
|
||||
addChild(mSvgContent.get());
|
||||
}
|
||||
|
||||
void IconNode::setFillColor(const Color& color)
|
||||
{
|
||||
if (mType == IconType::Svg)
|
||||
{
|
||||
mSvgContent->setFillColor(color);
|
||||
mSvgContent->setHasStrokeColor(false);
|
||||
}
|
||||
}
|
||||
|
||||
void IconNode::setWidth(unsigned width)
|
||||
{
|
||||
if (mType == IconType::Svg)
|
||||
{
|
||||
mSvgContent->setWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
void IconNode::setHeight(unsigned height)
|
||||
{
|
||||
if (mType == IconType::Svg)
|
||||
{
|
||||
mSvgContent->setFillColor(height);
|
||||
mSvgContent->setHasStrokeColor(false);
|
||||
}
|
||||
}
|
||||
|
||||
void IconNode::setOutlineColor(const Color& color)
|
||||
{
|
||||
if (mType == IconType::Svg)
|
||||
{
|
||||
dynamic_cast<SvgNode*>(mContent.get())->setStrokeColor(color);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include "SvgNode.h"
|
||||
|
||||
class IconNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
|
@ -14,10 +16,21 @@ public:
|
|||
|
||||
IconNode(const Point& loc);
|
||||
|
||||
void setContent(IconType type, std::unique_ptr<AbstractVisualNode>);
|
||||
void setLocation(const Point& loc) override;
|
||||
|
||||
void setWidth(unsigned width);
|
||||
|
||||
void setHeight(unsigned height);
|
||||
|
||||
void setFillColor(const Color& color);
|
||||
|
||||
void setOutlineColor(const Color& color);
|
||||
|
||||
void setSvgContent(std::unique_ptr<SvgNode> svg_node);
|
||||
|
||||
private:
|
||||
std::unique_ptr<AbstractVisualNode> mContent;
|
||||
std::unique_ptr<SvgNode> mSvgContent;
|
||||
|
||||
IconType mType{ IconType::Svg };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ unsigned FontTokens::getSize(Theme::Sys::Typescale typescale)
|
|||
switch (typescale)
|
||||
{
|
||||
case Theme::Sys::Typescale::Label_Large:
|
||||
return static_cast<unsigned>(57/3);
|
||||
return static_cast<unsigned>(57/3.5);
|
||||
default:
|
||||
return 57;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue