diff --git a/browser/gui/app.cpp b/browser/gui/app.cpp index 77e9a6c7b..f4ec1f92e 100644 --- a/browser/gui/app.cpp +++ b/browser/gui/app.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -156,6 +157,35 @@ void App::set_scale(unsigned scale) { engine_.set_layout_width(windowSize.x / scale_); } +void App::sticky_windows(sf::Event::SizeEvent size) { + const char *names[] = { + "Navigation", + "HTTP Response", + "DOM", + "Stylesheet", + "Layout", + NULL, + }; + + int delta = k_width - size.width; + for (uint8_t i = 0;; ++i) { + const char *name = names[i]; + if (!name) { + break; + } + ImGuiWindow *win = ImGui::FindWindowByName(name); + if (!win) { + continue; + } + int edge = win->Pos.x + win->Size.x; + if (edge == k_width) { + ImGui::SetWindowPos(name, {win->Pos.x - delta, win->Pos.y}); + } + } + k_width = size.width; + k_height = size.height; +} + int App::run() { while (window_.isOpen()) { sf::Event event; @@ -170,6 +200,7 @@ int App::run() { case sf::Event::Resized: { canvas_->set_viewport_size(event.size.width, event.size.height); engine_.set_layout_width(event.size.width / scale_); + sticky_windows(event.size); break; } case sf::Event::KeyPressed: { diff --git a/browser/gui/app.h b/browser/gui/app.h index 0ef275fe5..2b0d19667 100644 --- a/browser/gui/app.h +++ b/browser/gui/app.h @@ -14,6 +14,7 @@ #include "uri/uri.h" #include "util/history.h" +#include #include #include #include @@ -74,7 +75,9 @@ class App final { void navigate(); void layout(); - + void sticky_windows(sf::Event::SizeEvent); + int k_width, k_height; + std::vector get_hovered_nodes(geom::Position document_position) const; geom::Position to_document_position(geom::Position window_position) const;