LibGUI: Add GHBoxLayout and GVBoxLayout convenience classes

This commit is contained in:
Andreas Kling 2020-02-02 09:48:11 +01:00
parent 63364f8a5d
commit d67da8c101
Notes: sideshowbarker 2024-07-19 09:41:40 +09:00
50 changed files with 128 additions and 114 deletions

View File

@ -64,7 +64,7 @@ int main(int argc, char** argv)
auto widget = GWidget::construct();
window->set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_margins({ 0, 8, 0, 8 });
widget->layout()->set_spacing(8);

View File

@ -38,7 +38,7 @@
InspectorWidget::InspectorWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
auto splitter = GSplitter::construct(Orientation::Vertical, this);
m_dom_tree_view = GTreeView::construct(splitter);
m_dom_tree_view->on_selection = [this](auto& index) {

View File

@ -77,7 +77,7 @@ int main(int argc, char** argv)
auto widget = GWidget::construct();
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
auto toolbar = GToolBar::construct(widget);

View File

@ -60,7 +60,7 @@ int main(int argc, char** argv)
auto widget = GWidget::construct();
window->set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
auto board_combo = GComboBox::construct(widget);
board_combo->set_only_allow_values_from_model(true);

View File

@ -101,7 +101,7 @@ void DisplayPropertiesWidget::create_resolution_list()
void DisplayPropertiesWidget::create_root_widget()
{
m_root_widget = GWidget::construct();
m_root_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
m_root_widget->set_layout(make<GVBoxLayout>());
m_root_widget->set_fill_with_background_color(true);
m_root_widget->layout()->set_margins({ 4, 4, 4, 16 });
}
@ -130,7 +130,7 @@ void DisplayPropertiesWidget::create_frame()
tab_widget->add_widget("Wallpaper", background_splitter);
auto background_content = GWidget::construct(background_splitter.ptr());
background_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
background_content->set_layout(make<GVBoxLayout>());
background_content->layout()->set_margins({ 4, 4, 4, 4 });
m_wallpaper_preview = GLabel::construct(background_splitter);
@ -160,7 +160,7 @@ void DisplayPropertiesWidget::create_frame()
tab_widget->add_widget("Settings", settings_splitter);
auto settings_content = GWidget::construct(settings_splitter.ptr());
settings_content->set_layout(make<GBoxLayout>(Orientation::Vertical));
settings_content->set_layout(make<GVBoxLayout>());
settings_content->layout()->set_margins({ 4, 4, 4, 4 });
auto resolution_list = GListView::construct(settings_content);
@ -182,7 +182,7 @@ void DisplayPropertiesWidget::create_frame()
// Add the apply and cancel buttons
auto bottom_widget = GWidget::construct(m_root_widget.ptr());
bottom_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
bottom_widget->set_layout(make<GHBoxLayout>());
bottom_widget->layout()->add_spacer();
bottom_widget->set_size_policy(Orientation::Vertical, SizePolicy::Fixed);
bottom_widget->set_preferred_size(1, 22);

View File

@ -43,7 +43,7 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di
ASSERT(file_path.is_valid());
auto main_widget = GWidget::construct();
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
main_widget->set_layout(make<GVBoxLayout>());
main_widget->layout()->set_margins({ 4, 4, 4, 4 });
main_widget->set_fill_with_background_color(true);
@ -54,7 +54,7 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di
auto tab_widget = GTabWidget::construct(main_widget);
auto general_tab = GWidget::construct(tab_widget.ptr());
general_tab->set_layout(make<GBoxLayout>(Orientation::Vertical));
general_tab->set_layout(make<GVBoxLayout>());
general_tab->layout()->set_margins({ 12, 8, 12, 8 });
general_tab->layout()->set_spacing(10);
tab_widget->add_widget("General", general_tab);
@ -62,7 +62,7 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di
general_tab->layout()->add_spacer();
auto file_container = GWidget::construct(general_tab.ptr());
file_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
file_container->set_layout(make<GHBoxLayout>());
file_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
file_container->layout()->set_spacing(20);
file_container->set_preferred_size(0, 34);
@ -132,7 +132,7 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di
general_tab->layout()->add_spacer();
auto button_widget = GWidget::construct(main_widget.ptr());
button_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_widget->set_layout(make<GHBoxLayout>());
button_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
button_widget->set_preferred_size(0, 24);
button_widget->layout()->set_spacing(5);
@ -212,7 +212,7 @@ bool PropertiesDialog::apply_changes()
void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GWidget>& parent, PermissionMasks masks, String label_string, mode_t mode)
{
auto widget = GWidget::construct(parent.ptr());
widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
widget->set_layout(make<GHBoxLayout>());
widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
widget->set_preferred_size(0, 16);
widget->layout()->set_spacing(10);
@ -241,7 +241,7 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
property_labels.ensure_capacity(pairs.size());
for (auto pair : pairs) {
auto label_container = GWidget::construct(parent.ptr());
label_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
label_container->set_layout(make<GHBoxLayout>());
label_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
label_container->set_preferred_size(0, 14);
label_container->layout()->set_spacing(12);

View File

@ -91,7 +91,7 @@ int main(int argc, char** argv)
window->set_rect({ left, top, width, heigth });
auto widget = GWidget::construct();
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
auto main_toolbar = GToolBar::construct(widget);

View File

@ -79,7 +79,7 @@ int main(int argc, char* argv[])
window->set_rect(300, 200, 570, 500);
auto widget = GWidget::construct();
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
auto toolbar = GToolBar::construct(widget);

View File

@ -46,7 +46,7 @@
HexEditorWidget::HexEditorWidget()
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_spacing(0);
m_editor = HexEditor::construct(this);

View File

@ -182,7 +182,7 @@ void IRCAppWindow::setup_widgets()
auto widget = GWidget::construct();
set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
auto toolbar = GToolBar::construct(widget);
@ -197,7 +197,7 @@ void IRCAppWindow::setup_widgets()
toolbar->add_action(*m_close_query_action);
auto outer_container = GWidget::construct(widget.ptr());
outer_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
outer_container->set_layout(make<GVBoxLayout>());
outer_container->layout()->set_margins({ 2, 0, 2, 2 });
auto horizontal_container = GSplitter::construct(Orientation::Horizontal, outer_container);

View File

@ -42,7 +42,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
, m_type(type)
, m_name(name)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
// Make a container for the log buffer view + (optional) member list.
auto container = GSplitter::construct(Orientation::Horizontal, this);

View File

@ -111,15 +111,15 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent)
auto color_container = GWidget::construct(this);
color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32);
color_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
color_container->set_layout(make<GVBoxLayout>());
color_container->layout()->set_spacing(1);
auto top_color_container = GWidget::construct(color_container.ptr());
top_color_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
top_color_container->set_layout(make<GHBoxLayout>());
top_color_container->layout()->set_spacing(1);
auto bottom_color_container = GWidget::construct(color_container.ptr());
bottom_color_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
bottom_color_container->set_layout(make<GHBoxLayout>());
bottom_color_container->layout()->set_spacing(1);
auto add_color_widget = [&](GWidget* container, Color color) {

View File

@ -73,7 +73,7 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
set_preferred_size(48, 0);
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {

View File

@ -60,13 +60,13 @@ int main(int argc, char** argv)
auto horizontal_container = GWidget::construct();
window->set_main_widget(horizontal_container);
horizontal_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
horizontal_container->set_layout(make<GHBoxLayout>());
horizontal_container->layout()->set_spacing(0);
new ToolboxWidget(horizontal_container);
auto vertical_container = GWidget::construct(horizontal_container.ptr());
vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
vertical_container->set_layout(make<GVBoxLayout>());
vertical_container->layout()->set_spacing(0);
auto paintable_widget = PaintableWidget::construct(vertical_container);

View File

@ -40,11 +40,11 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget&
set_frame_thickness(2);
set_frame_shadow(FrameShadow::Sunken);
set_frame_shape(FrameShape::Container);
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
set_fill_with_background_color(true);
m_labels_container = GWidget::construct(this);
m_labels_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_labels_container->set_layout(make<GHBoxLayout>());
m_labels_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_labels_container->set_preferred_size(0, 20);
@ -54,7 +54,7 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget&
m_delay_label = GLabel::construct("Delay", m_labels_container);
m_values_container = GWidget::construct(this);
m_values_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_values_container->set_layout(make<GHBoxLayout>());
m_values_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_values_container->set_preferred_size(0, 10);
@ -64,7 +64,7 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget&
m_delay_value = GLabel::construct(String::number(m_audio_engine.delay() / m_audio_engine.tick()), m_values_container);
m_knobs_container = GWidget::construct(this);
m_knobs_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_knobs_container->set_layout(make<GHBoxLayout>());
// FIXME: Implement vertical flipping in GSlider, not here.

View File

@ -36,7 +36,7 @@
MainWidget::MainWidget(AudioEngine& audio_engine)
: m_audio_engine(audio_engine)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_spacing(2);
layout()->set_margins({ 2, 2, 2, 2 });
set_fill_with_background_color(true);
@ -50,7 +50,7 @@ MainWidget::MainWidget(AudioEngine& audio_engine)
m_roll_widget->set_preferred_size(0, 300);
m_keys_and_knobs_container = GWidget::construct(this);
m_keys_and_knobs_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_keys_and_knobs_container->set_layout(make<GHBoxLayout>());
m_keys_and_knobs_container->layout()->set_spacing(2);
m_keys_and_knobs_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_keys_and_knobs_container->set_preferred_size(0, 100);

View File

@ -38,12 +38,12 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConne
, m_manager(connection)
{
set_fill_with_background_color(true);
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 2, 2, 2, 2 });
auto status_widget = GWidget::construct(this);
status_widget->set_fill_with_background_color(true);
status_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
status_widget->set_layout(make<GHBoxLayout>());
m_elapsed = GLabel::construct(status_widget);
m_elapsed->set_frame_shape(FrameShape::Container);
@ -53,7 +53,7 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConne
m_elapsed->set_preferred_size(80, 0);
auto sample_widget_container = GWidget::construct(status_widget.ptr());
sample_widget_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
sample_widget_container->set_layout(make<GHBoxLayout>());
sample_widget_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
m_sample_widget = SampleWidget::construct(sample_widget_container);
@ -72,7 +72,7 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConne
auto control_widget = GWidget::construct(this);
control_widget->set_fill_with_background_color(true);
control_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
control_widget->set_layout(make<GHBoxLayout>());
control_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
control_widget->set_preferred_size(0, 30);
control_widget->layout()->set_margins({ 10, 2, 10, 2 });

View File

@ -52,13 +52,13 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 72);
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 0, 8, 0, 0 });
layout()->set_spacing(3);
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GLabel> {
auto container = GWidget::construct(this);
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
container->set_layout(make<GHBoxLayout>());
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
container->set_preferred_size(275, 12);
auto description_label = GLabel::construct(description, container);

View File

@ -34,12 +34,12 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
: GLazyWidget(parent)
{
on_first_show = [this](auto&) {
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
set_fill_with_background_color(true);
auto adapters_group_box = GGroupBox::construct("Adapters", this);
adapters_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
adapters_group_box->set_layout(make<GVBoxLayout>());
adapters_group_box->layout()->set_margins({ 6, 16, 6, 6 });
adapters_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
adapters_group_box->set_preferred_size(0, 120);
@ -59,7 +59,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
m_adapter_table_view->set_model(GJsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
auto sockets_group_box = GGroupBox::construct("Sockets", this);
sockets_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
sockets_group_box->set_layout(make<GVBoxLayout>());
sockets_group_box->layout()->set_margins({ 6, 16, 6, 6 });
sockets_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
sockets_group_box->set_preferred_size(0, 0);

View File

@ -32,7 +32,7 @@
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View File

@ -34,7 +34,7 @@
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View File

@ -32,7 +32,7 @@
ProcessStacksWidget::ProcessStacksWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_stacks_editor = GTextEditor::construct(GTextEditor::Type::MultiLine, this);
m_stacks_editor->set_readonly(true);

View File

@ -32,7 +32,7 @@
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_margins({ 4, 4, 4, 4 });
m_table_view = GTableView::construct(this);
m_table_view->set_size_columns_to_fit_content(true);

View File

@ -116,7 +116,7 @@ int main(int argc, char** argv)
auto keeper = GWidget::construct();
window->set_main_widget(keeper);
keeper->set_layout(make<GBoxLayout>(Orientation::Vertical));
keeper->set_layout(make<GVBoxLayout>());
keeper->set_fill_with_background_color(true);
keeper->layout()->set_margins({ 4, 4, 4, 4 });
@ -138,7 +138,7 @@ int main(int argc, char** argv)
auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr);
tabwidget->add_widget("Network", network_stats_widget);
process_table_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
process_table_container->set_layout(make<GVBoxLayout>());
process_table_container->layout()->set_margins({ 4, 0, 4, 4 });
process_table_container->layout()->set_spacing(0);
@ -279,7 +279,7 @@ RefPtr<GWidget> build_file_systems_tab()
auto fs_widget = GLazyWidget::construct();
fs_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto fs_table_view = GTableView::construct(&self);
fs_table_view->set_size_columns_to_fit_content(true);
@ -368,7 +368,7 @@ RefPtr<GWidget> build_pci_devices_tab()
auto pci_widget = GLazyWidget::construct();
pci_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto pci_table_view = GTableView::construct(&self);
pci_table_view->set_size_columns_to_fit_content(true);
@ -426,7 +426,7 @@ RefPtr<GWidget> build_devices_tab()
auto devices_widget = GLazyWidget::construct();
devices_widget->on_first_show = [](auto& self) {
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto devices_table_view = GTableView::construct(&self);
@ -445,11 +445,11 @@ NonnullRefPtr<GWidget> build_graphs_tab()
graphs_container->on_first_show = [](auto& self) {
self.set_fill_with_background_color(true);
self.set_background_role(ColorRole::Button);
self.set_layout(make<GBoxLayout>(Orientation::Vertical));
self.set_layout(make<GVBoxLayout>());
self.layout()->set_margins({ 4, 4, 4, 4 });
auto cpu_graph_group_box = GGroupBox::construct("CPU usage", &self);
cpu_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
cpu_graph_group_box->set_layout(make<GVBoxLayout>());
cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
cpu_graph_group_box->set_preferred_size(0, 120);
@ -466,7 +466,7 @@ NonnullRefPtr<GWidget> build_graphs_tab()
};
auto memory_graph_group_box = GGroupBox::construct("Memory usage", &self);
memory_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
memory_graph_group_box->set_layout(make<GVBoxLayout>());
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
memory_graph_group_box->set_preferred_size(0, 120);

View File

@ -48,7 +48,7 @@ TaskbarWindow::TaskbarWindow()
auto widget = GFrame::construct();
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
widget->set_layout(make<GHBoxLayout>());
widget->layout()->set_margins({ 3, 2, 3, 2 });
widget->layout()->set_spacing(3);
widget->set_frame_thickness(1);
@ -71,7 +71,7 @@ void TaskbarWindow::create_quick_launch_bar()
{
auto quick_launch_bar = GFrame::construct(main_widget());
quick_launch_bar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
quick_launch_bar->set_layout(make<GBoxLayout>(Orientation::Horizontal));
quick_launch_bar->set_layout(make<GHBoxLayout>());
quick_launch_bar->layout()->set_spacing(3);
quick_launch_bar->layout()->set_margins({ 3, 0, 3, 0 });
quick_launch_bar->set_frame_thickness(1);

View File

@ -135,11 +135,11 @@ RefPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigF
window->set_main_widget(settings);
settings->set_fill_with_background_color(true);
settings->set_background_role(ColorRole::Button);
settings->set_layout(make<GBoxLayout>(Orientation::Vertical));
settings->set_layout(make<GVBoxLayout>());
settings->layout()->set_margins({ 4, 4, 4, 4 });
auto radio_container = GGroupBox::construct("Bell Mode", settings);
radio_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
radio_container->set_layout(make<GVBoxLayout>());
radio_container->layout()->set_margins({ 6, 16, 6, 6 });
radio_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
radio_container->set_preferred_size(100, 70);
@ -153,7 +153,7 @@ RefPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigF
};
auto slider_container = GGroupBox::construct("Background Opacity", settings);
slider_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
slider_container->set_layout(make<GVBoxLayout>());
slider_container->layout()->set_margins({ 6, 16, 6, 6 });
slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
slider_container->set_preferred_size(100, 50);

View File

@ -45,7 +45,7 @@
TextEditorWidget::TextEditorWidget()
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
layout()->set_spacing(0);
auto toolbar = GToolBar::construct(this);
@ -71,7 +71,7 @@ TextEditorWidget::TextEditorWidget()
m_find_replace_widget->set_fill_with_background_color(true);
m_find_replace_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_find_replace_widget->set_preferred_size(0, 48);
m_find_replace_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
m_find_replace_widget->set_layout(make<GVBoxLayout>());
m_find_replace_widget->layout()->set_margins({ 2, 2, 2, 4 });
m_find_replace_widget->set_visible(false);
@ -79,14 +79,14 @@ TextEditorWidget::TextEditorWidget()
m_find_widget->set_fill_with_background_color(true);
m_find_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_find_widget->set_preferred_size(0, 22);
m_find_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_find_widget->set_layout(make<GHBoxLayout>());
m_find_widget->set_visible(false);
m_replace_widget = GWidget::construct(m_find_replace_widget);
m_replace_widget->set_fill_with_background_color(true);
m_replace_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_replace_widget->set_preferred_size(0, 22);
m_replace_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
m_replace_widget->set_layout(make<GHBoxLayout>());
m_replace_widget->set_visible(false);
m_find_textbox = GTextBox::construct(m_find_widget);

View File

@ -98,7 +98,7 @@ int main(int argc, char** argv)
auto background = GLabel::construct();
window->set_main_widget(background);
background->set_fill_with_background_color(true);
background->set_layout(make<GBoxLayout>(Orientation::Vertical));
background->set_layout(make<GVBoxLayout>());
background->layout()->set_margins({ 8, 8, 8, 8 });
background->layout()->set_spacing(8);
background->set_icon(load_png_from_memory((const u8*)&_binary_background_png_start, (size_t)&_binary_background_png_size));
@ -121,13 +121,13 @@ int main(int argc, char** argv)
//
auto main_section = GWidget::construct(background.ptr());
main_section->set_layout(make<GBoxLayout>(Orientation::Horizontal));
main_section->set_layout(make<GHBoxLayout>());
main_section->layout()->set_margins({ 0, 0, 0, 0 });
main_section->layout()->set_spacing(8);
main_section->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
auto menu = GWidget::construct(main_section.ptr());
menu->set_layout(make<GBoxLayout>(Orientation::Vertical));
menu->set_layout(make<GVBoxLayout>());
menu->layout()->set_margins({ 0, 0, 0, 0 });
menu->layout()->set_spacing(8);
menu->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
@ -138,7 +138,7 @@ int main(int argc, char** argv)
for (auto& page : pages) {
auto content = GWidget::construct(stack.ptr());
content->set_layout(make<GBoxLayout>(Orientation::Vertical));
content->set_layout(make<GVBoxLayout>());
content->layout()->set_margins({ 0, 0, 0, 0 });
content->layout()->set_spacing(8);
content->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);

View File

@ -43,7 +43,7 @@ int main(int argc, char** argv)
window->set_main_widget(main_widget);
main_widget->set_fill_with_background_color(true);
main_widget->set_background_color(Color::White);
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
main_widget->set_layout(make<GVBoxLayout>());
main_widget->layout()->set_margins({ 4, 4, 4, 4 });
auto label = GLabel::construct(main_widget);

View File

@ -51,7 +51,7 @@ int main(int argc, char** argv)
auto main_widget = GWidget::construct();
window->set_main_widget(main_widget);
main_widget->set_fill_with_background_color(true);
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
main_widget->set_layout(make<GVBoxLayout>());
main_widget->layout()->set_margins({ 4, 4, 4, 4 });
auto checkbox1 = GCheckBox::construct("GCheckBox 1", main_widget);
@ -95,7 +95,7 @@ int main(int argc, char** argv)
auto vertical_slider_container = GWidget::construct(main_widget.ptr());
vertical_slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
vertical_slider_container->set_preferred_size(0, 100);
vertical_slider_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
vertical_slider_container->set_layout(make<GHBoxLayout>());
auto vslider1 = GSlider::construct(Orientation::Vertical, vertical_slider_container);
(void)vslider1;
auto vslider2 = GSlider::construct(Orientation::Vertical, vertical_slider_container);

View File

@ -36,13 +36,13 @@ extern RefPtr<EditorWrapper> g_current_editor_wrapper;
EditorWrapper::EditorWrapper(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
auto label_wrapper = GWidget::construct(this);
label_wrapper->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
label_wrapper->set_preferred_size(0, 14);
label_wrapper->set_fill_with_background_color(true);
label_wrapper->set_layout(make<GBoxLayout>(Orientation::Horizontal));
label_wrapper->set_layout(make<GHBoxLayout>());
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
m_filename_label = GLabel::construct("(Untitled)", label_wrapper);

View File

@ -130,7 +130,7 @@ static RefPtr<SearchResultsModel> find_in_files(const StringView& text)
FindInFilesWidget::FindInFilesWidget(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
m_textbox = GTextBox::construct(this);
m_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_textbox->set_preferred_size(0, 20);

View File

@ -107,7 +107,7 @@ Locator::Locator(GWidget* parent)
s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png");
}
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 20);
m_textbox = LocatorTextBox::construct(this);

View File

@ -38,7 +38,7 @@ ProcessStateWidget::ProcessStateWidget(GWidget* parent)
set_preferred_size(0, 20);
set_visible(false);
set_layout(make<GBoxLayout>(Orientation::Horizontal));
set_layout(make<GHBoxLayout>());
auto pid_label_label = GLabel::construct("Process:", this);
pid_label_label->set_font(Font::default_bold_font());

View File

@ -161,7 +161,7 @@ void TerminalWrapper::kill_running_command()
TerminalWrapper::TerminalWrapper(GWidget* parent)
: GWidget(parent)
{
set_layout(make<GBoxLayout>(Orientation::Vertical));
set_layout(make<GVBoxLayout>());
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
m_terminal_widget = TerminalWidget::construct(-1, false, config);

View File

@ -145,7 +145,7 @@ int main(int argc, char** argv)
g_window->set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
StringBuilder path;
@ -266,7 +266,7 @@ int main(int argc, char** argv)
g_right_hand_stack = GStackWidget::construct(outer_splitter);
g_form_inner_container = GWidget::construct(g_right_hand_stack);
g_form_inner_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
g_form_inner_container->set_layout(make<GHBoxLayout>());
auto form_widgets_toolbar = GToolBar::construct(Orientation::Vertical, 26, g_form_inner_container);
form_widgets_toolbar->set_preferred_size(38, 0);
@ -303,11 +303,11 @@ int main(int argc, char** argv)
auto form_editing_pane_container = GSplitter::construct(Orientation::Vertical, form_editor_inner_splitter);
form_editing_pane_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
form_editing_pane_container->set_preferred_size(190, 0);
form_editing_pane_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
form_editing_pane_container->set_layout(make<GVBoxLayout>());
auto add_properties_pane = [&](auto& text, auto pane_widget) {
auto wrapper = GWidget::construct(form_editing_pane_container.ptr());
wrapper->set_layout(make<GBoxLayout>(Orientation::Vertical));
wrapper->set_layout(make<GVBoxLayout>());
auto label = GLabel::construct(text, wrapper);
label->set_fill_with_background_color(true);
label->set_text_alignment(TextAlignment::CenterLeft);

View File

@ -61,7 +61,7 @@ int main(int argc, char** argv)
auto widget = GWidget::construct();
window->set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
auto splitter = GSplitter::construct(Orientation::Horizontal, widget);

View File

@ -59,7 +59,7 @@ int main(int argc, char** argv)
auto main_widget = GWidget::construct();
window->set_main_widget(main_widget);
main_widget->set_fill_with_background_color(true);
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
main_widget->set_layout(make<GVBoxLayout>());
auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);

View File

@ -66,13 +66,13 @@ VBForm::VBForm(const String& name, GWidget* parent)
m_context_menu->add_action(GAction::create("Lay out horizontally", load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) {
if (auto* widget = single_selected_widget()) {
dbg() << "Giving " << *widget->gwidget() << " a horizontal box layout";
widget->gwidget()->set_layout(make<GBoxLayout>(Orientation::Horizontal));
widget->gwidget()->set_layout(make<GHBoxLayout>());
}
}));
m_context_menu->add_action(GAction::create("Lay out vertically", load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) {
if (auto* widget = single_selected_widget()) {
dbg() << "Giving " << *widget->gwidget() << " a vertical box layout";
widget->gwidget()->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->gwidget()->set_layout(make<GVBoxLayout>());
}
}));
m_context_menu->add_separator();

View File

@ -83,7 +83,7 @@ VBPropertiesWindow::VBPropertiesWindow()
auto widget = GWidget::construct();
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_margins({ 2, 2, 2, 2 });
set_main_widget(widget);

View File

@ -108,7 +108,7 @@ RefPtr<GWindow> make_toolbox_window()
auto widget = GWidget::construct();
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
window->set_main_widget(widget);

View File

@ -60,14 +60,14 @@ int main(int argc, char** argv)
auto widget = GWidget::construct();
window->set_main_widget(widget);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->layout()->set_spacing(0);
auto container = GWidget::construct(widget.ptr());
container->set_fill_with_background_color(true);
container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
container->set_preferred_size(0, 36);
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
container->set_layout(make<GHBoxLayout>());
auto flag_icon_label = GLabel::construct(container);
flag_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png"));
auto flag_label = GLabel::construct(container);

View File

@ -42,12 +42,12 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C
auto widget = GWidget::construct();
set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
widget->set_layout(make<GHBoxLayout>());
auto left_container = GWidget::construct(widget.ptr());
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
left_container->set_preferred_size(48, 0);
left_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
left_container->set_layout(make<GVBoxLayout>());
auto icon_label = GLabel::construct(left_container);
icon_label->set_icon(m_icon);
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
@ -55,7 +55,7 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C
left_container->layout()->add_spacer();
auto right_container = GWidget::construct(widget.ptr());
right_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
right_container->set_layout(make<GVBoxLayout>());
right_container->layout()->set_margins({ 0, 4, 4, 4 });
auto make_label = [&](const StringView& text, bool bold = false) {
@ -75,7 +75,7 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C
auto button_container = GWidget::construct(right_container.ptr());
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
button_container->set_preferred_size(0, 20);
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container->set_layout(make<GHBoxLayout>());
button_container->layout()->add_spacer();
auto ok_button = GButton::construct("OK", button_container);
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);

View File

@ -35,10 +35,6 @@ GBoxLayout::GBoxLayout(Orientation orientation)
{
}
GBoxLayout::~GBoxLayout()
{
}
void GBoxLayout::run(GWidget& widget)
{
bool should_log = false;

View File

@ -29,10 +29,10 @@
#include <LibGUI/GLayout.h>
#include <LibGUI/GWidget.h>
class GBoxLayout final : public GLayout {
class GBoxLayout : public GLayout {
public:
explicit GBoxLayout(Orientation);
virtual ~GBoxLayout() override;
virtual ~GBoxLayout() override {}
Orientation orientation() const { return m_orientation; }
@ -41,3 +41,21 @@ public:
private:
Orientation m_orientation;
};
class GVBoxLayout final : public GBoxLayout {
public:
explicit GVBoxLayout()
: GBoxLayout(Orientation::Vertical)
{
}
virtual ~GVBoxLayout() override {}
};
class GHBoxLayout final : public GBoxLayout {
public:
explicit GHBoxLayout()
: GBoxLayout(Orientation::Horizontal)
{
}
virtual ~GHBoxLayout() override {}
};

View File

@ -47,15 +47,15 @@ void GColorPicker::build()
{
auto horizontal_container = GWidget::construct();
horizontal_container->set_fill_with_background_color(true);
horizontal_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
horizontal_container->set_layout(make<GHBoxLayout>());
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
set_main_widget(horizontal_container);
auto left_vertical_container = GWidget::construct(horizontal_container.ptr());
left_vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
left_vertical_container->set_layout(make<GVBoxLayout>());
auto right_vertical_container = GWidget::construct(horizontal_container.ptr());
right_vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
right_vertical_container->set_layout(make<GVBoxLayout>());
enum RGBComponent {
Red,

View File

@ -81,16 +81,16 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
set_rect(200, 200, 700, 400);
auto horizontal_container = GWidget::construct();
set_main_widget(horizontal_container);
horizontal_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
horizontal_container->set_layout(make<GHBoxLayout>());
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
horizontal_container->set_fill_with_background_color(true);
auto vertical_container = GWidget::construct(horizontal_container.ptr());
vertical_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
vertical_container->set_layout(make<GVBoxLayout>());
vertical_container->layout()->set_spacing(4);
auto upper_container = GWidget::construct(vertical_container.ptr());
upper_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
upper_container->set_layout(make<GHBoxLayout>());
upper_container->layout()->set_spacing(4);
upper_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
upper_container->set_preferred_size(0, 26);
@ -148,7 +148,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
toolbar->add_action(*mkdir_action);
auto lower_container = GWidget::construct(vertical_container.ptr());
lower_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
lower_container->set_layout(make<GVBoxLayout>());
lower_container->layout()->set_spacing(4);
lower_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
lower_container->set_preferred_size(0, 60);
@ -156,7 +156,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
auto filename_container = GWidget::construct(lower_container.ptr());
filename_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
filename_container->set_preferred_size(0, 20);
filename_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
filename_container->set_layout(make<GHBoxLayout>());
auto filename_label = GLabel::construct("File name:", filename_container);
filename_label->set_text_alignment(TextAlignment::CenterLeft);
filename_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
@ -187,7 +187,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
auto button_container = GWidget::construct(lower_container.ptr());
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
button_container->set_preferred_size(0, 20);
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container->set_layout(make<GHBoxLayout>());
button_container->layout()->set_spacing(4);
button_container->layout()->add_spacer();
@ -227,7 +227,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
preview_container->set_frame_shape(FrameShape::Container);
preview_container->set_frame_shadow(FrameShadow::Sunken);
preview_container->set_frame_thickness(2);
preview_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
preview_container->set_layout(make<GVBoxLayout>());
preview_container->layout()->set_margins({ 8, 8, 8, 8 });
m_preview_image_label = GLabel::construct(preview_container);

View File

@ -54,7 +54,7 @@ void GInputBox::build()
set_rect(x(), y(), max_width + 80, 80);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->set_fill_with_background_color(true);
widget->layout()->set_margins({ 8, 8, 8, 8 });
@ -71,10 +71,10 @@ void GInputBox::build()
auto button_container_outer = GWidget::construct(widget.ptr());
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
button_container_outer->set_preferred_size(0, 20);
button_container_outer->set_layout(make<GBoxLayout>(Orientation::Vertical));
button_container_outer->set_layout(make<GVBoxLayout>());
auto button_container_inner = GWidget::construct(button_container_outer.ptr());
button_container_inner->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container_inner->set_layout(make<GHBoxLayout>());
button_container_inner->layout()->set_spacing(8);
m_cancel_button = GButton::construct(button_container_inner);

View File

@ -82,7 +82,7 @@ void GMessageBox::build()
int text_width = widget->font().width(m_text);
int icon_width = 0;
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
widget->set_layout(make<GVBoxLayout>());
widget->set_fill_with_background_color(true);
widget->layout()->set_margins({ 0, 15, 0, 15 });
@ -91,7 +91,7 @@ void GMessageBox::build()
RefPtr<GWidget> message_container = widget;
if (m_type != Type::None) {
message_container = GWidget::construct(widget.ptr());
message_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
message_container->set_layout(make<GHBoxLayout>());
message_container->layout()->set_margins({ 8, 0, 8, 0 });
message_container->layout()->set_spacing(8);
@ -107,7 +107,7 @@ void GMessageBox::build()
label->set_preferred_size(text_width, 16);
auto button_container = GWidget::construct(widget.ptr());
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
button_container->set_layout(make<GHBoxLayout>());
button_container->layout()->set_spacing(5);
button_container->layout()->set_margins({ 15, 0, 15, 0 });

View File

@ -41,7 +41,7 @@ GStatusBar::GStatusBar(int label_count, GWidget* parent)
{
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 20);
set_layout(make<GBoxLayout>(Orientation::Horizontal));
set_layout(make<GHBoxLayout>());
layout()->set_margins({ 2, 2, 2, 2 });
layout()->set_spacing(2);