Skip to content

Commit f12b931

Browse files
committed
karm-kira: Added checkbox context menu item.
1 parent 2a8e86a commit f12b931

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/apps/hideo-files/widgets.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ Ui::Child mainMenu([[maybe_unused]] State const &s) {
259259
),
260260
Kr::contextMenuItem(Ui::NOP, Mdi::BOOKMARK, "Bookmarks"),
261261
Ui::separator(),
262-
Kr::contextMenuItem(Model::bind<ToggleHidden>(), s.showHidden ? Mdi::CHECKBOX_MARKED : Mdi::CHECKBOX_BLANK_OUTLINE, "Show hidden"),
262+
Kr::contextMenuCheck(Model::bind<ToggleHidden>(), s.showHidden, "Show hidden"),
263263
});
264264
}
265265

src/libs/karm-kira/context-menu.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <karm-ui/layout.h>
33
#include <karm-ui/popover.h>
44

5+
#include "checkbox.h"
56
#include "context-menu.h"
67

78
namespace Karm::Kira {
@@ -75,6 +76,25 @@ Ui::Child contextMenuItem(Ui::OnPress onPress, Opt<Mdi::Icon> i, Str t) {
7576
Ui::insets(4);
7677
}
7778

79+
Ui::Child contextMenuCheck(Ui::OnPress onPress, bool checked, Str t) {
80+
return Ui::hflow(
81+
12,
82+
Math::Align::CENTER,
83+
checkbox(checked, NONE),
84+
Ui::text(t)
85+
) |
86+
Ui::insets({6, 6, 6, 10}) |
87+
Ui::minSize({Ui::UNCONSTRAINED, 36}) |
88+
Ui::button(
89+
[onPress = std::move(onPress)](auto &n) {
90+
onPress(n);
91+
Ui::closePopover(n);
92+
},
93+
Ui::ButtonStyle::subtle()
94+
) |
95+
Ui::insets(4);
96+
}
97+
7898
Ui::Child contextMenuDock(Ui::Children children) {
7999
return Ui::hflow(
80100
2,

src/libs/karm-kira/context-menu.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Ui::Child contextMenuContent(Ui::Children children);
1818

1919
Ui::Child contextMenuItem(Ui::OnPress onPress, Opt<Mdi::Icon> i, Str t);
2020

21+
Ui::Child contextMenuCheck(Ui::OnPress onPress, bool checked, Str t);
22+
2123
Ui::Child contextMenuDock(Ui::Children children);
2224

2325
Ui::Child contextMenuIcon(Ui::OnPress onPress, Mdi::Icon i);

0 commit comments

Comments
 (0)