mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
Browser: Generate the main browser window UI from JSON :^)
This commit is contained in:
parent
3355a3e179
commit
856f683dc9
3 changed files with 24 additions and 6 deletions
18
Applications/Browser/BrowserWindow.json
Normal file
18
Applications/Browser/BrowserWindow.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "browser",
|
||||
"fill_with_background_color": true,
|
||||
|
||||
"layout": {
|
||||
"class": "GUI::VerticalBoxLayout",
|
||||
"spacing": 2
|
||||
},
|
||||
|
||||
"children": [
|
||||
{
|
||||
"class": "GUI::TabWidget",
|
||||
"name": "tab_widget",
|
||||
"container_padding": 0,
|
||||
"uniform_tabs": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
compile_json_gui(BrowserWindow.json BrowserWindowUI.h browser_window_ui_json)
|
||||
|
||||
set(SOURCES
|
||||
BookmarksBarWidget.cpp
|
||||
BrowserConsoleClient.cpp
|
||||
|
@ -8,6 +10,7 @@ set(SOURCES
|
|||
main.cpp
|
||||
Tab.cpp
|
||||
WindowActions.cpp
|
||||
BrowserWindowUI.h
|
||||
)
|
||||
|
||||
serenity_bin(Browser)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "Tab.h"
|
||||
#include "WindowActions.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Applications/Browser/BrowserWindowUI.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -134,14 +135,10 @@ int main(int argc, char** argv)
|
|||
window->set_title("Browser");
|
||||
|
||||
auto& widget = window->set_main_widget<GUI::Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
widget.layout()->set_spacing(2);
|
||||
widget.load_from_json(browser_window_ui_json);
|
||||
|
||||
auto& tab_widget = widget.add<GUI::TabWidget>();
|
||||
auto& tab_widget = static_cast<GUI::TabWidget&>(*widget.find_descendant_by_name("tab_widget"));
|
||||
tab_widget.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
tab_widget.set_container_padding(0);
|
||||
tab_widget.set_uniform_tabs(true);
|
||||
|
||||
auto default_favicon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png");
|
||||
ASSERT(default_favicon);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue