diff --git a/src/web/vaev-browser/app.cpp b/src/web/vaev-browser/app.cpp index 0b0b7fb..5578e5a 100644 --- a/src/web/vaev-browser/app.cpp +++ b/src/web/vaev-browser/app.cpp @@ -1,3 +1,5 @@ +module; + #include #include #include @@ -36,7 +38,9 @@ #include #include -#include "inspect.h" +export module Vaev.Browser:app; + +import :inspect; namespace Vaev::Browser { diff --git a/src/web/vaev-browser/app.h b/src/web/vaev-browser/app.h deleted file mode 100644 index cef2e98..0000000 --- a/src/web/vaev-browser/app.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include -#include - -namespace Vaev::Browser { - -Ui::Child app(Mime::Url url, Res> dom); - -} // namespace Vaev::Browser diff --git a/src/web/vaev-browser/inspect.cpp b/src/web/vaev-browser/inspect.cpp index 9a5eb74..9bbbb1d 100644 --- a/src/web/vaev-browser/inspect.cpp +++ b/src/web/vaev-browser/inspect.cpp @@ -1,3 +1,5 @@ +module; + #include #include #include @@ -10,10 +12,45 @@ #include #include -#include "inspect.h" +export module Vaev.Browser:inspect; namespace Vaev::Browser { +// MARK: Inspector ------------------------------------------------------------- + +struct ExpandNode { + Strong node; +}; + +struct SelectNode { + Strong node; +}; + +export using InspectorAction = Union; + +export struct InspectState { + Map, bool> expandedNodes = {}; + Opt> 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), @@ -143,7 +180,7 @@ Ui::Child computedStyles() { Ui::pinSize(128); } -Ui::Child inspect(Strong n, InspectState const &s, Ui::Action a) { +export Ui::Child inspect(Strong n, InspectState const &s, Ui::Action a) { return Ui::vflow( node(n, s, a) | Ui::vscroll() | Ui::grow(), computedStyles() | Kr::resizable(Kr::ResizeHandle::TOP, {128}, NONE) diff --git a/src/web/vaev-browser/inspect.h b/src/web/vaev-browser/inspect.h deleted file mode 100644 index 2d09e2b..0000000 --- a/src/web/vaev-browser/inspect.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace Vaev::Browser { - -struct ExpandNode { - Strong node; -}; - -struct SelectNode { - Strong node; -}; - -using InspectorAction = Union; - -struct InspectState { - Map, bool> expandedNodes = {}; - Opt> 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; - }, - }); - } -}; - -Ui::Child inspect(Strong dom, InspectState const &s, Ui::Action action); - -} // namespace Vaev::Browser diff --git a/src/web/vaev-browser/main/main.cpp b/src/web/vaev-browser/main/main.cpp index 5d797e4..9be180c 100644 --- a/src/web/vaev-browser/main/main.cpp +++ b/src/web/vaev-browser/main/main.cpp @@ -2,7 +2,7 @@ #include #include -#include "../app.h" +import Vaev.Browser; Async::Task<> entryPointAsync(Sys::Context &ctx) { auto args = Sys::useArgs(ctx); diff --git a/src/web/vaev-browser/mod.cpp b/src/web/vaev-browser/mod.cpp new file mode 100644 index 0000000..2fcd11d --- /dev/null +++ b/src/web/vaev-browser/mod.cpp @@ -0,0 +1,3 @@ +export module Vaev.Browser; + +export import :app;