Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Dec 9, 2024
1 parent c84f23c commit a97aa80
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 56 deletions.
6 changes: 5 additions & 1 deletion src/web/vaev-browser/app.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module;

#include <karm-kira/context-menu.h>
#include <karm-kira/dialog.h>
#include <karm-kira/error-page.h>
Expand Down Expand Up @@ -36,7 +38,9 @@
#include <vaev-view/dialog.h>
#include <vaev-view/view.h>

#include "inspect.h"
export module Vaev.Browser:app;

import :inspect;

namespace Vaev::Browser {

Expand Down
10 changes: 0 additions & 10 deletions src/web/vaev-browser/app.h

This file was deleted.

41 changes: 39 additions & 2 deletions src/web/vaev-browser/inspect.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module;

#include <karm-kira/resizable.h>
#include <karm-kira/side-panel.h>
#include <karm-ui/input.h>
Expand All @@ -10,10 +12,45 @@
#include <vaev-markup/dom.h>
#include <vaev-style/styles.h>

#include "inspect.h"
export module Vaev.Browser:inspect;

namespace Vaev::Browser {

// MARK: Inspector -------------------------------------------------------------

struct ExpandNode {
Strong<Markup::Node> node;
};

struct SelectNode {
Strong<Markup::Node> node;
};

export using InspectorAction = Union<ExpandNode, SelectNode>;

export struct InspectState {
Map<Strong<Markup::Node>, bool> expandedNodes = {};
Opt<Strong<Markup::Node>> selectedNode = NONE;

void apply(InspectorAction &a) {
a.visit(Visitor{
[&](ExpandNode e) {
if (expandedNodes.has(e.node))
expandedNodes.del(e.node);
else
expandedNodes.put(e.node, true);
},
[&](SelectNode e) {
if (e.node->children())
expandedNodes.put(e.node, true);
selectedNode = e.node;
},
});
}
};

// MARK: Components ------------------------------------------------------------

auto guide() {
return Ui::hflow(
Ui::empty(8),
Expand Down Expand Up @@ -143,7 +180,7 @@ Ui::Child computedStyles() {
Ui::pinSize(128);
}

Ui::Child inspect(Strong<Vaev::Markup::Document> n, InspectState const &s, Ui::Action<InspectorAction> a) {
export Ui::Child inspect(Strong<Vaev::Markup::Document> n, InspectState const &s, Ui::Action<InspectorAction> a) {
return Ui::vflow(
node(n, s, a) | Ui::vscroll() | Ui::grow(),
computedStyles() | Kr::resizable(Kr::ResizeHandle::TOP, {128}, NONE)
Expand Down
42 changes: 0 additions & 42 deletions src/web/vaev-browser/inspect.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/web/vaev-browser/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <karm-ui/app.h>
#include <vaev-driver/fetcher.h>

#include "../app.h"
import Vaev.Browser;

Async::Task<> entryPointAsync(Sys::Context &ctx) {
auto args = Sys::useArgs(ctx);
Expand Down
3 changes: 3 additions & 0 deletions src/web/vaev-browser/mod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export module Vaev.Browser;

export import :app;

0 comments on commit a97aa80

Please sign in to comment.