Skip to content

Commit

Permalink
karm-app: Started isolating application code into a separeted library.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Aug 3, 2024
1 parent 7858fab commit be76696
Show file tree
Hide file tree
Showing 48 changed files with 718 additions and 690 deletions.
8 changes: 4 additions & 4 deletions src/apps/hideo-base/scafold.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <karm-app/host.h>
#include <karm-kira/about-dialog.h>
#include <karm-sys/context.h>
#include <karm-ui/dialog.h>
#include <karm-ui/drag.h>
#include <karm-ui/input.h>
Expand Down Expand Up @@ -28,19 +28,19 @@ Ui::Child controls(TitlebarStyle style) {
return Ui::hflow(
12,
Ui::button(
Ui::bindBubble<Events::RequestMinimizeEvent>(),
Ui::bindBubble<App::RequestMinimizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::MINUS
) | Ui::cond(style == TitlebarStyle::DEFAULT),

Ui::button(
Ui::bindBubble<Events::RequestMaximizeEvent>(),
Ui::bindBubble<App::RequestMaximizeEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::CROP_SQUARE
) | Ui::cond(style == TitlebarStyle::DEFAULT),

Ui::button(
Ui::bindBubble<Events::RequestExitEvent>(),
Ui::bindBubble<App::RequestExitEvent>(),
Ui::ButtonStyle::subtle(),
Mdi::CLOSE
)
Expand Down
2 changes: 1 addition & 1 deletion src/apps/hideo-demos/demo-bezier.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static inline Demo BEZIER_DEMO{
Ui::bound() |
Ui::dragRegion() |
Ui::placed(Math::Recti::fromCenter(pos.cast<isize>(), {24, 24})) |
Ui::intent([=](Ui::Node &n, Sys::Event &e) {
Ui::intent([=](Ui::Node &n, App::Event &e) {
if (auto *m = e.is<Ui::DragEvent>()) {
e.accept();
Model::bubble<Edit>(n, {index, pos + m->delta});
Expand Down
2 changes: 1 addition & 1 deletion src/apps/hideo-demos/demo-mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static inline Demo MESH_DEMO{
Ui::bound() |
Ui::dragRegion() |
Ui::placed(Math::Recti::fromCenter(pos.cast<isize>(), {24, 24})) |
Ui::intent([=](Ui::Node &n, Sys::Event &e) {
Ui::intent([=](Ui::Node &n, App::Event &e) {
if (auto *m = e.is<Ui::DragEvent>()) {
e.accept();
Model::bubble<Edit>(n, {index, pos + m->delta});
Expand Down
5 changes: 3 additions & 2 deletions src/apps/hideo-shell/app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <hideo-base/scafold.h>
#include <hideo-keyboard/views.h>
#include <karm-app/host.h>
#include <karm-ui/dialog.h>
#include <karm-ui/drag.h>
#include <karm-ui/input.h>
Expand Down Expand Up @@ -183,11 +184,11 @@ Ui::Child appStack(State const &state) {
.shadowStyle = Gfx::BoxShadow::elevated(index ? 4 : 16),
}) |
Ui::placed(s->bound) |
Ui::intent([=](Ui::Node &n, Sys::Event &e) {
Ui::intent([=](Ui::Node &n, App::Event &e) {
if (auto *m = e.is<Ui::DragEvent>()) {
e.accept();
Model::bubble<MoveInstance>(n, {index, m->delta});
} else if (auto *c = e.is<Events::RequestExitEvent>()) {
} else if (auto *c = e.is<App::RequestExitEvent>()) {
e.accept();
Model::bubble<CloseInstance>(n, {index});
}
Expand Down
8 changes: 4 additions & 4 deletions src/apps/hideo-spreadsheet/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ struct Table : public Ui::View<Table> {

// MARK: Events ------------------------------------------------------------

void event(Sys::Event &event) override {
auto *e = event.is<Events::MouseEvent>();
void event(App::Event &event) override {
auto *e = event.is<App::MouseEvent>();
if (not e)
return;

auto pos = e->pos - bound().topStart();
if (not bound().contains(e->pos))
return;

if (e->type == Events::MouseEvent::PRESS) {
if (e->type == App::MouseEvent::PRESS) {
auto cell = sheet().cellAt(pos - Math::Vec2i{CELL_WIDTH, CELL_HEIGHT});
if (cell) {
Model::bubble(*this, UpdateSelection{Range{*cell}});
}
} else if (e->type == Events::MouseEvent::MOVE and (e->buttons & Events::Button::LEFT) == Events::Button::LEFT) {
} else if (e->type == App::MouseEvent::MOVE and (e->buttons & App::MouseButton::LEFT) == App::MouseButton::LEFT) {
auto cell = sheet().cellAt(pos - Math::Vec2i{CELL_WIDTH, CELL_HEIGHT});
if (cell) {
auto sel = *_state->selection;
Expand Down
4 changes: 2 additions & 2 deletions src/impls/impl-efi/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ struct EfiHost :
Efi::Key key = {};
_stip->readKeyStroke(_stip, &key).unwrap();
auto e = key.toKeyEvent();
event<Events::KeyboardEvent>(*this, e);
event<App::KeyboardEvent>(*this, e);
return Ok();
}

void bubble(Sys::Event &e) override {
void bubble(App::Event &e) override {
Host::bubble(e);
}
};
Expand Down
Loading

0 comments on commit be76696

Please sign in to comment.