Widgets: Fix ButtonWidget

This commit is contained in:
Jérôme Leclercq
2021-11-21 19:07:46 +01:00
parent b12d2eeb0f
commit 4df0b16d19
3 changed files with 38 additions and 38 deletions

View File

@@ -15,6 +15,7 @@
namespace Nz
{
class AbstractTextDrawer;
class MaterialPass;
class NAZARA_WIDGETS_API ButtonWidget : public BaseWidget
{
@@ -31,10 +32,6 @@ namespace Nz
inline const Color& GetPressColor() const;
inline const Color& GetPressCornerColor() const;
inline const std::shared_ptr<Texture>& GetTexture() const;
inline const std::shared_ptr<Texture>& GetHoverTexture() const;
inline const std::shared_ptr<Texture>& GetPressTexture() const;
inline void SetColor(const Color& color, const Color& cornerColor);
inline void SetHoverColor(const Color& color, const Color& cornerColor);
inline void SetPressColor(const Color& color, const Color& cornerColor);
@@ -54,6 +51,7 @@ namespace Nz
void OnMouseButtonRelease(int x, int y, Mouse::Button button) override;
void OnMouseExit() override;
std::shared_ptr<MaterialPass> m_gradientMaterialPass;
std::shared_ptr<Sprite> m_gradientSprite;
std::shared_ptr<TextSprite> m_textSprite;
entt::entity m_textEntity;

View File

@@ -43,8 +43,8 @@ namespace Nz
m_cornerColor = cornerColor;
m_gradientSprite->SetColor(m_color);
m_gradientSprite->SetCornerColor(Nz::RectCorner::LeftBottom, m_cornerColor);
m_gradientSprite->SetCornerColor(Nz::RectCorner::RightBottom, m_cornerColor);
m_gradientSprite->SetCornerColor(RectCorner::LeftBottom, m_cornerColor);
m_gradientSprite->SetCornerColor(RectCorner::RightBottom, m_cornerColor);
}
inline void ButtonWidget::SetHoverColor(const Color& color, const Color& cornerColor)
@@ -59,13 +59,13 @@ namespace Nz
m_pressCornerColor = cornerColor;
}
inline void ButtonWidget::UpdateText(const Nz::AbstractTextDrawer& drawer)
inline void ButtonWidget::UpdateText(const AbstractTextDrawer& drawer)
{
m_textSprite->Update(drawer);
Nz::Vector2f textSize = Nz::Vector2f(m_textSprite->GetAABB().GetLengths());
Vector2f textSize = Vector2f(m_textSprite->GetAABB().GetLengths());
SetMinimumSize(textSize);
SetPreferredSize(textSize + Nz::Vector2f(20.f, 10.f));
SetPreferredSize(textSize + Vector2f(20.f, 10.f));
Layout();
}