mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
Browser: Move the basic Tab UI skeleton to JSON GUI
This commit is contained in:
parent
1307f7292c
commit
d67b421628
Notes:
sideshowbarker
2024-07-19 02:24:36 +09:00
Author: https://github.com/awesomekling
Commit: d67b421628
3 changed files with 40 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
|||
compile_json_gui(BrowserWindow.json BrowserWindowUI.h browser_window_ui_json)
|
||||
compile_json_gui(Tab.json TabUI.h tab_ui_json)
|
||||
|
||||
set(SOURCES
|
||||
BookmarksBarWidget.cpp
|
||||
|
@ -11,6 +12,7 @@ set(SOURCES
|
|||
Tab.cpp
|
||||
WindowActions.cpp
|
||||
BrowserWindowUI.h
|
||||
TabUI.h
|
||||
)
|
||||
|
||||
serenity_bin(Browser)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "InspectorWidget.h"
|
||||
#include "WindowActions.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Applications/Browser/TabUI.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -76,16 +77,17 @@ URL url_from_user_input(const String& input)
|
|||
Tab::Tab(Type type)
|
||||
: m_type(type)
|
||||
{
|
||||
auto& widget = *this;
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
load_from_json(tab_ui_json);
|
||||
|
||||
m_toolbar_container = widget.add<GUI::ToolBarContainer>();
|
||||
auto& toolbar = m_toolbar_container->add<GUI::ToolBar>();
|
||||
m_toolbar_container = static_cast<GUI::ToolBarContainer&>(*find_descendant_by_name("toolbar_container"));
|
||||
auto& toolbar = static_cast<GUI::ToolBar&>(*find_descendant_by_name("toolbar"));
|
||||
|
||||
auto& webview_container = *find_descendant_by_name("webview_container");
|
||||
|
||||
if (m_type == Type::InProcessWebView)
|
||||
m_page_view = widget.add<Web::InProcessWebView>();
|
||||
m_page_view = webview_container.add<Web::InProcessWebView>();
|
||||
else
|
||||
m_web_content_view = widget.add<Web::OutOfProcessWebView>();
|
||||
m_web_content_view = webview_container.add<Web::OutOfProcessWebView>();
|
||||
|
||||
m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { go_back(); }, this);
|
||||
m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { go_forward(); }, this);
|
||||
|
@ -217,7 +219,7 @@ Tab::Tab(Type type)
|
|||
},
|
||||
this);
|
||||
|
||||
m_statusbar = widget.add<GUI::StatusBar>();
|
||||
m_statusbar = static_cast<GUI::StatusBar&>(*find_descendant_by_name("statusbar"));
|
||||
|
||||
hooks().on_link_hover = [this](auto& url) {
|
||||
if (url.is_valid())
|
||||
|
|
29
Applications/Browser/Tab.json
Normal file
29
Applications/Browser/Tab.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"layout": {
|
||||
"class": "GUI::VerticalBoxLayout"
|
||||
},
|
||||
|
||||
"children": [
|
||||
{
|
||||
"class": "GUI::ToolBarContainer",
|
||||
"name": "toolbar_container",
|
||||
"children": [
|
||||
{
|
||||
"class": "GUI::ToolBar",
|
||||
"name": "toolbar"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"class": "GUI::Widget",
|
||||
"name": "webview_container",
|
||||
"layout": {
|
||||
"class": "GUI::VerticalBoxLayout"
|
||||
}
|
||||
},
|
||||
{
|
||||
"class": "GUI::StatusBar",
|
||||
"name": "statusbar"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue