Skip to content

Commit d03480e

Browse files
committed
karm-kira: Fix repaint of selection.
1 parent d741dba commit d03480e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/karm-kira/row.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export Ui::Child titleRow(String t) {
6868
Ui::insets({16, 12, 8, 12});
6969
}
7070

71+
export Ui::Child labelRow(String t) {
72+
return rowContent(Ui::labelMedium(t));
73+
}
74+
7175
export Ui::Child pressableRow(Opt<Ui::Send<>> onPress, Opt<Ui::Child> leading, String title, Opt<String> subtitle, Opt<Ui::Child> trailing) {
7276
return button(
7377
std::move(onPress),

src/karm-kira/selection.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct SelectionArea : Ui::ProxyNode<SelectionArea> {
3838

3939
void paint(Gfx::Canvas& g, Math::Recti r) override {
4040
ProxyNode::paint(g, r);
41-
41+
4242
if (_selecting) {
4343
g.push();
4444
g.fillStyle(Ui::ACCENT500.withOpacity(0.25));
@@ -59,6 +59,7 @@ struct SelectionArea : Ui::ProxyNode<SelectionArea> {
5959
if (mouseEvent->type == App::MouseEvent::RELEASE and
6060
mouseEvent->button == App::MouseButton::LEFT) {
6161
_selecting = false;
62+
Ui::shouldRepaint(*this, selectionRect().clipTo(bound()));
6263
e.accept();
6364
}
6465

@@ -101,10 +102,11 @@ struct SelectionItem : Ui::ProxyNode<SelectionItem> {
101102

102103
void event(App::Event& e) override {
103104
if (auto selectionEvent = e.is<SelectionUpdateEvent>()) {
104-
if (selectionEvent->rect.colide(bound()))
105-
_selected = true;
106-
else
107-
_selected = false;
105+
bool const newSelected = selectionEvent->rect.colide(bound());
106+
if (_selected != newSelected) {
107+
_selected = newSelected;
108+
Ui::shouldRepaint(*this);
109+
}
108110
return;
109111
}
110112

@@ -128,4 +130,4 @@ export auto selectionItem() {
128130
};
129131
}
130132

131-
} // namespace Karm::Kira
133+
} // namespace Karm::Kira

0 commit comments

Comments
 (0)