Skip to content

Commit

Permalink
karm-kira: Added checkbox context menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Nov 17, 2024
1 parent 2a8e86a commit f12b931
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/apps/hideo-files/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Ui::Child mainMenu([[maybe_unused]] State const &s) {
),
Kr::contextMenuItem(Ui::NOP, Mdi::BOOKMARK, "Bookmarks"),
Ui::separator(),
Kr::contextMenuItem(Model::bind<ToggleHidden>(), s.showHidden ? Mdi::CHECKBOX_MARKED : Mdi::CHECKBOX_BLANK_OUTLINE, "Show hidden"),
Kr::contextMenuCheck(Model::bind<ToggleHidden>(), s.showHidden, "Show hidden"),
});
}

Expand Down
20 changes: 20 additions & 0 deletions src/libs/karm-kira/context-menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <karm-ui/layout.h>
#include <karm-ui/popover.h>

#include "checkbox.h"
#include "context-menu.h"

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

Ui::Child contextMenuCheck(Ui::OnPress onPress, bool checked, Str t) {
return Ui::hflow(
12,
Math::Align::CENTER,
checkbox(checked, NONE),
Ui::text(t)
) |
Ui::insets({6, 6, 6, 10}) |
Ui::minSize({Ui::UNCONSTRAINED, 36}) |
Ui::button(
[onPress = std::move(onPress)](auto &n) {
onPress(n);
Ui::closePopover(n);
},
Ui::ButtonStyle::subtle()
) |
Ui::insets(4);
}

Ui::Child contextMenuDock(Ui::Children children) {
return Ui::hflow(
2,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/karm-kira/context-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Ui::Child contextMenuContent(Ui::Children children);

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

Ui::Child contextMenuCheck(Ui::OnPress onPress, bool checked, Str t);

Ui::Child contextMenuDock(Ui::Children children);

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

0 comments on commit f12b931

Please sign in to comment.