diff --git a/src/apps/hideo-shell/app.cpp b/src/apps/hideo-shell/app.cpp index 83f09d4ebc6..68a85898e7f 100644 --- a/src/apps/hideo-shell/app.cpp +++ b/src/apps/hideo-shell/app.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -149,12 +148,10 @@ Ui::Child tabletPanels(State const &state) { } Ui::Child appHost(State const &state) { - if (state.instances.len() == 0) + if (isEmpty(state.instances)) return Ui::grow(NONE); - auto surface = state.instances[0]; - return Ui::empty() | - Ui::box({.backgroundFill = surface->color}); + return first(state.instances)->build(); } Ui::Child tablet(State const &state) { @@ -172,33 +169,25 @@ Ui::Child tablet(State const &state) { Ui::Child appStack(State const &state) { Ui::Children apps; - usize index = state.instances.len() - 1; - for (auto &s : iterRev(state.instances)) { + usize zindex = state.instances.len() - 1; + for (auto &i : iterRev(state.instances)) { apps.pushBack( - Kr::scaffold({ - .icon = s->manifest->icon, - .title = s->manifest->name, - .body = slot$(Ui::empty()), - }) | + i->build() | Ui::box({ - .borderRadii = 6, - .borderWidth = 1, - .borderFill = Ui::GRAY800, - .backgroundFill = Ui::GRAY900, - .shadowStyle = Gfx::BoxShadow::elevated(index ? 4 : 16), + .shadowStyle = Gfx::BoxShadow::elevated(zindex ? 4 : 16), }) | - Ui::placed(s->bound) | + Ui::placed(i->bound) | Ui::intent([=](Ui::Node &n, App::Event &e) { if (auto m = e.is()) { e.accept(); - Model::bubble(n, {index, m->delta}); + Model::bubble(n, {zindex, m->delta}); } else if (auto c = e.is()) { e.accept(); - Model::bubble(n, {index}); + Model::bubble(n, {zindex}); } }) ); - index--; + zindex--; } return Ui::stack(apps); diff --git a/src/apps/hideo-shell/cursor.path b/src/apps/hideo-shell/cursor.path index 53c14abf0f0..c8c99b91b9c 100644 --- a/src/apps/hideo-shell/cursor.path +++ b/src/apps/hideo-shell/cursor.path @@ -1 +1 @@ -"M13.1 14.9 1.4 3.1 1.4 20 5 16.2 8.3 23.8 11 22.6 7.7 15Z" +"M11.7 11.8 0 0 0 16.9 3.6 13.1 6.9 20.7 9.6 19.5 6.3 11.9Z" diff --git a/src/apps/hideo-shell/instance.h b/src/apps/hideo-shell/instance.h deleted file mode 100644 index e919492f9ea..00000000000 --- a/src/apps/hideo-shell/instance.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include - -namespace Hideo::Shell { - -struct Instance; - -struct Manifest { - Mdi::Icon icon; - String name; - Gfx::ColorRamp ramp; -}; - -struct Instance { - usize id; - Math::Recti bound; - Gfx::Color color; - Strong manifest; -}; - -} // namespace Hideo::Shell diff --git a/src/apps/hideo-shell/main/main.cpp b/src/apps/hideo-shell/main/main.cpp index 37d585416d2..3eefe5d6713 100644 --- a/src/apps/hideo-shell/main/main.cpp +++ b/src/apps/hideo-shell/main/main.cpp @@ -16,6 +16,7 @@ #include #include "../app.h" +#include "../mock.h" Async::Task<> entryPointAsync(Sys::Context &ctx) { auto args = useArgs(ctx); @@ -26,19 +27,19 @@ Async::Task<> entryPointAsync(Sys::Context &ctx) { .dateTime = Sys::dateTime(), .background = co_try$(Image::loadOrFallback("bundle://hideo-shell/wallpapers/winter.qoi"_url)), .noti = {}, - .manifests = { - makeStrong(Mdi::INFORMATION_OUTLINE, "About"s, Gfx::BLUE_RAMP), - makeStrong(Mdi::CALCULATOR, "Calculator"s, Gfx::ORANGE_RAMP), - makeStrong(Mdi::PALETTE_SWATCH, "Color Picker"s, Gfx::RED_RAMP), - makeStrong(Mdi::COUNTER, "Counter"s, Gfx::GREEN_RAMP), - makeStrong(Mdi::DUCK, "Demos"s, Gfx::YELLOW_RAMP), - makeStrong(Mdi::FILE, "Files"s, Gfx::ORANGE_RAMP), - makeStrong(Mdi::FORMAT_FONT, "Fonts"s, Gfx::BLUE_RAMP), - makeStrong(Mdi::EMOTICON, "Hello World"s, Gfx::RED_RAMP), - makeStrong(Mdi::IMAGE, "Icons"s, Gfx::GREEN_RAMP), - makeStrong(Mdi::IMAGE, "Image Viewer"s, Gfx::YELLOW_RAMP), - makeStrong(Mdi::COG, "Settings"s, Gfx::ZINC_RAMP), - makeStrong(Mdi::TABLE, "Spreadsheet"s, Gfx::GREEN_RAMP), + .launchers = { + makeStrong(Mdi::INFORMATION_OUTLINE, "About"s, Gfx::BLUE_RAMP), + makeStrong(Mdi::CALCULATOR, "Calculator"s, Gfx::ORANGE_RAMP), + makeStrong(Mdi::PALETTE_SWATCH, "Color Picker"s, Gfx::RED_RAMP), + makeStrong(Mdi::COUNTER, "Counter"s, Gfx::GREEN_RAMP), + makeStrong(Mdi::DUCK, "Demos"s, Gfx::YELLOW_RAMP), + makeStrong(Mdi::FILE, "Files"s, Gfx::ORANGE_RAMP), + makeStrong(Mdi::FORMAT_FONT, "Fonts"s, Gfx::BLUE_RAMP), + makeStrong(Mdi::EMOTICON, "Hello World"s, Gfx::RED_RAMP), + makeStrong(Mdi::IMAGE, "Icons"s, Gfx::GREEN_RAMP), + makeStrong(Mdi::IMAGE, "Image Viewer"s, Gfx::YELLOW_RAMP), + makeStrong(Mdi::COG, "Settings"s, Gfx::ZINC_RAMP), + makeStrong(Mdi::TABLE, "Spreadsheet"s, Gfx::GREEN_RAMP), }, .instances = {} }; diff --git a/src/apps/hideo-shell/mock.cpp b/src/apps/hideo-shell/mock.cpp new file mode 100644 index 00000000000..11381479f6a --- /dev/null +++ b/src/apps/hideo-shell/mock.cpp @@ -0,0 +1,31 @@ +#include +#include + +#include "mock.h" + +namespace Hideo::Shell { + +void MockLauncher::launch(State &s) { + auto instance = makeStrong( + icon, + name, + ramp + ); + s.activePanel = Panel::NIL; + s.instances.emplaceFront(instance); +} + +Ui::Child MockInstance::build() const { + return Kr::scaffold({ + .icon = icon, + .title = name, + .body = [name = this->name] { + return Ui::labelMedium(name) | Ui::center(); + }, + }) | + Ui::box({ + .backgroundFill = Ui::GRAY950, + }); +} + +} // namespace Hideo::Shell diff --git a/src/apps/hideo-shell/mock.h b/src/apps/hideo-shell/mock.h new file mode 100644 index 00000000000..eeb291f7ce7 --- /dev/null +++ b/src/apps/hideo-shell/mock.h @@ -0,0 +1,24 @@ +#pragma once + +#include "model.h" + +namespace Hideo::Shell { + +struct MockLauncher : public Launcher { + using Launcher::Launcher; + + void launch(State &) override; +}; + +struct MockInstance : public Instance { + Mdi::Icon icon; + String name; + Gfx::ColorRamp ramp; + + MockInstance(Mdi::Icon icon, String name, Gfx::ColorRamp ramp) + : icon(icon), name(name), ramp(ramp) {} + + Ui::Child build() const override; +}; + +} // namespace Hideo::Shell diff --git a/src/apps/hideo-shell/model.cpp b/src/apps/hideo-shell/model.cpp index 6813b18065a..3ac01fb9333 100644 --- a/src/apps/hideo-shell/model.cpp +++ b/src/apps/hideo-shell/model.cpp @@ -29,15 +29,7 @@ Ui::Task reduce(State &s, Action a) { s.noti.removeAt(dismis.index); }, [&](StartInstance start) { - auto instance = makeStrong( - 0, - Math::Recti{100, 100, 600, 400}, - Gfx::randomColor(), - s.manifests[start.index] - ); - - s.activePanel = Panel::NIL; - s.instances.emplaceFront(instance); + s.launchers[start.index]->launch(s); }, [&](MoveInstance move) { s.activePanel = Panel::NIL; diff --git a/src/apps/hideo-shell/model.h b/src/apps/hideo-shell/model.h index 2bae2f1c96c..756b9bb9b8d 100644 --- a/src/apps/hideo-shell/model.h +++ b/src/apps/hideo-shell/model.h @@ -1,20 +1,53 @@ #pragma once +#include +#include #include #include - -#include "instance.h" +#include namespace Hideo::Shell { +struct State; +struct Launcher; + +// MARK: Notification ---------------------------------------------------------- + struct Noti { usize id; String title; String body; Vec actions{}; - Strong manifest; }; +// MARK: Manifest & Instance --------------------------------------------------- + +struct Launcher { + Mdi::Icon icon = Mdi::APPLICATION; + String name; + Gfx::ColorRamp ramp; + + Launcher(Mdi::Icon icon, String name, Gfx::ColorRamp ramp) + : icon(icon), name(name), ramp(ramp) {} + + virtual ~Launcher() = default; + + virtual void launch(State &) = 0; +}; + +struct Instance { + usize id; + Math::Recti bound = {100, 100, 600, 400}; + + Instance() = default; + + virtual ~Instance() = default; + + virtual Ui::Child build() const = 0; +}; + +// MARK: Model ----------------------------------------------------------------- + enum struct Panel { NIL, APPS, @@ -36,7 +69,7 @@ struct State : Meta::NoCopy { Image::Picture background; Vec noti; - Vec> manifests; + Vec> launchers; Vec> instances; }; diff --git a/src/apps/hideo-shell/tray-apps.cpp b/src/apps/hideo-shell/tray-apps.cpp index abd6c20c492..1eb938bf20f 100644 --- a/src/apps/hideo-shell/tray-apps.cpp +++ b/src/apps/hideo-shell/tray-apps.cpp @@ -27,7 +27,7 @@ Ui::Child appIcon(Mdi::Icon const &icon, Gfx::ColorRamp ramp, isize size = 22) { }); } -Ui::Child appRow(Manifest const &manifest, usize i) { +Ui::Child appRow(Launcher const &manifest, usize i) { return Ui::ButtonStyle::subtle(), Ui::hflow( 12, @@ -41,7 +41,7 @@ Ui::Child appRow(Manifest const &manifest, usize i) { Ui::Child appsList(State const &state) { return Ui::vflow( - iter(state.manifests) + iter(state.launchers) .mapi([](auto &man, usize i) { return appRow(*man, i); }) @@ -49,7 +49,7 @@ Ui::Child appsList(State const &state) { ); } -Ui::Child appTile(Manifest const &manifest, usize i) { +Ui::Child appTile(Launcher const &manifest, usize i) { return Ui::vflow( 26, appIcon(manifest.icon, manifest.ramp, 26), @@ -64,7 +64,7 @@ Ui::Child appTile(Manifest const &manifest, usize i) { Ui::Child appsGrid(State const &state) { return Ui::grid( Ui::GridStyle::simpleFixed({8, 64}, {4, 64}), - iter(state.manifests) + iter(state.launchers) .mapi([](auto &man, usize i) { return appTile(*man, i); }) diff --git a/src/apps/hideo-shell/tray-sys.cpp b/src/apps/hideo-shell/tray-sys.cpp index 563f42b0f3d..3cf295e8d62 100644 --- a/src/apps/hideo-shell/tray-sys.cpp +++ b/src/apps/hideo-shell/tray-sys.cpp @@ -273,13 +273,12 @@ Ui::Child quickSettings(State const &state) { } Ui::Child noti(Noti const ¬i, usize i) { - auto const &manifest = *noti.manifest; return Ui::vflow( 8, Ui::hflow( 4, - Ui::icon(manifest.icon, 12) | Ui::box({.foregroundFill = manifest.ramp[4]}), - Ui::text(Ui::TextStyles::labelMedium().withColor(Ui::GRAY400), manifest.name) + Ui::icon(Mdi::INFORMATION, 12) | Ui::box({.foregroundFill = Gfx::BLUE_RAMP[4]}), + Ui::text(Ui::TextStyles::labelMedium().withColor(Ui::GRAY400), "Hideo Shell") ), Ui::vflow( 6, diff --git a/src/impls/impl-uring/async.cpp b/src/impls/impl-uring/async.cpp index 9e42f0cf9d3..41fba975e24 100644 --- a/src/impls/impl-uring/async.cpp +++ b/src/impls/impl-uring/async.cpp @@ -1,9 +1,9 @@ #include - // #include #include +#include #include #include #include diff --git a/src/srvs/grund-shell/main.cpp b/src/srvs/grund-shell/main.cpp index e67ba55a79d..d565ea14641 100644 --- a/src/srvs/grund-shell/main.cpp +++ b/src/srvs/grund-shell/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -112,8 +113,8 @@ Async::Task<> servAsync(Sys::Context &ctx) { .dateTime = Sys::dateTime(), .background = co_try$(Image::loadOrFallback("bundle://hideo-shell/wallpapers/winter.qoi"_url)), .noti = {}, - .manifests = { - makeStrong(Mdi::CALCULATOR, "hideo-calculator.main"s, Gfx::ORANGE_RAMP), + .launchers = { + makeStrong(Mdi::CALCULATOR, "hideo-calculator.main"s, Gfx::ORANGE_RAMP), }, .instances = {} };