mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:57:35 +00:00
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can simply vend a ChildType&. This allows us to use "." instead of "->" at the call site, which is quite nice. :^)
This commit is contained in:
parent
fb09b6a8ce
commit
028c011760
46 changed files with 1035 additions and 1039 deletions
|
@ -68,60 +68,60 @@ int main(int argc, char** argv)
|
||||||
outer_widget.set_layout<GUI::VerticalBoxLayout>();
|
outer_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
outer_widget.layout()->set_margins({ 8, 8, 8, 8 });
|
outer_widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||||
|
|
||||||
auto inner_widget = outer_widget.add<GUI::Widget>();
|
auto& inner_widget = outer_widget.add<GUI::Widget>();
|
||||||
inner_widget->set_layout<GUI::HorizontalBoxLayout>();
|
inner_widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
inner_widget->layout()->set_spacing(8);
|
inner_widget.layout()->set_spacing(8);
|
||||||
|
|
||||||
auto left_outer_container = inner_widget->add<GUI::Widget>();
|
auto& left_outer_container = inner_widget.add<GUI::Widget>();
|
||||||
left_outer_container->set_layout<GUI::HorizontalBoxLayout>();
|
left_outer_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
|
|
||||||
auto left_inner_container = left_outer_container->add<GUI::Widget>();
|
auto& left_inner_container = left_outer_container.add<GUI::Widget>();
|
||||||
left_inner_container->set_layout<GUI::VerticalBoxLayout>();
|
left_inner_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
left_inner_container->layout()->set_spacing(8);
|
left_inner_container.layout()->set_spacing(8);
|
||||||
left_inner_container->set_preferred_size(0, 50);
|
left_inner_container.set_preferred_size(0, 50);
|
||||||
left_inner_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
left_inner_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
|
|
||||||
auto label = left_inner_container->add<GUI::Label>();
|
auto& label = left_inner_container.add<GUI::Label>();
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
label.set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
label->set_font(Gfx::Font::default_bold_font());
|
label.set_font(Gfx::Font::default_bold_font());
|
||||||
label->set_text("SerenityOS");
|
label.set_text("SerenityOS");
|
||||||
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label->set_preferred_size(0, 11);
|
label.set_preferred_size(0, 11);
|
||||||
|
|
||||||
utsname uts;
|
utsname uts;
|
||||||
int rc = uname(&uts);
|
int rc = uname(&uts);
|
||||||
ASSERT(rc == 0);
|
ASSERT(rc == 0);
|
||||||
|
|
||||||
auto version_label = left_inner_container->add<GUI::Label>();
|
auto& version_label = left_inner_container.add<GUI::Label>();
|
||||||
version_label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
version_label.set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
version_label->set_text(String::format("Version %s", uts.release));
|
version_label.set_text(String::format("Version %s", uts.release));
|
||||||
version_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
version_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
version_label->set_preferred_size(0, 11);
|
version_label.set_preferred_size(0, 11);
|
||||||
|
|
||||||
auto git_info_label = left_inner_container->add<GUI::Label>();
|
auto& git_info_label = left_inner_container.add<GUI::Label>();
|
||||||
git_info_label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
git_info_label.set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
git_info_label->set_text(String::format("%s@%s", GIT_BRANCH, GIT_COMMIT));
|
git_info_label.set_text(String::format("%s@%s", GIT_BRANCH, GIT_COMMIT));
|
||||||
git_info_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
git_info_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
git_info_label->set_preferred_size(0, 11);
|
git_info_label.set_preferred_size(0, 11);
|
||||||
|
|
||||||
auto right_container = inner_widget->add<GUI::Widget>();
|
auto& right_container = inner_widget.add<GUI::Widget>();
|
||||||
right_container->set_layout<GUI::VerticalBoxLayout>();
|
right_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto icon_label = right_container->add<GUI::Label>();
|
auto& icon_label = right_container.add<GUI::Label>();
|
||||||
icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/buggie.png"));
|
icon_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/buggie.png"));
|
||||||
icon_label->set_tooltip("Buggie");
|
icon_label.set_tooltip("Buggie");
|
||||||
icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
icon_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
icon_label->set_preferred_size(icon_label->icon()->size());
|
icon_label.set_preferred_size(icon_label.icon()->size());
|
||||||
|
|
||||||
auto quit_button = outer_widget.add<GUI::Button>();
|
auto& quit_button = outer_widget.add<GUI::Button>();
|
||||||
quit_button->set_text("Okay");
|
quit_button.set_text("Okay");
|
||||||
quit_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
quit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
quit_button->set_preferred_size(100, 20);
|
quit_button.set_preferred_size(100, 20);
|
||||||
quit_button->on_click = [] {
|
quit_button.on_click = [] {
|
||||||
GUI::Application::the().quit(0);
|
GUI::Application::the().quit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
quit_button->set_focus(true);
|
quit_button.set_focus(true);
|
||||||
window->show();
|
window->show();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
InspectorWidget::InspectorWidget()
|
InspectorWidget::InspectorWidget()
|
||||||
{
|
{
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
auto splitter = add<GUI::VerticalSplitter>();
|
auto& splitter = add<GUI::VerticalSplitter>();
|
||||||
m_dom_tree_view = splitter->add<GUI::TreeView>();
|
m_dom_tree_view = splitter.add<GUI::TreeView>();
|
||||||
m_dom_tree_view->on_selection = [this](auto& index) {
|
m_dom_tree_view->on_selection = [this](auto& index) {
|
||||||
auto* node = static_cast<Node*>(index.internal_data());
|
auto* node = static_cast<Node*>(index.internal_data());
|
||||||
node->document().set_inspected_node(node);
|
node->document().set_inspected_node(node);
|
||||||
|
@ -55,12 +55,12 @@ InspectorWidget::InspectorWidget()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto tab_widget = splitter->add<GUI::TabWidget>();
|
auto& tab_widget = splitter.add<GUI::TabWidget>();
|
||||||
|
|
||||||
m_style_table_view = tab_widget->add_tab<GUI::TableView>("Styles");
|
m_style_table_view = tab_widget.add_tab<GUI::TableView>("Styles");
|
||||||
m_style_table_view->set_size_columns_to_fit_content(true);
|
m_style_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
m_computed_style_table_view = tab_widget->add_tab<GUI::TableView>("Computed");
|
m_computed_style_table_view = tab_widget.add_tab<GUI::TableView>("Computed");
|
||||||
m_computed_style_table_view->set_size_columns_to_fit_content(true);
|
m_computed_style_table_view->set_size_columns_to_fit_content(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,8 @@ int main(int argc, char** argv)
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto toolbar = widget.add<GUI::ToolBar>();
|
auto& toolbar = widget.add<GUI::ToolBar>();
|
||||||
auto html_widget = widget.add<HtmlView>();
|
auto& html_widget = widget.add<HtmlView>();
|
||||||
|
|
||||||
History<URL> history;
|
History<URL> history;
|
||||||
|
|
||||||
|
@ -99,70 +99,70 @@ int main(int argc, char** argv)
|
||||||
history.go_back();
|
history.go_back();
|
||||||
update_actions();
|
update_actions();
|
||||||
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
||||||
html_widget->load(history.current());
|
html_widget.load(history.current());
|
||||||
});
|
});
|
||||||
|
|
||||||
go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) {
|
go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) {
|
||||||
history.go_forward();
|
history.go_forward();
|
||||||
update_actions();
|
update_actions();
|
||||||
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
||||||
html_widget->load(history.current());
|
html_widget.load(history.current());
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbar->add_action(*go_back_action);
|
toolbar.add_action(*go_back_action);
|
||||||
toolbar->add_action(*go_forward_action);
|
toolbar.add_action(*go_forward_action);
|
||||||
|
|
||||||
toolbar->add_action(GUI::CommonActions::make_go_home_action([&](auto&) {
|
toolbar.add_action(GUI::CommonActions::make_go_home_action([&](auto&) {
|
||||||
html_widget->load(home_url);
|
html_widget.load(home_url);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
toolbar->add_action(GUI::CommonActions::make_reload_action([&](auto&) {
|
toolbar.add_action(GUI::CommonActions::make_reload_action([&](auto&) {
|
||||||
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
TemporaryChange<bool> change(should_push_loads_to_history, false);
|
||||||
html_widget->reload();
|
html_widget.reload();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto location_box = toolbar->add<GUI::TextBox>();
|
auto& location_box = toolbar.add<GUI::TextBox>();
|
||||||
|
|
||||||
location_box->on_return_pressed = [&] {
|
location_box.on_return_pressed = [&] {
|
||||||
html_widget->load(location_box->text());
|
html_widget.load(location_box.text());
|
||||||
};
|
};
|
||||||
|
|
||||||
html_widget->on_load_start = [&](auto& url) {
|
html_widget.on_load_start = [&](auto& url) {
|
||||||
location_box->set_text(url.to_string());
|
location_box.set_text(url.to_string());
|
||||||
if (should_push_loads_to_history)
|
if (should_push_loads_to_history)
|
||||||
history.push(url);
|
history.push(url);
|
||||||
update_actions();
|
update_actions();
|
||||||
};
|
};
|
||||||
|
|
||||||
html_widget->on_link_click = [&](auto& url) {
|
html_widget.on_link_click = [&](auto& url) {
|
||||||
if (url.starts_with("#")) {
|
if (url.starts_with("#")) {
|
||||||
html_widget->scroll_to_anchor(url.substring_view(1, url.length() - 1));
|
html_widget.scroll_to_anchor(url.substring_view(1, url.length() - 1));
|
||||||
} else {
|
} else {
|
||||||
html_widget->load(html_widget->document()->complete_url(url));
|
html_widget.load(html_widget.document()->complete_url(url));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
html_widget->on_title_change = [&](auto& title) {
|
html_widget.on_title_change = [&](auto& title) {
|
||||||
window->set_title(String::format("%s - Browser", title.characters()));
|
window->set_title(String::format("%s - Browser", title.characters()));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto focus_location_box_action = GUI::Action::create("Focus location box", { Mod_Ctrl, Key_L }, [&](auto&) {
|
auto focus_location_box_action = GUI::Action::create("Focus location box", { Mod_Ctrl, Key_L }, [&](auto&) {
|
||||||
location_box->select_all();
|
location_box.select_all();
|
||||||
location_box->set_focus(true);
|
location_box.set_focus(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto statusbar = widget.add<GUI::StatusBar>();
|
auto& statusbar = widget.add<GUI::StatusBar>();
|
||||||
|
|
||||||
html_widget->on_link_hover = [&](auto& href) {
|
html_widget.on_link_hover = [&](auto& href) {
|
||||||
statusbar->set_text(href);
|
statusbar.set_text(href);
|
||||||
};
|
};
|
||||||
|
|
||||||
ResourceLoader::the().on_load_counter_change = [&] {
|
ResourceLoader::the().on_load_counter_change = [&] {
|
||||||
if (ResourceLoader::the().pending_loads() == 0) {
|
if (ResourceLoader::the().pending_loads() == 0) {
|
||||||
statusbar->set_text("");
|
statusbar.set_text("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statusbar->set_text(String::format("Loading (%d pending resources...)", ResourceLoader::the().pending_loads()));
|
statusbar.set_text(String::format("Loading (%d pending resources...)", ResourceLoader::the().pending_loads()));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
@ -179,13 +179,13 @@ int main(int argc, char** argv)
|
||||||
inspect_menu->add_action(GUI::Action::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) {
|
inspect_menu->add_action(GUI::Action::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) {
|
||||||
String filename_to_open;
|
String filename_to_open;
|
||||||
char tmp_filename[] = "/tmp/view-source.XXXXXX";
|
char tmp_filename[] = "/tmp/view-source.XXXXXX";
|
||||||
ASSERT(html_widget->document());
|
ASSERT(html_widget.document());
|
||||||
if (html_widget->document()->url().protocol() == "file") {
|
if (html_widget.document()->url().protocol() == "file") {
|
||||||
filename_to_open = html_widget->document()->url().path();
|
filename_to_open = html_widget.document()->url().path();
|
||||||
} else {
|
} else {
|
||||||
int fd = mkstemp(tmp_filename);
|
int fd = mkstemp(tmp_filename);
|
||||||
ASSERT(fd >= 0);
|
ASSERT(fd >= 0);
|
||||||
auto source = html_widget->document()->source();
|
auto source = html_widget.document()->source();
|
||||||
write(fd, source.characters(), source.length());
|
write(fd, source.characters(), source.length());
|
||||||
close(fd);
|
close(fd);
|
||||||
filename_to_open = tmp_filename;
|
filename_to_open = tmp_filename;
|
||||||
|
@ -203,7 +203,7 @@ int main(int argc, char** argv)
|
||||||
dom_inspector_window->set_main_widget<InspectorWidget>();
|
dom_inspector_window->set_main_widget<InspectorWidget>();
|
||||||
}
|
}
|
||||||
auto* inspector_widget = static_cast<InspectorWidget*>(dom_inspector_window->main_widget());
|
auto* inspector_widget = static_cast<InspectorWidget*>(dom_inspector_window->main_widget());
|
||||||
inspector_widget->set_document(html_widget->document());
|
inspector_widget->set_document(html_widget.document());
|
||||||
dom_inspector_window->show();
|
dom_inspector_window->show();
|
||||||
dom_inspector_window->move_to_front();
|
dom_inspector_window->move_to_front();
|
||||||
}));
|
}));
|
||||||
|
@ -211,21 +211,21 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto debug_menu = GUI::Menu::construct("Debug");
|
auto debug_menu = GUI::Menu::construct("Debug");
|
||||||
debug_menu->add_action(GUI::Action::create("Dump DOM tree", [&](auto&) {
|
debug_menu->add_action(GUI::Action::create("Dump DOM tree", [&](auto&) {
|
||||||
dump_tree(*html_widget->document());
|
dump_tree(*html_widget.document());
|
||||||
}));
|
}));
|
||||||
debug_menu->add_action(GUI::Action::create("Dump Layout tree", [&](auto&) {
|
debug_menu->add_action(GUI::Action::create("Dump Layout tree", [&](auto&) {
|
||||||
dump_tree(*html_widget->document()->layout_node());
|
dump_tree(*html_widget.document()->layout_node());
|
||||||
}));
|
}));
|
||||||
debug_menu->add_action(GUI::Action::create("Dump Style sheets", [&](auto&) {
|
debug_menu->add_action(GUI::Action::create("Dump Style sheets", [&](auto&) {
|
||||||
for (auto& sheet : html_widget->document()->stylesheets()) {
|
for (auto& sheet : html_widget.document()->stylesheets()) {
|
||||||
dump_sheet(sheet);
|
dump_sheet(sheet);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
debug_menu->add_separator();
|
debug_menu->add_separator();
|
||||||
auto line_box_borders_action = GUI::Action::create("Line box borders", [&](auto& action) {
|
auto line_box_borders_action = GUI::Action::create("Line box borders", [&](auto& action) {
|
||||||
action.set_checked(!action.is_checked());
|
action.set_checked(!action.is_checked());
|
||||||
html_widget->set_should_show_line_box_borders(action.is_checked());
|
html_widget.set_should_show_line_box_borders(action.is_checked());
|
||||||
html_widget->update();
|
html_widget.update();
|
||||||
});
|
});
|
||||||
line_box_borders_action->set_checkable(true);
|
line_box_borders_action->set_checkable(true);
|
||||||
line_box_borders_action->set_checked(false);
|
line_box_borders_action->set_checked(false);
|
||||||
|
@ -253,7 +253,7 @@ int main(int argc, char** argv)
|
||||||
url_to_load.set_path(app.args()[0]);
|
url_to_load.set_path(app.args()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
html_widget->load(url_to_load);
|
html_widget.load(url_to_load);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,30 +61,30 @@ int main(int argc, char** argv)
|
||||||
widget.set_fill_with_background_color(true);
|
widget.set_fill_with_background_color(true);
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto board_combo = widget.add<GUI::ComboBox>();
|
auto& board_combo = widget.add<GUI::ComboBox>();
|
||||||
board_combo->set_only_allow_values_from_model(true);
|
board_combo.set_only_allow_values_from_model(true);
|
||||||
board_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
board_combo.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
board_combo->set_preferred_size(0, 20);
|
board_combo.set_preferred_size(0, 20);
|
||||||
board_combo->set_model(BoardListModel::create());
|
board_combo.set_model(BoardListModel::create());
|
||||||
|
|
||||||
auto catalog_view = widget.add<GUI::TableView>();
|
auto& catalog_view = widget.add<GUI::TableView>();
|
||||||
catalog_view->set_model(ThreadCatalogModel::create());
|
catalog_view.set_model(ThreadCatalogModel::create());
|
||||||
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model());
|
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view.model());
|
||||||
|
|
||||||
auto statusbar = widget.add<GUI::StatusBar>();
|
auto& statusbar = widget.add<GUI::StatusBar>();
|
||||||
|
|
||||||
board_combo->on_change = [&] (auto&, const GUI::ModelIndex& index) {
|
board_combo.on_change = [&] (auto&, const GUI::ModelIndex& index) {
|
||||||
auto selected_board = board_combo->model()->data(index, GUI::Model::Role::Custom);
|
auto selected_board = board_combo.model()->data(index, GUI::Model::Role::Custom);
|
||||||
ASSERT(selected_board.is_string());
|
ASSERT(selected_board.is_string());
|
||||||
catalog_model.set_board(selected_board.to_string());
|
catalog_model.set_board(selected_board.to_string());
|
||||||
};
|
};
|
||||||
|
|
||||||
catalog_model.on_load_started = [&] {
|
catalog_model.on_load_started = [&] {
|
||||||
statusbar->set_text(String::format("Loading /%s/...", catalog_model.board().characters()));
|
statusbar.set_text(String::format("Loading /%s/...", catalog_model.board().characters()));
|
||||||
};
|
};
|
||||||
|
|
||||||
catalog_model.on_load_finished = [&](bool success) {
|
catalog_model.on_load_finished = [&](bool success) {
|
||||||
statusbar->set_text(success ? "Load finished" : "Load failed");
|
statusbar.set_text(success ? "Load finished" : "Load failed");
|
||||||
if (success) {
|
if (success) {
|
||||||
window->set_title(String::format("/%s/ - ChanViewer", catalog_model.board().characters()));
|
window->set_title(String::format("/%s/ - ChanViewer", catalog_model.board().characters()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,30 +125,30 @@ void DisplayPropertiesWidget::create_wallpaper_list()
|
||||||
|
|
||||||
void DisplayPropertiesWidget::create_frame()
|
void DisplayPropertiesWidget::create_frame()
|
||||||
{
|
{
|
||||||
auto tab_widget = m_root_widget->add<GUI::TabWidget>();
|
auto& tab_widget = m_root_widget->add<GUI::TabWidget>();
|
||||||
|
|
||||||
auto wallpaper_splitter = tab_widget->add_tab<GUI::VerticalSplitter>("Wallpaper");
|
auto wallpaper_splitter = tab_widget.add_tab<GUI::VerticalSplitter>("Wallpaper");
|
||||||
|
|
||||||
auto wallpaper_content = wallpaper_splitter->add<GUI::Widget>();
|
auto& wallpaper_content = wallpaper_splitter->add<GUI::Widget>();
|
||||||
wallpaper_content->set_layout<GUI::VerticalBoxLayout>();
|
wallpaper_content.set_layout<GUI::VerticalBoxLayout>();
|
||||||
wallpaper_content->layout()->set_margins({ 4, 4, 4, 4 });
|
wallpaper_content.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
m_wallpaper_preview = wallpaper_splitter->add<GUI::Label>();
|
m_wallpaper_preview = wallpaper_splitter->add<GUI::Label>();
|
||||||
|
|
||||||
auto wallpaper_list = wallpaper_content->add<GUI::ListView>();
|
auto& wallpaper_list = wallpaper_content.add<GUI::ListView>();
|
||||||
wallpaper_list->set_background_color(Color::White);
|
wallpaper_list.set_background_color(Color::White);
|
||||||
wallpaper_list->set_model(*ItemListModel<AK::String>::create(m_wallpapers));
|
wallpaper_list.set_model(*ItemListModel<AK::String>::create(m_wallpapers));
|
||||||
|
|
||||||
auto wallpaper_model = wallpaper_list->model();
|
auto wallpaper_model = wallpaper_list.model();
|
||||||
auto find_first_wallpaper_index = m_wallpapers.find_first_index(m_selected_wallpaper);
|
auto find_first_wallpaper_index = m_wallpapers.find_first_index(m_selected_wallpaper);
|
||||||
if (find_first_wallpaper_index.has_value()) {
|
if (find_first_wallpaper_index.has_value()) {
|
||||||
auto wallpaper_index_in_model = wallpaper_model->index(find_first_wallpaper_index.value(), wallpaper_list->model_column());
|
auto wallpaper_index_in_model = wallpaper_model->index(find_first_wallpaper_index.value(), wallpaper_list.model_column());
|
||||||
if (wallpaper_model->is_valid(wallpaper_index_in_model))
|
if (wallpaper_model->is_valid(wallpaper_index_in_model))
|
||||||
wallpaper_list->selection().set(wallpaper_index_in_model);
|
wallpaper_list.selection().set(wallpaper_index_in_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
wallpaper_list->horizontal_scrollbar().set_visible(false);
|
wallpaper_list.horizontal_scrollbar().set_visible(false);
|
||||||
wallpaper_list->on_selection = [this](auto& index) {
|
wallpaper_list.on_selection = [this](auto& index) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
m_selected_wallpaper = m_wallpapers.at(index.row());
|
m_selected_wallpaper = m_wallpapers.at(index.row());
|
||||||
builder.append("/res/wallpapers/");
|
builder.append("/res/wallpapers/");
|
||||||
|
@ -157,62 +157,62 @@ void DisplayPropertiesWidget::create_frame()
|
||||||
m_wallpaper_preview->set_should_stretch_icon(true);
|
m_wallpaper_preview->set_should_stretch_icon(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto settings_splitter = tab_widget->add_tab<GUI::VerticalSplitter>("Settings");
|
auto settings_splitter = tab_widget.add_tab<GUI::VerticalSplitter>("Settings");
|
||||||
|
|
||||||
auto settings_content = settings_splitter->add<GUI::Widget>();
|
auto& settings_content = settings_splitter->add<GUI::Widget>();
|
||||||
settings_content->set_layout<GUI::VerticalBoxLayout>();
|
settings_content.set_layout<GUI::VerticalBoxLayout>();
|
||||||
settings_content->layout()->set_margins({ 4, 4, 4, 4 });
|
settings_content.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto resolution_list = settings_content->add<GUI::ListView>();
|
auto& resolution_list = settings_content.add<GUI::ListView>();
|
||||||
resolution_list->set_background_color(Color::White);
|
resolution_list.set_background_color(Color::White);
|
||||||
resolution_list->set_model(*ItemListModel<Gfx::Size>::create(m_resolutions));
|
resolution_list.set_model(*ItemListModel<Gfx::Size>::create(m_resolutions));
|
||||||
|
|
||||||
auto resolution_model = resolution_list->model();
|
auto resolution_model = resolution_list.model();
|
||||||
auto find_first_resolution_index = m_resolutions.find_first_index(m_selected_resolution);
|
auto find_first_resolution_index = m_resolutions.find_first_index(m_selected_resolution);
|
||||||
ASSERT(find_first_resolution_index.has_value());
|
ASSERT(find_first_resolution_index.has_value());
|
||||||
auto resolution_index_in_model = resolution_model->index(find_first_resolution_index.value(), resolution_list->model_column());
|
auto resolution_index_in_model = resolution_model->index(find_first_resolution_index.value(), resolution_list.model_column());
|
||||||
if (resolution_model->is_valid(resolution_index_in_model))
|
if (resolution_model->is_valid(resolution_index_in_model))
|
||||||
resolution_list->selection().set(resolution_index_in_model);
|
resolution_list.selection().set(resolution_index_in_model);
|
||||||
|
|
||||||
resolution_list->horizontal_scrollbar().set_visible(false);
|
resolution_list.horizontal_scrollbar().set_visible(false);
|
||||||
resolution_list->on_selection = [this](auto& index) {
|
resolution_list.on_selection = [this](auto& index) {
|
||||||
m_selected_resolution = m_resolutions.at(index.row());
|
m_selected_resolution = m_resolutions.at(index.row());
|
||||||
};
|
};
|
||||||
|
|
||||||
settings_content->layout()->add_spacer();
|
settings_content.layout()->add_spacer();
|
||||||
|
|
||||||
// Add the apply and cancel buttons
|
// Add the apply and cancel buttons
|
||||||
auto bottom_widget = m_root_widget->add<GUI::Widget>();
|
auto& bottom_widget = m_root_widget->add<GUI::Widget>();
|
||||||
bottom_widget->set_layout<GUI::HorizontalBoxLayout>();
|
bottom_widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
bottom_widget->layout()->add_spacer();
|
bottom_widget.layout()->add_spacer();
|
||||||
bottom_widget->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
bottom_widget.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
||||||
bottom_widget->set_preferred_size(1, 22);
|
bottom_widget.set_preferred_size(1, 22);
|
||||||
|
|
||||||
auto apply_button = bottom_widget->add<GUI::Button>();
|
auto& apply_button = bottom_widget.add<GUI::Button>();
|
||||||
apply_button->set_text("Apply");
|
apply_button.set_text("Apply");
|
||||||
apply_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
apply_button.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
||||||
apply_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
apply_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
||||||
apply_button->set_preferred_size(60, 22);
|
apply_button.set_preferred_size(60, 22);
|
||||||
apply_button->on_click = [this, tab_widget] {
|
apply_button.on_click = [this, tab_widget = &tab_widget] {
|
||||||
send_settings_to_window_server(tab_widget->active_tab_index());
|
send_settings_to_window_server(tab_widget->active_tab_index());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto ok_button = bottom_widget->add<GUI::Button>();
|
auto& ok_button = bottom_widget.add<GUI::Button>();
|
||||||
ok_button->set_text("OK");
|
ok_button.set_text("OK");
|
||||||
ok_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
ok_button.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
||||||
ok_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
ok_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
||||||
ok_button->set_preferred_size(60, 22);
|
ok_button.set_preferred_size(60, 22);
|
||||||
ok_button->on_click = [this, tab_widget] {
|
ok_button.on_click = [this, tab_widget = &tab_widget] {
|
||||||
send_settings_to_window_server(tab_widget->active_tab_index());
|
send_settings_to_window_server(tab_widget->active_tab_index());
|
||||||
GUI::Application::the().quit();
|
GUI::Application::the().quit();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto cancel_button = bottom_widget->add<GUI::Button>();
|
auto& cancel_button = bottom_widget.add<GUI::Button>();
|
||||||
cancel_button->set_text("Cancel");
|
cancel_button.set_text("Cancel");
|
||||||
cancel_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
cancel_button.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed);
|
||||||
cancel_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
||||||
cancel_button->set_preferred_size(60, 22);
|
cancel_button.set_preferred_size(60, 22);
|
||||||
cancel_button->on_click = [] {
|
cancel_button.on_click = [] {
|
||||||
GUI::Application::the().quit();
|
GUI::Application::the().quit();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,28 +51,28 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
||||||
set_rect({ 0, 0, 360, 420 });
|
set_rect({ 0, 0, 360, 420 });
|
||||||
set_resizable(false);
|
set_resizable(false);
|
||||||
|
|
||||||
auto tab_widget = main_widget.add<GUI::TabWidget>();
|
auto& tab_widget = main_widget.add<GUI::TabWidget>();
|
||||||
|
|
||||||
auto general_tab = tab_widget->add_tab<GUI::Widget>("General");
|
auto general_tab = tab_widget.add_tab<GUI::Widget>("General");
|
||||||
general_tab->set_layout<GUI::VerticalBoxLayout>();
|
general_tab->set_layout<GUI::VerticalBoxLayout>();
|
||||||
general_tab->layout()->set_margins({ 12, 8, 12, 8 });
|
general_tab->layout()->set_margins({ 12, 8, 12, 8 });
|
||||||
general_tab->layout()->set_spacing(10);
|
general_tab->layout()->set_spacing(10);
|
||||||
|
|
||||||
general_tab->layout()->add_spacer();
|
general_tab->layout()->add_spacer();
|
||||||
|
|
||||||
auto file_container = general_tab->add<GUI::Widget>();
|
auto& file_container = general_tab->add<GUI::Widget>();
|
||||||
file_container->set_layout<GUI::HorizontalBoxLayout>();
|
file_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
file_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
file_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
file_container->layout()->set_spacing(20);
|
file_container.layout()->set_spacing(20);
|
||||||
file_container->set_preferred_size(0, 34);
|
file_container.set_preferred_size(0, 34);
|
||||||
|
|
||||||
m_icon = file_container->add<GUI::Label>();
|
m_icon = file_container.add<GUI::Label>();
|
||||||
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
m_icon->set_preferred_size(32, 32);
|
m_icon->set_preferred_size(32, 32);
|
||||||
|
|
||||||
m_name = file_path.basename();
|
m_name = file_path.basename();
|
||||||
|
|
||||||
m_name_box = file_container->add<GUI::TextBox>();
|
m_name_box = file_container.add<GUI::TextBox>();
|
||||||
m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_name_box->set_preferred_size({ 0, 22 });
|
m_name_box->set_preferred_size({ 0, 22 });
|
||||||
m_name_box->set_text(m_name);
|
m_name_box->set_text(m_name);
|
||||||
|
@ -130,19 +130,19 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
||||||
|
|
||||||
general_tab->layout()->add_spacer();
|
general_tab->layout()->add_spacer();
|
||||||
|
|
||||||
auto button_widget = main_widget.add<GUI::Widget>();
|
auto& button_widget = main_widget.add<GUI::Widget>();
|
||||||
button_widget->set_layout<GUI::HorizontalBoxLayout>();
|
button_widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
button_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
button_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
button_widget->set_preferred_size(0, 24);
|
button_widget.set_preferred_size(0, 24);
|
||||||
button_widget->layout()->set_spacing(5);
|
button_widget.layout()->set_spacing(5);
|
||||||
|
|
||||||
button_widget->layout()->add_spacer();
|
button_widget.layout()->add_spacer();
|
||||||
|
|
||||||
make_button("OK", button_widget)->on_click = [this] {
|
make_button("OK", button_widget).on_click = [this] {
|
||||||
if (apply_changes())
|
if (apply_changes())
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
make_button("Cancel", button_widget)->on_click = [this] {
|
make_button("Cancel", button_widget).on_click = [this] {
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,48 +215,48 @@ bool PropertiesDialog::apply_changes()
|
||||||
|
|
||||||
void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks masks, String label_string, mode_t mode)
|
void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks masks, String label_string, mode_t mode)
|
||||||
{
|
{
|
||||||
auto widget = parent->add<GUI::Widget>();
|
auto& widget = parent->add<GUI::Widget>();
|
||||||
widget->set_layout<GUI::HorizontalBoxLayout>();
|
widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
widget->set_preferred_size(0, 16);
|
widget.set_preferred_size(0, 16);
|
||||||
widget->layout()->set_spacing(10);
|
widget.layout()->set_spacing(10);
|
||||||
|
|
||||||
auto label = widget->add<GUI::Label>(label_string);
|
auto& label = widget.add<GUI::Label>(label_string);
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
auto box_read = widget->add<GUI::CheckBox>("Read");
|
auto& box_read = widget.add<GUI::CheckBox>("Read");
|
||||||
box_read->set_checked(mode & masks.read);
|
box_read.set_checked(mode & masks.read);
|
||||||
box_read->on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); };
|
box_read.on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); };
|
||||||
|
|
||||||
auto box_write = widget->add<GUI::CheckBox>("Write");
|
auto& box_write = widget.add<GUI::CheckBox>("Write");
|
||||||
box_write->set_checked(mode & masks.write);
|
box_write.set_checked(mode & masks.write);
|
||||||
box_write->on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); };
|
box_write.on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); };
|
||||||
|
|
||||||
auto box_execute = widget->add<GUI::CheckBox>("Execute");
|
auto& box_execute = widget.add<GUI::CheckBox>("Execute");
|
||||||
box_execute->set_checked(mode & masks.execute);
|
box_execute.set_checked(mode & masks.execute);
|
||||||
box_execute->on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); };
|
box_execute.on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); };
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>& pairs, NonnullRefPtr<GUI::Widget>& parent)
|
void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>& pairs, GUI::Widget& parent)
|
||||||
{
|
{
|
||||||
int max_width = 0;
|
int max_width = 0;
|
||||||
Vector<NonnullRefPtr<GUI::Label>> property_labels;
|
Vector<NonnullRefPtr<GUI::Label>> property_labels;
|
||||||
|
|
||||||
property_labels.ensure_capacity(pairs.size());
|
property_labels.ensure_capacity(pairs.size());
|
||||||
for (auto pair : pairs) {
|
for (auto pair : pairs) {
|
||||||
auto label_container = parent->add<GUI::Widget>();
|
auto& label_container = parent.add<GUI::Widget>();
|
||||||
label_container->set_layout<GUI::HorizontalBoxLayout>();
|
label_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
label_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label_container->set_preferred_size(0, 14);
|
label_container.set_preferred_size(0, 14);
|
||||||
label_container->layout()->set_spacing(12);
|
label_container.layout()->set_spacing(12);
|
||||||
|
|
||||||
auto label_property = label_container->add<GUI::Label>(pair.property);
|
auto& label_property = label_container.add<GUI::Label>(pair.property);
|
||||||
label_property->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label_property.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
label_property.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
label_container->add<GUI::Label>(pair.value)->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label_container.add<GUI::Label>(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
max_width = max(max_width, label_property->font().width(pair.property));
|
max_width = max(max_width, label_property.font().width(pair.property));
|
||||||
property_labels.append(label_property);
|
property_labels.append(label_property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,21 +264,21 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
|
||||||
label->set_preferred_size({ max_width, 0 });
|
label->set_preferred_size({ max_width, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<GUI::Button> PropertiesDialog::make_button(String text, NonnullRefPtr<GUI::Widget>& parent)
|
GUI::Button& PropertiesDialog::make_button(String text, GUI::Widget& parent)
|
||||||
{
|
{
|
||||||
auto button = parent->add<GUI::Button>(text);
|
auto& button = parent.add<GUI::Button>(text);
|
||||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(70, 22);
|
button.set_preferred_size(70, 22);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& parent)
|
void PropertiesDialog::make_divider(GUI::Widget& parent)
|
||||||
{
|
{
|
||||||
parent->layout()->add_spacer();
|
parent.layout()->add_spacer();
|
||||||
|
|
||||||
auto divider = parent->add<GUI::Frame>();
|
auto& divider = parent.add<GUI::Frame>();
|
||||||
divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
divider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
divider->set_preferred_size({ 0, 2 });
|
divider.set_preferred_size({ 0, 2 });
|
||||||
|
|
||||||
parent->layout()->add_spacer();
|
parent.layout()->add_spacer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,9 @@ private:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<GUI::Button> make_button(String, NonnullRefPtr<GUI::Widget>&);
|
GUI::Button& make_button(String, GUI::Widget& parent);
|
||||||
void make_divider(NonnullRefPtr<GUI::Widget>&);
|
void make_divider(GUI::Widget& parent);
|
||||||
void make_property_value_pairs(const Vector<PropertyValuePair>& pairs, NonnullRefPtr<GUI::Widget>& parent);
|
void make_property_value_pairs(const Vector<PropertyValuePair>& pairs, GUI::Widget& parent);
|
||||||
void make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks, String label_string, mode_t mode);
|
void make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks, String label_string, mode_t mode);
|
||||||
void permission_changed(mode_t mask, bool set);
|
void permission_changed(mode_t mask, bool set);
|
||||||
bool apply_changes();
|
bool apply_changes();
|
||||||
|
|
|
@ -96,56 +96,56 @@ int main(int argc, char** argv)
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto main_toolbar = widget.add<GUI::ToolBar>();
|
auto& main_toolbar = widget.add<GUI::ToolBar>();
|
||||||
auto location_toolbar = widget.add<GUI::ToolBar>();
|
auto& location_toolbar = widget.add<GUI::ToolBar>();
|
||||||
location_toolbar->layout()->set_margins({ 6, 3, 6, 3 });
|
location_toolbar.layout()->set_margins({ 6, 3, 6, 3 });
|
||||||
location_toolbar->set_preferred_size(0, 25);
|
location_toolbar.set_preferred_size(0, 25);
|
||||||
|
|
||||||
auto location_label = location_toolbar->add<GUI::Label>("Location: ");
|
auto& location_label = location_toolbar.add<GUI::Label>("Location: ");
|
||||||
location_label->size_to_fit();
|
location_label.size_to_fit();
|
||||||
|
|
||||||
auto location_textbox = location_toolbar->add<GUI::TextBox>();
|
auto& location_textbox = location_toolbar.add<GUI::TextBox>();
|
||||||
|
|
||||||
auto splitter = widget.add<GUI::HorizontalSplitter>();
|
auto& splitter = widget.add<GUI::HorizontalSplitter>();
|
||||||
auto tree_view = splitter->add<GUI::TreeView>();
|
auto& tree_view = splitter.add<GUI::TreeView>();
|
||||||
auto directories_model = GUI::FileSystemModel::create("/", GUI::FileSystemModel::Mode::DirectoriesOnly);
|
auto directories_model = GUI::FileSystemModel::create("/", GUI::FileSystemModel::Mode::DirectoriesOnly);
|
||||||
tree_view->set_model(directories_model);
|
tree_view.set_model(directories_model);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Icon, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Icon, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Size, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Size, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Owner, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Owner, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Group, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Group, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Permissions, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Permissions, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::ModificationTime, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::ModificationTime, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::Inode, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::Inode, true);
|
||||||
tree_view->set_column_hidden(GUI::FileSystemModel::Column::SymlinkTarget, true);
|
tree_view.set_column_hidden(GUI::FileSystemModel::Column::SymlinkTarget, true);
|
||||||
tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
tree_view->set_preferred_size(150, 0);
|
tree_view.set_preferred_size(150, 0);
|
||||||
auto directory_view = splitter->add<DirectoryView>();
|
auto& directory_view = splitter.add<DirectoryView>();
|
||||||
|
|
||||||
auto statusbar = widget.add<GUI::StatusBar>();
|
auto& statusbar = widget.add<GUI::StatusBar>();
|
||||||
|
|
||||||
auto progressbar = statusbar->add<GUI::ProgressBar>();
|
auto& progressbar = statusbar.add<GUI::ProgressBar>();
|
||||||
progressbar->set_caption("Generating thumbnails: ");
|
progressbar.set_caption("Generating thumbnails: ");
|
||||||
progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax);
|
progressbar.set_format(GUI::ProgressBar::Format::ValueSlashMax);
|
||||||
progressbar->set_visible(false);
|
progressbar.set_visible(false);
|
||||||
progressbar->set_frame_shape(Gfx::FrameShape::Panel);
|
progressbar.set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
progressbar->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
progressbar.set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
progressbar->set_frame_thickness(1);
|
progressbar.set_frame_thickness(1);
|
||||||
|
|
||||||
location_textbox->on_return_pressed = [&] {
|
location_textbox.on_return_pressed = [&] {
|
||||||
directory_view->open(location_textbox->text());
|
directory_view.open(location_textbox.text());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto refresh_tree_view = [&] {
|
auto refresh_tree_view = [&] {
|
||||||
directories_model->update();
|
directories_model->update();
|
||||||
|
|
||||||
auto current_path = directory_view->path();
|
auto current_path = directory_view.path();
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
// If the directory no longer exists, we find a parent that does.
|
// If the directory no longer exists, we find a parent that does.
|
||||||
while (stat(current_path.characters(), &st) != 0) {
|
while (stat(current_path.characters(), &st) != 0) {
|
||||||
directory_view->open_parent_directory();
|
directory_view.open_parent_directory();
|
||||||
current_path = directory_view->path();
|
current_path = directory_view.path();
|
||||||
if (current_path == directories_model->root_path()) {
|
if (current_path == directories_model->root_path()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -153,11 +153,11 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
// Reselect the existing folder in the tree.
|
// Reselect the existing folder in the tree.
|
||||||
auto new_index = directories_model->index(current_path, GUI::FileSystemModel::Column::Name);
|
auto new_index = directories_model->index(current_path, GUI::FileSystemModel::Column::Name);
|
||||||
tree_view->selection().set(new_index);
|
tree_view.selection().set(new_index);
|
||||||
tree_view->scroll_into_view(new_index, Orientation::Vertical);
|
tree_view.scroll_into_view(new_index, Orientation::Vertical);
|
||||||
tree_view->update();
|
tree_view.update();
|
||||||
|
|
||||||
directory_view->refresh();
|
directory_view.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto directory_context_menu = GUI::Menu::construct("Directory View Directory");
|
auto directory_context_menu = GUI::Menu::construct("Directory View Directory");
|
||||||
|
@ -167,16 +167,16 @@ int main(int argc, char** argv)
|
||||||
auto tree_view_context_menu = GUI::Menu::construct("Tree View");
|
auto tree_view_context_menu = GUI::Menu::construct("Tree View");
|
||||||
|
|
||||||
auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
|
auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
|
||||||
directory_view->open_parent_directory();
|
directory_view.open_parent_directory();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
|
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
|
||||||
auto input_box = window->add<GUI::InputBox>("Enter name:", "New directory");
|
auto& input_box = window->add<GUI::InputBox>("Enter name:", "New directory");
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
if (input_box.exec() == GUI::InputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||||
auto new_dir_path = canonicalized_path(
|
auto new_dir_path = canonicalized_path(
|
||||||
String::format("%s/%s",
|
String::format("%s/%s",
|
||||||
directory_view->path().characters(),
|
directory_view.path().characters(),
|
||||||
input_box->text_value().characters()));
|
input_box.text_value().characters()));
|
||||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
||||||
|
@ -192,7 +192,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
view_as_table_action = GUI::Action::create(
|
view_as_table_action = GUI::Action::create(
|
||||||
"Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
"Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::List);
|
directory_view.set_view_mode(DirectoryView::ViewMode::List);
|
||||||
view_as_table_action->set_checked(true);
|
view_as_table_action->set_checked(true);
|
||||||
|
|
||||||
config->write_entry("DirectoryView", "ViewMode", "List");
|
config->write_entry("DirectoryView", "ViewMode", "List");
|
||||||
|
@ -203,7 +203,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
view_as_icons_action = GUI::Action::create(
|
view_as_icons_action = GUI::Action::create(
|
||||||
"Icon view", { Mod_Ctrl, KeyCode::Key_I }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
|
"Icon view", { Mod_Ctrl, KeyCode::Key_I }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Icon);
|
||||||
view_as_icons_action->set_checked(true);
|
view_as_icons_action->set_checked(true);
|
||||||
|
|
||||||
config->write_entry("DirectoryView", "ViewMode", "Icon");
|
config->write_entry("DirectoryView", "ViewMode", "Icon");
|
||||||
|
@ -214,7 +214,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
view_as_columns_action = GUI::Action::create(
|
view_as_columns_action = GUI::Action::create(
|
||||||
"Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
|
"Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Columns);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Columns);
|
||||||
view_as_columns_action->set_checked(true);
|
view_as_columns_action->set_checked(true);
|
||||||
|
|
||||||
config->write_entry("DirectoryView", "ViewMode", "Columns");
|
config->write_entry("DirectoryView", "ViewMode", "Columns");
|
||||||
|
@ -231,7 +231,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto selected_file_paths = [&] {
|
auto selected_file_paths = [&] {
|
||||||
Vector<String> paths;
|
Vector<String> paths;
|
||||||
auto& view = directory_view->current_view();
|
auto& view = directory_view.current_view();
|
||||||
auto& model = *view.model();
|
auto& model = *view.model();
|
||||||
view.selection().for_each_index([&](const GUI::ModelIndex& index) {
|
view.selection().for_each_index([&](const GUI::ModelIndex& index) {
|
||||||
auto parent_index = model.parent_index(index);
|
auto parent_index = model.parent_index(index);
|
||||||
|
@ -245,20 +245,20 @@ int main(int argc, char** argv)
|
||||||
auto tree_view_selected_file_paths = [&] {
|
auto tree_view_selected_file_paths = [&] {
|
||||||
Vector<String> paths;
|
Vector<String> paths;
|
||||||
auto& view = tree_view;
|
auto& view = tree_view;
|
||||||
view->selection().for_each_index([&](const GUI::ModelIndex& index) {
|
view.selection().for_each_index([&](const GUI::ModelIndex& index) {
|
||||||
paths.append(directories_model->full_path(index));
|
paths.append(directories_model->full_path(index));
|
||||||
});
|
});
|
||||||
return paths;
|
return paths;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto select_all_action = GUI::Action::create("Select all", { Mod_Ctrl, KeyCode::Key_A }, [&](const GUI::Action&) {
|
auto select_all_action = GUI::Action::create("Select all", { Mod_Ctrl, KeyCode::Key_A }, [&](const GUI::Action&) {
|
||||||
directory_view->current_view().select_all();
|
directory_view.current_view().select_all();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto copy_action = GUI::CommonActions::make_copy_action(
|
auto copy_action = GUI::CommonActions::make_copy_action(
|
||||||
[&](const GUI::Action& action) {
|
[&](const GUI::Action& action) {
|
||||||
Vector<String> paths;
|
Vector<String> paths;
|
||||||
if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) {
|
if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
|
||||||
paths = selected_file_paths();
|
paths = selected_file_paths();
|
||||||
} else {
|
} else {
|
||||||
paths = tree_view_selected_file_paths();
|
paths = tree_view_selected_file_paths();
|
||||||
|
@ -289,7 +289,7 @@ int main(int argc, char** argv)
|
||||||
for (auto& current_path : copied_lines) {
|
for (auto& current_path : copied_lines) {
|
||||||
if (current_path.is_empty())
|
if (current_path.is_empty())
|
||||||
continue;
|
continue;
|
||||||
auto current_directory = directory_view->path();
|
auto current_directory = directory_view.path();
|
||||||
auto new_path = String::format("%s/%s",
|
auto new_path = String::format("%s/%s",
|
||||||
current_directory.characters(),
|
current_directory.characters(),
|
||||||
FileSystemPath(current_path).basename().characters());
|
FileSystemPath(current_path).basename().characters());
|
||||||
|
@ -312,14 +312,14 @@ int main(int argc, char** argv)
|
||||||
auto properties_action
|
auto properties_action
|
||||||
= GUI::Action::create(
|
= GUI::Action::create(
|
||||||
"Properties...", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
|
"Properties...", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
|
||||||
auto& model = directory_view->model();
|
auto& model = directory_view.model();
|
||||||
String path;
|
String path;
|
||||||
Vector<String> selected;
|
Vector<String> selected;
|
||||||
if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) {
|
if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
|
||||||
path = directory_view->path();
|
path = directory_view.path();
|
||||||
selected = selected_file_paths();
|
selected = selected_file_paths();
|
||||||
} else {
|
} else {
|
||||||
path = directories_model->full_path(tree_view->selection().first());
|
path = directories_model->full_path(tree_view.selection().first());
|
||||||
selected = tree_view_selected_file_paths();
|
selected = tree_view_selected_file_paths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action& action) {
|
auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action& action) {
|
||||||
Vector<String> paths;
|
Vector<String> paths;
|
||||||
if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) {
|
if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
|
||||||
paths = selected_file_paths();
|
paths = selected_file_paths();
|
||||||
} else {
|
} else {
|
||||||
paths = tree_view_selected_file_paths();
|
paths = tree_view_selected_file_paths();
|
||||||
|
@ -425,19 +425,19 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto go_back_action = GUI::CommonActions::make_go_back_action(
|
auto go_back_action = GUI::CommonActions::make_go_back_action(
|
||||||
[&](auto&) {
|
[&](auto&) {
|
||||||
directory_view->open_previous_directory();
|
directory_view.open_previous_directory();
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
|
|
||||||
auto go_forward_action = GUI::CommonActions::make_go_forward_action(
|
auto go_forward_action = GUI::CommonActions::make_go_forward_action(
|
||||||
[&](auto&) {
|
[&](auto&) {
|
||||||
directory_view->open_next_directory();
|
directory_view.open_next_directory();
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
|
|
||||||
auto go_home_action = GUI::CommonActions::make_go_home_action(
|
auto go_home_action = GUI::CommonActions::make_go_home_action(
|
||||||
[&](auto&) {
|
[&](auto&) {
|
||||||
directory_view->open(get_current_user_home_path());
|
directory_view.open(get_current_user_home_path());
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
|
|
||||||
|
@ -475,52 +475,52 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
main_toolbar->add_action(go_back_action);
|
main_toolbar.add_action(go_back_action);
|
||||||
main_toolbar->add_action(go_forward_action);
|
main_toolbar.add_action(go_forward_action);
|
||||||
main_toolbar->add_action(open_parent_directory_action);
|
main_toolbar.add_action(open_parent_directory_action);
|
||||||
main_toolbar->add_action(go_home_action);
|
main_toolbar.add_action(go_home_action);
|
||||||
|
|
||||||
main_toolbar->add_separator();
|
main_toolbar.add_separator();
|
||||||
main_toolbar->add_action(mkdir_action);
|
main_toolbar.add_action(mkdir_action);
|
||||||
main_toolbar->add_action(copy_action);
|
main_toolbar.add_action(copy_action);
|
||||||
main_toolbar->add_action(paste_action);
|
main_toolbar.add_action(paste_action);
|
||||||
main_toolbar->add_action(delete_action);
|
main_toolbar.add_action(delete_action);
|
||||||
|
|
||||||
main_toolbar->add_separator();
|
main_toolbar.add_separator();
|
||||||
main_toolbar->add_action(*view_as_icons_action);
|
main_toolbar.add_action(*view_as_icons_action);
|
||||||
main_toolbar->add_action(*view_as_table_action);
|
main_toolbar.add_action(*view_as_table_action);
|
||||||
main_toolbar->add_action(*view_as_columns_action);
|
main_toolbar.add_action(*view_as_columns_action);
|
||||||
|
|
||||||
directory_view->on_path_change = [&](const String& new_path) {
|
directory_view.on_path_change = [&](const String& new_path) {
|
||||||
window->set_title(String::format("File Manager: %s", new_path.characters()));
|
window->set_title(String::format("File Manager: %s", new_path.characters()));
|
||||||
location_textbox->set_text(new_path);
|
location_textbox.set_text(new_path);
|
||||||
auto new_index = directories_model->index(new_path, GUI::FileSystemModel::Column::Name);
|
auto new_index = directories_model->index(new_path, GUI::FileSystemModel::Column::Name);
|
||||||
if (new_index.is_valid()) {
|
if (new_index.is_valid()) {
|
||||||
tree_view->selection().set(new_index);
|
tree_view.selection().set(new_index);
|
||||||
tree_view->scroll_into_view(new_index, Orientation::Vertical);
|
tree_view.scroll_into_view(new_index, Orientation::Vertical);
|
||||||
tree_view->update();
|
tree_view.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
go_forward_action->set_enabled(directory_view->path_history_position()
|
go_forward_action->set_enabled(directory_view.path_history_position()
|
||||||
< directory_view->path_history_size() - 1);
|
< directory_view.path_history_size() - 1);
|
||||||
go_back_action->set_enabled(directory_view->path_history_position() > 0);
|
go_back_action->set_enabled(directory_view.path_history_position() > 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
directory_view->on_status_message = [&](const StringView& message) {
|
directory_view.on_status_message = [&](const StringView& message) {
|
||||||
statusbar->set_text(message);
|
statusbar.set_text(message);
|
||||||
};
|
};
|
||||||
|
|
||||||
directory_view->on_thumbnail_progress = [&](int done, int total) {
|
directory_view.on_thumbnail_progress = [&](int done, int total) {
|
||||||
if (done == total) {
|
if (done == total) {
|
||||||
progressbar->set_visible(false);
|
progressbar.set_visible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
progressbar->set_range(0, total);
|
progressbar.set_range(0, total);
|
||||||
progressbar->set_value(done);
|
progressbar.set_value(done);
|
||||||
progressbar->set_visible(true);
|
progressbar.set_visible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
directory_view->on_selection_change = [&](GUI::AbstractView& view) {
|
directory_view.on_selection_change = [&](GUI::AbstractView& view) {
|
||||||
// FIXME: Figure out how we can enable/disable the paste action, based on clipboard contents.
|
// FIXME: Figure out how we can enable/disable the paste action, based on clipboard contents.
|
||||||
copy_action->set_enabled(!view.selection().is_empty());
|
copy_action->set_enabled(!view.selection().is_empty());
|
||||||
delete_action->set_enabled(!view.selection().is_empty());
|
delete_action->set_enabled(!view.selection().is_empty());
|
||||||
|
@ -561,9 +561,9 @@ int main(int argc, char** argv)
|
||||||
tree_view_directory_context_menu->add_separator();
|
tree_view_directory_context_menu->add_separator();
|
||||||
tree_view_directory_context_menu->add_action(mkdir_action);
|
tree_view_directory_context_menu->add_action(mkdir_action);
|
||||||
|
|
||||||
directory_view->on_context_menu_request = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
directory_view.on_context_menu_request = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||||
if (index.is_valid()) {
|
if (index.is_valid()) {
|
||||||
auto& node = directory_view->model().node(index);
|
auto& node = directory_view.model().node(index);
|
||||||
|
|
||||||
if (node.is_directory())
|
if (node.is_directory())
|
||||||
directory_context_menu->popup(event.screen_position());
|
directory_context_menu->popup(event.screen_position());
|
||||||
|
@ -574,7 +574,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
directory_view->on_drop = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::DropEvent& event) {
|
directory_view.on_drop = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::DropEvent& event) {
|
||||||
if (!index.is_valid())
|
if (!index.is_valid())
|
||||||
return;
|
return;
|
||||||
if (!event.mime_data().has_urls())
|
if (!event.mime_data().has_urls())
|
||||||
|
@ -585,7 +585,7 @@ int main(int argc, char** argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& target_node = directory_view->model().node(index);
|
auto& target_node = directory_view.model().node(index);
|
||||||
if (!target_node.is_directory())
|
if (!target_node.is_directory())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ int main(int argc, char** argv)
|
||||||
if (!url_to_copy.is_valid())
|
if (!url_to_copy.is_valid())
|
||||||
continue;
|
continue;
|
||||||
auto new_path = String::format("%s/%s",
|
auto new_path = String::format("%s/%s",
|
||||||
target_node.full_path(directory_view->model()).characters(),
|
target_node.full_path(directory_view.model()).characters(),
|
||||||
FileSystemPath(url_to_copy.path()).basename().characters());
|
FileSystemPath(url_to_copy.path()).basename().characters());
|
||||||
|
|
||||||
if (!FileUtils::copy_file_or_directory(url_to_copy.path(), new_path)) {
|
if (!FileUtils::copy_file_or_directory(url_to_copy.path(), new_path)) {
|
||||||
|
@ -607,16 +607,16 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tree_view->on_selection_change = [&] {
|
tree_view.on_selection_change = [&] {
|
||||||
auto path = directories_model->full_path(tree_view->selection().first());
|
auto path = directories_model->full_path(tree_view.selection().first());
|
||||||
if (directory_view->path() == path)
|
if (directory_view.path() == path)
|
||||||
return;
|
return;
|
||||||
directory_view->open(path);
|
directory_view.open(path);
|
||||||
copy_action->set_enabled(!tree_view->selection().is_empty());
|
copy_action->set_enabled(!tree_view.selection().is_empty());
|
||||||
delete_action->set_enabled(!tree_view->selection().is_empty());
|
delete_action->set_enabled(!tree_view.selection().is_empty());
|
||||||
};
|
};
|
||||||
|
|
||||||
tree_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
tree_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||||
if (index.is_valid()) {
|
if (index.is_valid()) {
|
||||||
tree_view_directory_context_menu->popup(event.screen_position());
|
tree_view_directory_context_menu->popup(event.screen_position());
|
||||||
}
|
}
|
||||||
|
@ -638,8 +638,8 @@ int main(int argc, char** argv)
|
||||||
if (initial_location.is_empty())
|
if (initial_location.is_empty())
|
||||||
initial_location = "/";
|
initial_location = "/";
|
||||||
|
|
||||||
directory_view->open(initial_location);
|
directory_view.open(initial_location);
|
||||||
directory_view->set_focus(true);
|
directory_view.set_focus(true);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
@ -649,13 +649,13 @@ int main(int argc, char** argv)
|
||||||
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
||||||
|
|
||||||
if (dir_view_mode.contains("List")) {
|
if (dir_view_mode.contains("List")) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::List);
|
directory_view.set_view_mode(DirectoryView::ViewMode::List);
|
||||||
view_as_table_action->set_checked(true);
|
view_as_table_action->set_checked(true);
|
||||||
} else if (dir_view_mode.contains("Columns")) {
|
} else if (dir_view_mode.contains("Columns")) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Columns);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Columns);
|
||||||
view_as_columns_action->set_checked(true);
|
view_as_columns_action->set_checked(true);
|
||||||
} else {
|
} else {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Icon);
|
||||||
view_as_icons_action->set_checked(true);
|
view_as_icons_action->set_checked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ private:
|
||||||
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&);
|
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&);
|
||||||
RefPtr<Gfx::Font> m_edited_font;
|
RefPtr<Gfx::Font> m_edited_font;
|
||||||
|
|
||||||
GlyphMapWidget* m_glyph_map_widget { nullptr };
|
RefPtr<GlyphMapWidget> m_glyph_map_widget;
|
||||||
GlyphEditorWidget* m_glyph_editor_widget { nullptr };
|
RefPtr<GlyphEditorWidget> m_glyph_editor_widget;
|
||||||
|
|
||||||
String m_path;
|
String m_path;
|
||||||
|
|
||||||
|
|
|
@ -82,18 +82,18 @@ int main(int argc, char* argv[])
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto toolbar = widget.add<GUI::ToolBar>();
|
auto& toolbar = widget.add<GUI::ToolBar>();
|
||||||
|
|
||||||
auto splitter = widget.add<GUI::HorizontalSplitter>();
|
auto& splitter = widget.add<GUI::HorizontalSplitter>();
|
||||||
|
|
||||||
auto model = ManualModel::create();
|
auto model = ManualModel::create();
|
||||||
|
|
||||||
auto tree_view = splitter->add<GUI::TreeView>();
|
auto& tree_view = splitter.add<GUI::TreeView>();
|
||||||
tree_view->set_model(model);
|
tree_view.set_model(model);
|
||||||
tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
tree_view->set_preferred_size(200, 500);
|
tree_view.set_preferred_size(200, 500);
|
||||||
|
|
||||||
auto html_view = splitter->add<HtmlView>();
|
auto& html_view = splitter.add<HtmlView>();
|
||||||
|
|
||||||
History history;
|
History history;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
auto open_page = [&](const String& path) {
|
auto open_page = [&](const String& path) {
|
||||||
if (path.is_null()) {
|
if (path.is_null()) {
|
||||||
html_view->set_document(nullptr);
|
html_view.set_document(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,16 +130,16 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
String html = md_document.render_to_html();
|
String html = md_document.render_to_html();
|
||||||
auto html_document = parse_html_document(html);
|
auto html_document = parse_html_document(html);
|
||||||
html_view->set_document(html_document);
|
html_view.set_document(html_document);
|
||||||
|
|
||||||
String page_and_section = model->page_and_section(tree_view->selection().first());
|
String page_and_section = model->page_and_section(tree_view.selection().first());
|
||||||
window->set_title(String::format("Help: %s", page_and_section.characters()));
|
window->set_title(String::format("Help: %s", page_and_section.characters()));
|
||||||
};
|
};
|
||||||
|
|
||||||
tree_view->on_selection_change = [&] {
|
tree_view.on_selection_change = [&] {
|
||||||
String path = model->page_path(tree_view->selection().first());
|
String path = model->page_path(tree_view.selection().first());
|
||||||
if (path.is_null()) {
|
if (path.is_null()) {
|
||||||
html_view->set_document(nullptr);
|
html_view.set_document(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
history.push(path);
|
history.push(path);
|
||||||
|
@ -147,7 +147,7 @@ int main(int argc, char* argv[])
|
||||||
open_page(path);
|
open_page(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
html_view->on_link_click = [&](const String& href) {
|
html_view.on_link_click = [&](const String& href) {
|
||||||
char* current_path = strdup(history.current().characters());
|
char* current_path = strdup(history.current().characters());
|
||||||
char* dir_path = dirname(current_path);
|
char* dir_path = dirname(current_path);
|
||||||
char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);
|
char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);
|
||||||
|
@ -173,8 +173,8 @@ int main(int argc, char* argv[])
|
||||||
go_back_action->set_enabled(false);
|
go_back_action->set_enabled(false);
|
||||||
go_forward_action->set_enabled(false);
|
go_forward_action->set_enabled(false);
|
||||||
|
|
||||||
toolbar->add_action(*go_back_action);
|
toolbar.add_action(*go_back_action);
|
||||||
toolbar->add_action(*go_forward_action);
|
toolbar.add_action(*go_forward_action);
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
window->set_focused_widget(tree_view);
|
window->set_focused_widget(&tree_view);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"));
|
||||||
|
|
|
@ -94,12 +94,12 @@ void IRCAppWindow::setup_client()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (m_client->hostname().is_empty()) {
|
if (m_client->hostname().is_empty()) {
|
||||||
auto input_box = add<GUI::InputBox>("Enter server:", "Connect to server");
|
auto& input_box = add<GUI::InputBox>("Enter server:", "Connect to server");
|
||||||
auto result = input_box->exec();
|
auto result = input_box.exec();
|
||||||
if (result == GUI::InputBox::ExecCancel)
|
if (result == GUI::InputBox::ExecCancel)
|
||||||
::exit(0);
|
::exit(0);
|
||||||
|
|
||||||
m_client->set_server(input_box->text_value(), 6667);
|
m_client->set_server(input_box.text_value(), 6667);
|
||||||
}
|
}
|
||||||
update_title();
|
update_title();
|
||||||
bool success = m_client->connect();
|
bool success = m_client->connect();
|
||||||
|
@ -109,9 +109,9 @@ void IRCAppWindow::setup_client()
|
||||||
void IRCAppWindow::setup_actions()
|
void IRCAppWindow::setup_actions()
|
||||||
{
|
{
|
||||||
m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
||||||
auto input_box = add<GUI::InputBox>("Enter channel name:", "Join channel");
|
auto& input_box = add<GUI::InputBox>("Enter channel name:", "Join channel");
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
if (input_box.exec() == GUI::InputBox::ExecOK && !input_box.text_value().is_empty())
|
||||||
m_client->handle_join_action(input_box->text_value());
|
m_client->handle_join_action(input_box.text_value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
||||||
|
@ -184,24 +184,24 @@ void IRCAppWindow::setup_widgets()
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto toolbar = widget.add<GUI::ToolBar>();
|
auto& toolbar = widget.add<GUI::ToolBar>();
|
||||||
toolbar->set_has_frame(false);
|
toolbar.set_has_frame(false);
|
||||||
toolbar->add_action(*m_change_nick_action);
|
toolbar.add_action(*m_change_nick_action);
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
toolbar->add_action(*m_join_action);
|
toolbar.add_action(*m_join_action);
|
||||||
toolbar->add_action(*m_part_action);
|
toolbar.add_action(*m_part_action);
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
toolbar->add_action(*m_whois_action);
|
toolbar.add_action(*m_whois_action);
|
||||||
toolbar->add_action(*m_open_query_action);
|
toolbar.add_action(*m_open_query_action);
|
||||||
toolbar->add_action(*m_close_query_action);
|
toolbar.add_action(*m_close_query_action);
|
||||||
|
|
||||||
auto outer_container = widget.add<GUI::Widget>();
|
auto& outer_container = widget.add<GUI::Widget>();
|
||||||
outer_container->set_layout<GUI::VerticalBoxLayout>();
|
outer_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
outer_container->layout()->set_margins({ 2, 0, 2, 2 });
|
outer_container.layout()->set_margins({ 2, 0, 2, 2 });
|
||||||
|
|
||||||
auto horizontal_container = outer_container->add<GUI::HorizontalSplitter>();
|
auto& horizontal_container = outer_container.add<GUI::HorizontalSplitter>();
|
||||||
|
|
||||||
m_window_list = horizontal_container->add<GUI::TableView>();
|
m_window_list = horizontal_container.add<GUI::TableView>();
|
||||||
m_window_list->set_headers_visible(false);
|
m_window_list->set_headers_visible(false);
|
||||||
m_window_list->set_alternating_row_colors(false);
|
m_window_list->set_alternating_row_colors(false);
|
||||||
m_window_list->set_size_columns_to_fit_content(true);
|
m_window_list->set_size_columns_to_fit_content(true);
|
||||||
|
@ -213,7 +213,7 @@ void IRCAppWindow::setup_widgets()
|
||||||
set_active_window(m_client->window_at(index.row()));
|
set_active_window(m_client->window_at(index.row()));
|
||||||
};
|
};
|
||||||
|
|
||||||
m_container = horizontal_container->add<GUI::StackWidget>();
|
m_container = horizontal_container.add<GUI::StackWidget>();
|
||||||
m_container->on_active_widget_change = [this](auto*) {
|
m_container->on_active_widget_change = [this](auto*) {
|
||||||
update_part_action();
|
update_part_action();
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,18 +44,18 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
// Make a container for the log buffer view + (optional) member list.
|
// Make a container for the log buffer view + (optional) member list.
|
||||||
auto container = add<GUI::HorizontalSplitter>();
|
auto& container = add<GUI::HorizontalSplitter>();
|
||||||
|
|
||||||
m_html_view = container->add<HtmlView>();
|
m_html_view = container.add<HtmlView>();
|
||||||
|
|
||||||
if (m_type == Channel) {
|
if (m_type == Channel) {
|
||||||
auto member_view = container->add<GUI::TableView>();
|
auto& member_view = container.add<GUI::TableView>();
|
||||||
member_view->set_headers_visible(false);
|
member_view.set_headers_visible(false);
|
||||||
member_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
member_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
member_view->set_preferred_size(100, 0);
|
member_view.set_preferred_size(100, 0);
|
||||||
member_view->set_alternating_row_colors(false);
|
member_view.set_alternating_row_colors(false);
|
||||||
member_view->set_model(channel().member_model());
|
member_view.set_model(channel().member_model());
|
||||||
member_view->set_activates_on_selection(true);
|
member_view.set_activates_on_selection(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text_editor = add<GUI::TextBox>();
|
m_text_editor = add<GUI::TextBox>();
|
||||||
|
|
|
@ -99,25 +99,25 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget)
|
||||||
set_secondary_color(color);
|
set_secondary_color(color);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto color_container = add<GUI::Widget>();
|
auto& color_container = add<GUI::Widget>();
|
||||||
color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32);
|
color_container.set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32);
|
||||||
color_container->set_layout<GUI::VerticalBoxLayout>();
|
color_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
color_container->layout()->set_spacing(1);
|
color_container.layout()->set_spacing(1);
|
||||||
|
|
||||||
auto top_color_container = color_container->add<GUI::Widget>();
|
auto& top_color_container = color_container.add<GUI::Widget>();
|
||||||
top_color_container->set_layout<GUI::HorizontalBoxLayout>();
|
top_color_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
top_color_container->layout()->set_spacing(1);
|
top_color_container.layout()->set_spacing(1);
|
||||||
|
|
||||||
auto bottom_color_container = color_container->add<GUI::Widget>();
|
auto& bottom_color_container = color_container.add<GUI::Widget>();
|
||||||
bottom_color_container->set_layout<GUI::HorizontalBoxLayout>();
|
bottom_color_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
bottom_color_container->layout()->set_spacing(1);
|
bottom_color_container.layout()->set_spacing(1);
|
||||||
|
|
||||||
auto add_color_widget = [&](GUI::Widget* container, Color color) {
|
auto add_color_widget = [&](GUI::Widget& container, Color color) {
|
||||||
auto color_widget = container->add<ColorWidget>(color, *this);
|
auto& color_widget = container.add<ColorWidget>(color, *this);
|
||||||
color_widget->set_fill_with_background_color(true);
|
color_widget.set_fill_with_background_color(true);
|
||||||
auto pal = color_widget->palette();
|
auto pal = color_widget.palette();
|
||||||
pal.set_color(ColorRole::Background, color);
|
pal.set_color(ColorRole::Background, color);
|
||||||
color_widget->set_palette(pal);
|
color_widget.set_palette(pal);
|
||||||
};
|
};
|
||||||
|
|
||||||
add_color_widget(top_color_container, Color::from_rgb(0x000000));
|
add_color_widget(top_color_container, Color::from_rgb(0x000000));
|
||||||
|
|
|
@ -74,15 +74,15 @@ ToolboxWidget::ToolboxWidget()
|
||||||
layout()->set_margins({ 4, 4, 4, 4 });
|
layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {
|
auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {
|
||||||
auto button = add<ToolButton>(name, move(tool));
|
auto& button = add<ToolButton>(name, move(tool));
|
||||||
button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(0, 32);
|
button.set_preferred_size(0, 32);
|
||||||
button->set_checkable(true);
|
button.set_checkable(true);
|
||||||
button->set_exclusive(true);
|
button.set_exclusive(true);
|
||||||
|
|
||||||
button->set_icon(Gfx::Bitmap::load_from_file(String::format("/res/icons/paintbrush/%s.png", String(icon_name).characters())));
|
button.set_icon(Gfx::Bitmap::load_from_file(String::format("/res/icons/paintbrush/%s.png", String(icon_name).characters())));
|
||||||
|
|
||||||
button->on_checked = [button = button.ptr()](auto checked) {
|
button.on_checked = [button = &button](auto checked) {
|
||||||
if (checked)
|
if (checked)
|
||||||
PaintableWidget::the().set_tool(&button->tool());
|
PaintableWidget::the().set_tool(&button->tool());
|
||||||
else
|
else
|
||||||
|
|
|
@ -64,13 +64,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
horizontal_container.add<ToolboxWidget>();
|
horizontal_container.add<ToolboxWidget>();
|
||||||
|
|
||||||
auto vertical_container = horizontal_container.add<GUI::Widget>();
|
auto& vertical_container = horizontal_container.add<GUI::Widget>();
|
||||||
vertical_container->set_layout<GUI::VerticalBoxLayout>();
|
vertical_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
vertical_container->layout()->set_spacing(0);
|
vertical_container.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto paintable_widget = vertical_container->add<PaintableWidget>();
|
auto& paintable_widget = vertical_container.add<PaintableWidget>();
|
||||||
paintable_widget->set_focus(true);
|
paintable_widget.set_focus(true);
|
||||||
vertical_container->add<PaletteWidget>(*paintable_widget);
|
vertical_container.add<PaletteWidget>(paintable_widget);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ int main(int argc, char** argv)
|
||||||
GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
paintable_widget->set_bitmap(*bitmap);
|
paintable_widget.set_bitmap(*bitmap);
|
||||||
}));
|
}));
|
||||||
app_menu->add_separator();
|
app_menu->add_separator();
|
||||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||||
|
|
|
@ -41,24 +41,24 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
layout()->set_margins({ 2, 2, 2, 2 });
|
layout()->set_margins({ 2, 2, 2, 2 });
|
||||||
|
|
||||||
auto status_widget = add<GUI::Widget>();
|
auto& status_widget = add<GUI::Widget>();
|
||||||
status_widget->set_fill_with_background_color(true);
|
status_widget.set_fill_with_background_color(true);
|
||||||
status_widget->set_layout<GUI::HorizontalBoxLayout>();
|
status_widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
|
|
||||||
m_elapsed = status_widget->add<GUI::Label>();
|
m_elapsed = status_widget.add<GUI::Label>();
|
||||||
m_elapsed->set_frame_shape(Gfx::FrameShape::Container);
|
m_elapsed->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_elapsed->set_frame_thickness(2);
|
m_elapsed->set_frame_thickness(2);
|
||||||
m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
m_elapsed->set_preferred_size(80, 0);
|
m_elapsed->set_preferred_size(80, 0);
|
||||||
|
|
||||||
auto sample_widget_container = status_widget->add<GUI::Widget>();
|
auto& sample_widget_container = status_widget.add<GUI::Widget>();
|
||||||
sample_widget_container->set_layout<GUI::HorizontalBoxLayout>();
|
sample_widget_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
sample_widget_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
sample_widget_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
m_sample_widget = sample_widget_container->add<SampleWidget>();
|
m_sample_widget = sample_widget_container.add<SampleWidget>();
|
||||||
|
|
||||||
m_remaining = status_widget->add<GUI::Label>();
|
m_remaining = status_widget.add<GUI::Label>();
|
||||||
m_remaining->set_frame_shape(Gfx::FrameShape::Container);
|
m_remaining->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_remaining->set_frame_thickness(2);
|
m_remaining->set_frame_thickness(2);
|
||||||
|
@ -70,22 +70,22 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
|
||||||
m_slider->set_enabled(false);
|
m_slider->set_enabled(false);
|
||||||
m_slider->on_knob_released = [&](int value) { m_manager.seek(denormalize_rate(value)); };
|
m_slider->on_knob_released = [&](int value) { m_manager.seek(denormalize_rate(value)); };
|
||||||
|
|
||||||
auto control_widget = add<GUI::Widget>();
|
auto& control_widget = add<GUI::Widget>();
|
||||||
control_widget->set_fill_with_background_color(true);
|
control_widget.set_fill_with_background_color(true);
|
||||||
control_widget->set_layout<GUI::HorizontalBoxLayout>();
|
control_widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
control_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
control_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
control_widget->set_preferred_size(0, 30);
|
control_widget.set_preferred_size(0, 30);
|
||||||
control_widget->layout()->set_margins({ 10, 2, 10, 2 });
|
control_widget.layout()->set_margins({ 10, 2, 10, 2 });
|
||||||
control_widget->layout()->set_spacing(10);
|
control_widget.layout()->set_spacing(10);
|
||||||
|
|
||||||
m_play = control_widget->add<GUI::Button>();
|
m_play = control_widget.add<GUI::Button>();
|
||||||
m_play->set_icon(*m_pause_icon);
|
m_play->set_icon(*m_pause_icon);
|
||||||
m_play->set_enabled(false);
|
m_play->set_enabled(false);
|
||||||
m_play->on_click = [this] {
|
m_play->on_click = [this] {
|
||||||
m_play->set_icon(m_manager.toggle_pause() ? *m_play_icon : *m_pause_icon);
|
m_play->set_icon(m_manager.toggle_pause() ? *m_play_icon : *m_pause_icon);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_stop = control_widget->add<GUI::Button>();
|
m_stop = control_widget.add<GUI::Button>();
|
||||||
m_stop->set_enabled(false);
|
m_stop->set_enabled(false);
|
||||||
m_stop->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"));
|
m_stop->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"));
|
||||||
m_stop->on_click = [this] { m_manager.stop(); };
|
m_stop->on_click = [this] { m_manager.stop(); };
|
||||||
|
|
|
@ -75,43 +75,43 @@ PowerDialog::PowerDialog()
|
||||||
main.layout()->set_spacing(8);
|
main.layout()->set_spacing(8);
|
||||||
main.set_fill_with_background_color(true);
|
main.set_fill_with_background_color(true);
|
||||||
|
|
||||||
auto header = main.add<GUI::Label>();
|
auto& header = main.add<GUI::Label>();
|
||||||
header->set_text("What would you like to do?");
|
header.set_text("What would you like to do?");
|
||||||
header->set_preferred_size(0, 16);
|
header.set_preferred_size(0, 16);
|
||||||
header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
header->set_font(Gfx::Font::default_bold_font());
|
header.set_font(Gfx::Font::default_bold_font());
|
||||||
|
|
||||||
for (size_t i = 0; i < options.size(); i++) {
|
for (size_t i = 0; i < options.size(); i++) {
|
||||||
auto action = options[i];
|
auto action = options[i];
|
||||||
auto radio = main.add<GUI::RadioButton>();
|
auto& radio = main.add<GUI::RadioButton>();
|
||||||
radio->set_enabled(action.enabled);
|
radio.set_enabled(action.enabled);
|
||||||
radio->set_text(action.title);
|
radio.set_text(action.title);
|
||||||
|
|
||||||
radio->on_checked = [this, i](auto) {
|
radio.on_checked = [this, i](auto) {
|
||||||
m_selected_option = i;
|
m_selected_option = i;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (action.default_action) {
|
if (action.default_action) {
|
||||||
radio->set_checked(true);
|
radio.set_checked(true);
|
||||||
m_selected_option = i;
|
m_selected_option = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto button_box = main.add<GUI::Widget>();
|
auto& button_box = main.add<GUI::Widget>();
|
||||||
button_box->set_layout<GUI::HorizontalBoxLayout>();
|
button_box.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
button_box->layout()->set_spacing(8);
|
button_box.layout()->set_spacing(8);
|
||||||
|
|
||||||
auto ok_button = button_box->add<GUI::Button>();
|
auto& ok_button = button_box.add<GUI::Button>();
|
||||||
ok_button->on_click = [this] {
|
ok_button.on_click = [this] {
|
||||||
done(m_selected_option);
|
done(m_selected_option);
|
||||||
};
|
};
|
||||||
ok_button->set_text("OK");
|
ok_button.set_text("OK");
|
||||||
|
|
||||||
auto cancel_button = button_box->add<GUI::Button>();
|
auto& cancel_button = button_box.add<GUI::Button>();
|
||||||
cancel_button->on_click = [this] {
|
cancel_button.on_click = [this] {
|
||||||
done(-1);
|
done(-1);
|
||||||
};
|
};
|
||||||
cancel_button->set_text("Cancel");
|
cancel_button.set_text("Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerDialog::~PowerDialog()
|
PowerDialog::~PowerDialog()
|
||||||
|
|
|
@ -57,15 +57,15 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
|
||||||
layout()->set_spacing(3);
|
layout()->set_spacing(3);
|
||||||
|
|
||||||
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> {
|
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> {
|
||||||
auto container = add<GUI::Widget>();
|
auto& container = add<GUI::Widget>();
|
||||||
container->set_layout<GUI::HorizontalBoxLayout>();
|
container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
container->set_preferred_size(275, 12);
|
container.set_preferred_size(275, 12);
|
||||||
auto description_label = container->add<GUI::Label>(description);
|
auto& description_label = container.add<GUI::Label>(description);
|
||||||
description_label->set_font(Gfx::Font::default_bold_font());
|
description_label.set_font(Gfx::Font::default_bold_font());
|
||||||
description_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
auto label = container->add<GUI::Label>();
|
auto& label = container.add<GUI::Label>();
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
label.set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
return label;
|
return label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,13 +37,13 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
||||||
layout()->set_margins({ 4, 4, 4, 4 });
|
layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
|
||||||
auto adapters_group_box = add<GUI::GroupBox>("Adapters");
|
auto& adapters_group_box = add<GUI::GroupBox>("Adapters");
|
||||||
adapters_group_box->set_layout<GUI::VerticalBoxLayout>();
|
adapters_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||||
adapters_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
adapters_group_box.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
adapters_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
adapters_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
adapters_group_box->set_preferred_size(0, 120);
|
adapters_group_box.set_preferred_size(0, 120);
|
||||||
|
|
||||||
m_adapter_table_view = adapters_group_box->add<GUI::TableView>();
|
m_adapter_table_view = adapters_group_box.add<GUI::TableView>();
|
||||||
m_adapter_table_view->set_size_columns_to_fit_content(true);
|
m_adapter_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields;
|
||||||
|
@ -57,13 +57,13 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
||||||
net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
|
net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
|
||||||
m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
|
m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
|
||||||
|
|
||||||
auto sockets_group_box = add<GUI::GroupBox>("Sockets");
|
auto& sockets_group_box = add<GUI::GroupBox>("Sockets");
|
||||||
sockets_group_box->set_layout<GUI::VerticalBoxLayout>();
|
sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||||
sockets_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
sockets_group_box.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
sockets_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
sockets_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
sockets_group_box->set_preferred_size(0, 0);
|
sockets_group_box.set_preferred_size(0, 0);
|
||||||
|
|
||||||
m_socket_table_view = sockets_group_box->add<GUI::TableView>();
|
m_socket_table_view = sockets_group_box.add<GUI::TableView>();
|
||||||
m_socket_table_view->set_size_columns_to_fit_content(true);
|
m_socket_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> net_tcp_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> net_tcp_fields;
|
||||||
|
|
|
@ -120,59 +120,59 @@ int main(int argc, char** argv)
|
||||||
keeper.set_fill_with_background_color(true);
|
keeper.set_fill_with_background_color(true);
|
||||||
keeper.layout()->set_margins({ 4, 4, 4, 4 });
|
keeper.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto tabwidget = keeper.add<GUI::TabWidget>();
|
auto& tabwidget = keeper.add<GUI::TabWidget>();
|
||||||
|
|
||||||
auto process_container_splitter = tabwidget->add_tab<GUI::VerticalSplitter>("Processes");
|
auto process_container_splitter = tabwidget.add_tab<GUI::VerticalSplitter>("Processes");
|
||||||
|
|
||||||
auto process_table_container = process_container_splitter->add<GUI::Widget>();
|
auto& process_table_container = process_container_splitter->add<GUI::Widget>();
|
||||||
|
|
||||||
tabwidget->add_widget("Graphs", build_graphs_tab());
|
tabwidget.add_widget("Graphs", build_graphs_tab());
|
||||||
|
|
||||||
tabwidget->add_widget("File systems", build_file_systems_tab());
|
tabwidget.add_widget("File systems", build_file_systems_tab());
|
||||||
|
|
||||||
tabwidget->add_widget("PCI devices", build_pci_devices_tab());
|
tabwidget.add_widget("PCI devices", build_pci_devices_tab());
|
||||||
|
|
||||||
tabwidget->add_widget("Devices", build_devices_tab());
|
tabwidget.add_widget("Devices", build_devices_tab());
|
||||||
|
|
||||||
auto network_stats_widget = NetworkStatisticsWidget::construct();
|
auto network_stats_widget = NetworkStatisticsWidget::construct();
|
||||||
tabwidget->add_widget("Network", network_stats_widget);
|
tabwidget.add_widget("Network", network_stats_widget);
|
||||||
|
|
||||||
process_table_container->set_layout<GUI::VerticalBoxLayout>();
|
process_table_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
process_table_container->layout()->set_margins({ 4, 0, 4, 0 });
|
process_table_container.layout()->set_margins({ 4, 0, 4, 0 });
|
||||||
process_table_container->layout()->set_spacing(0);
|
process_table_container.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto toolbar = process_table_container->add<GUI::ToolBar>();
|
auto& toolbar = process_table_container.add<GUI::ToolBar>();
|
||||||
toolbar->set_has_frame(false);
|
toolbar.set_has_frame(false);
|
||||||
auto process_table_view = process_table_container->add<ProcessTableView>();
|
auto& process_table_view = process_table_container.add<ProcessTableView>();
|
||||||
|
|
||||||
auto refresh_timer = window->add<Core::Timer>(
|
auto& refresh_timer = window->add<Core::Timer>(
|
||||||
1000, [&] {
|
1000, [&] {
|
||||||
process_table_view->refresh();
|
process_table_view.refresh();
|
||||||
if (auto* memory_stats_widget = MemoryStatsWidget::the())
|
if (auto* memory_stats_widget = MemoryStatsWidget::the())
|
||||||
memory_stats_widget->refresh();
|
memory_stats_widget->refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GUI::Action&) {
|
auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::load_from_file("/res/icons/kill16.png"), [&process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view.selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto stop_action = GUI::Action::create("Stop process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GUI::Action&) {
|
auto stop_action = GUI::Action::create("Stop process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/stop16.png"), [&process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view.selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGSTOP);
|
kill(pid, SIGSTOP);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto continue_action = GUI::Action::create("Continue process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GUI::Action&) {
|
auto continue_action = GUI::Action::create("Continue process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/continue16.png"), [&process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view.selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGCONT);
|
kill(pid, SIGCONT);
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbar->add_action(kill_action);
|
toolbar.add_action(kill_action);
|
||||||
toolbar->add_action(stop_action);
|
toolbar.add_action(stop_action);
|
||||||
toolbar->add_action(continue_action);
|
toolbar.add_action(continue_action);
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
auto app_menu = GUI::Menu::construct("System Monitor");
|
auto app_menu = GUI::Menu::construct("System Monitor");
|
||||||
|
@ -192,7 +192,7 @@ int main(int argc, char** argv)
|
||||||
process_context_menu->add_action(kill_action);
|
process_context_menu->add_action(kill_action);
|
||||||
process_context_menu->add_action(stop_action);
|
process_context_menu->add_action(stop_action);
|
||||||
process_context_menu->add_action(continue_action);
|
process_context_menu->add_action(continue_action);
|
||||||
process_table_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
process_table_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||||
(void)index;
|
(void)index;
|
||||||
process_context_menu->popup(event.screen_position());
|
process_context_menu->popup(event.screen_position());
|
||||||
};
|
};
|
||||||
|
@ -203,7 +203,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto make_frequency_action = [&](auto& title, int interval, bool checked = false) {
|
auto make_frequency_action = [&](auto& title, int interval, bool checked = false) {
|
||||||
auto action = GUI::Action::create(title, [&refresh_timer, interval](auto& action) {
|
auto action = GUI::Action::create(title, [&refresh_timer, interval](auto& action) {
|
||||||
refresh_timer->restart(interval);
|
refresh_timer.restart(interval);
|
||||||
action.set_checked(true);
|
action.set_checked(true);
|
||||||
});
|
});
|
||||||
action->set_checkable(true);
|
action->set_checkable(true);
|
||||||
|
@ -228,14 +228,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
auto process_tab_widget = process_container_splitter->add<GUI::TabWidget>();
|
auto& process_tab_widget = process_container_splitter->add<GUI::TabWidget>();
|
||||||
|
|
||||||
auto memory_map_widget = process_tab_widget->add_tab<ProcessMemoryMapWidget>("Memory map");
|
auto memory_map_widget = process_tab_widget.add_tab<ProcessMemoryMapWidget>("Memory map");
|
||||||
auto open_files_widget = process_tab_widget->add_tab<ProcessFileDescriptorMapWidget>("Open files");
|
auto open_files_widget = process_tab_widget.add_tab<ProcessFileDescriptorMapWidget>("Open files");
|
||||||
auto unveiled_paths_widget = process_tab_widget->add_tab<ProcessUnveiledPathsWidget>("Unveiled paths");
|
auto unveiled_paths_widget = process_tab_widget.add_tab<ProcessUnveiledPathsWidget>("Unveiled paths");
|
||||||
auto stacks_widget = process_tab_widget->add_tab<ProcessStacksWidget>("Stacks");
|
auto stacks_widget = process_tab_widget.add_tab<ProcessStacksWidget>("Stacks");
|
||||||
|
|
||||||
process_table_view->on_process_selected = [&](pid_t pid) {
|
process_table_view.on_process_selected = [&](pid_t pid) {
|
||||||
open_files_widget->set_pid(pid);
|
open_files_widget->set_pid(pid);
|
||||||
stacks_widget->set_pid(pid);
|
stacks_widget->set_pid(pid);
|
||||||
memory_map_widget->set_pid(pid);
|
memory_map_widget->set_pid(pid);
|
||||||
|
@ -274,8 +274,8 @@ NonnullRefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
fs_widget->on_first_show = [](GUI::LazyWidget& self) {
|
fs_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||||
self.set_layout<GUI::VerticalBoxLayout>();
|
self.set_layout<GUI::VerticalBoxLayout>();
|
||||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
auto fs_table_view = self.add<GUI::TableView>();
|
auto& fs_table_view = self.add<GUI::TableView>();
|
||||||
fs_table_view->set_size_columns_to_fit_content(true);
|
fs_table_view.set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> df_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> df_fields;
|
||||||
df_fields.empend("mount_point", "Mount point", Gfx::TextAlignment::CenterLeft);
|
df_fields.empend("mount_point", "Mount point", Gfx::TextAlignment::CenterLeft);
|
||||||
|
@ -351,11 +351,11 @@ NonnullRefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
df_fields.empend("free_inode_count", "Free inodes", Gfx::TextAlignment::CenterRight);
|
df_fields.empend("free_inode_count", "Free inodes", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("total_inode_count", "Total inodes", Gfx::TextAlignment::CenterRight);
|
df_fields.empend("total_inode_count", "Total inodes", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("block_size", "Block size", Gfx::TextAlignment::CenterRight);
|
df_fields.empend("block_size", "Block size", Gfx::TextAlignment::CenterRight);
|
||||||
fs_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields))));
|
fs_table_view.set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields))));
|
||||||
|
|
||||||
fs_table_view->set_cell_painting_delegate(3, make<ProgressBarPaintingDelegate>());
|
fs_table_view.set_cell_painting_delegate(3, make<ProgressBarPaintingDelegate>());
|
||||||
|
|
||||||
fs_table_view->model()->update();
|
fs_table_view.model()->update();
|
||||||
};
|
};
|
||||||
return fs_widget;
|
return fs_widget;
|
||||||
}
|
}
|
||||||
|
@ -367,8 +367,8 @@ NonnullRefPtr<GUI::Widget> build_pci_devices_tab()
|
||||||
pci_widget->on_first_show = [](GUI::LazyWidget& self) {
|
pci_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||||
self.set_layout<GUI::VerticalBoxLayout>();
|
self.set_layout<GUI::VerticalBoxLayout>();
|
||||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
auto pci_table_view = self.add<GUI::TableView>();
|
auto& pci_table_view = self.add<GUI::TableView>();
|
||||||
pci_table_view->set_size_columns_to_fit_content(true);
|
pci_table_view.set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
auto db = PCIDB::Database::open();
|
auto db = PCIDB::Database::open();
|
||||||
|
|
||||||
|
@ -411,8 +411,8 @@ NonnullRefPtr<GUI::Widget> build_pci_devices_tab()
|
||||||
return String::format("%02x", revision_id);
|
return String::format("%02x", revision_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
pci_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/pci", move(pci_fields))));
|
pci_table_view.set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/pci", move(pci_fields))));
|
||||||
pci_table_view->model()->update();
|
pci_table_view.model()->update();
|
||||||
};
|
};
|
||||||
|
|
||||||
return pci_widget;
|
return pci_widget;
|
||||||
|
@ -426,10 +426,10 @@ NonnullRefPtr<GUI::Widget> build_devices_tab()
|
||||||
self.set_layout<GUI::VerticalBoxLayout>();
|
self.set_layout<GUI::VerticalBoxLayout>();
|
||||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto devices_table_view = self.add<GUI::TableView>();
|
auto& devices_table_view = self.add<GUI::TableView>();
|
||||||
devices_table_view->set_size_columns_to_fit_content(true);
|
devices_table_view.set_size_columns_to_fit_content(true);
|
||||||
devices_table_view->set_model(GUI::SortingProxyModel::create(DevicesModel::create()));
|
devices_table_view.set_model(GUI::SortingProxyModel::create(DevicesModel::create()));
|
||||||
devices_table_view->model()->update();
|
devices_table_view.model()->update();
|
||||||
};
|
};
|
||||||
|
|
||||||
return devices_widget;
|
return devices_widget;
|
||||||
|
@ -445,36 +445,36 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
||||||
self.set_layout<GUI::VerticalBoxLayout>();
|
self.set_layout<GUI::VerticalBoxLayout>();
|
||||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto cpu_graph_group_box = self.add<GUI::GroupBox>("CPU usage");
|
auto& cpu_graph_group_box = self.add<GUI::GroupBox>("CPU usage");
|
||||||
cpu_graph_group_box->set_layout<GUI::VerticalBoxLayout>();
|
cpu_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||||
cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
cpu_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
cpu_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
cpu_graph_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
cpu_graph_group_box->set_preferred_size(0, 120);
|
cpu_graph_group_box.set_preferred_size(0, 120);
|
||||||
auto cpu_graph = cpu_graph_group_box->add<GraphWidget>();
|
auto& cpu_graph = cpu_graph_group_box.add<GraphWidget>();
|
||||||
cpu_graph->set_max(100);
|
cpu_graph.set_max(100);
|
||||||
cpu_graph->set_text_color(Color::Green);
|
cpu_graph.set_text_color(Color::Green);
|
||||||
cpu_graph->set_graph_color(Color::from_rgb(0x00bb00));
|
cpu_graph.set_graph_color(Color::from_rgb(0x00bb00));
|
||||||
cpu_graph->text_formatter = [](int value, int) {
|
cpu_graph.text_formatter = [](int value, int) {
|
||||||
return String::format("%d%%", value);
|
return String::format("%d%%", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessModel::the().on_new_cpu_data_point = [graph = cpu_graph.ptr()](float cpu_percent) {
|
ProcessModel::the().on_new_cpu_data_point = [graph = &cpu_graph](float cpu_percent) {
|
||||||
graph->add_value(cpu_percent);
|
graph->add_value(cpu_percent);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto memory_graph_group_box = self.add<GUI::GroupBox>("Memory usage");
|
auto& memory_graph_group_box = self.add<GUI::GroupBox>("Memory usage");
|
||||||
memory_graph_group_box->set_layout<GUI::VerticalBoxLayout>();
|
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||||
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
memory_graph_group_box.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
memory_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
memory_graph_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
memory_graph_group_box->set_preferred_size(0, 120);
|
memory_graph_group_box.set_preferred_size(0, 120);
|
||||||
auto memory_graph = memory_graph_group_box->add<GraphWidget>();
|
auto& memory_graph = memory_graph_group_box.add<GraphWidget>();
|
||||||
memory_graph->set_text_color(Color::Cyan);
|
memory_graph.set_text_color(Color::Cyan);
|
||||||
memory_graph->set_graph_color(Color::from_rgb(0x00bbbb));
|
memory_graph.set_graph_color(Color::from_rgb(0x00bbbb));
|
||||||
memory_graph->text_formatter = [](int value, int max) {
|
memory_graph.text_formatter = [](int value, int max) {
|
||||||
return String::format("%d / %d KB", value, max);
|
return String::format("%d / %d KB", value, max);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto memory_stats_widget = self.add<MemoryStatsWidget>(*memory_graph);
|
self.add<MemoryStatsWidget>(memory_graph);
|
||||||
};
|
};
|
||||||
return graphs_container;
|
return graphs_container;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,14 @@ TaskbarWindow::~TaskbarWindow()
|
||||||
|
|
||||||
void TaskbarWindow::create_quick_launch_bar()
|
void TaskbarWindow::create_quick_launch_bar()
|
||||||
{
|
{
|
||||||
auto quick_launch_bar = main_widget()->add<GUI::Frame>();
|
auto& quick_launch_bar = main_widget()->add<GUI::Frame>();
|
||||||
quick_launch_bar->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
quick_launch_bar.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
quick_launch_bar->set_layout<GUI::HorizontalBoxLayout>();
|
quick_launch_bar.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
quick_launch_bar->layout()->set_spacing(3);
|
quick_launch_bar.layout()->set_spacing(3);
|
||||||
quick_launch_bar->layout()->set_margins({ 3, 0, 3, 0 });
|
quick_launch_bar.layout()->set_margins({ 3, 0, 3, 0 });
|
||||||
quick_launch_bar->set_frame_thickness(1);
|
quick_launch_bar.set_frame_thickness(1);
|
||||||
quick_launch_bar->set_frame_shape(Gfx::FrameShape::Container);
|
quick_launch_bar.set_frame_shape(Gfx::FrameShape::Container);
|
||||||
quick_launch_bar->set_frame_shadow(Gfx::FrameShadow::Raised);
|
quick_launch_bar.set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
|
|
||||||
int total_width = 6;
|
int total_width = 6;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -92,15 +92,15 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
auto app_executable = af->read_entry("App", "Executable");
|
auto app_executable = af->read_entry("App", "Executable");
|
||||||
auto app_icon_path = af->read_entry("Icons", "16x16");
|
auto app_icon_path = af->read_entry("Icons", "16x16");
|
||||||
|
|
||||||
auto button = quick_launch_bar->add<GUI::Button>();
|
auto& button = quick_launch_bar.add<GUI::Button>();
|
||||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(22, 22);
|
button.set_preferred_size(22, 22);
|
||||||
button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
|
|
||||||
button->set_icon(Gfx::Bitmap::load_from_file(app_icon_path));
|
button.set_icon(Gfx::Bitmap::load_from_file(app_icon_path));
|
||||||
// FIXME: the tooltip ends up outside the screen rect.
|
// FIXME: the tooltip ends up outside the screen rect.
|
||||||
button->set_tooltip(name);
|
button.set_tooltip(name);
|
||||||
button->on_click = [app_executable] {
|
button.on_click = [app_executable] {
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
perror("fork");
|
perror("fork");
|
||||||
|
@ -117,7 +117,7 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
total_width += 22;
|
total_width += 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
quick_launch_bar->set_preferred_size(total_width, 22);
|
quick_launch_bar.set_preferred_size(total_width, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect)
|
void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect)
|
||||||
|
@ -128,11 +128,11 @@ void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect)
|
||||||
|
|
||||||
NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier)
|
NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier)
|
||||||
{
|
{
|
||||||
auto button = main_widget()->add<TaskbarButton>(identifier);
|
auto& button = main_widget()->add<TaskbarButton>(identifier);
|
||||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(140, 22);
|
button.set_preferred_size(140, 22);
|
||||||
button->set_checkable(true);
|
button.set_checkable(true);
|
||||||
button->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
button.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,33 +140,33 @@ RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
|
||||||
settings.set_layout<GUI::VerticalBoxLayout>();
|
settings.set_layout<GUI::VerticalBoxLayout>();
|
||||||
settings.layout()->set_margins({ 4, 4, 4, 4 });
|
settings.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto radio_container = settings.add<GUI::GroupBox>("Bell Mode");
|
auto& radio_container = settings.add<GUI::GroupBox>("Bell Mode");
|
||||||
radio_container->set_layout<GUI::VerticalBoxLayout>();
|
radio_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
radio_container->layout()->set_margins({ 6, 16, 6, 6 });
|
radio_container.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
radio_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
radio_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
radio_container->set_preferred_size(100, 70);
|
radio_container.set_preferred_size(100, 70);
|
||||||
|
|
||||||
auto sysbell_radio = radio_container->add<GUI::RadioButton>("Use (Audible) System Bell");
|
auto& sysbell_radio = radio_container.add<GUI::RadioButton>("Use (Audible) System Bell");
|
||||||
auto visbell_radio = radio_container->add<GUI::RadioButton>("Use (Visual) Terminal Bell");
|
auto& visbell_radio = radio_container.add<GUI::RadioButton>("Use (Visual) Terminal Bell");
|
||||||
sysbell_radio->set_checked(terminal.should_beep());
|
sysbell_radio.set_checked(terminal.should_beep());
|
||||||
visbell_radio->set_checked(!terminal.should_beep());
|
visbell_radio.set_checked(!terminal.should_beep());
|
||||||
sysbell_radio->on_checked = [&terminal](const bool checked) {
|
sysbell_radio.on_checked = [&terminal](const bool checked) {
|
||||||
terminal.set_should_beep(checked);
|
terminal.set_should_beep(checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto slider_container = settings.add<GUI::GroupBox>("Background Opacity");
|
auto& slider_container = settings.add<GUI::GroupBox>("Background Opacity");
|
||||||
slider_container->set_layout<GUI::VerticalBoxLayout>();
|
slider_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
slider_container->layout()->set_margins({ 6, 16, 6, 6 });
|
slider_container.layout()->set_margins({ 6, 16, 6, 6 });
|
||||||
slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
slider_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
slider_container->set_preferred_size(100, 50);
|
slider_container.set_preferred_size(100, 50);
|
||||||
auto slider = slider_container->add<GUI::HorizontalSlider>();
|
auto& slider = slider_container.add<GUI::HorizontalSlider>();
|
||||||
|
|
||||||
slider->on_value_changed = [&terminal](int value) {
|
slider.on_value_changed = [&terminal](int value) {
|
||||||
terminal.set_opacity(value);
|
terminal.set_opacity(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
slider->set_range(0, 255);
|
slider.set_range(0, 255);
|
||||||
slider->set_value(terminal.opacity());
|
slider.set_value(terminal.opacity());
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
layout()->set_spacing(0);
|
layout()->set_spacing(0);
|
||||||
|
|
||||||
auto toolbar = add<GUI::ToolBar>();
|
auto& toolbar = add<GUI::ToolBar>();
|
||||||
m_editor = add<GUI::TextEditor>();
|
m_editor = add<GUI::TextEditor>();
|
||||||
m_editor->set_ruler_visible(true);
|
m_editor->set_ruler_visible(true);
|
||||||
m_editor->set_automatic_indentation_enabled(true);
|
m_editor->set_automatic_indentation_enabled(true);
|
||||||
|
@ -391,21 +391,21 @@ TextEditorWidget::TextEditorWidget()
|
||||||
|
|
||||||
GUI::Application::the().set_menubar(move(menubar));
|
GUI::Application::the().set_menubar(move(menubar));
|
||||||
|
|
||||||
toolbar->add_action(*m_new_action);
|
toolbar.add_action(*m_new_action);
|
||||||
toolbar->add_action(*m_open_action);
|
toolbar.add_action(*m_open_action);
|
||||||
toolbar->add_action(*m_save_action);
|
toolbar.add_action(*m_save_action);
|
||||||
|
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
toolbar->add_action(m_editor->cut_action());
|
toolbar.add_action(m_editor->cut_action());
|
||||||
toolbar->add_action(m_editor->copy_action());
|
toolbar.add_action(m_editor->copy_action());
|
||||||
toolbar->add_action(m_editor->paste_action());
|
toolbar.add_action(m_editor->paste_action());
|
||||||
toolbar->add_action(m_editor->delete_action());
|
toolbar.add_action(m_editor->delete_action());
|
||||||
|
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
toolbar->add_action(m_editor->undo_action());
|
toolbar.add_action(m_editor->undo_action());
|
||||||
toolbar->add_action(m_editor->redo_action());
|
toolbar.add_action(m_editor->redo_action());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorWidget::~TextEditorWidget()
|
TextEditorWidget::~TextEditorWidget()
|
||||||
|
|
|
@ -69,11 +69,11 @@ private:
|
||||||
|
|
||||||
RefPtr<GUI::TextBox> m_find_textbox;
|
RefPtr<GUI::TextBox> m_find_textbox;
|
||||||
RefPtr<GUI::TextBox> m_replace_textbox;
|
RefPtr<GUI::TextBox> m_replace_textbox;
|
||||||
GUI::Button* m_find_previous_button { nullptr };
|
RefPtr<GUI::Button> m_find_previous_button;
|
||||||
GUI::Button* m_find_next_button { nullptr };
|
RefPtr<GUI::Button> m_find_next_button;
|
||||||
GUI::Button* m_replace_previous_button { nullptr };
|
RefPtr<GUI::Button> m_replace_previous_button;
|
||||||
GUI::Button* m_replace_next_button { nullptr };
|
RefPtr<GUI::Button> m_replace_next_button;
|
||||||
GUI::Button* m_replace_all_button { nullptr };
|
RefPtr<GUI::Button> m_replace_all_button;
|
||||||
RefPtr<GUI::Widget> m_find_replace_widget;
|
RefPtr<GUI::Widget> m_find_replace_widget;
|
||||||
RefPtr<GUI::Widget> m_find_widget;
|
RefPtr<GUI::Widget> m_find_widget;
|
||||||
RefPtr<GUI::Widget> m_replace_widget;
|
RefPtr<GUI::Widget> m_replace_widget;
|
||||||
|
|
|
@ -172,84 +172,84 @@ int main(int argc, char** argv)
|
||||||
// header
|
// header
|
||||||
//
|
//
|
||||||
|
|
||||||
auto header = background.add<GUI::Label>();
|
auto& header = background.add<GUI::Label>();
|
||||||
header->set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold11.font"));
|
header.set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold11.font"));
|
||||||
header->set_text("Welcome to SerenityOS!");
|
header.set_text("Welcome to SerenityOS!");
|
||||||
header->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
header.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
header->set_preferred_size(0, 30);
|
header.set_preferred_size(0, 30);
|
||||||
|
|
||||||
//
|
//
|
||||||
// main section
|
// main section
|
||||||
//
|
//
|
||||||
|
|
||||||
auto main_section = background.add<GUI::Widget>();
|
auto& main_section = background.add<GUI::Widget>();
|
||||||
main_section->set_layout<GUI::HorizontalBoxLayout>();
|
main_section.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
main_section->layout()->set_margins({ 0, 0, 0, 0 });
|
main_section.layout()->set_margins({ 0, 0, 0, 0 });
|
||||||
main_section->layout()->set_spacing(8);
|
main_section.layout()->set_spacing(8);
|
||||||
main_section->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
main_section.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
auto menu = main_section->add<GUI::Widget>();
|
auto& menu = main_section.add<GUI::Widget>();
|
||||||
menu->set_layout<GUI::VerticalBoxLayout>();
|
menu.set_layout<GUI::VerticalBoxLayout>();
|
||||||
menu->layout()->set_margins({ 0, 0, 0, 0 });
|
menu.layout()->set_margins({ 0, 0, 0, 0 });
|
||||||
menu->layout()->set_spacing(4);
|
menu.layout()->set_spacing(4);
|
||||||
menu->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
menu.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
menu->set_preferred_size(100, 0);
|
menu.set_preferred_size(100, 0);
|
||||||
|
|
||||||
auto stack = main_section->add<GUI::StackWidget>();
|
auto& stack = main_section.add<GUI::StackWidget>();
|
||||||
stack->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
stack.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto& page : pages) {
|
for (auto& page : pages) {
|
||||||
auto content = stack->add<GUI::Widget>();
|
auto& content = stack.add<GUI::Widget>();
|
||||||
content->set_layout<GUI::VerticalBoxLayout>();
|
content.set_layout<GUI::VerticalBoxLayout>();
|
||||||
content->layout()->set_margins({ 0, 0, 0, 0 });
|
content.layout()->set_margins({ 0, 0, 0, 0 });
|
||||||
content->layout()->set_spacing(8);
|
content.layout()->set_spacing(8);
|
||||||
content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
content.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
auto title_box = content->add<GUI::Widget>();
|
auto& title_box = content.add<GUI::Widget>();
|
||||||
title_box->set_layout<GUI::HorizontalBoxLayout>();
|
title_box.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
title_box->layout()->set_spacing(4);
|
title_box.layout()->set_spacing(4);
|
||||||
title_box->set_preferred_size(0, 16);
|
title_box.set_preferred_size(0, 16);
|
||||||
title_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
title_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
|
|
||||||
if (!page.icon.is_empty()) {
|
if (!page.icon.is_empty()) {
|
||||||
auto icon = title_box->add<GUI::Label>();
|
auto& icon = title_box.add<GUI::Label>();
|
||||||
icon->set_icon(Gfx::Bitmap::load_from_file(page.icon));
|
icon.set_icon(Gfx::Bitmap::load_from_file(page.icon));
|
||||||
icon->set_preferred_size(16, 16);
|
icon.set_preferred_size(16, 16);
|
||||||
icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
icon.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto content_title = title_box->add<GUI::Label>();
|
auto& content_title = title_box.add<GUI::Label>();
|
||||||
content_title->set_font(Gfx::Font::default_bold_font());
|
content_title.set_font(Gfx::Font::default_bold_font());
|
||||||
content_title->set_text(page.title);
|
content_title.set_text(page.title);
|
||||||
content_title->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
content_title.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
content_title->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
content_title.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
content_title->set_preferred_size(0, 10);
|
content_title.set_preferred_size(0, 10);
|
||||||
|
|
||||||
for (auto& paragraph : page.content) {
|
for (auto& paragraph : page.content) {
|
||||||
auto content_text = content->add<TextWidget>();
|
auto& content_text = content.add<TextWidget>();
|
||||||
content_text->set_font(Gfx::Font::default_font());
|
content_text.set_font(Gfx::Font::default_font());
|
||||||
content_text->set_text(paragraph);
|
content_text.set_text(paragraph);
|
||||||
content_text->set_text_alignment(Gfx::TextAlignment::TopLeft);
|
content_text.set_text_alignment(Gfx::TextAlignment::TopLeft);
|
||||||
content_text->set_line_height(12);
|
content_text.set_line_height(12);
|
||||||
content_text->wrap_and_set_height();
|
content_text.wrap_and_set_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto menu_option = menu->add<UnuncheckableButton>();
|
auto& menu_option = menu.add<UnuncheckableButton>();
|
||||||
menu_option->set_font(Gfx::Font::default_font());
|
menu_option.set_font(Gfx::Font::default_font());
|
||||||
menu_option->set_text(page.menu_name);
|
menu_option.set_text(page.menu_name);
|
||||||
menu_option->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
menu_option.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
menu_option->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
menu_option.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
menu_option->set_preferred_size(0, 20);
|
menu_option.set_preferred_size(0, 20);
|
||||||
menu_option->set_checkable(true);
|
menu_option.set_checkable(true);
|
||||||
menu_option->set_exclusive(true);
|
menu_option.set_exclusive(true);
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
menu_option->set_checked(true);
|
menu_option.set_checked(true);
|
||||||
|
|
||||||
menu_option->on_click = [content = content.ptr(), &stack] {
|
menu_option.on_click = [content = &content, &stack] {
|
||||||
stack->set_active_widget(content);
|
stack.set_active_widget(content);
|
||||||
content->invalidate_layout();
|
content->invalidate_layout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -248,10 +248,10 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto& fire = window->set_main_widget<Fire>();
|
auto& fire = window->set_main_widget<Fire>();
|
||||||
|
|
||||||
auto time = fire.add<GUI::Label>();
|
auto& time = fire.add<GUI::Label>();
|
||||||
time->set_relative_rect({ 0, 4, 40, 10 });
|
time.set_relative_rect({ 0, 4, 40, 10 });
|
||||||
time->move_by({ window->width() - time->width(), 0 });
|
time.move_by({ window->width() - time.width(), 0 });
|
||||||
time->set_foreground_color(Color::from_rgb(0x444444));
|
time.set_foreground_color(Color::from_rgb(0x444444));
|
||||||
fire.set_stat_label(time);
|
fire.set_stat_label(time);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
|
@ -45,14 +45,14 @@ int main(int argc, char** argv)
|
||||||
auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
|
auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
layout.set_margins({ 4, 4, 4, 4 });
|
layout.set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto label = main_widget.add<GUI::Label>();
|
auto& label = main_widget.add<GUI::Label>();
|
||||||
label->set_text("Hello\nWorld!");
|
label.set_text("Hello\nWorld!");
|
||||||
|
|
||||||
auto button = main_widget.add<GUI::Button>();
|
auto& button = main_widget.add<GUI::Button>();
|
||||||
button->set_text("Good-bye");
|
button.set_text("Good-bye");
|
||||||
button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(0, 20);
|
button.set_preferred_size(0, 20);
|
||||||
button->on_click = [&] {
|
button.on_click = [&] {
|
||||||
app.quit();
|
app.quit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,74 +53,74 @@ int main(int argc, char** argv)
|
||||||
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
|
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto checkbox1 = main_widget.add<GUI::CheckBox>("GCheckBox 1");
|
auto& checkbox1 = main_widget.add<GUI::CheckBox>("GCheckBox 1");
|
||||||
(void)checkbox1;
|
(void)checkbox1;
|
||||||
auto checkbox2 = main_widget.add<GUI::CheckBox>("GCheckBox 2");
|
auto& checkbox2 = main_widget.add<GUI::CheckBox>("GCheckBox 2");
|
||||||
checkbox2->set_enabled(false);
|
checkbox2.set_enabled(false);
|
||||||
|
|
||||||
auto radio1 = main_widget.add<GUI::RadioButton>("GRadioButton 1");
|
auto& radio1 = main_widget.add<GUI::RadioButton>("GRadioButton 1");
|
||||||
(void)radio1;
|
(void)radio1;
|
||||||
auto radio2 = main_widget.add<GUI::RadioButton>("GRadioButton 2");
|
auto& radio2 = main_widget.add<GUI::RadioButton>("GRadioButton 2");
|
||||||
radio2->set_enabled(false);
|
radio2.set_enabled(false);
|
||||||
|
|
||||||
auto button1 = main_widget.add<GUI::Button>("GButton 1");
|
auto& button1 = main_widget.add<GUI::Button>("GButton 1");
|
||||||
(void)button1;
|
(void)button1;
|
||||||
auto button2 = main_widget.add<GUI::Button>("GButton 2");
|
auto& button2 = main_widget.add<GUI::Button>("GButton 2");
|
||||||
button2->set_enabled(false);
|
button2.set_enabled(false);
|
||||||
|
|
||||||
auto progress1 = main_widget.add<GUI::ProgressBar>();
|
auto& progress1 = main_widget.add<GUI::ProgressBar>();
|
||||||
auto timer = progress1->add<Core::Timer>(100, [&] {
|
progress1.add<Core::Timer>(100, [&] {
|
||||||
progress1->set_value(progress1->value() + 1);
|
progress1.set_value(progress1.value() + 1);
|
||||||
if (progress1->value() == progress1->max())
|
if (progress1.value() == progress1.max())
|
||||||
progress1->set_value(progress1->min());
|
progress1.set_value(progress1.min());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto label1 = main_widget.add<GUI::Label>("GLabel 1");
|
auto& label1 = main_widget.add<GUI::Label>("GLabel 1");
|
||||||
(void)label1;
|
(void)label1;
|
||||||
auto label2 = main_widget.add<GUI::Label>("GLabel 2");
|
auto& label2 = main_widget.add<GUI::Label>("GLabel 2");
|
||||||
label2->set_enabled(false);
|
label2.set_enabled(false);
|
||||||
|
|
||||||
auto textbox1 = main_widget.add<GUI::TextBox>();
|
auto& textbox1 = main_widget.add<GUI::TextBox>();
|
||||||
textbox1->set_text("GTextBox 1");
|
textbox1.set_text("GTextBox 1");
|
||||||
auto textbox2 = main_widget.add<GUI::TextBox>();
|
auto& textbox2 = main_widget.add<GUI::TextBox>();
|
||||||
textbox2->set_text("GTextBox 2");
|
textbox2.set_text("GTextBox 2");
|
||||||
textbox2->set_enabled(false);
|
textbox2.set_enabled(false);
|
||||||
|
|
||||||
auto spinbox1 = main_widget.add<GUI::SpinBox>();
|
auto& spinbox1 = main_widget.add<GUI::SpinBox>();
|
||||||
(void)spinbox1;
|
(void)spinbox1;
|
||||||
auto spinbox2 = main_widget.add<GUI::SpinBox>();
|
auto& spinbox2 = main_widget.add<GUI::SpinBox>();
|
||||||
spinbox2->set_enabled(false);
|
spinbox2.set_enabled(false);
|
||||||
|
|
||||||
auto vertical_slider_container = main_widget.add<GUI::Widget>();
|
auto& vertical_slider_container = main_widget.add<GUI::Widget>();
|
||||||
vertical_slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
vertical_slider_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
vertical_slider_container->set_preferred_size(0, 100);
|
vertical_slider_container.set_preferred_size(0, 100);
|
||||||
vertical_slider_container->set_layout<GUI::HorizontalBoxLayout>();
|
vertical_slider_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
auto vslider1 = vertical_slider_container->add<GUI::VerticalSlider>();
|
auto& vslider1 = vertical_slider_container.add<GUI::VerticalSlider>();
|
||||||
(void)vslider1;
|
(void)vslider1;
|
||||||
auto vslider2 = vertical_slider_container->add<GUI::VerticalSlider>();
|
auto& vslider2 = vertical_slider_container.add<GUI::VerticalSlider>();
|
||||||
vslider2->set_enabled(false);
|
vslider2.set_enabled(false);
|
||||||
auto vslider3 = vertical_slider_container->add<GUI::VerticalSlider>();
|
auto& vslider3 = vertical_slider_container.add<GUI::VerticalSlider>();
|
||||||
vslider3->set_max(5);
|
vslider3.set_max(5);
|
||||||
vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
vslider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
||||||
|
|
||||||
auto slider1 = main_widget.add<GUI::HorizontalSlider>();
|
auto& slider1 = main_widget.add<GUI::HorizontalSlider>();
|
||||||
(void)slider1;
|
(void)slider1;
|
||||||
auto slider2 = main_widget.add<GUI::HorizontalSlider>();
|
auto& slider2 = main_widget.add<GUI::HorizontalSlider>();
|
||||||
slider2->set_enabled(false);
|
slider2.set_enabled(false);
|
||||||
auto slider3 = main_widget.add<GUI::HorizontalSlider>();
|
auto& slider3 = main_widget.add<GUI::HorizontalSlider>();
|
||||||
slider3->set_max(5);
|
slider3.set_max(5);
|
||||||
slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
slider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
||||||
|
|
||||||
auto scrollbar1 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
auto& scrollbar1 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||||
scrollbar1->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
scrollbar1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
scrollbar1->set_preferred_size(0, 16);
|
scrollbar1.set_preferred_size(0, 16);
|
||||||
scrollbar1->set_min(0);
|
scrollbar1.set_min(0);
|
||||||
scrollbar1->set_max(100);
|
scrollbar1.set_max(100);
|
||||||
scrollbar1->set_value(50);
|
scrollbar1.set_value(50);
|
||||||
auto scrollbar2 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
auto& scrollbar2 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||||
scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
scrollbar2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
scrollbar2->set_preferred_size(0, 16);
|
scrollbar2.set_preferred_size(0, 16);
|
||||||
scrollbar2->set_enabled(false);
|
scrollbar2.set_enabled(false);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
|
|
@ -38,19 +38,19 @@ EditorWrapper::EditorWrapper()
|
||||||
{
|
{
|
||||||
set_layout<GUI::VerticalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto label_wrapper = add<GUI::Widget>();
|
auto& label_wrapper = add<GUI::Widget>();
|
||||||
label_wrapper->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label_wrapper.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label_wrapper->set_preferred_size(0, 14);
|
label_wrapper.set_preferred_size(0, 14);
|
||||||
label_wrapper->set_fill_with_background_color(true);
|
label_wrapper.set_fill_with_background_color(true);
|
||||||
label_wrapper->set_layout<GUI::HorizontalBoxLayout>();
|
label_wrapper.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
|
label_wrapper.layout()->set_margins({ 2, 0, 2, 0 });
|
||||||
|
|
||||||
m_filename_label = label_wrapper->add<GUI::Label>("(Untitled)");
|
m_filename_label = label_wrapper.add<GUI::Label>("(Untitled)");
|
||||||
m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_filename_label->set_preferred_size(0, 14);
|
m_filename_label->set_preferred_size(0, 14);
|
||||||
|
|
||||||
m_cursor_label = label_wrapper->add<GUI::Label>("(Cursor)");
|
m_cursor_label = label_wrapper.add<GUI::Label>("(Cursor)");
|
||||||
m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_cursor_label->set_preferred_size(0, 14);
|
m_cursor_label->set_preferred_size(0, 14);
|
||||||
|
|
|
@ -40,21 +40,21 @@ ProcessStateWidget::ProcessStateWidget()
|
||||||
|
|
||||||
set_layout<GUI::HorizontalBoxLayout>();
|
set_layout<GUI::HorizontalBoxLayout>();
|
||||||
|
|
||||||
auto pid_label_label = add<GUI::Label>("Process:");
|
auto& pid_label_label = add<GUI::Label>("Process:");
|
||||||
pid_label_label->set_font(Gfx::Font::default_bold_font());
|
pid_label_label.set_font(Gfx::Font::default_bold_font());
|
||||||
m_pid_label = add<GUI::Label>("");
|
m_pid_label = add<GUI::Label>("");
|
||||||
|
|
||||||
auto state_label_label = add<GUI::Label>("State:");
|
auto& state_label_label = add<GUI::Label>("State:");
|
||||||
state_label_label->set_font(Gfx::Font::default_bold_font());
|
state_label_label.set_font(Gfx::Font::default_bold_font());
|
||||||
m_state_label = add<GUI::Label>("");
|
m_state_label = add<GUI::Label>("");
|
||||||
|
|
||||||
// FIXME: This should show CPU% instead.
|
// FIXME: This should show CPU% instead.
|
||||||
auto cpu_label_label = add<GUI::Label>("Times scheduled:");
|
auto& cpu_label_label = add<GUI::Label>("Times scheduled:");
|
||||||
cpu_label_label->set_font(Gfx::Font::default_bold_font());
|
cpu_label_label.set_font(Gfx::Font::default_bold_font());
|
||||||
m_cpu_label = add<GUI::Label>("");
|
m_cpu_label = add<GUI::Label>("");
|
||||||
|
|
||||||
auto memory_label_label = add<GUI::Label>("Memory (resident):");
|
auto& memory_label_label = add<GUI::Label>("Memory (resident):");
|
||||||
memory_label_label->set_font(Gfx::Font::default_bold_font());
|
memory_label_label.set_font(Gfx::Font::default_bold_font());
|
||||||
m_memory_label = add<GUI::Label>("");
|
m_memory_label = add<GUI::Label>("");
|
||||||
|
|
||||||
m_timer = add<Core::Timer>(500, [this] {
|
m_timer = add<Core::Timer>(500, [this] {
|
||||||
|
|
|
@ -164,7 +164,7 @@ int main(int argc, char** argv)
|
||||||
g_project = Project::load_from_file("little.files");
|
g_project = Project::load_from_file("little.files");
|
||||||
ASSERT(g_project);
|
ASSERT(g_project);
|
||||||
|
|
||||||
auto toolbar = widget.add<GUI::ToolBar>();
|
auto& toolbar = widget.add<GUI::ToolBar>();
|
||||||
|
|
||||||
auto selected_file_names = [&] {
|
auto selected_file_names = [&] {
|
||||||
Vector<String> files;
|
Vector<String> files;
|
||||||
|
@ -175,10 +175,10 @@ int main(int argc, char** argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
|
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
|
||||||
auto input_box = g_window->add<GUI::InputBox>("Enter name of new file:", "Add new file to project");
|
auto& input_box = g_window->add<GUI::InputBox>("Enter name of new file:", "Add new file to project");
|
||||||
if (input_box->exec() == GUI::InputBox::ExecCancel)
|
if (input_box.exec() == GUI::InputBox::ExecCancel)
|
||||||
return;
|
return;
|
||||||
auto filename = input_box->text_value();
|
auto filename = input_box.text_value();
|
||||||
auto file = Core::File::construct(filename);
|
auto file = Core::File::construct(filename);
|
||||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||||
GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||||
|
@ -246,8 +246,8 @@ int main(int argc, char** argv)
|
||||||
project_tree_view_context_menu->add_action(add_existing_file_action);
|
project_tree_view_context_menu->add_action(add_existing_file_action);
|
||||||
project_tree_view_context_menu->add_action(delete_action);
|
project_tree_view_context_menu->add_action(delete_action);
|
||||||
|
|
||||||
auto outer_splitter = widget.add<GUI::HorizontalSplitter>();
|
auto& outer_splitter = widget.add<GUI::HorizontalSplitter>();
|
||||||
g_project_tree_view = outer_splitter->add<GUI::TreeView>();
|
g_project_tree_view = outer_splitter.add<GUI::TreeView>();
|
||||||
g_project_tree_view->set_model(g_project->model());
|
g_project_tree_view->set_model(g_project->model());
|
||||||
g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
g_project_tree_view->set_preferred_size(140, 0);
|
g_project_tree_view->set_preferred_size(140, 0);
|
||||||
|
@ -262,12 +262,12 @@ int main(int argc, char** argv)
|
||||||
delete_action->set_enabled(!g_project_tree_view->selection().is_empty());
|
delete_action->set_enabled(!g_project_tree_view->selection().is_empty());
|
||||||
};
|
};
|
||||||
|
|
||||||
g_right_hand_stack = outer_splitter->add<GUI::StackWidget>();
|
g_right_hand_stack = outer_splitter.add<GUI::StackWidget>();
|
||||||
|
|
||||||
g_form_inner_container = g_right_hand_stack->add<GUI::Widget>();
|
g_form_inner_container = g_right_hand_stack->add<GUI::Widget>();
|
||||||
g_form_inner_container->set_layout<GUI::HorizontalBoxLayout>();
|
g_form_inner_container->set_layout<GUI::HorizontalBoxLayout>();
|
||||||
auto form_widgets_toolbar = g_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26);
|
auto& form_widgets_toolbar = g_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26);
|
||||||
form_widgets_toolbar->set_preferred_size(38, 0);
|
form_widgets_toolbar.set_preferred_size(38, 0);
|
||||||
|
|
||||||
GUI::ActionGroup tool_actions;
|
GUI::ActionGroup tool_actions;
|
||||||
tool_actions.set_exclusive(true);
|
tool_actions.set_exclusive(true);
|
||||||
|
@ -279,7 +279,7 @@ int main(int argc, char** argv)
|
||||||
cursor_tool_action->set_checked(true);
|
cursor_tool_action->set_checked(true);
|
||||||
tool_actions.add_action(cursor_tool_action);
|
tool_actions.add_action(cursor_tool_action);
|
||||||
|
|
||||||
form_widgets_toolbar->add_action(cursor_tool_action);
|
form_widgets_toolbar.add_action(cursor_tool_action);
|
||||||
|
|
||||||
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
|
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
|
||||||
auto icon_path = String::format("/res/icons/widgets/G%s.png", reg.class_name().characters());
|
auto icon_path = String::format("/res/icons/widgets/G%s.png", reg.class_name().characters());
|
||||||
|
@ -293,28 +293,28 @@ int main(int argc, char** argv)
|
||||||
action->set_checkable(true);
|
action->set_checkable(true);
|
||||||
action->set_checked(false);
|
action->set_checked(false);
|
||||||
tool_actions.add_action(action);
|
tool_actions.add_action(action);
|
||||||
form_widgets_toolbar->add_action(move(action));
|
form_widgets_toolbar.add_action(move(action));
|
||||||
});
|
});
|
||||||
|
|
||||||
auto form_editor_inner_splitter = g_form_inner_container->add<GUI::HorizontalSplitter>();
|
auto& form_editor_inner_splitter = g_form_inner_container->add<GUI::HorizontalSplitter>();
|
||||||
|
|
||||||
g_form_editor_widget = form_editor_inner_splitter->add<FormEditorWidget>();
|
g_form_editor_widget = form_editor_inner_splitter.add<FormEditorWidget>();
|
||||||
|
|
||||||
auto form_editing_pane_container = form_editor_inner_splitter->add<GUI::VerticalSplitter>();
|
auto& form_editing_pane_container = form_editor_inner_splitter.add<GUI::VerticalSplitter>();
|
||||||
form_editing_pane_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
form_editing_pane_container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
form_editing_pane_container->set_preferred_size(190, 0);
|
form_editing_pane_container.set_preferred_size(190, 0);
|
||||||
form_editing_pane_container->set_layout<GUI::VerticalBoxLayout>();
|
form_editing_pane_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto add_properties_pane = [&](auto& text, auto pane_widget) {
|
auto add_properties_pane = [&](auto& text, auto pane_widget) {
|
||||||
auto wrapper = form_editing_pane_container->add<GUI::Widget>();
|
auto& wrapper = form_editing_pane_container.add<GUI::Widget>();
|
||||||
wrapper->set_layout<GUI::VerticalBoxLayout>();
|
wrapper.set_layout<GUI::VerticalBoxLayout>();
|
||||||
auto label = wrapper->add<GUI::Label>(text);
|
auto& label = wrapper.add<GUI::Label>(text);
|
||||||
label->set_fill_with_background_color(true);
|
label.set_fill_with_background_color(true);
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
label->set_font(Gfx::Font::default_bold_font());
|
label.set_font(Gfx::Font::default_bold_font());
|
||||||
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label->set_preferred_size(0, 16);
|
label.set_preferred_size(0, 16);
|
||||||
wrapper->add_child(pane_widget);
|
wrapper.add_child(pane_widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto form_widget_tree_view = GUI::TreeView::construct();
|
auto form_widget_tree_view = GUI::TreeView::construct();
|
||||||
|
@ -401,19 +401,19 @@ int main(int argc, char** argv)
|
||||||
current_editor().write_to_file(g_currently_open_file);
|
current_editor().write_to_file(g_currently_open_file);
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbar->add_action(new_action);
|
toolbar.add_action(new_action);
|
||||||
toolbar->add_action(add_existing_file_action);
|
toolbar.add_action(add_existing_file_action);
|
||||||
toolbar->add_action(save_action);
|
toolbar.add_action(save_action);
|
||||||
toolbar->add_action(delete_action);
|
toolbar.add_action(delete_action);
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
toolbar->add_action(GUI::CommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); }));
|
toolbar.add_action(GUI::CommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); }));
|
||||||
toolbar->add_action(GUI::CommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); }));
|
toolbar.add_action(GUI::CommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); }));
|
||||||
toolbar->add_action(GUI::CommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); }));
|
toolbar.add_action(GUI::CommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); }));
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
toolbar->add_action(GUI::CommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); }));
|
toolbar.add_action(GUI::CommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); }));
|
||||||
toolbar->add_action(GUI::CommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); }));
|
toolbar.add_action(GUI::CommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); }));
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
g_project_tree_view->on_activation = [&](auto& index) {
|
g_project_tree_view->on_activation = [&](auto& index) {
|
||||||
auto filename = g_project_tree_view->model()->data(index, GUI::Model::Role::Custom).to_string();
|
auto filename = g_project_tree_view->model()->data(index, GUI::Model::Role::Custom).to_string();
|
||||||
|
@ -447,10 +447,10 @@ int main(int argc, char** argv)
|
||||||
auto find_in_files_widget = s_action_tab_widget->add_tab<FindInFilesWidget>("Find in files");
|
auto find_in_files_widget = s_action_tab_widget->add_tab<FindInFilesWidget>("Find in files");
|
||||||
auto terminal_wrapper = s_action_tab_widget->add_tab<TerminalWrapper>("Console");
|
auto terminal_wrapper = s_action_tab_widget->add_tab<TerminalWrapper>("Console");
|
||||||
|
|
||||||
auto locator = widget.add<Locator>();
|
auto& locator = widget.add<Locator>();
|
||||||
|
|
||||||
auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) {
|
auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) {
|
||||||
locator->open();
|
locator.open();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
@ -487,15 +487,15 @@ int main(int argc, char** argv)
|
||||||
build(terminal_wrapper);
|
build(terminal_wrapper);
|
||||||
stop_action->set_enabled(true);
|
stop_action->set_enabled(true);
|
||||||
});
|
});
|
||||||
toolbar->add_action(build_action);
|
toolbar.add_action(build_action);
|
||||||
|
|
||||||
auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
|
auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
|
||||||
reveal_action_tab(terminal_wrapper);
|
reveal_action_tab(terminal_wrapper);
|
||||||
run(terminal_wrapper);
|
run(terminal_wrapper);
|
||||||
stop_action->set_enabled(true);
|
stop_action->set_enabled(true);
|
||||||
});
|
});
|
||||||
toolbar->add_action(run_action);
|
toolbar.add_action(run_action);
|
||||||
toolbar->add_action(stop_action);
|
toolbar.add_action(stop_action);
|
||||||
|
|
||||||
auto build_menu = GUI::Menu::construct("Build");
|
auto build_menu = GUI::Menu::construct("Build");
|
||||||
build_menu->add_action(build_action);
|
build_menu->add_action(build_action);
|
||||||
|
|
|
@ -62,7 +62,7 @@ int main(int argc, char** argv)
|
||||||
widget.set_fill_with_background_color(true);
|
widget.set_fill_with_background_color(true);
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto splitter = widget.add<GUI::HorizontalSplitter>();
|
auto& splitter = widget.add<GUI::HorizontalSplitter>();
|
||||||
|
|
||||||
RemoteProcess remote_process(pid);
|
RemoteProcess remote_process(pid);
|
||||||
|
|
||||||
|
@ -71,16 +71,16 @@ int main(int argc, char** argv)
|
||||||
window->set_title(String::format("Inspector: %s (%d)", remote_process.process_name().characters(), remote_process.pid()));
|
window->set_title(String::format("Inspector: %s (%d)", remote_process.process_name().characters(), remote_process.pid()));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto tree_view = splitter->add<GUI::TreeView>();
|
auto& tree_view = splitter.add<GUI::TreeView>();
|
||||||
tree_view->set_model(remote_process.object_graph_model());
|
tree_view.set_model(remote_process.object_graph_model());
|
||||||
tree_view->set_activates_on_selection(true);
|
tree_view.set_activates_on_selection(true);
|
||||||
|
|
||||||
auto properties_table_view = splitter->add<GUI::TableView>();
|
auto& properties_table_view = splitter.add<GUI::TableView>();
|
||||||
properties_table_view->set_size_columns_to_fit_content(true);
|
properties_table_view.set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
tree_view->on_activation = [&](auto& index) {
|
tree_view.on_activation = [&](auto& index) {
|
||||||
auto* remote_object = static_cast<RemoteObject*>(index.internal_data());
|
auto* remote_object = static_cast<RemoteObject*>(index.internal_data());
|
||||||
properties_table_view->set_model(remote_object->property_model());
|
properties_table_view.set_model(remote_object->property_model());
|
||||||
};
|
};
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
|
@ -61,12 +61,12 @@ int main(int argc, char** argv)
|
||||||
main_widget.set_fill_with_background_color(true);
|
main_widget.set_fill_with_background_color(true);
|
||||||
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto timeline_widget = main_widget.add<ProfileTimelineWidget>(*profile);
|
main_widget.add<ProfileTimelineWidget>(*profile);
|
||||||
|
|
||||||
auto tree_view = main_widget.add<GUI::TreeView>();
|
auto& tree_view = main_widget.add<GUI::TreeView>();
|
||||||
tree_view->set_headers_visible(true);
|
tree_view.set_headers_visible(true);
|
||||||
tree_view->set_size_columns_to_fit_content(true);
|
tree_view.set_size_columns_to_fit_content(true);
|
||||||
tree_view->set_model(profile->model());
|
tree_view.set_model(profile->model());
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
auto app_menu = GUI::Menu::construct("ProfileViewer");
|
auto app_menu = GUI::Menu::construct("ProfileViewer");
|
||||||
|
@ -86,7 +86,7 @@ int main(int argc, char** argv)
|
||||||
auto percent_action = GUI::Action::create("Show percentages", { Mod_Ctrl, Key_P }, [&](auto& action) {
|
auto percent_action = GUI::Action::create("Show percentages", { Mod_Ctrl, Key_P }, [&](auto& action) {
|
||||||
action.set_checked(!action.is_checked());
|
action.set_checked(!action.is_checked());
|
||||||
profile->set_show_percentages(action.is_checked());
|
profile->set_show_percentages(action.is_checked());
|
||||||
tree_view->update();
|
tree_view.update();
|
||||||
});
|
});
|
||||||
percent_action->set_checkable(true);
|
percent_action->set_checkable(true);
|
||||||
percent_action->set_checked(false);
|
percent_action->set_checked(false);
|
||||||
|
|
|
@ -104,43 +104,43 @@ static RefPtr<GUI::Widget> build_gwidget(VBWidgetType type, GUI::Widget* parent)
|
||||||
case VBWidgetType::GGroupBox:
|
case VBWidgetType::GGroupBox:
|
||||||
return parent->add<GUI::GroupBox>("groupbox_1");
|
return parent->add<GUI::GroupBox>("groupbox_1");
|
||||||
case VBWidgetType::GLabel: {
|
case VBWidgetType::GLabel: {
|
||||||
auto label = parent->add<GUI::Label>();
|
auto& label = parent->add<GUI::Label>();
|
||||||
label->set_fill_with_background_color(true);
|
label.set_fill_with_background_color(true);
|
||||||
label->set_text("label_1");
|
label.set_text("label_1");
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GButton: {
|
case VBWidgetType::GButton: {
|
||||||
auto button = parent->add<GUI::Button>();
|
auto& button = parent->add<GUI::Button>();
|
||||||
button->set_text("button_1");
|
button.set_text("button_1");
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GSpinBox: {
|
case VBWidgetType::GSpinBox: {
|
||||||
auto box = parent->add<GUI::SpinBox>();
|
auto& box = parent->add<GUI::SpinBox>();
|
||||||
box->set_range(0, 100);
|
box.set_range(0, 100);
|
||||||
box->set_value(0);
|
box.set_value(0);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GTextEditor: {
|
case VBWidgetType::GTextEditor: {
|
||||||
auto editor = parent->add<GUI::TextEditor>();
|
auto& editor = parent->add<GUI::TextEditor>();
|
||||||
editor->set_ruler_visible(false);
|
editor.set_ruler_visible(false);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GProgressBar: {
|
case VBWidgetType::GProgressBar: {
|
||||||
auto bar = parent->add<GUI::ProgressBar>();
|
auto& bar = parent->add<GUI::ProgressBar>();
|
||||||
bar->set_format(GUI::ProgressBar::Format::NoText);
|
bar.set_format(GUI::ProgressBar::Format::NoText);
|
||||||
bar->set_range(0, 100);
|
bar.set_range(0, 100);
|
||||||
bar->set_value(50);
|
bar.set_value(50);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GSlider: {
|
case VBWidgetType::GSlider: {
|
||||||
auto slider = parent->add<GUI::HorizontalSlider>();
|
auto& slider = parent->add<GUI::HorizontalSlider>();
|
||||||
slider->set_range(0, 100);
|
slider.set_range(0, 100);
|
||||||
slider->set_value(50);
|
slider.set_value(50);
|
||||||
return slider;
|
return slider;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GCheckBox: {
|
case VBWidgetType::GCheckBox: {
|
||||||
auto box = parent->add<GUI::CheckBox>();
|
auto& box = parent->add<GUI::CheckBox>();
|
||||||
box->set_text("checkbox_1");
|
box.set_text("checkbox_1");
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
case VBWidgetType::GRadioButton:
|
case VBWidgetType::GRadioButton:
|
||||||
|
|
|
@ -111,84 +111,84 @@ RefPtr<GUI::Window> make_toolbox_window()
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto label_button = widget.add<GUI::Button>();
|
auto& label_button = widget.add<GUI::Button>();
|
||||||
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
label_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
label_button->set_tooltip("GLabel");
|
label_button.set_tooltip("GLabel");
|
||||||
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
label_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||||
label_button->on_click = [] {
|
label_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GLabel);
|
form->insert_widget(VBWidgetType::GLabel);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto button_button = widget.add<GUI::Button>();
|
auto& button_button = widget.add<GUI::Button>();
|
||||||
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
button_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
button_button->set_tooltip("GButton");
|
button_button.set_tooltip("GButton");
|
||||||
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
button_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||||
button_button->on_click = [] {
|
button_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GButton);
|
form->insert_widget(VBWidgetType::GButton);
|
||||||
};
|
};
|
||||||
auto spinbox_button = widget.add<GUI::Button>();
|
auto& spinbox_button = widget.add<GUI::Button>();
|
||||||
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
spinbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
spinbox_button->set_tooltip("GSpinBox");
|
spinbox_button.set_tooltip("GSpinBox");
|
||||||
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
spinbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||||
spinbox_button->on_click = [] {
|
spinbox_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GSpinBox);
|
form->insert_widget(VBWidgetType::GSpinBox);
|
||||||
};
|
};
|
||||||
auto editor_button = widget.add<GUI::Button>();
|
auto& editor_button = widget.add<GUI::Button>();
|
||||||
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
editor_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
editor_button->set_tooltip("GTextEditor");
|
editor_button.set_tooltip("GTextEditor");
|
||||||
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
editor_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||||
editor_button->on_click = [] {
|
editor_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GTextEditor);
|
form->insert_widget(VBWidgetType::GTextEditor);
|
||||||
};
|
};
|
||||||
auto progress_bar_button = widget.add<GUI::Button>();
|
auto& progress_bar_button = widget.add<GUI::Button>();
|
||||||
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
progress_bar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
progress_bar_button->set_tooltip("GProgressBar");
|
progress_bar_button.set_tooltip("GProgressBar");
|
||||||
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
progress_bar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||||
progress_bar_button->on_click = [] {
|
progress_bar_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GProgressBar);
|
form->insert_widget(VBWidgetType::GProgressBar);
|
||||||
};
|
};
|
||||||
auto slider_button = widget.add<GUI::Button>();
|
auto& slider_button = widget.add<GUI::Button>();
|
||||||
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
slider_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
slider_button->set_tooltip("GSlider");
|
slider_button.set_tooltip("GSlider");
|
||||||
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
slider_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||||
slider_button->on_click = [] {
|
slider_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GSlider);
|
form->insert_widget(VBWidgetType::GSlider);
|
||||||
};
|
};
|
||||||
auto checkbox_button = widget.add<GUI::Button>();
|
auto& checkbox_button = widget.add<GUI::Button>();
|
||||||
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
checkbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
checkbox_button->set_tooltip("GCheckBox");
|
checkbox_button.set_tooltip("GCheckBox");
|
||||||
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
checkbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||||
checkbox_button->on_click = [] {
|
checkbox_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GCheckBox);
|
form->insert_widget(VBWidgetType::GCheckBox);
|
||||||
};
|
};
|
||||||
auto radiobutton_button = widget.add<GUI::Button>();
|
auto& radiobutton_button = widget.add<GUI::Button>();
|
||||||
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
radiobutton_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
radiobutton_button->set_tooltip("GRadioButton");
|
radiobutton_button.set_tooltip("GRadioButton");
|
||||||
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
radiobutton_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||||
radiobutton_button->on_click = [] {
|
radiobutton_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GRadioButton);
|
form->insert_widget(VBWidgetType::GRadioButton);
|
||||||
};
|
};
|
||||||
auto scrollbar_button = widget.add<GUI::Button>();
|
auto& scrollbar_button = widget.add<GUI::Button>();
|
||||||
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
scrollbar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
scrollbar_button->set_tooltip("GScrollBar");
|
scrollbar_button.set_tooltip("GScrollBar");
|
||||||
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
scrollbar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||||
scrollbar_button->on_click = [] {
|
scrollbar_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GScrollBar);
|
form->insert_widget(VBWidgetType::GScrollBar);
|
||||||
};
|
};
|
||||||
auto groupbox_button = widget.add<GUI::Button>();
|
auto& groupbox_button = widget.add<GUI::Button>();
|
||||||
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
groupbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
groupbox_button->set_tooltip("GGroupBox");
|
groupbox_button.set_tooltip("GGroupBox");
|
||||||
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
groupbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||||
groupbox_button->on_click = [] {
|
groupbox_button.on_click = [] {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GGroupBox);
|
form->insert_widget(VBWidgetType::GGroupBox);
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,7 +51,6 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
window->set_resizable(false);
|
window->set_resizable(false);
|
||||||
window->set_title("Minesweeper");
|
window->set_title("Minesweeper");
|
||||||
|
@ -61,23 +60,23 @@ int main(int argc, char** argv)
|
||||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
widget.layout()->set_spacing(0);
|
widget.layout()->set_spacing(0);
|
||||||
|
|
||||||
auto container = widget.add<GUI::Widget>();
|
auto& container = widget.add<GUI::Widget>();
|
||||||
container->set_fill_with_background_color(true);
|
container.set_fill_with_background_color(true);
|
||||||
container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
container->set_preferred_size(0, 36);
|
container.set_preferred_size(0, 36);
|
||||||
container->set_layout<GUI::HorizontalBoxLayout>();
|
container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
auto flag_icon_label = container->add<GUI::Label>();
|
auto& flag_icon_label = container.add<GUI::Label>();
|
||||||
flag_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png"));
|
flag_icon_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png"));
|
||||||
auto flag_label = container->add<GUI::Label>();
|
auto& flag_label = container.add<GUI::Label>();
|
||||||
auto face_button = container->add<GUI::Button>();
|
auto& face_button = container.add<GUI::Button>();
|
||||||
face_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
face_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
face_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
face_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
face_button->set_preferred_size(36, 0);
|
face_button.set_preferred_size(36, 0);
|
||||||
auto time_icon_label = container->add<GUI::Label>();
|
auto& time_icon_label = container.add<GUI::Label>();
|
||||||
time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
time_icon_label.set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
||||||
auto time_label = container->add<GUI::Label>();
|
auto& time_label = container.add<GUI::Label>();
|
||||||
auto field = widget.add<Field>(*flag_label, *time_label, *face_button, [&](auto size) {
|
auto& field = widget.add<Field>(flag_label, time_label, face_button, [&](auto size) {
|
||||||
size.set_height(size.height() + container->preferred_size().height());
|
size.set_height(size.height() + container.preferred_size().height());
|
||||||
window->resize(size);
|
window->resize(size);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,20 +85,18 @@ int main(int argc, char** argv)
|
||||||
auto app_menu = GUI::Menu::construct("Minesweeper");
|
auto app_menu = GUI::Menu::construct("Minesweeper");
|
||||||
|
|
||||||
app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) {
|
app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) {
|
||||||
field->reset();
|
field.reset();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
app_menu->add_separator();
|
app_menu->add_separator();
|
||||||
|
|
||||||
|
|
||||||
NonnullRefPtr<GUI::Action> chord_toggler_action = GUI::Action::create("Single-click chording", [&](const GUI::Action&) {
|
NonnullRefPtr<GUI::Action> chord_toggler_action = GUI::Action::create("Single-click chording", [&](const GUI::Action&) {
|
||||||
bool toggled = !field->is_single_chording();
|
bool toggled = !field.is_single_chording();
|
||||||
field->set_single_chording(toggled);
|
field.set_single_chording(toggled);
|
||||||
chord_toggler_action->set_checked(toggled);
|
chord_toggler_action->set_checked(toggled);
|
||||||
});
|
});
|
||||||
chord_toggler_action->set_checkable(true);
|
chord_toggler_action->set_checkable(true);
|
||||||
chord_toggler_action->set_checked(field->is_single_chording());
|
chord_toggler_action->set_checked(field.is_single_chording());
|
||||||
|
|
||||||
app_menu->add_action(*chord_toggler_action);
|
app_menu->add_action(*chord_toggler_action);
|
||||||
app_menu->add_separator();
|
app_menu->add_separator();
|
||||||
|
@ -112,16 +109,16 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto difficulty_menu = GUI::Menu::construct("Difficulty");
|
auto difficulty_menu = GUI::Menu::construct("Difficulty");
|
||||||
difficulty_menu->add_action(GUI::Action::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) {
|
difficulty_menu->add_action(GUI::Action::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) {
|
||||||
field->set_field_size(9, 9, 10);
|
field.set_field_size(9, 9, 10);
|
||||||
}));
|
}));
|
||||||
difficulty_menu->add_action(GUI::Action::create("Intermediate", { Mod_Ctrl, Key_I }, [&](const GUI::Action&) {
|
difficulty_menu->add_action(GUI::Action::create("Intermediate", { Mod_Ctrl, Key_I }, [&](const GUI::Action&) {
|
||||||
field->set_field_size(16, 16, 40);
|
field.set_field_size(16, 16, 40);
|
||||||
}));
|
}));
|
||||||
difficulty_menu->add_action(GUI::Action::create("Expert", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) {
|
difficulty_menu->add_action(GUI::Action::create("Expert", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) {
|
||||||
field->set_field_size(16, 30, 99);
|
field.set_field_size(16, 30, 99);
|
||||||
}));
|
}));
|
||||||
difficulty_menu->add_action(GUI::Action::create("Madwoman", { Mod_Ctrl, Key_M }, [&](const GUI::Action&) {
|
difficulty_menu->add_action(GUI::Action::create("Madwoman", { Mod_Ctrl, Key_M }, [&](const GUI::Action&) {
|
||||||
field->set_field_size(32, 60, 350);
|
field.set_field_size(32, 60, 350);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(difficulty_menu));
|
menubar->add_menu(move(difficulty_menu));
|
||||||
|
|
||||||
|
|
|
@ -121,11 +121,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
inline NonnullRefPtr<T> add(Args&&... args)
|
inline T& add(Args&&... args)
|
||||||
{
|
{
|
||||||
auto t = T::construct(forward<Args>(args)...);
|
auto child = T::construct(forward<Args>(args)...);
|
||||||
add_child(*t);
|
add_child(*child);
|
||||||
return t;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool is_visible_for_timer_purposes() const;
|
virtual bool is_visible_for_timer_purposes() const;
|
||||||
|
|
|
@ -46,43 +46,43 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
||||||
widget.set_fill_with_background_color(true);
|
widget.set_fill_with_background_color(true);
|
||||||
widget.set_layout<HorizontalBoxLayout>();
|
widget.set_layout<HorizontalBoxLayout>();
|
||||||
|
|
||||||
auto left_container = widget.add<Widget>();
|
auto& left_container = widget.add<Widget>();
|
||||||
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
left_container.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
left_container->set_preferred_size(48, 0);
|
left_container.set_preferred_size(48, 0);
|
||||||
left_container->set_layout<VerticalBoxLayout>();
|
left_container.set_layout<VerticalBoxLayout>();
|
||||||
auto icon_label = left_container->add<Label>();
|
auto& icon_label = left_container.add<Label>();
|
||||||
icon_label->set_icon(m_icon);
|
icon_label.set_icon(m_icon);
|
||||||
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
icon_label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
icon_label->set_preferred_size(40, 40);
|
icon_label.set_preferred_size(40, 40);
|
||||||
left_container->layout()->add_spacer();
|
left_container.layout()->add_spacer();
|
||||||
|
|
||||||
auto right_container = widget.add<Widget>();
|
auto& right_container = widget.add<Widget>();
|
||||||
right_container->set_layout<VerticalBoxLayout>();
|
right_container.set_layout<VerticalBoxLayout>();
|
||||||
right_container->layout()->set_margins({ 0, 4, 4, 4 });
|
right_container.layout()->set_margins({ 0, 4, 4, 4 });
|
||||||
|
|
||||||
auto make_label = [&](const StringView& text, bool bold = false) {
|
auto make_label = [&](const StringView& text, bool bold = false) {
|
||||||
auto label = right_container->add<Label>(text);
|
auto& label = right_container.add<Label>(text);
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
label.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
label->set_preferred_size(0, 14);
|
label.set_preferred_size(0, 14);
|
||||||
if (bold)
|
if (bold)
|
||||||
label->set_font(Gfx::Font::default_bold_font());
|
label.set_font(Gfx::Font::default_bold_font());
|
||||||
};
|
};
|
||||||
make_label(m_name, true);
|
make_label(m_name, true);
|
||||||
make_label("SerenityOS");
|
make_label("SerenityOS");
|
||||||
make_label("(C) The SerenityOS developers");
|
make_label("(C) The SerenityOS developers");
|
||||||
|
|
||||||
right_container->layout()->add_spacer();
|
right_container.layout()->add_spacer();
|
||||||
|
|
||||||
auto button_container = right_container->add<Widget>();
|
auto& button_container = right_container.add<Widget>();
|
||||||
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
button_container->set_preferred_size(0, 20);
|
button_container.set_preferred_size(0, 20);
|
||||||
button_container->set_layout<HorizontalBoxLayout>();
|
button_container.set_layout<HorizontalBoxLayout>();
|
||||||
button_container->layout()->add_spacer();
|
button_container.layout()->add_spacer();
|
||||||
auto ok_button = button_container->add<Button>("OK");
|
auto& ok_button = button_container.add<Button>("OK");
|
||||||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
ok_button->set_preferred_size(80, 20);
|
ok_button.set_preferred_size(80, 20);
|
||||||
ok_button->on_click = [this] {
|
ok_button.on_click = [this] {
|
||||||
done(Dialog::ExecOK);
|
done(Dialog::ExecOK);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,11 +53,11 @@ void ColorPicker::build()
|
||||||
horizontal_container.set_layout<HorizontalBoxLayout>();
|
horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto left_vertical_container = horizontal_container.add<Widget>();
|
auto& left_vertical_container = horizontal_container.add<Widget>();
|
||||||
left_vertical_container->set_layout<VerticalBoxLayout>();
|
left_vertical_container.set_layout<VerticalBoxLayout>();
|
||||||
|
|
||||||
auto right_vertical_container = horizontal_container.add<Widget>();
|
auto& right_vertical_container = horizontal_container.add<Widget>();
|
||||||
right_vertical_container->set_layout<VerticalBoxLayout>();
|
right_vertical_container.set_layout<VerticalBoxLayout>();
|
||||||
|
|
||||||
enum RGBComponent {
|
enum RGBComponent {
|
||||||
Red,
|
Red,
|
||||||
|
@ -65,34 +65,34 @@ void ColorPicker::build()
|
||||||
Blue
|
Blue
|
||||||
};
|
};
|
||||||
|
|
||||||
m_preview_widget = right_vertical_container->add<Frame>();
|
m_preview_widget = right_vertical_container.add<Frame>();
|
||||||
auto pal = m_preview_widget->palette();
|
auto pal = m_preview_widget->palette();
|
||||||
pal.set_color(ColorRole::Background, m_color);
|
pal.set_color(ColorRole::Background, m_color);
|
||||||
m_preview_widget->set_fill_with_background_color(true);
|
m_preview_widget->set_fill_with_background_color(true);
|
||||||
m_preview_widget->set_palette(pal);
|
m_preview_widget->set_palette(pal);
|
||||||
right_vertical_container->layout()->add_spacer();
|
right_vertical_container.layout()->add_spacer();
|
||||||
auto cancel_button = right_vertical_container->add<Button>("Cancel");
|
auto& cancel_button = right_vertical_container.add<Button>("Cancel");
|
||||||
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
cancel_button.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
cancel_button->set_preferred_size(0, 20);
|
cancel_button.set_preferred_size(0, 20);
|
||||||
cancel_button->on_click = [&] {
|
cancel_button.on_click = [&] {
|
||||||
done(Dialog::ExecCancel);
|
done(Dialog::ExecCancel);
|
||||||
};
|
};
|
||||||
auto ok_button = right_vertical_container->add<Button>("Okay");
|
auto& ok_button = right_vertical_container.add<Button>("Okay");
|
||||||
ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
ok_button.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
ok_button->set_preferred_size(0, 20);
|
ok_button.set_preferred_size(0, 20);
|
||||||
ok_button->on_click = [&] {
|
ok_button.on_click = [&] {
|
||||||
done(Dialog::ExecOK);
|
done(Dialog::ExecOK);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_spinbox = [&](RGBComponent component, int initial_value) {
|
auto make_spinbox = [&](RGBComponent component, int initial_value) {
|
||||||
auto spinbox = left_vertical_container->add<SpinBox>();
|
auto& spinbox = left_vertical_container.add<SpinBox>();
|
||||||
spinbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
spinbox.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
spinbox->set_preferred_size(0, 20);
|
spinbox.set_preferred_size(0, 20);
|
||||||
spinbox->set_min(0);
|
spinbox.set_min(0);
|
||||||
spinbox->set_max(255);
|
spinbox.set_max(255);
|
||||||
spinbox->set_value(initial_value);
|
spinbox.set_value(initial_value);
|
||||||
|
|
||||||
spinbox->on_change = [this, component](auto value) {
|
spinbox.on_change = [this, component](auto value) {
|
||||||
if (component == Red)
|
if (component == Red)
|
||||||
m_color.set_red(value);
|
m_color.set_red(value);
|
||||||
if (component == Green)
|
if (component == Green)
|
||||||
|
@ -105,7 +105,6 @@ void ColorPicker::build()
|
||||||
m_preview_widget->set_palette(pal);
|
m_preview_widget->set_palette(pal);
|
||||||
m_preview_widget->update();
|
m_preview_widget->update();
|
||||||
};
|
};
|
||||||
return spinbox;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
make_spinbox(Red, m_color.red());
|
make_spinbox(Red, m_color.red());
|
||||||
|
|
|
@ -86,26 +86,26 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
horizontal_container.set_fill_with_background_color(true);
|
horizontal_container.set_fill_with_background_color(true);
|
||||||
|
|
||||||
auto vertical_container = horizontal_container.add<Widget>();
|
auto& vertical_container = horizontal_container.add<Widget>();
|
||||||
vertical_container->set_layout<VerticalBoxLayout>();
|
vertical_container.set_layout<VerticalBoxLayout>();
|
||||||
vertical_container->layout()->set_spacing(4);
|
vertical_container.layout()->set_spacing(4);
|
||||||
|
|
||||||
auto upper_container = vertical_container->add<Widget>();
|
auto& upper_container = vertical_container.add<Widget>();
|
||||||
upper_container->set_layout<HorizontalBoxLayout>();
|
upper_container.set_layout<HorizontalBoxLayout>();
|
||||||
upper_container->layout()->set_spacing(4);
|
upper_container.layout()->set_spacing(4);
|
||||||
upper_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
upper_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
upper_container->set_preferred_size(0, 26);
|
upper_container.set_preferred_size(0, 26);
|
||||||
|
|
||||||
auto toolbar = upper_container->add<ToolBar>();
|
auto& toolbar = upper_container.add<ToolBar>();
|
||||||
toolbar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
toolbar.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
toolbar->set_preferred_size(165, 0);
|
toolbar.set_preferred_size(165, 0);
|
||||||
toolbar->set_has_frame(false);
|
toolbar.set_has_frame(false);
|
||||||
|
|
||||||
auto location_textbox = upper_container->add<TextBox>();
|
auto& location_textbox = upper_container.add<TextBox>();
|
||||||
location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
location_textbox.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
location_textbox->set_preferred_size(0, 20);
|
location_textbox.set_preferred_size(0, 20);
|
||||||
|
|
||||||
m_view = vertical_container->add<MultiView>();
|
m_view = vertical_container.add<MultiView>();
|
||||||
m_view->set_model(SortingProxyModel::create(*m_model));
|
m_view->set_model(SortingProxyModel::create(*m_model));
|
||||||
m_view->set_model_column(FileSystemModel::Column::Name);
|
m_view->set_model_column(FileSystemModel::Column::Name);
|
||||||
m_view->set_column_hidden(FileSystemModel::Column::Owner, true);
|
m_view->set_column_hidden(FileSystemModel::Column::Owner, true);
|
||||||
|
@ -115,8 +115,8 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
m_view->set_column_hidden(FileSystemModel::Column::SymlinkTarget, true);
|
m_view->set_column_hidden(FileSystemModel::Column::SymlinkTarget, true);
|
||||||
m_model->set_root_path(path);
|
m_model->set_root_path(path);
|
||||||
|
|
||||||
location_textbox->on_return_pressed = [&] {
|
location_textbox.on_return_pressed = [&] {
|
||||||
m_model->set_root_path(location_textbox->text());
|
m_model->set_root_path(location_textbox.text());
|
||||||
clear_preview();
|
clear_preview();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,20 +124,20 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
m_model->set_root_path(String::format("%s/..", m_model->root_path().characters()));
|
m_model->set_root_path(String::format("%s/..", m_model->root_path().characters()));
|
||||||
clear_preview();
|
clear_preview();
|
||||||
});
|
});
|
||||||
toolbar->add_action(*open_parent_directory_action);
|
toolbar.add_action(*open_parent_directory_action);
|
||||||
|
|
||||||
auto go_home_action = CommonActions::make_go_home_action([this](auto&) {
|
auto go_home_action = CommonActions::make_go_home_action([this](auto&) {
|
||||||
m_model->set_root_path(get_current_user_home_path());
|
m_model->set_root_path(get_current_user_home_path());
|
||||||
});
|
});
|
||||||
toolbar->add_action(go_home_action);
|
toolbar.add_action(go_home_action);
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
auto mkdir_action = Action::create("New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
|
auto mkdir_action = Action::create("New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
|
||||||
auto input_box = add<InputBox>("Enter name:", "New directory");
|
auto& input_box = add<InputBox>("Enter name:", "New directory");
|
||||||
if (input_box->exec() == InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
if (input_box.exec() == InputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||||
m_model->root_path().characters(),
|
m_model->root_path().characters(),
|
||||||
input_box->text_value().characters()))
|
input_box.text_value().characters()))
|
||||||
.string();
|
.string();
|
||||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
@ -148,33 +148,33 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
toolbar->add_action(*mkdir_action);
|
toolbar.add_action(*mkdir_action);
|
||||||
|
|
||||||
toolbar->add_separator();
|
toolbar.add_separator();
|
||||||
|
|
||||||
toolbar->add_action(m_view->view_as_icons_action());
|
toolbar.add_action(m_view->view_as_icons_action());
|
||||||
toolbar->add_action(m_view->view_as_table_action());
|
toolbar.add_action(m_view->view_as_table_action());
|
||||||
|
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
m_view->view_as_columns_action().set_enabled(false);
|
m_view->view_as_columns_action().set_enabled(false);
|
||||||
toolbar->add_action(m_view->view_as_columns_action());
|
toolbar.add_action(m_view->view_as_columns_action());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto lower_container = vertical_container->add<Widget>();
|
auto& lower_container = vertical_container.add<Widget>();
|
||||||
lower_container->set_layout<VerticalBoxLayout>();
|
lower_container.set_layout<VerticalBoxLayout>();
|
||||||
lower_container->layout()->set_spacing(4);
|
lower_container.layout()->set_spacing(4);
|
||||||
lower_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
lower_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
lower_container->set_preferred_size(0, 60);
|
lower_container.set_preferred_size(0, 60);
|
||||||
|
|
||||||
auto filename_container = lower_container->add<Widget>();
|
auto& filename_container = lower_container.add<Widget>();
|
||||||
filename_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
filename_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
filename_container->set_preferred_size(0, 20);
|
filename_container.set_preferred_size(0, 20);
|
||||||
filename_container->set_layout<HorizontalBoxLayout>();
|
filename_container.set_layout<HorizontalBoxLayout>();
|
||||||
auto filename_label = filename_container->add<Label>("File name:");
|
auto& filename_label = filename_container.add<Label>("File name:");
|
||||||
filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
filename_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
filename_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
filename_label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
filename_label->set_preferred_size(60, 0);
|
filename_label.set_preferred_size(60, 0);
|
||||||
m_filename_textbox = filename_container->add<TextBox>();
|
m_filename_textbox = filename_container.add<TextBox>();
|
||||||
if (m_mode == Mode::Save) {
|
if (m_mode == Mode::Save) {
|
||||||
m_filename_textbox->set_text(file_name);
|
m_filename_textbox->set_text(file_name);
|
||||||
m_filename_textbox->set_focus(true);
|
m_filename_textbox->set_focus(true);
|
||||||
|
@ -198,26 +198,26 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
set_preview(path);
|
set_preview(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto button_container = lower_container->add<Widget>();
|
auto& button_container = lower_container.add<Widget>();
|
||||||
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
button_container->set_preferred_size(0, 20);
|
button_container.set_preferred_size(0, 20);
|
||||||
button_container->set_layout<HorizontalBoxLayout>();
|
button_container.set_layout<HorizontalBoxLayout>();
|
||||||
button_container->layout()->set_spacing(4);
|
button_container.layout()->set_spacing(4);
|
||||||
button_container->layout()->add_spacer();
|
button_container.layout()->add_spacer();
|
||||||
|
|
||||||
auto cancel_button = button_container->add<Button>();
|
auto& cancel_button = button_container.add<Button>();
|
||||||
cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
cancel_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
cancel_button->set_preferred_size(80, 0);
|
cancel_button.set_preferred_size(80, 0);
|
||||||
cancel_button->set_text("Cancel");
|
cancel_button.set_text("Cancel");
|
||||||
cancel_button->on_click = [this] {
|
cancel_button.on_click = [this] {
|
||||||
done(ExecCancel);
|
done(ExecCancel);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto ok_button = button_container->add<Button>();
|
auto& ok_button = button_container.add<Button>();
|
||||||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
ok_button->set_preferred_size(80, 0);
|
ok_button.set_preferred_size(80, 0);
|
||||||
ok_button->set_text(ok_button_name(m_mode));
|
ok_button.set_text(ok_button_name(m_mode));
|
||||||
ok_button->on_click = [this] {
|
ok_button.on_click = [this] {
|
||||||
on_file_return();
|
on_file_return();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -235,23 +235,23 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto preview_container = horizontal_container.add<Frame>();
|
auto& preview_container = horizontal_container.add<Frame>();
|
||||||
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
preview_container.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
preview_container->set_preferred_size(180, 0);
|
preview_container.set_preferred_size(180, 0);
|
||||||
preview_container->set_layout<VerticalBoxLayout>();
|
preview_container.set_layout<VerticalBoxLayout>();
|
||||||
preview_container->layout()->set_margins({ 8, 8, 8, 8 });
|
preview_container.layout()->set_margins({ 8, 8, 8, 8 });
|
||||||
|
|
||||||
m_preview_image_label = preview_container->add<Label>();
|
m_preview_image_label = preview_container.add<Label>();
|
||||||
m_preview_image_label->set_should_stretch_icon(true);
|
m_preview_image_label->set_should_stretch_icon(true);
|
||||||
m_preview_image_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
m_preview_image_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
m_preview_image_label->set_preferred_size(160, 160);
|
m_preview_image_label->set_preferred_size(160, 160);
|
||||||
|
|
||||||
m_preview_name_label = preview_container->add<Label>();
|
m_preview_name_label = preview_container.add<Label>();
|
||||||
m_preview_name_label->set_font(Gfx::Font::default_bold_font());
|
m_preview_name_label->set_font(Gfx::Font::default_bold_font());
|
||||||
m_preview_name_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
m_preview_name_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
m_preview_name_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
m_preview_name_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
||||||
|
|
||||||
m_preview_geometry_label = preview_container->add<Label>();
|
m_preview_geometry_label = preview_container.add<Label>();
|
||||||
m_preview_geometry_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
m_preview_geometry_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
m_preview_geometry_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
m_preview_geometry_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,24 +62,24 @@ void InputBox::build()
|
||||||
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||||
widget.layout()->set_spacing(8);
|
widget.layout()->set_spacing(8);
|
||||||
|
|
||||||
auto label = widget.add<Label>(m_prompt);
|
auto& label = widget.add<Label>(m_prompt);
|
||||||
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
label->set_preferred_size(text_width, 16);
|
label.set_preferred_size(text_width, 16);
|
||||||
|
|
||||||
m_text_editor = widget.add<TextBox>();
|
m_text_editor = widget.add<TextBox>();
|
||||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
m_text_editor->set_preferred_size(0, 19);
|
m_text_editor->set_preferred_size(0, 19);
|
||||||
|
|
||||||
auto button_container_outer = widget.add<Widget>();
|
auto& button_container_outer = widget.add<Widget>();
|
||||||
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
button_container_outer.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
button_container_outer->set_preferred_size(0, 20);
|
button_container_outer.set_preferred_size(0, 20);
|
||||||
button_container_outer->set_layout<VerticalBoxLayout>();
|
button_container_outer.set_layout<VerticalBoxLayout>();
|
||||||
|
|
||||||
auto button_container_inner = button_container_outer->add<Widget>();
|
auto& button_container_inner = button_container_outer.add<Widget>();
|
||||||
button_container_inner->set_layout<HorizontalBoxLayout>();
|
button_container_inner.set_layout<HorizontalBoxLayout>();
|
||||||
button_container_inner->layout()->set_spacing(8);
|
button_container_inner.layout()->set_spacing(8);
|
||||||
|
|
||||||
m_cancel_button = button_container_inner->add<Button>();
|
m_cancel_button = button_container_inner.add<Button>();
|
||||||
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
m_cancel_button->set_preferred_size(0, 20);
|
m_cancel_button->set_preferred_size(0, 20);
|
||||||
m_cancel_button->set_text("Cancel");
|
m_cancel_button->set_text("Cancel");
|
||||||
|
@ -88,7 +88,7 @@ void InputBox::build()
|
||||||
done(ExecCancel);
|
done(ExecCancel);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_ok_button = button_container_inner->add<Button>();
|
m_ok_button = button_container_inner.add<Button>();
|
||||||
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
m_ok_button->set_preferred_size(0, 20);
|
m_ok_button->set_preferred_size(0, 20);
|
||||||
m_ok_button->set_text("OK");
|
m_ok_button->set_text("OK");
|
||||||
|
|
|
@ -109,28 +109,28 @@ void MessageBox::build()
|
||||||
message_container->layout()->set_margins({ 8, 0, 8, 0 });
|
message_container->layout()->set_margins({ 8, 0, 8, 0 });
|
||||||
message_container->layout()->set_spacing(8);
|
message_container->layout()->set_spacing(8);
|
||||||
|
|
||||||
auto icon_label = message_container->add<Label>();
|
auto& icon_label = message_container->add<Label>();
|
||||||
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
icon_label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
icon_label->set_preferred_size(32, 32);
|
icon_label.set_preferred_size(32, 32);
|
||||||
icon_label->set_icon(icon());
|
icon_label.set_icon(icon());
|
||||||
icon_width = icon_label->icon()->width();
|
icon_width = icon_label.icon()->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto label = message_container->add<Label>(m_text);
|
auto& label = message_container->add<Label>(m_text);
|
||||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
label.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
label->set_preferred_size(text_width, 16);
|
label.set_preferred_size(text_width, 16);
|
||||||
|
|
||||||
auto button_container = widget.add<Widget>();
|
auto& button_container = widget.add<Widget>();
|
||||||
button_container->set_layout<HorizontalBoxLayout>();
|
button_container.set_layout<HorizontalBoxLayout>();
|
||||||
button_container->layout()->set_spacing(5);
|
button_container.layout()->set_spacing(5);
|
||||||
button_container->layout()->set_margins({ 15, 0, 15, 0 });
|
button_container.layout()->set_margins({ 15, 0, 15, 0 });
|
||||||
|
|
||||||
auto add_button = [&](String label, Dialog::ExecResult result) {
|
auto add_button = [&](String label, Dialog::ExecResult result) {
|
||||||
auto button = button_container->add<Button>();
|
auto& button = button_container.add<Button>();
|
||||||
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
button.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||||
button->set_preferred_size(0, 20);
|
button.set_preferred_size(0, 20);
|
||||||
button->set_text(label);
|
button.set_text(label);
|
||||||
button->on_click = [this, label, result] {
|
button.on_click = [this, label, result] {
|
||||||
dbg() << "GUI::MessageBox: '" << label << "' button clicked";
|
dbg() << "GUI::MessageBox: '" << label << "' button clicked";
|
||||||
done(result);
|
done(result);
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,11 +57,11 @@ StatusBar::~StatusBar()
|
||||||
|
|
||||||
NonnullRefPtr<Label> StatusBar::create_label()
|
NonnullRefPtr<Label> StatusBar::create_label()
|
||||||
{
|
{
|
||||||
auto label = add<Label>();
|
auto& label = add<Label>();
|
||||||
label->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
label.set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
label->set_frame_shape(Gfx::FrameShape::Panel);
|
label.set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
label->set_frame_thickness(1);
|
label.set_frame_thickness(1);
|
||||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,21 +59,21 @@ void ToolBar::add_action(Action& action)
|
||||||
item->type = Item::Type::Action;
|
item->type = Item::Type::Action;
|
||||||
item->action = action;
|
item->action = action;
|
||||||
|
|
||||||
auto button = add<Button>();
|
auto& button = add<Button>();
|
||||||
if (action.group() && action.group()->is_exclusive())
|
if (action.group() && action.group()->is_exclusive())
|
||||||
button->set_exclusive(true);
|
button.set_exclusive(true);
|
||||||
button->set_action(*item->action);
|
button.set_action(*item->action);
|
||||||
button->set_tooltip(item->action->text());
|
button.set_tooltip(item->action->text());
|
||||||
if (item->action->icon())
|
if (item->action->icon())
|
||||||
button->set_icon(item->action->icon());
|
button.set_icon(item->action->icon());
|
||||||
else
|
else
|
||||||
button->set_text(item->action->text());
|
button.set_text(item->action->text());
|
||||||
|
|
||||||
button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||||
ASSERT(button->size_policy(Orientation::Horizontal) == SizePolicy::Fixed);
|
ASSERT(button.size_policy(Orientation::Horizontal) == SizePolicy::Fixed);
|
||||||
ASSERT(button->size_policy(Orientation::Vertical) == SizePolicy::Fixed);
|
ASSERT(button.size_policy(Orientation::Vertical) == SizePolicy::Fixed);
|
||||||
button->set_preferred_size(m_button_size + 8, m_button_size + 8);
|
button.set_preferred_size(m_button_size + 8, m_button_size + 8);
|
||||||
|
|
||||||
m_items.append(move(item));
|
m_items.append(move(item));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,10 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
|
||||||
|
|
||||||
RefPtr<GUI::Widget> widget;
|
RefPtr<GUI::Widget> widget;
|
||||||
if (type() == "submit") {
|
if (type() == "submit") {
|
||||||
auto button = html_view.add<GUI::Button>(value());
|
auto& button = html_view.add<GUI::Button>(value());
|
||||||
int text_width = Gfx::Font::default_font().width(value());
|
int text_width = Gfx::Font::default_font().width(value());
|
||||||
button->set_relative_rect(0, 0, text_width + 20, 20);
|
button.set_relative_rect(0, 0, text_width + 20, 20);
|
||||||
button->on_click = [this] {
|
button.on_click = [this] {
|
||||||
if (auto* form = first_ancestor_of_type<HTMLFormElement>()) {
|
if (auto* form = first_ancestor_of_type<HTMLFormElement>()) {
|
||||||
// FIXME: Remove this const_cast once we have a non-const first_ancestor_of_type.
|
// FIXME: Remove this const_cast once we have a non-const first_ancestor_of_type.
|
||||||
const_cast<HTMLFormElement*>(form)->submit();
|
const_cast<HTMLFormElement*>(form)->submit();
|
||||||
|
@ -63,14 +63,14 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
|
||||||
};
|
};
|
||||||
widget = button;
|
widget = button;
|
||||||
} else {
|
} else {
|
||||||
auto text_box = html_view.add<GUI::TextBox>();
|
auto& text_box = html_view.add<GUI::TextBox>();
|
||||||
text_box->set_text(value());
|
text_box.set_text(value());
|
||||||
text_box->on_change = [this] {
|
text_box.on_change = [this] {
|
||||||
auto& widget = to<LayoutWidget>(layout_node())->widget();
|
auto& widget = to<LayoutWidget>(layout_node())->widget();
|
||||||
const_cast<HTMLInputElement*>(this)->set_attribute("value", static_cast<const GUI::TextBox&>(widget).text());
|
const_cast<HTMLInputElement*>(this)->set_attribute("value", static_cast<const GUI::TextBox&>(widget).text());
|
||||||
};
|
};
|
||||||
int text_width = Gfx::Font::default_font().width(value());
|
int text_width = Gfx::Font::default_font().width(value());
|
||||||
text_box->set_relative_rect(0, 0, text_width + 20, 20);
|
text_box.set_relative_rect(0, 0, text_width + 20, 20);
|
||||||
widget = text_box;
|
widget = text_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,22 +68,22 @@ NotificationWindow::NotificationWindow(const String& text, const String& title)
|
||||||
widget.layout()->set_margins({ 4, 4, 4, 4 });
|
widget.layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
widget.layout()->set_spacing(4);
|
widget.layout()->set_spacing(4);
|
||||||
|
|
||||||
auto left_container = widget.add<GUI::Widget>();
|
auto& left_container = widget.add<GUI::Widget>();
|
||||||
left_container->set_layout<GUI::VerticalBoxLayout>();
|
left_container.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto title_label = left_container->add<GUI::Label>(title);
|
auto& title_label = left_container.add<GUI::Label>(title);
|
||||||
title_label->set_font(Gfx::Font::default_bold_font());
|
title_label.set_font(Gfx::Font::default_bold_font());
|
||||||
title_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
title_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
auto text_label = left_container->add<GUI::Label>(text);
|
auto& text_label = left_container.add<GUI::Label>(text);
|
||||||
text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
text_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
auto right_container = widget.add<GUI::Widget>();
|
auto& right_container = widget.add<GUI::Widget>();
|
||||||
right_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
right_container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
right_container->set_preferred_size(40, 0);
|
right_container.set_preferred_size(40, 0);
|
||||||
right_container->set_layout<GUI::HorizontalBoxLayout>();
|
right_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
|
|
||||||
auto button = right_container->add<GUI::Button>("Okay");
|
auto& button = right_container.add<GUI::Button>("Okay");
|
||||||
button->on_click = [this] {
|
button.on_click = [this] {
|
||||||
s_windows.remove(this);
|
s_windows.remove(this);
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue