Add more styles & support border and shadow in default button
This commit is contained in:
parent
72ae8604cb
commit
38123ace0e
2 changed files with 10 additions and 3 deletions
|
|
@ -13,10 +13,11 @@ namespace psemek::ui
|
|||
gfx::color_rgba highlight_color{159, 159, 159, 255};
|
||||
gfx::color_rgba action_color{63, 63, 63, 255};
|
||||
|
||||
gfx::color_rgba border_color{255, 255, 255, 255};
|
||||
int border_width = 3;
|
||||
|
||||
int shadow_width = 1;
|
||||
gfx::color_rgba shadow_color{0, 0, 0, 127};
|
||||
geom::vector<int, 2> shadow_offset{1, 1};
|
||||
gfx::color_rgba shadow_color{0, 0, 0, 255};
|
||||
|
||||
gfx::color_rgba text_color{0, 0, 0, 255};
|
||||
std::shared_ptr<struct font> font;
|
||||
|
|
|
|||
|
|
@ -26,12 +26,18 @@ namespace psemek::ui
|
|||
auto s = style();
|
||||
if (!s) return;
|
||||
|
||||
if (s->shadow_offset != geom::vector{0, 0})
|
||||
p.draw_rect(shape_.box + geom::cast<float>(s->shadow_offset), s->shadow_color);
|
||||
|
||||
if (s->border_width > 0)
|
||||
p.draw_rect(shape_.box, s->border_color);
|
||||
|
||||
gfx::color_rgba color = s->fg_color;
|
||||
if (state() == state_t::mouseover)
|
||||
color = s->highlight_color;
|
||||
else if (state() == state_t::mousedown)
|
||||
color = s->action_color;
|
||||
p.draw_rect(shape_.box, color);
|
||||
p.draw_rect(geom::shrink(shape_.box, 1.f * s->border_width), color);
|
||||
}
|
||||
|
||||
geom::box<float, 2> size_constraints() const override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue