mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +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
|
set(SOURCES
|
||||||
BookmarksBarWidget.cpp
|
BookmarksBarWidget.cpp
|
||||||
BrowserConsoleClient.cpp
|
BrowserConsoleClient.cpp
|
||||||
|
@ -8,6 +10,7 @@ set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
Tab.cpp
|
Tab.cpp
|
||||||
WindowActions.cpp
|
WindowActions.cpp
|
||||||
|
BrowserWindowUI.h
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(Browser)
|
serenity_bin(Browser)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "Tab.h"
|
#include "Tab.h"
|
||||||
#include "WindowActions.h"
|
#include "WindowActions.h"
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <Applications/Browser/BrowserWindowUI.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
|
@ -134,14 +135,10 @@ int main(int argc, char** argv)
|
||||||
window->set_title("Browser");
|
window->set_title("Browser");
|
||||||
|
|
||||||
auto& widget = window->set_main_widget<GUI::Widget>();
|
auto& widget = window->set_main_widget<GUI::Widget>();
|
||||||
widget.set_fill_with_background_color(true);
|
widget.load_from_json(browser_window_ui_json);
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
|
||||||
widget.layout()->set_spacing(2);
|
|
||||||
|
|
||||||
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_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");
|
auto default_favicon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png");
|
||||||
ASSERT(default_favicon);
|
ASSERT(default_favicon);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue