Skip to content

Commit

Permalink
Improved devtools's UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Aug 30, 2024
1 parent aec06f6 commit 51ba53e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 28 deletions.
52 changes: 26 additions & 26 deletions src/web/vaev-devtools/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <karm-mime/mime.h>
#include <karm-sys/file.h>
#include <karm-sys/launch.h>
#include <karm-ui/drag.h>
#include <karm-ui/input.h>
#include <karm-ui/popover.h>
#include <karm-ui/scroll.h>
Expand All @@ -17,7 +18,6 @@ namespace Hideo::Browser {

enum struct SidePanel {
CLOSE,
BOOKMARKS,
DEVELOPER_TOOLS,
};

Expand Down Expand Up @@ -62,10 +62,8 @@ using Model = Ui::Model<State, Action, reduce>;

Ui::Child mainMenu([[maybe_unused]] State const &s) {
return Kr::contextMenuContent({
Kr::contextMenuItem(Model::bind(SidePanel::BOOKMARKS), Mdi::BOOKMARK, "Bookmarks"),
Ui::separator(),
Kr::contextMenuItem(Ui::NOP, Mdi::PRINTER, "Print..."),
#ifdef __ck_host__
Kr::contextMenuItem(
[&](auto &n) {
auto res = Sys::launch(Mime::Uti::PUBLIC_OPEN, s.url);
Expand All @@ -80,11 +78,8 @@ Ui::Child mainMenu([[maybe_unused]] State const &s) {
},
Mdi::WEB, "Open in default browser..."
),
#endif
Ui::separator(),
Kr::contextMenuItem(Model::bind(SidePanel::DEVELOPER_TOOLS), Mdi::CODE_TAGS, "Developer Tools"),
Ui::separator(),
Kr::contextMenuItem(Ui::NOP, Mdi::COG, "Settings"),
Kr::contextMenuItem(Model::bind(SidePanel::DEVELOPER_TOOLS), Mdi::CODE_TAGS, "Inspector"),
});
}

Expand All @@ -93,8 +88,7 @@ Ui::Child addressBar(Mime::Url const &url) {
0,
Math::Align::CENTER,
Ui::text("{}", url),
Ui::grow(NONE),
Ui::button(Ui::NOP, Ui::ButtonStyle::subtle(), Mdi::BOOKMARK_OUTLINE)
Ui::grow(NONE)
) |
Ui::box({
.padding = {12, 0, 0, 0},
Expand All @@ -107,9 +101,7 @@ Ui::Child addressBar(Mime::Url const &url) {
Ui::Child contextMenu(State const &s) {
return Kr::contextMenuContent({
Kr::contextMenuDock({
Kr::contextMenuIcon(Ui::NOP, Mdi::ARROW_LEFT),
Kr::contextMenuIcon(Ui::NOP, Mdi::ARROW_RIGHT),
Kr::contextMenuIcon(Ui::NOP, Mdi::REFRESH),
Kr::contextMenuIcon(Model::bind<Reload>(), Mdi::REFRESH),
}),
Ui::separator(),
Kr::contextMenuItem(
Expand All @@ -133,18 +125,9 @@ Ui::Child inspectorContent(State const &s) {

Ui::Child sidePanel(State const &s) {
switch (s.sidePanel) {
case SidePanel::BOOKMARKS:
return Kr::sidePanelContent({
Kr::sidePanelTitle(Model::bind(SidePanel::CLOSE), "Bookmarks"),
Ui::separator(),
Ui::labelMedium(Ui::GRAY500, "No bookmarks") |
Ui::center() |
Ui::grow(),
});

case SidePanel::DEVELOPER_TOOLS:
return Kr::sidePanelContent({
Kr::sidePanelTitle(Model::bind(SidePanel::CLOSE), "Developer Tools"),
Kr::sidePanelTitle(Model::bind(SidePanel::CLOSE), "Inspector"),
Ui::separator(),
inspectorContent(s) | Ui::grow(),
});
Expand Down Expand Up @@ -194,12 +177,29 @@ Ui::Child app(Mime::Url url, Res<Strong<Vaev::Dom::Document>> dom) {
dom,
},
[](State const &s) {
return Ui::vflow(
Hideo::toolbar(
Ui::button(
[&](Ui::Node &n) {
Ui::showDialog(n, Kr::alert("Vaev"s, "Copyright © 2024, Odoo S.A."s));
},
Ui::ButtonStyle::subtle(),
Mdi::SURFING
),
addressBar(s.url) | Ui::grow(), Ui::button(Model::bind<Reload>(), Ui::ButtonStyle::subtle(), Mdi::REFRESH), Ui::button([&](Ui::Node &n) {
Ui::showPopover(n, n.bound().bottomEnd(), mainMenu(s));
},
Ui::ButtonStyle::subtle(), Mdi::DOTS_HORIZONTAL),
Hideo::controls()
) | Ui::dragRegion(),
appContent(s) | Ui::grow()
) |
Ui::pinSize({800, 600}) | Ui::dialogLayer() | Ui::popoverLayer();

return Hideo::scafold({
.icon = Mdi::WEB,
.title = "Browser"s,
.icon = Mdi::SURFING,
.title = "Vaev"s,
.startTools = slots$(
Ui::button(Model::bindIf<GoBack>(s.canGoBack()), Ui::ButtonStyle::subtle(), Mdi::ARROW_LEFT),
Ui::button(Model::bindIf<GoForward>(s.canGoForward()), Ui::ButtonStyle::subtle(), Mdi::ARROW_RIGHT),
Ui::button(Model::bind<Reload>(), Ui::ButtonStyle::subtle(), Mdi::REFRESH)
),
.midleTools = slots$(addressBar(s.url) | Ui::grow()),
Expand Down
4 changes: 2 additions & 2 deletions src/web/vaev-driver/fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Res<Strong<Dom::Document>> fetchDocument(Mime::Url url) {

if (url.scheme == "about") {
if (url.path.str() == "blank")
return fetchDocument("bundle://hideo-browser/blank.xhtml"_url);
return fetchDocument("bundle://vaev-driver/blank.xhtml"_url);

if (url.path.str() == "start")
return fetchDocument("bundle://hideo-browser/start-page.xhtml"_url);
return fetchDocument("bundle://vaev-driver/start-page.xhtml"_url);

return Error::invalidInput("unsupported about page");
}
Expand Down
14 changes: 14 additions & 0 deletions src/web/vaev-driver/res/blank.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>

<body>

</body>

</html>
14 changes: 14 additions & 0 deletions src/web/vaev-driver/res/start-page.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Start Page</title>
</head>

<body>
Hello, world!
</body>

</html>

0 comments on commit 51ba53e

Please sign in to comment.