Skip to content

Commit

Permalink
karm-kira: Moved rows from hideo-base.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Aug 27, 2024
1 parent 079d87c commit ed21eac
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 93 deletions.
8 changes: 3 additions & 5 deletions src/apps/hideo-base/scafold.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ struct Scafold : Meta::NoCopy {
using Action = Union<ToggleSidebar>;

static void reduce(State &s, Action a) {
a.visit(::Visitor{
[&](ToggleSidebar) {
s.sidebarOpen = !s.sidebarOpen;
},
});
if (a.is<ToggleSidebar>()) {
s.sidebarOpen = !s.sidebarOpen;
}
}

using Model = Ui::Model<State, Action, reduce>;
Expand Down
2 changes: 0 additions & 2 deletions src/apps/hideo-demos/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "demo-gradient.h"
#include "demo-hello.h"
#include "demo-icons.h"
#include "demo-inputs.h"
#include "demo-mixbox.h"
#include "demo-stroke.h"
#include "demo-svg.h"
Expand All @@ -27,7 +26,6 @@ static Array DEMOS = {
&GRADIENT_DEMO,
&HELLO_DEMO,
&ICONS_DEMO,
&INPUTS_DEMO,
&MIXBOX_DEMO,
&STROKE_DEMO,
&SVG_DEMO,
Expand Down
10 changes: 5 additions & 5 deletions src/apps/hideo-demos/demo-text.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <hideo-base/row.h>
#include <karm-kira/row.h>
#include <karm-ui/layout.h>
#include <karm-ui/scroll.h>
#include <karm-ui/view.h>
Expand All @@ -15,7 +15,7 @@ static inline Demo TEXT_DEMO{
"Typography",
[] {
return Ui::vflow(
Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::TEXT)), "Display"s, NONE,
slots$(
Ui::displayLarge("Display Large"),
Expand All @@ -24,7 +24,7 @@ static inline Demo TEXT_DEMO{
)
),

Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::TEXT)), "Headlines"s, NONE,
slots$(
Ui::headlineLarge("Headline Large"),
Expand All @@ -33,7 +33,7 @@ static inline Demo TEXT_DEMO{
)
),

Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::TEXT)), "Titles"s, NONE,
slots$(
Ui::titleLarge("Title Large"),
Expand All @@ -42,7 +42,7 @@ static inline Demo TEXT_DEMO{
)
),

Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::TEXT)), "Body"s, NONE,
slots$(
Ui::bodyLarge("Body Large"),
Expand Down
2 changes: 1 addition & 1 deletion src/apps/hideo-images/editor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <hideo-base/row.h>
#include <hideo-base/scafold.h>
#include <karm-kira/row.h>
#include <karm-kira/slider.h>
#include <karm-ui/anim.h>
#include <karm-ui/input.h>
Expand Down
3 changes: 0 additions & 3 deletions src/apps/hideo-sandbox/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Async::Task<> entryPointAsync(Sys::Context &ctx) {
Ui::center() |
Ui::box({
.padding = {16, 8},
.borderRadii = {32, 8, 0, 0, 0, 0, 0, 0},
.borderWidth = 10,
.borderFill = Gfx::RED,
.backgroundFill = Gfx::WHITE,
})
);
Expand Down
32 changes: 16 additions & 16 deletions src/apps/hideo-settings/page-about.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <hideo-base/row.h>
#include <hideo-base/scafold.h>
#include <karm-kira/card.h>
#include <karm-kira/row.h>
#include <karm-sys/info.h>
#include <karm-ui/error.h>

Expand All @@ -9,55 +9,55 @@
namespace Hideo::Settings {

Ui::Child userInfos() {
return Hideo::treeRow(
return Kr::treeRow(
slot$(Ui::icon(Mdi::ACCOUNT)),
"User"s,
NONE,
slots$(Ui::errorScope("user informations", [&] -> Res<Ui::Child> {
auto userinfo = try$(Sys::userinfo());
return Ok(Ui::vflow(
Hideo::row(NONE, "Username"s, NONE, Ui::text(userinfo.name)),
Hideo::row(NONE, "Home"s, NONE, Ui::text(userinfo.home.str())),
Hideo::row(NONE, "Shell"s, NONE, Ui::text(userinfo.shell.str()))
Kr::rowContent(NONE, "Username"s, NONE, Ui::text(userinfo.name)),
Kr::rowContent(NONE, "Home"s, NONE, Ui::text(userinfo.home.str())),
Kr::rowContent(NONE, "Shell"s, NONE, Ui::text(userinfo.shell.str()))
));
}))
);
}

Ui::Child sysInfos() {
return Hideo::treeRow(
return Kr::treeRow(
slot$(Ui::icon(Mdi::INFORMATION_OUTLINE)),
"System"s,
NONE,
slot$(Ui::errorScope("system informations", [] -> Res<Ui::Child> {
auto sysinfo = try$(Sys::sysinfo());
return Ok(Ui::vflow(
Hideo::row(NONE, "System"s, NONE, Ui::text(sysinfo.sysName)),
Hideo::row(NONE, "System Version"s, NONE, Ui::text(sysinfo.sysVersion)),
Hideo::row(NONE, "Kernel"s, NONE, Ui::text(sysinfo.kernelName)),
Hideo::row(NONE, "Kernel Version"s, NONE, Ui::text(sysinfo.kernelVersion))
Kr::rowContent(NONE, "System"s, NONE, Ui::text(sysinfo.sysName)),
Kr::rowContent(NONE, "System Version"s, NONE, Ui::text(sysinfo.sysVersion)),
Kr::rowContent(NONE, "Kernel"s, NONE, Ui::text(sysinfo.kernelName)),
Kr::rowContent(NONE, "Kernel Version"s, NONE, Ui::text(sysinfo.kernelVersion))
));
}))
);
}

Ui::Child memInfos() {
return Hideo::treeRow(
return Kr::treeRow(
slot$(Ui::icon(Mdi::MEMORY)),
"Memory"s,
NONE,
slot$(Ui::errorScope("memory informations"s, [&] -> Res<Ui::Child> {
auto meminfo = try$(Sys::meminfo());
return Ok(vflow(
Hideo::row(NONE, "Physical"s, NONE, Ui::text("{}bytes", meminfo.physicalUsed)),
Hideo::row(NONE, "Swap"s, NONE, Ui::text("{}bytes", meminfo.swapUsed))
Kr::rowContent(NONE, "Physical"s, NONE, Ui::text("{}bytes", meminfo.physicalUsed)),
Kr::rowContent(NONE, "Swap"s, NONE, Ui::text("{}bytes", meminfo.swapUsed))
));
}))
);
}

Ui::Child cpuInfos() {
return Hideo::treeRow(
return Kr::treeRow(
slot$(Ui::icon(Mdi::CPU_64_BIT)),
"CPU"s,
NONE,
Expand All @@ -67,7 +67,7 @@ Ui::Child cpuInfos() {
Ui::Children children;

for (auto &cpu : cpusinfo) {
children.pushBack(Hideo::row(
children.pushBack(Kr::rowContent(
NONE,
"CPU"s,
NONE,
Expand All @@ -83,7 +83,7 @@ Ui::Child cpuInfos() {
Ui::Child pageAbout(State const &) {
return Ui::vflow(
8,
Hideo::titleRow("About"s),
Kr::titleRow("About"s),
userInfos() | Kr::card(),
sysInfos() | Kr::card(),
memInfos() | Kr::card(),
Expand Down
26 changes: 13 additions & 13 deletions src/apps/hideo-spreadsheet/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <hideo-base/row.h>
#include <hideo-base/scafold.h>
#include <karm-kira/row.h>
#include <karm-sys/entry.h>
#include <karm-ui/app.h>
#include <karm-ui/dialog.h>
Expand Down Expand Up @@ -50,11 +50,11 @@ Ui::Child toolbar(State const &state) {
Ui::Child properties() {
return Ui::vscroll(
Ui::vflow(
Hideo::titleRow("Text Properties"s),
Kr::titleRow("Text Properties"s),

Hideo::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Color"s),
Kr::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Color"s),

Hideo::row(
Kr::rowContent(
NONE,
"Format"s,
NONE,
Expand All @@ -67,7 +67,7 @@ Ui::Child properties() {
)
),

Hideo::row(
Kr::rowContent(
NONE,
"Wrapping"s,
NONE,
Expand All @@ -78,7 +78,7 @@ Ui::Child properties() {
)
),

Hideo::row(
Kr::rowContent(
NONE,
"Horizontal Align"s,
NONE,
Expand All @@ -90,7 +90,7 @@ Ui::Child properties() {
)
),

Hideo::row(
Kr::rowContent(
NONE,
"Vertical Align"s,
NONE,
Expand All @@ -104,11 +104,11 @@ Ui::Child properties() {

Ui::separator(),

Hideo::titleRow("Cell Properties"s),
Hideo::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Background Color"s),
Hideo::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Border Color"s),
Kr::titleRow("Cell Properties"s),
Kr::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Background Color"s),
Kr::colorRow(Gfx::RED, Ui::IGNORE<Gfx::Color>, "Border Color"s),

Hideo::row(
Kr::rowContent(
NONE,
"Borders"s,
NONE,
Expand All @@ -121,7 +121,7 @@ Ui::Child properties() {
)
),

Hideo::row(
Kr::rowContent(
NONE,
""s,
NONE,
Expand All @@ -138,7 +138,7 @@ Ui::Child properties() {

Ui::separator(),

Hideo::titleRow("Sheet Properties"s)
Kr::titleRow("Sheet Properties"s)
)
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/apps/hideo-zoo/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "page-hsv-square.h"
#include "page-navbar.h"
#include "page-radio.h"
#include "page-rows.h"
#include "page-side-nav.h"
#include "page-side-panel.h"
#include "page-slider.h"
Expand All @@ -34,6 +35,7 @@ static Array PAGES = {
&PAGE_HSV_SQUARE,
&PAGE_NAVBAR,
&PAGE_RADIO,
&PAGE_ROWS,
&PAGE_SIDE_PANEL,
&PAGE_SIDENAV,
&PAGE_SLIDER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
#pragma once

#include <hideo-base/row.h>
#include <hideo-base/scafold.h>
#include <karm-kira/card.h>
#include <karm-kira/dialog.h>
#include <karm-kira/row.h>
#include <karm-ui/dialog.h>
#include <karm-ui/layout.h>
#include <karm-ui/scroll.h>
#include <karm-ui/view.h>

#include "base.h"
#include "model.h"

namespace Hideo::Demos {
namespace Hideo::Zoo {

static void willShowMessage(Ui::Node &n) {
Ui::showDialog(n, Kr::alert("Message"s, "This is a message"s));
}

static inline Demo INPUTS_DEMO{
Mdi::LIST_BOX_OUTLINE,
"Inputs",
"Form inputs widgets",
static inline Page PAGE_ROWS{
Mdi::FORMAT_LIST_BULLETED_TYPE,
"Settings Rows",
"A collection of rows that can be used to display settings.",
[] {
auto button = Hideo::buttonRow(
auto button = Kr::buttonRow(
willShowMessage,
"Cool duck app"s,
"Install"s
);

auto title = Hideo::titleRow("Some Settings"s);
auto title = Kr::titleRow("Some Settings"s);

auto list = Kr::card(
button,
Ui::separator(),
Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::TOGGLE_SWITCH)), "Switches"s, NONE,
slots$(
Hideo::toggleRow(true, NONE, "Some property"s),
Hideo::toggleRow(true, NONE, "Some property"s),
Hideo::toggleRow(true, NONE, "Some property"s)
Kr::toggleRow(true, NONE, "Some property"s),
Kr::toggleRow(true, NONE, "Some property"s),
Kr::toggleRow(true, NONE, "Some property"s)
)
),

Ui::separator(),
Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::CHECKBOX_MARKED)),
"Checkboxs"s,
NONE,
slots$(
Hideo::checkboxRow(true, NONE, "Some property"s),
Hideo::checkboxRow(false, NONE, "Some property"s),
Hideo::checkboxRow(false, NONE, "Some property"s)
Kr::checkboxRow(true, NONE, "Some property"s),
Kr::checkboxRow(false, NONE, "Some property"s),
Kr::checkboxRow(false, NONE, "Some property"s)
)
),

Ui::separator(),
Hideo::treeRow(
Kr::treeRow(
slot$(Ui::icon(Mdi::RADIOBOX_MARKED)),
"Radios"s,
NONE,
slots$(
Hideo::radioRow(true, NONE, "Some property"s),
Hideo::radioRow(false, NONE, "Some property"s),
Hideo::radioRow(false, NONE, "Some property"s)
Kr::radioRow(true, NONE, "Some property"s),
Kr::radioRow(false, NONE, "Some property"s),
Kr::radioRow(false, NONE, "Some property"s)
)
),
Ui::separator(),
Hideo::sliderRow(
Kr::sliderRow(
0.5,
NONE,
"Some property"s
Expand All @@ -81,4 +79,4 @@ static inline Demo INPUTS_DEMO{
},
};

} // namespace Hideo::Demos
} // namespace Hideo::Zoo
Loading

0 comments on commit ed21eac

Please sign in to comment.