Skip to content

Commit

Permalink
karm-kira: Fixed oversized checkbox, radio, and toggle.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Nov 17, 2024
1 parent 081435d commit 2a8e86a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/libs/karm-kira/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct Checkbox : public Ui::View<Checkbox> {
g.fill(bound(), 4);

g.fillStyle(Gfx::GRAY50);
Gfx::Icon{Mdi::CHECK_BOLD, 26}.fill(g, bound().topStart());
Gfx::Icon{Mdi::CHECK_BOLD, 18}.fill(g, bound().topStart());

if (_mouseListener.isPress()) {
g.strokeStyle(Gfx::stroke(Ui::ACCENT600).withWidth(1).withAlign(Gfx::INSIDE_ALIGN));
Expand All @@ -54,7 +54,7 @@ struct Checkbox : public Ui::View<Checkbox> {
}

Math::Vec2i size(Math::Vec2i, Ui::Hint) override {
return {26, 26};
return {18, 18};
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/libs/karm-kira/radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Radio : public Ui::View<Radio> {
g.fill(bound(), 999);

g.fillStyle(Gfx::GRAY50);
g.fill(bound().shrink(6), 999);
g.fill(bound().shrink(4), 999);

if (_mouseListener.isPress()) {
g.strokeStyle(Gfx::stroke(Ui::ACCENT600).withWidth(1).withAlign(Gfx::INSIDE_ALIGN));
Expand All @@ -49,7 +49,7 @@ struct Radio : public Ui::View<Radio> {
}

Math::Vec2i size(Math::Vec2i, Ui::Hint) override {
return {26, 26};
return {18, 18};
}
};

Expand Down
13 changes: 8 additions & 5 deletions src/libs/karm-kira/toggle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
namespace Karm::Kira {

struct Toggle : public Ui::View<Toggle> {
static constexpr auto PADDING = 3;
static constexpr auto SIZE = 18;

bool _value = false;
Ui::Easedf _anim;
Ui::OnChange<bool> _onChange;
Expand All @@ -26,10 +29,10 @@ struct Toggle : public Ui::View<Toggle> {
g.push();

Math::Recti thumb = {
bound().x + (isize)(6 + 26 * _anim.value()),
bound().y + 6,
14,
14,
bound().x + (isize)(PADDING + SIZE * _anim.value()),
bound().y + PADDING,
SIZE - PADDING * 2,
SIZE - PADDING * 2,
};

auto inactiveBackground = (_mouseListener.isHover() ? Ui::GRAY600 : Ui::GRAY700);
Expand Down Expand Up @@ -69,7 +72,7 @@ struct Toggle : public Ui::View<Toggle> {
}

Math::Vec2i size(Math::Vec2i, Ui::Hint) override {
return {52, 26};
return {SIZE * 2, SIZE};
}
};

Expand Down

0 comments on commit 2a8e86a

Please sign in to comment.