summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Demos/WidgetGallery/CMakeLists.txt13
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml377
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/CursorsTab.gml16
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/IconsTab.gml16
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml168
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/Window.gml10
-rw-r--r--Userland/Demos/WidgetGallery/GalleryGML/WizardsTab.gml25
-rw-r--r--Userland/Demos/WidgetGallery/GalleryModels.h216
-rw-r--r--Userland/Demos/WidgetGallery/GalleryWidget.cpp398
-rw-r--r--Userland/Demos/WidgetGallery/GalleryWidget.h90
-rw-r--r--Userland/Demos/WidgetGallery/main.cpp532
11 files changed, 1347 insertions, 514 deletions
diff --git a/Userland/Demos/WidgetGallery/CMakeLists.txt b/Userland/Demos/WidgetGallery/CMakeLists.txt
index 4fb67e3285..69179e26a2 100644
--- a/Userland/Demos/WidgetGallery/CMakeLists.txt
+++ b/Userland/Demos/WidgetGallery/CMakeLists.txt
@@ -1,8 +1,21 @@
+compile_gml(./GalleryGML/Window.gml WindowGML.h window_gml)
+compile_gml(./GalleryGML/BasicsTab.gml BasicsTabGML.h basics_tab_gml)
+compile_gml(./GalleryGML/SlidersTab.gml SlidersTabGML.h sliders_tab_gml)
+compile_gml(./GalleryGML/CursorsTab.gml CursorsTabGML.h cursors_tab_gml)
+compile_gml(./GalleryGML/IconsTab.gml IconsTabGML.h icons_tab_gml)
+compile_gml(./GalleryGML/WizardsTab.gml WizardsTabGML.h wizards_tab_gml)
compile_gml(DemoWizardPage1.gml DemoWizardPage1GML.h demo_wizard_page_1_gml)
compile_gml(DemoWizardPage2.gml DemoWizardPage2GML.h demo_wizard_page_2_gml)
set(SOURCES
main.cpp
+ GalleryWidget.cpp
+ WindowGML.h
+ BasicsTabGML.h
+ SlidersTabGML.h
+ CursorsTabGML.h
+ IconsTabGML.h
+ WizardsTabGML.h
DemoWizardDialog.cpp
DemoWizardPage1GML.h
DemoWizardPage2GML.h
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml
new file mode 100644
index 0000000000..dfd3f03ff6
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml
@@ -0,0 +1,377 @@
+@GUI::Widget {
+ name: "basics_tab"
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::GroupBox {
+ fixed_height: 95
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::HorizontalSplitter {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Frame {
+ name: "label_frame"
+ shape: "Panel"
+ shadow: "Sunken"
+ thickness: 1
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 3, 4, 3]
+ }
+
+ @GUI::Label {
+ name: "enabled_label"
+ text: "Label"
+ }
+
+ @GUI::Label {
+ name: "disabled_label"
+ text: "Disabled"
+ enabled: false
+ }
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 0, 4, 0]
+ }
+
+ @GUI::Label {
+ name: "word_wrap_label"
+ word_wrap: true
+ text_alignment: "TopLeft"
+ text: "Lorem ipsum sistema serenitas, per construxit klingre sed quis awesomatia, ergo salve amici."
+ }
+ }
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Widget {
+ fixed_height: 22
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::ComboBox {
+ name: "frame_shape_combobox"
+ placeholder: "Combo box"
+ }
+
+ @GUI::ComboBox {
+ placeholder: "Disabled"
+ enabled: false
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::SpinBox {
+ name: "thickness_spinbox"
+ min: 0
+ max: 2
+ }
+
+ @GUI::SpinBox {
+ enabled: false
+ }
+ }
+ }
+
+ @GUI::Widget {
+ fixed_height: 125
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 3, 8, 3]
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::Button {
+ name: "normal_button"
+ text: "Button"
+ }
+
+ @GUI::Button {
+ name: "disabled_normal_button"
+ text: "Disabled"
+ enabled: "false"
+ }
+
+ @GUI::Widget {
+ }
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::Button {
+ name: "enabled_coolbar_button"
+ text: "CoolBar button"
+ button_style: "CoolBar"
+ }
+
+ @GUI::Button {
+ name: "disabled_coolbar_button"
+ text: "Disabled"
+ enabled: "false"
+ button_style: "CoolBar"
+ }
+
+ @GUI::Widget {
+ }
+ }
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Widget {
+ fixed_width: 60
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::RadioButton {
+ name: "top_radiobutton"
+ text: "Radio 1"
+ checked: true
+ }
+
+ @GUI::RadioButton {
+ name: "bottom_radiobutton"
+ text: "Radio 2"
+ }
+
+ @GUI::Widget {
+ }
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::Widget {
+ fixed_width: 70
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::CheckBox {
+ name: "top_checkbox"
+ text: "Checkbox"
+ }
+
+ @GUI::CheckBox {
+ name: "bottom_checkbox"
+ text: "Disabled"
+ enabled: false
+ }
+
+ @GUI::Widget {
+ }
+ }
+
+ @GUI::Widget {
+ }
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::Button {
+ name: "icon_button"
+ text: "Icon button"
+
+ }
+
+ @GUI::Button {
+ name: "disabled_icon_button"
+ text: "Disabled"
+ enabled: "false"
+
+ }
+
+ @GUI::Widget {
+ }
+ }
+ }
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::Widget {
+ fixed_height: 47
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::TextBox {
+ placeholder: "Text box"
+ mode: "Editable"
+ }
+
+ @GUI::TextBox {
+ text: "Disabled"
+ enabled: false
+ }
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::TextBox {
+ text: "Read only"
+ mode: "ReadOnly"
+ }
+
+ @GUI::TextBox {
+ text: "Display only"
+ mode: "DisplayOnly"
+ }
+ }
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::TextEditor {
+ name: "text_editor"
+ placeholder: "Text editor"
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::VerticalBoxLayout {
+ }
+
+ @GUI::Widget {
+ fixed_height: 22
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::ColorInput {
+ name: "font_colorinput"
+ placeholder: "Color dialog"
+ }
+
+ @GUI::ColorInput {
+ placeholder: "Disabled"
+ enabled: false
+ }
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::Button {
+ name: "font_button"
+ text: "Font picker dialog..."
+ }
+
+ @GUI::Button {
+ name: "file_button"
+ text: "File picker dialog..."
+ }
+
+ @GUI::Button {
+ name: "input_button"
+ text: "Input dialog..."
+ }
+
+ @GUI::Widget {
+ }
+ }
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Widget {
+ fixed_height: 22
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::ComboBox {
+ name: "msgbox_icon_combobox"
+ model_only: true
+ }
+
+ @GUI::ComboBox {
+ name: "msgbox_buttons_combobox"
+ model_only: true
+ }
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::Button {
+ name: "msgbox_button"
+ text: "Message box dialog..."
+ }
+ }
+ }
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/CursorsTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/CursorsTab.gml
new file mode 100644
index 0000000000..e610f819b8
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/CursorsTab.gml
@@ -0,0 +1,16 @@
+@GUI::Widget {
+ name: "cursors_tab"
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::TableView {
+ name: "cursors_tableview"
+ }
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/IconsTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/IconsTab.gml
new file mode 100644
index 0000000000..d6d1533759
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/IconsTab.gml
@@ -0,0 +1,16 @@
+@GUI::Widget {
+ name: "icons_tab"
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::TableView {
+ name: "icons_tableview"
+ }
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml
new file mode 100644
index 0000000000..87943af289
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml
@@ -0,0 +1,168 @@
+@GUI::Widget {
+ name: "sliders_tab"
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::GroupBox {
+ fixed_height: 129
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::OpacitySlider {
+ name: "opacity_slider"
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Frame {
+ shape: "Panel"
+ shadow: "Sunken"
+ thickness: 1
+ max_width: 394
+ max_height: 79
+ layout: @GUI::VerticalBoxLayout {
+ margins: [1, 1, 1, 1]
+ }
+
+ @GUI::ImageWidget {
+ name: "opacity_imagewidget"
+ }
+ }
+ }
+
+ @GUI::Widget {
+ fixed_height: 88
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 0, 8, 0]
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::ScrollBar {
+ name: "enabled_scrollbar"
+ fixed_height: 16
+ fixed_width: -1
+ min: 0
+ max: 100
+ value: 50
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::Widget {
+ }
+
+ @GUI::ScrollBar {
+ name: "disabled_scrollbar"
+ fixed_height: 16
+ fixed_width: -1
+ }
+
+ @GUI::Widget {
+ }
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::HorizontalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::VerticalProgressBar {
+ name: "vertical_progressbar_left"
+ fixed_width: 36
+ }
+
+ @GUI::VerticalSlider {
+ name: "vertical_slider_left"
+ knob_size_mode: "Fixed"
+ min: 0
+ max: 100
+ value: 100
+ tooltip: "Fixed"
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::VerticalSlider {
+ enabled: false
+ tooltip: "Disabled"
+ min: 0
+ max: 10
+ value: 5
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::VerticalProgressBar {
+ name: "vertical_progressbar_right"
+ fixed_width: 36
+ }
+
+ @GUI::VerticalSlider {
+ name: "vertical_slider_right"
+ knob_size_mode: "Proportional"
+ min: 0
+ max: 4
+ value: 0
+ tooltip: "Proportional"
+ }
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ }
+
+ @GUI::HorizontalSlider {
+ name: "horizontal_slider_left"
+ knob_size_mode: "Fixed"
+ min: 0
+ max: 100
+ value: 0
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::HorizontalSlider {
+ enabled: false
+ min: 0
+ max: 10
+ value: 5
+ }
+
+ @GUI::VerticalSeparator {
+ }
+
+ @GUI::HorizontalSlider {
+ name: "horizontal_slider_right"
+ knob_size_mode: "Proportional"
+ min: 0
+ max: 5
+ value: 0
+ }
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::HorizontalProgressBar {
+ name: "horizontal_progressbar"
+ fixed_height: 20
+ }
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/Window.gml b/Userland/Demos/WidgetGallery/GalleryGML/Window.gml
new file mode 100644
index 0000000000..33fd586ad5
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/Window.gml
@@ -0,0 +1,10 @@
+@GUI::Widget {
+ fill_with_background_color: true
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::TabWidget {
+ name: "tab_widget"
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryGML/WizardsTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/WizardsTab.gml
new file mode 100644
index 0000000000..2466a748d0
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryGML/WizardsTab.gml
@@ -0,0 +1,25 @@
+@GUI::Widget {
+ name: "wizards_tab"
+ layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
+ }
+
+ @GUI::GroupBox {
+ layout: @GUI::VerticalBoxLayout {
+ margins: [8, 8, 8, 8]
+ }
+
+ @GUI::Button {
+ name: "wizard_button"
+ text: "Start wizard"
+ }
+
+ @GUI::HorizontalSeparator {
+ }
+
+ @GUI::TextEditor {
+ name: "wizard_output"
+ mode: "ReadOnly"
+ }
+ }
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h
new file mode 100644
index 0000000000..07d4791428
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryModels.h
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <AK/NonnullRefPtr.h>
+#include <AK/Vector.h>
+#include <LibCore/DirIterator.h>
+#include <LibGUI/Model.h>
+
+class MouseCursorModel final : public GUI::Model {
+public:
+ static NonnullRefPtr<MouseCursorModel> create() { return adopt(*new MouseCursorModel); }
+ virtual ~MouseCursorModel() override { }
+
+ enum Column {
+ Bitmap,
+ Name,
+ __Count,
+ };
+
+ virtual int row_count(const GUI::ModelIndex&) const override { return m_cursors.size(); }
+ virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
+ virtual String column_name(int column_index) const override
+ {
+ switch (column_index) {
+ case Column::Bitmap:
+ return {};
+ case Column::Name:
+ return "Name";
+ }
+ VERIFY_NOT_REACHED();
+ }
+ virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override
+ {
+ auto& cursor = m_cursors[index.row()];
+
+ if (role == GUI::ModelRole::Display) {
+ switch (index.column()) {
+ case Column::Bitmap:
+ if (!cursor.bitmap)
+ return {};
+ return *cursor.bitmap;
+ case Column::Name:
+ return cursor.name;
+ }
+ VERIFY_NOT_REACHED();
+ }
+ return {};
+ }
+ virtual void update() override
+ {
+ m_cursors.clear();
+
+ Core::DirIterator iterator("/res/cursors", Core::DirIterator::Flags::SkipDots);
+
+ while (iterator.has_next()) {
+ auto path = iterator.next_path();
+ if (path.contains("2x"))
+ continue;
+ Cursor cursor;
+ StringBuilder full_path;
+ full_path.append("/res/cursors/");
+ full_path.append(path);
+ cursor.path = full_path.to_string();
+ cursor.bitmap = Gfx::Bitmap::load_from_file(cursor.path);
+ auto filename_split = path.split('.');
+ cursor.name = filename_split[0];
+ m_cursors.append(move(cursor));
+ }
+
+ did_update();
+ }
+
+private:
+ MouseCursorModel() { }
+
+ struct Cursor {
+ RefPtr<Gfx::Bitmap> bitmap;
+ String path;
+ String name;
+ };
+
+ Vector<Cursor> m_cursors;
+};
+
+class FileIconsModel final : public GUI::Model {
+public:
+ static NonnullRefPtr<MouseCursorModel> create() { return adopt(*new FileIconsModel); }
+ virtual ~FileIconsModel() override { }
+
+ enum Column {
+ BigIcon,
+ LittleIcon,
+ Name,
+ __Count,
+ };
+
+ virtual int row_count(const GUI::ModelIndex&) const override { return m_icon_sets.size(); }
+ virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
+ virtual String column_name(int column_index) const override
+ {
+ switch (column_index) {
+ case Column::BigIcon:
+ return {};
+ case Column::LittleIcon:
+ return {};
+ case Column::Name:
+ return "Name";
+ }
+ VERIFY_NOT_REACHED();
+ }
+ virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override
+ {
+ auto& icon_set = m_icon_sets[index.row()];
+
+ if (role == GUI::ModelRole::Display) {
+ switch (index.column()) {
+ case Column::BigIcon:
+ if (!icon_set.big_icon)
+ return {};
+ return *icon_set.big_icon;
+ case Column::LittleIcon:
+ if (!icon_set.little_icon)
+ return {};
+ return *icon_set.little_icon;
+ case Column::Name:
+ return icon_set.name;
+ }
+ VERIFY_NOT_REACHED();
+ }
+ return {};
+ }
+ virtual void update() override
+ {
+ m_icon_sets.clear();
+
+ Core::DirIterator big_iterator("/res/icons/32x32", Core::DirIterator::Flags::SkipDots);
+
+ while (big_iterator.has_next()) {
+ auto path = big_iterator.next_path();
+ if (!path.contains("filetype-") && !path.contains("app-"))
+ continue;
+ IconSet icon_set;
+ StringBuilder full_path;
+ full_path.append("/res/icons/32x32/");
+ full_path.append(path);
+ icon_set.big_icon = Gfx::Bitmap::load_from_file(full_path.to_string());
+ auto filename_split = path.split('.');
+ icon_set.name = filename_split[0];
+ m_icon_sets.append(move(icon_set));
+ }
+
+ auto big_icons_found = m_icon_sets.size();
+
+ Core::DirIterator little_iterator("/res/icons/16x16", Core::DirIterator::Flags::SkipDots);
+
+ while (little_iterator.has_next()) {
+ auto path = little_iterator.next_path();
+ if (!path.contains("filetype-") && !path.contains("app-"))
+ continue;
+ IconSet icon_set;
+ StringBuilder full_path;
+ full_path.append("/res/icons/16x16/");
+ full_path.append(path);
+ icon_set.little_icon = Gfx::Bitmap::load_from_file(full_path.to_string());
+ auto filename_split = path.split('.');
+ icon_set.name = filename_split[0];
+ for (size_t i = 0; i < big_icons_found; i++) {
+ if (icon_set.name == m_icon_sets[i].name) {
+ m_icon_sets[i].little_icon = icon_set.little_icon;
+ goto next_iteration;
+ }
+ }
+ m_icon_sets.append(move(icon_set));
+ next_iteration:
+ continue;
+ }
+
+ did_update();
+ }
+
+private:
+ FileIconsModel() { }
+
+ struct IconSet {
+ RefPtr<Gfx::Bitmap> big_icon;
+ RefPtr<Gfx::Bitmap> little_icon;
+ String name;
+ };
+
+ Vector<IconSet> m_icon_sets;
+};
diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp
new file mode 100644
index 0000000000..3add7b662c
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "GalleryWidget.h"
+#include "DemoWizardDialog.h"
+#include "GalleryModels.h"
+#include <AK/StringBuilder.h>
+#include <Demos/WidgetGallery/BasicsTabGML.h>
+#include <Demos/WidgetGallery/CursorsTabGML.h>
+#include <Demos/WidgetGallery/IconsTabGML.h>
+#include <Demos/WidgetGallery/SlidersTabGML.h>
+#include <Demos/WidgetGallery/WindowGML.h>
+#include <Demos/WidgetGallery/WizardsTabGML.h>
+#include <LibGUI/Button.h>
+#include <LibGUI/ColorInput.h>
+#include <LibGUI/FilePicker.h>
+#include <LibGUI/FontPicker.h>
+#include <LibGUI/InputBox.h>
+#include <LibGUI/ItemListModel.h>
+#include <LibGUI/MessageBox.h>
+#include <LibGUI/SeparatorWidget.h>
+#include <LibGUI/SortingProxyModel.h>
+#include <LibGUI/SpinBox.h>
+#include <LibGUI/TabWidget.h>
+#include <LibGUI/TableView.h>
+#include <LibGfx/FontDatabase.h>
+#include <LibGfx/Palette.h>
+
+GalleryWidget::GalleryWidget()
+{
+ load_from_gml(window_gml);
+
+ auto& tab_widget = *find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
+
+ auto& basics_tab = tab_widget.add_tab<GUI::Widget>("Basics");
+ basics_tab.load_from_gml(basics_tab_gml);
+
+ m_enabled_label = basics_tab.find_descendant_of_type_named<GUI::Label>("enabled_label");
+ m_label_frame = basics_tab.find_descendant_of_type_named<GUI::Frame>("label_frame");
+
+ m_frame_shapes.append("No Frame");
+ m_frame_shapes.append("Plain Box");
+ m_frame_shapes.append("Plain Container");
+ m_frame_shapes.append("Plain Panel");
+ m_frame_shapes.append("Raised Box");
+ m_frame_shapes.append("Raised Container");
+ m_frame_shapes.append("Raised Panel");
+ m_frame_shapes.append("Sunken Box");
+ m_frame_shapes.append("Sunken Container");
+ m_frame_shapes.append("Sunken Panel");
+
+ m_frame_shape_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("frame_shape_combobox");
+ m_frame_shape_combobox->set_model(*GUI::ItemListModel<String>::create(m_frame_shapes));
+
+ m_frame_shape_combobox->on_change = [&](auto&, const auto& index) {
+ m_label_frame->set_frame_shape(static_cast<Gfx::FrameShape>((index.row() - 1) % 3 + 1));
+ m_label_frame->set_frame_shadow(static_cast<Gfx::FrameShadow>((index.row() - 1) / 3));
+ m_label_frame->update();
+ };
+
+ m_frame_shape_combobox->on_return_pressed = [&]() {
+ m_enabled_label->set_text(m_frame_shape_combobox->text());
+ };
+
+ m_thickness_spinbox = basics_tab.find_descendant_of_type_named<GUI::SpinBox>("thickness_spinbox");
+ m_thickness_spinbox->set_value(1);
+
+ m_thickness_spinbox->on_change = [&](auto value) {
+ m_label_frame->set_frame_thickness(value);
+ };
+
+ m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png"));
+ m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
+ m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"));
+
+ m_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("icon_button");
+ m_icon_button->set_icon(*m_button_icons[2]);
+
+ m_disabled_icon_button = basics_tab.find_descendant_of_type_named<GUI::Button>("disabled_icon_button");
+ m_disabled_icon_button->set_icon(*m_button_icons[2]);
+
+ m_icon_button->on_click = [&]() {
+ static size_t i;
+ if (i >= m_button_icons.size())
+ i = 0;
+ m_icon_button->set_icon(*m_button_icons[i]);
+ m_disabled_icon_button->set_icon(*m_button_icons[i]);
+ i++;
+ };
+
+ m_text_editor = basics_tab.find_descendant_of_type_named<GUI::TextEditor>("text_editor");
+
+ m_font_button = basics_tab.find_descendant_of_type_named<GUI::Button>("font_button");
+ m_font_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"));
+
+ m_font_button->on_click = [&]() {
+ auto picker = GUI::FontPicker::construct(window(), &m_text_editor->font(), false);
+ if (picker->exec() == GUI::Dialog::ExecOK) {
+ m_text_editor->set_font(picker->font());
+ }
+ };
+
+ m_file_button = basics_tab.find_descendant_of_type_named<GUI::Button>("file_button");
+ m_file_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"));
+
+ m_file_button->on_click = [&]() {
+ Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
+ if (!open_path.has_value())
+ return;
+ m_text_editor->set_text(open_path.value());
+ };
+
+ m_input_button = basics_tab.find_descendant_of_type_named<GUI::Button>("input_button");
+ m_input_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"));
+
+ m_input_button->on_click = [&]() {
+ String value;
+ if (GUI::InputBox::show(window(), value, "Enter input:", "Input") == GUI::InputBox::ExecOK && !value.is_empty())
+ m_text_editor->set_text(value);
+ };
+
+ m_font_colorinput = basics_tab.find_descendant_of_type_named<GUI::ColorInput>("font_colorinput");
+
+ m_font_colorinput->on_change = [&]() {
+ auto palette = m_text_editor->palette();
+ palette.set_color(Gfx::ColorRole::BaseText, m_font_colorinput->color());
+ m_text_editor->set_palette(palette);
+ m_text_editor->update();
+ };
+
+ m_msgbox_button = basics_tab.find_descendant_of_type_named<GUI::Button>("msgbox_button");
+ m_msgbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-irc-client.png"));
+
+ m_msgbox_type = GUI::MessageBox::Type::None;
+ m_msgbox_input_type = GUI::MessageBox::InputType::OK;
+
+ m_msgbox_icons.append("None");
+ m_msgbox_icons.append("Information");
+ m_msgbox_icons.append("Warning");
+ m_msgbox_icons.append("Error");
+ m_msgbox_icons.append("Question");
+
+ m_msgbox_buttons.append("OK");
+ m_msgbox_buttons.append("OK Cancel");
+ m_msgbox_buttons.append("Yes No");
+ m_msgbox_buttons.append("Yes No Cancel");
+
+ m_msgbox_icon_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("msgbox_icon_combobox");
+ m_msgbox_icon_combobox->set_model(*GUI::ItemListModel<String>::create(m_msgbox_icons));
+ m_msgbox_icon_combobox->set_selected_index(0);
+
+ m_msgbox_icon_combobox->on_change = [&](auto&, const auto& index) {
+ m_msgbox_type = static_cast<GUI::MessageBox::Type>(index.row());
+ };
+
+ m_msgbox_buttons_combobox = basics_tab.find_descendant_of_type_named<GUI::ComboBox>("msgbox_buttons_combobox");
+ m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel<String>::create(m_msgbox_buttons));
+ m_msgbox_buttons_combobox->set_selected_index(0);
+
+ m_msgbox_buttons_combobox->on_change = [&](auto&, const auto& index) {
+ m_msgbox_input_type = static_cast<GUI::MessageBox::InputType>(index.row());
+ };
+
+ m_msgbox_button->on_click = [&]() {
+ GUI::MessageBox::show(window(), m_text_editor->text(), "Message", m_msgbox_type, m_msgbox_input_type);
+ };
+
+ auto& sliders_tab = tab_widget.add_tab<GUI::Widget>("Sliders");
+ sliders_tab.load_from_gml(sliders_tab_gml);
+
+ m_vertical_progressbar_left = sliders_tab.find_descendant_of_type_named<GUI::VerticalProgressBar>("vertical_progressbar_left");
+ m_vertical_progressbar_left->set_value(0);
+
+ m_vertical_progressbar_right = sliders_tab.find_descendant_of_type_named<GUI::VerticalProgressBar>("vertical_progressbar_right");
+ m_vertical_progressbar_right->set_value(100);
+
+ m_vertical_slider_left = sliders_tab.find_descendant_of_type_named<GUI::VerticalSlider>("vertical_slider_left");
+ m_vertical_slider_right = sliders_tab.find_descendant_of_type_named<GUI::VerticalSlider>("vertical_slider_right");
+
+ m_vertical_slider_left->on_change = [&](auto value) {
+ m_vertical_progressbar_left->set_value(m_vertical_slider_left->max() - value);
+ };
+
+ m_vertical_slider_right->on_change = [&](auto value) {
+ m_vertical_progressbar_right->set_value((100 / m_vertical_slider_right->max()) * (m_vertical_slider_right->max() - value));
+ };
+
+ m_horizontal_progressbar = sliders_tab.find_descendant_of_type_named<GUI::HorizontalProgressBar>("horizontal_progressbar");
+ m_horizontal_progressbar->set_value(0);
+
+ m_horizontal_slider_left = sliders_tab.find_descendant_of_type_named<GUI::HorizontalSlider>("horizontal_slider_left");
+ m_horizontal_slider_right = sliders_tab.find_descendant_of_type_named<GUI::HorizontalSlider>("horizontal_slider_right");
+
+ m_horizontal_slider_left->on_change = [&](auto value) {
+ m_horizontal_progressbar->set_value(value);
+ if (!(value % (100 / m_horizontal_slider_right->max())))
+ m_horizontal_slider_right->set_value(value / (100 / m_horizontal_slider_right->max()));
+ };
+
+ m_horizontal_slider_right->on_change = [&](auto value) {
+ m_horizontal_progressbar->set_value((value * 100) / m_horizontal_slider_right->max());
+ m_horizontal_slider_left->set_value((value * 100) / m_horizontal_slider_right->max());
+ };
+
+ m_enabled_scrollbar = sliders_tab.find_descendant_of_type_named<GUI::ScrollBar>("enabled_scrollbar");
+ m_enabled_scrollbar->set_orientation(Orientation::Horizontal);
+
+ m_disabled_scrollbar = sliders_tab.find_descendant_of_type_named<GUI::ScrollBar>("disabled_scrollbar");
+ m_disabled_scrollbar->set_orientation(Orientation::Horizontal);
+
+ m_opacity_imagewidget = sliders_tab.find_descendant_of_type_named<GUI::ImageWidget>("opacity_imagewidget");
+ m_opacity_imagewidget->load_from_file("/res/graphics/brand-banner.png");
+
+ m_opacity_slider = sliders_tab.find_descendant_of_type_named<GUI::OpacitySlider>("opacity_slider");
+
+ m_opacity_slider->on_change = [&](auto percent) {
+ m_opacity_imagewidget->set_opacity_percent(percent);
+ };
+
+ auto& wizards_tab = tab_widget.add_tab<GUI::Widget>("Wizards");
+ wizards_tab.load_from_gml(wizards_tab_gml);
+
+ m_wizard_button = wizards_tab.find_descendant_of_type_named<GUI::Button>("wizard_button");
+ m_wizard_output = wizards_tab.find_descendant_of_type_named<GUI::TextEditor>("wizard_output");
+ m_wizard_output->set_should_hide_unnecessary_scrollbars(true);
+
+ const char* serenityos_ascii = {
+ " ____ _ __ ____ ____\n"
+ " / __/__ _______ ___ (_) /___ __/ __ \\/ __/\n"
+ " _\\ \\/ -_) __/ -_) _ \\/ / __/ // / /_/ /\\ \\\n"
+ "/___/\\__/_/ \\__/_//_/_/\\__/\\_, /\\____/___/\n"
+ " /___/\n"
+ };
+
+ const char* wizard_ascii = {
+ " _,-'|\n"
+ " ,-'._ |\n"
+ " .||, |####\\ |\n"
+ "\\`' ,/ \\'L' | |\n"
+ "= ,. = |-,#| |\n"
+ "/ || \\ ,-'\\#/,'`.\n"
+ " || ,' `,,. `.\n"
+ " ,|____,' , ,;' \\| |\n"
+ " (3|\\ _/|/' _| |\n"
+ " ||/,-'' | >-'' _,\\\\\n"
+ " ||' ==\\ ,-' ,'\n"
+ " || | V \\ ,|\n"
+ " || | |` |\n"
+ " || | | \\\n"
+ " || | \\ \\\n"
+ " || | | \\\n"
+ " || | \\_,-'\n"
+ " || |___,,--')_\\\n"
+ " || |_| _ccc/-\n"
+ " || ccc/__\n"
+ " _||_-\n"
+ };
+
+ StringBuilder sb;
+ sb.appendf("%s%s", serenityos_ascii, wizard_ascii);
+ m_wizard_output->set_text(sb.to_string());
+
+ m_wizard_button->on_click = [&]() {
+ StringBuilder sb;
+ sb.append(m_wizard_output->get_text());
+ sb.append("\nWizard started.");
+ m_wizard_output->set_text(sb.to_string());
+
+ auto wizard = DemoWizardDialog::construct(window());
+ int result = wizard->exec();
+
+ sb.append(String::formatted("\nWizard execution complete.\nDialog ExecResult code: {}", result));
+ if (result == GUI::Dialog::ExecResult::ExecOK)
+ sb.append(String::formatted(" (ExecOK)\n'Installation' location: \"{}\"", wizard->page_1_location()));
+ m_wizard_output->set_text(sb.string_view());
+ };
+
+ auto& cursors_tab = tab_widget.add_tab<GUI::Widget>("Cursors");
+ cursors_tab.load_from_gml(cursors_tab_gml);
+
+ m_cursors_tableview = cursors_tab.find_descendant_of_type_named<GUI::TableView>("cursors_tableview");
+ m_cursors_tableview->set_highlight_selected_rows(true);
+ m_cursors_tableview->set_alternating_row_colors(false);
+ m_cursors_tableview->set_vertical_padding(16);
+ m_cursors_tableview->set_column_headers_visible(false);
+ m_cursors_tableview->set_font(Gfx::BitmapFont::load_from_file("/res/fonts/KaticaRegular12.font"));
+ m_cursors_tableview->set_highlight_key_column(false);
+
+ auto sorting_proxy_model = GUI::SortingProxyModel::create(MouseCursorModel::create());
+ sorting_proxy_model->set_sort_role(GUI::ModelRole::Display);
+
+ m_cursors_tableview->set_model(sorting_proxy_model);
+ m_cursors_tableview->set_key_column_and_sort_order(MouseCursorModel::Column::Name, GUI::SortOrder::Ascending);
+ m_cursors_tableview->model()->update();
+ m_cursors_tableview->set_column_width(0, 25);
+
+ m_cursors_tableview->on_activation = [&](const GUI::ModelIndex& index) {
+ switch (index.row()) {
+ case 0:
+ window()->set_cursor(Gfx::StandardCursor::Arrow);
+ break;
+ case 1:
+ window()->set_cursor(Gfx::StandardCursor::Crosshair);
+ break;
+ case 2:
+ window()->set_cursor(Gfx::StandardCursor::Disallowed);
+ break;
+ case 3:
+ window()->set_cursor(Gfx::StandardCursor::Drag);
+ break;
+ case 4:
+ window()->set_cursor(Gfx::StandardCursor::Hand);
+ break;
+ case 5:
+ window()->set_cursor(Gfx::StandardCursor::Help);
+ break;
+ case 6:
+ window()->set_cursor(Gfx::StandardCursor::Hidden);
+ break;
+ case 7:
+ window()->set_cursor(Gfx::StandardCursor::IBeam);
+ break;
+ case 8:
+ window()->set_cursor(Gfx::StandardCursor::Move);
+ break;
+ case 9:
+ window()->set_cursor(Gfx::StandardCursor::ResizeColumn);
+ break;
+ case 10:
+ window()->set_cursor(Gfx::StandardCursor::ResizeDiagonalBLTR);
+ break;
+ case 11:
+ window()->set_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR);
+ break;
+ case 12:
+ window()->set_cursor(Gfx::StandardCursor::ResizeHorizontal);
+ break;
+ case 13:
+ window()->set_cursor(Gfx::StandardCursor::ResizeRow);
+ break;
+ case 14:
+ window()->set_cursor(Gfx::StandardCursor::ResizeVertical);
+ break;
+ case 15:
+ window()->set_cursor(Gfx::StandardCursor::Wait);
+ break;
+ default:
+ window()->set_cursor(Gfx::StandardCursor::Arrow);
+ }
+ };
+
+ auto& icons_tab = tab_widget.add_tab<GUI::Widget>("Icons");
+ icons_tab.load_from_gml(icons_tab_gml);
+
+ m_icons_tableview = icons_tab.find_descendant_of_type_named<GUI::TableView>("icons_tableview");
+ m_icons_tableview->set_highlight_selected_rows(true);
+ m_icons_tableview->set_alternating_row_colors(false);
+ m_icons_tableview->set_vertical_padding(24);
+ m_icons_tableview->set_column_headers_visible(false);
+ m_icons_tableview->set_font(Gfx::BitmapFont::load_from_file("/res/fonts/KaticaRegular12.font"));
+ m_icons_tableview->set_highlight_key_column(false);
+
+ auto sorting_proxy_icons_model = GUI::SortingProxyModel::create(FileIconsModel::create());
+ sorting_proxy_icons_model->set_sort_role(GUI::ModelRole::Display);
+
+ m_icons_tableview->set_model(sorting_proxy_icons_model);
+ m_icons_tableview->set_key_column_and_sort_order(FileIconsModel::Column::Name, GUI::SortOrder::Ascending);
+ m_icons_tableview->model()->update();
+ m_icons_tableview->set_column_width(0, 36);
+ m_icons_tableview->set_column_width(1, 20);
+}
+
+GalleryWidget::~GalleryWidget()
+{
+}
diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.h b/Userland/Demos/WidgetGallery/GalleryWidget.h
new file mode 100644
index 0000000000..8e1a0a3fb5
--- /dev/null
+++ b/Userland/Demos/WidgetGallery/GalleryWidget.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <LibGUI/ColorInput.h>
+#include <LibGUI/ComboBox.h>
+#include <LibGUI/ImageWidget.h>
+#include <LibGUI/MessageBox.h>
+#include <LibGUI/OpacitySlider.h>
+#include <LibGUI/ProgressBar.h>
+#include <LibGUI/Slider.h>
+#include <LibGUI/Widget.h>
+#include <LibGfx/Bitmap.h>
+
+class GalleryWidget final : public GUI::Widget {
+ C_OBJECT(GalleryWidget)
+public:
+ virtual ~GalleryWidget() override;
+
+private:
+ GalleryWidget();
+
+ RefPtr<GUI::Button> m_font_button;
+ RefPtr<GUI::Button> m_file_button;
+ RefPtr<GUI::Button> m_icon_button;
+ RefPtr<GUI::Button> m_input_button;
+ RefPtr<GUI::Button> m_wizard_button;
+ RefPtr<GUI::Button> m_msgbox_button;
+ RefPtr<GUI::Button> m_disabled_icon_button;
+
+ RefPtr<GUI::ComboBox> m_frame_shape_combobox;
+ RefPtr<GUI::ComboBox> m_msgbox_icon_combobox;
+ RefPtr<GUI::ComboBox> m_msgbox_buttons_combobox;
+
+ RefPtr<GUI::VerticalSlider> m_vertical_slider_left;
+ RefPtr<GUI::VerticalSlider> m_vertical_slider_right;
+ RefPtr<GUI::HorizontalSlider> m_horizontal_slider_left;
+ RefPtr<GUI::HorizontalSlider> m_horizontal_slider_right;
+
+ RefPtr<GUI::VerticalProgressBar> m_vertical_progressbar_left;
+ RefPtr<GUI::VerticalProgressBar> m_vertical_progressbar_right;
+ RefPtr<GUI::HorizontalProgressBar> m_horizontal_progressbar;
+
+ RefPtr<GUI::ScrollBar> m_enabled_scrollbar;
+ RefPtr<GUI::ScrollBar> m_disabled_scrollbar;
+
+ RefPtr<GUI::TextEditor> m_text_editor;
+ RefPtr<GUI::TextEditor> m_wizard_output;
+
+ RefPtr<GUI::Frame> m_label_frame;
+ RefPtr<GUI::Label> m_enabled_label;
+ RefPtr<GUI::SpinBox> m_thickness_spinbox;
+ RefPtr<GUI::ColorInput> m_font_colorinput;
+ RefPtr<GUI::TableView> m_icons_tableview;
+ RefPtr<GUI::TableView> m_cursors_tableview;
+ RefPtr<GUI::OpacitySlider> m_opacity_slider;
+ RefPtr<GUI::ImageWidget> m_opacity_imagewidget;
+
+ Vector<String> m_frame_shapes;
+ Vector<String> m_msgbox_icons;
+ Vector<String> m_msgbox_buttons;
+ Vector<RefPtr<Gfx::Bitmap>> m_button_icons;
+
+ GUI::MessageBox::Type m_msgbox_type;
+ GUI::MessageBox::InputType m_msgbox_input_type;
+};
diff --git a/Userland/Demos/WidgetGallery/main.cpp b/Userland/Demos/WidgetGallery/main.cpp
index 9bba628dbc..352b864e7e 100644
--- a/Userland/Demos/WidgetGallery/main.cpp
+++ b/Userland/Demos/WidgetGallery/main.cpp
@@ -25,73 +25,23 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <AK/NonnullRefPtr.h>
-#include <AK/Vector.h>
-#include <LibGUI/Action.h>
+#include "GalleryWidget.h"
#include <LibGUI/Application.h>
-#include <LibGUI/BoxLayout.h>
-#include <LibGUI/Button.h>
-#include <LibGUI/CheckBox.h>
-#include <LibGUI/ColorInput.h>
-#include <LibGUI/ComboBox.h>
-#include <LibGUI/Dialog.h>
-#include <LibGUI/GroupBox.h>
#include <LibGUI/Icon.h>
-#include <LibGUI/ImageWidget.h>
-#include <LibGUI/InputBox.h>
-#include <LibGUI/Label.h>
-#include <LibGUI/ListView.h>
#include <LibGUI/Menu.h>
#include <LibGUI/MenuBar.h>
-#include <LibGUI/MessageBox.h>
-#include <LibGUI/Model.h>
-#include <LibGUI/OpacitySlider.h>
-#include <LibGUI/ProgressBar.h>
-#include <LibGUI/RadioButton.h>
-#include <LibGUI/ScrollBar.h>
-#include <LibGUI/Slider.h>
-#include <LibGUI/SpinBox.h>
-#include <LibGUI/TabWidget.h>
-#include <LibGUI/TextBox.h>
-#include <LibGUI/Variant.h>
-#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
-#include <LibGUI/Wizards/CoverWizardPage.h>
-#include <LibGUI/Wizards/WizardDialog.h>
-#include <LibGfx/FontDatabase.h>
-
-#include "DemoWizardDialog.h"
-
-template<typename T>
-class ListViewModel final : public GUI::Model {
-public:
- static NonnullRefPtr<ListViewModel> create(Vector<T>& model_items) { return adopt(*new ListViewModel(model_items)); }
- virtual ~ListViewModel() override { }
- virtual int row_count(const GUI::ModelIndex&) const override { return m_model_items.size(); }
- virtual int column_count(const GUI::ModelIndex&) const override { return 1; }
- virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override
- {
- VERIFY(index.is_valid());
- VERIFY(index.column() == 0);
- if (role == GUI::ModelRole::Display)
- return m_model_items.at(index.row());
- return {};
- }
- virtual void update() override { did_update(); }
-
-private:
- explicit ListViewModel(Vector<String>& model_items)
- : m_model_items(model_items)
- {
- }
- Vector<T>& m_model_items;
-};
int main(int argc, char** argv)
{
+ if (pledge("stdio recvfd sendfd rpath accept unix fattr", nullptr) < 0) {
+ perror("pledge");
+ return 1;
+ }
+
auto app = GUI::Application::construct(argc, argv);
- if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
+ if (pledge("stdio recvfd sendfd rpath accept", nullptr) < 0) {
perror("pledge");
return 1;
}
@@ -101,6 +51,16 @@ int main(int argc, char** argv)
return 1;
}
+ if (unveil("/home/anon", "r") < 0) {
+ perror("unveil");
+ return 1;
+ }
+
+ if (unveil("/etc/FileIconProvider.ini", "r") < 0) {
+ perror("unveil");
+ return 1;
+ }
+
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
@@ -112,6 +72,7 @@ int main(int argc, char** argv)
window->resize(430, 480);
window->set_title("Widget Gallery");
window->set_icon(app_icon.bitmap_for_size(16));
+ window->set_main_widget<GalleryWidget>();
auto menubar = GUI::MenuBar::construct();
@@ -121,463 +82,6 @@ int main(int argc, char** argv)
auto& help_menu = menubar->add_menu("Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Widget Gallery", app_icon, window));
- auto& root_widget = window->set_main_widget<GUI::Widget>();
- root_widget.set_fill_with_background_color(true);
- root_widget.set_layout<GUI::VerticalBoxLayout>();
- root_widget.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& tab_widget = root_widget.add<GUI::TabWidget>();
-
- auto& tab_basic = tab_widget.add_tab<GUI::Widget>("Basic");
- tab_basic.set_layout<GUI::VerticalBoxLayout>();
- tab_basic.layout()->set_margins({ 8, 8, 8, 8 });
- tab_basic.layout()->set_spacing(8);
-
- auto& radio_group_box = tab_basic.add<GUI::GroupBox>();
- radio_group_box.set_layout<GUI::HorizontalBoxLayout>();
- radio_group_box.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& radio_button_vert_container = radio_group_box.add<GUI::Widget>();
- radio_button_vert_container.set_layout<GUI::VerticalBoxLayout>();
- radio_button_vert_container.layout()->set_margins({ 4, 9, 4, 4 });
-
- auto& radio_button_container = radio_button_vert_container.add<GUI::Widget>();
- radio_button_container.set_layout<GUI::HorizontalBoxLayout>();
-
- auto& radio1 = radio_button_container.add<GUI::RadioButton>("RadioButton 1");
- radio1.set_checked(true);
- [[maybe_unused]] auto& radio2 = radio_button_container.add<GUI::RadioButton>("RadioButton 2");
- auto& radio3 = radio_button_container.add<GUI::RadioButton>("RadioButton 3");
- radio3.set_enabled(false);
-
- auto& checklabelspin_container = tab_basic.add<GUI::Widget>();
- checklabelspin_container.set_layout<GUI::HorizontalBoxLayout>();
-
- auto& check_group_box = checklabelspin_container.add<GUI::GroupBox>();
- check_group_box.set_layout<GUI::HorizontalBoxLayout>();
- check_group_box.layout()->set_margins({ 4, 12, 4, 4 });
-
- auto& checkbox_container = check_group_box.add<GUI::Widget>();
- checkbox_container.set_layout<GUI::VerticalBoxLayout>();
- checkbox_container.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& label_container = check_group_box.add<GUI::Widget>();
- label_container.set_layout<GUI::VerticalBoxLayout>();
- label_container.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& spin_group_box = checklabelspin_container.add<GUI::GroupBox>();
- spin_group_box.set_layout<GUI::HorizontalBoxLayout>();
- spin_group_box.layout()->set_margins({ 4, 4, 4, 4 });
- spin_group_box.set_title("Spin boxes");
-
- auto& spin_container = spin_group_box.add<GUI::Widget>();
- spin_container.set_layout<GUI::VerticalBoxLayout>();
- spin_container.layout()->set_margins({ 4, 12, 4, 4 });
-
- auto& checkbox1 = checkbox_container.add<GUI::CheckBox>("CheckBox 1");
- checkbox1.set_checked(true);
- auto& checkbox2 = checkbox_container.add<GUI::CheckBox>("CheckBox 2");
- checkbox2.set_enabled(false);
-
- auto& label1 = label_container.add<GUI::Label>("Label 1");
- label1.set_fixed_height(22);
- auto& label2 = label_container.add<GUI::Label>("Label 2");
- label2.set_enabled(false);
- label2.set_fixed_height(22);
-
- [[maybe_unused]] auto& spinbox1 = spin_container.add<GUI::SpinBox>();
- auto& spinbox2 = spin_container.add<GUI::SpinBox>();
- spinbox2.set_enabled(false);
-
- auto& button_container = tab_basic.add<GUI::Widget>();
- button_container.set_layout<GUI::HorizontalBoxLayout>();
-
- auto& button_vert1_container = button_container.add<GUI::Widget>();
- button_vert1_container.set_layout<GUI::VerticalBoxLayout>();
-
- auto& button_vert2_container = button_container.add<GUI::Widget>();
- button_vert2_container.set_layout<GUI::VerticalBoxLayout>();
-
- auto& button1 = button_vert1_container.add<GUI::Button>("Button 1");
- button1.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/kill.png"));
- auto& button2 = button_vert1_container.add<GUI::Button>("Button 2");
- button2.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/kill.png"));
- button2.set_enabled(false);
- [[maybe_unused]] auto& button3 = button_vert2_container.add<GUI::Button>("\xF0\x9F\x98\x88 Button 3");
- auto& button4 = button_vert2_container.add<GUI::Button>("\xF0\x9F\x8D\x86 Button 4");
- button4.set_enabled(false);
-
- auto& text_group_box = tab_basic.add<GUI::GroupBox>();
- text_group_box.set_layout<GUI::HorizontalBoxLayout>();
- text_group_box.set_title("Text boxes");
- text_group_box.layout()->set_margins({ 8, 4, 8, 4 });
-
- auto& textbox_vert1_container = text_group_box.add<GUI::Widget>();
- textbox_vert1_container.set_layout<GUI::VerticalBoxLayout>();
- textbox_vert1_container.layout()->set_margins({ 1, 12, 1, 4 });
-
- auto& textbox_vert2_container = text_group_box.add<GUI::Widget>();
- textbox_vert2_container.set_layout<GUI::VerticalBoxLayout>();
- textbox_vert2_container.layout()->set_margins({ 1, 12, 1, 4 });
-
- auto& textbox1 = textbox_vert1_container.add<GUI::TextBox>();
- textbox1.set_placeholder("Editable");
- auto& textbox2 = textbox_vert1_container.add<GUI::TextBox>();
- textbox2.set_text("Disabled");
- textbox2.set_enabled(false);
- auto& textbox3 = textbox_vert2_container.add<GUI::TextBox>();
- textbox3.set_text("Read only");
- textbox3.set_mode(GUI::TextEditor::ReadOnly);
- auto& textbox4 = textbox_vert2_container.add<GUI::TextBox>();
- textbox4.set_text("Display only");
- textbox4.set_mode(GUI::TextEditor::DisplayOnly);
-
- auto& combocolor_container = tab_basic.add<GUI::Widget>();
- combocolor_container.set_layout<GUI::HorizontalBoxLayout>();
-
- auto& combo_group_box = combocolor_container.add<GUI::GroupBox>();
- combo_group_box.set_layout<GUI::HorizontalBoxLayout>();
- combo_group_box.layout()->set_margins({ 4, 4, 4, 4 });
- combo_group_box.set_title("Combo boxes");
-
- auto& color_group_box = combocolor_container.add<GUI::GroupBox>();
- color_group_box.set_layout<GUI::HorizontalBoxLayout>();
- color_group_box.layout()->set_margins({ 4, 4, 4, 4 });
- color_group_box.set_title("Color pickers");
-
- auto& combo_container = combo_group_box.add<GUI::Widget>();
- combo_container.set_layout<GUI::VerticalBoxLayout>();
- combo_container.layout()->set_margins({ 4, 12, 4, 4 });
-
- auto& color_container = color_group_box.add<GUI::Widget>();
- color_container.set_layout<GUI::VerticalBoxLayout>();
- color_container.layout()->set_margins({ 4, 12, 4, 4 });
-
- Vector<String> model_items;
- model_items.append("Yes");
- model_items.append("No");
- model_items.append("Maybe");
- model_items.append("I don't know");
- model_items.append("Can you repeat the question?");
-
- auto& combobox1 = combo_container.add<GUI::ComboBox>();
- combobox1.set_only_allow_values_from_model(true);
- combobox1.set_model(*ListViewModel<String>::create(model_items));
-
- auto& combobox2 = combo_container.add<GUI::ComboBox>();
- combobox2.set_enabled(false);
-
- auto& color_input_enabled = color_container.add<GUI::ColorInput>();
- color_input_enabled.set_color(Color::from_string("#961605ff").value());
- color_input_enabled.set_color_picker_title("Select color for desktop");
-
- auto& color_input_disabled = color_container.add<GUI::ColorInput>();
- color_input_disabled.set_color(Color::from_string("#961605ff").value());
- color_input_disabled.set_enabled(false);
-
- auto& tab_others = tab_widget.add_tab<GUI::Widget>("Sliders");
- tab_others.set_layout<GUI::VerticalBoxLayout>();
- tab_others.layout()->set_margins({ 8, 8, 8, 8 });
- tab_others.layout()->set_spacing(8);
-
- auto& vert_slider_group_box = tab_others.add<GUI::GroupBox>();
- vert_slider_group_box.set_layout<GUI::HorizontalBoxLayout>();
- vert_slider_group_box.layout()->set_margins({ 4, 28, 4, 4 });
- vert_slider_group_box.set_title("Vertical sliders");
-
- auto& vslider1 = vert_slider_group_box.add<GUI::VerticalSlider>();
- vslider1.set_max(100);
- vslider1.set_tooltip("Fixed");
- auto& vslider2 = vert_slider_group_box.add<GUI::VerticalSlider>();
- vslider1.set_max(100);
- vslider2.set_enabled(false);
- vslider2.set_tooltip("Disabled");
- auto& vslider3 = vert_slider_group_box.add<GUI::VerticalSlider>();
- vslider3.set_max(5);
- vslider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
- vslider3.set_tooltip("Proportional");
-
- auto& horizontal_slider_group_box = tab_others.add<GUI::GroupBox>();
- horizontal_slider_group_box.set_layout<GUI::VerticalBoxLayout>();
- horizontal_slider_group_box.layout()->set_margins({ 4, 12, 4, 4 });
- horizontal_slider_group_box.set_title("Horizontal sliders");
-
- auto& horizontal_slider_container = horizontal_slider_group_box.add<GUI::Widget>();
- horizontal_slider_container.set_layout<GUI::HorizontalBoxLayout>();
- horizontal_slider_container.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& horizontal_slider_container2 = horizontal_slider_group_box.add<GUI::Widget>();
- horizontal_slider_container2.set_layout<GUI::HorizontalBoxLayout>();
- horizontal_slider_container2.layout()->set_margins({ 4, 4, 4, 4 });
-
- auto& slider1 = horizontal_slider_container.add<GUI::HorizontalSlider>();
- slider1.set_max(100);
- auto& slider2 = horizontal_slider_container.add<GUI::HorizontalSlider>();
- slider2.set_enabled(false);
- slider2.set_max(100);
- slider2.set_value(50);
- auto& slider3 = horizontal_slider_container.add<GUI::HorizontalSlider>();
- slider3.set_max(5);
- slider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
-
- auto& progress1 = horizontal_slider_container2.add<GUI::ProgressBar>();
- progress1.set_fixed_height(28);
-
- slider1.on_change = [&](int value) {
- progress1.set_value(value);
- if (!(value % (100 / slider3.max())))
- slider3.set_value(value / (100 / slider3.max()));
- };
-
- slider3.on_change = [&](int value) {
- progress1.set_value((value * 100) / slider3.max());
- slider1.set_value((value * 100) / slider3.max());
- };
-
- auto& opacity_slider_group_box = tab_others.add<GUI::GroupBox>();
- opacity_slider_group_box.set_fixed_height(48);
- opacity_slider_group_box.set_layout<GUI::VerticalBoxLayout>();
- opacity_slider_group_box.layout()->set_margins({ 8, 16, 8, 8 });
- opacity_slider_group_box.set_title("Opacity sliders");
-
- auto& opacity_slider = opacity_slider_group_box.add<GUI::OpacitySlider>();
- opacity_slider.set_range(0, 100);
- opacity_slider.set_value(75);
-
- auto& scroll_group_box = tab_others.add<GUI::GroupBox>();
- scroll_group_box.set_layout<GUI::VerticalBoxLayout>();
- scroll_group_box.layout()->set_margins({ 12, 12, 12, 12 });
- scroll_group_box.set_title("Scrollbars");
-
- scroll_group_box.layout()->add_spacer();
-
- auto& scrollbar1 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal);
- scrollbar1.set_fixed_height(16);
- scrollbar1.set_min(0);
- scrollbar1.set_max(100);
- scrollbar1.set_value(50);
-
- scroll_group_box.layout()->add_spacer();
-
- auto& scrollbar2 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal);
- scrollbar2.set_fixed_height(16);
- scrollbar2.set_enabled(false);
-
- scroll_group_box.layout()->add_spacer();
-
- auto& tab_modals = tab_widget.add_tab<GUI::Widget>("Modals");
- tab_modals.set_layout<GUI::VerticalBoxLayout>();
- tab_modals.layout()->set_margins({ 8, 8, 8, 8 });
- tab_modals.layout()->set_spacing(8);
-
- GUI::MessageBox::Type msg_box_type = GUI::MessageBox::Type::Error;
-
- auto& msgbox_group_container = tab_modals.add<GUI::GroupBox>("Message boxes");
- msgbox_group_container.set_layout<GUI::VerticalBoxLayout>();
- msgbox_group_container.layout()->set_margins({ 4, 12, 4, 2 });
-
- auto& msgbox_radio_container = msgbox_group_container.add<GUI::Widget>();
- msgbox_radio_container.set_layout<GUI::HorizontalBoxLayout>();
- msgbox_radio_container.layout()->set_margins({ 4, 12, 4, 4 });
-
- auto& icon_group_box = msgbox_radio_container.add<GUI::GroupBox>("Icon");
- icon_group_box.set_layout<GUI::VerticalBoxLayout>();
- icon_group_box.layout()->set_margins({ 4, 16, 4, 4 });
-
- auto& radio_none = icon_group_box.add<GUI::RadioButton>("None");
- radio_none.on_checked = [&](bool) {
- msg_box_type = GUI::MessageBox::Type::None;
- };
- auto& radio_information = icon_group_box.add<GUI::RadioButton>("\xE2\x84\xB9 Information");
- radio_information.on_checked = [&](bool) {
- msg_box_type = GUI::MessageBox::Type::Information;
- };
- auto& question_information = icon_group_box.add<GUI::RadioButton>("\xF0\x9F\xA4\x94 Question");
- question_information.on_checked = [&](bool) {
- msg_box_type = GUI::MessageBox::Type::Question;
- };
- auto& radio_warning = icon_group_box.add<GUI::RadioButton>("\xE2\x9A\xA0 Warning");
- radio_warning.on_checked = [&](bool) {
- msg_box_type = GUI::MessageBox::Type::Warning;
- };
- auto& radio_error = icon_group_box.add<GUI::RadioButton>("\xE2\x9D\x8C Error");
- radio_error.set_checked(true);
- radio_error.on_checked = [&](bool) {
- msg_box_type = GUI::MessageBox::Type::Error;
- };
-
- auto& button_group_box = msgbox_radio_container.add<GUI::GroupBox>("Buttons");
- button_group_box.set_layout<GUI::VerticalBoxLayout>();
- button_group_box.layout()->set_margins({ 4, 16, 4, 4 });
-
- GUI::MessageBox::InputType msg_box_input_type = GUI::MessageBox::InputType::OKCancel;
-
- auto& radio_ok = button_group_box.add<GUI::RadioButton>("OK");
- radio_ok.on_checked = [&](bool) {
- msg_box_input_type = GUI::MessageBox::InputType::OK;
- };
- auto& radio_ok_cancel = button_group_box.add<GUI::RadioButton>("OK & Cancel");
- radio_ok_cancel.set_checked(true);
- radio_ok_cancel.on_checked = [&](bool) {
- msg_box_input_type = GUI::MessageBox::InputType::OKCancel;
- };
- auto& radio_yes_no = button_group_box.add<GUI::RadioButton>("Yes & No");
- radio_yes_no.on_checked = [&](bool) {
- msg_box_input_type = GUI::MessageBox::InputType::YesNo;
- };
- auto& radio_yes_no_cancel = button_group_box.add<GUI::RadioButton>("Yes & No & Cancel");
- radio_yes_no_cancel.on_checked = [&](bool) {
- msg_box_input_type = GUI::MessageBox::InputType::YesNoCancel;
- };
-
- auto& msgbox_text_container = msgbox_group_container.add<GUI::Widget>();
- msgbox_text_container.set_layout<GUI::VerticalBoxLayout>();
- msgbox_text_container.set_fixed_height(100);
- msgbox_text_container.layout()->set_margins({ 4, 8, 4, 8 });
-
- auto& title_textbox = msgbox_text_container.add<GUI::TextBox>();
- title_textbox.set_fixed_height(24);
- title_textbox.set_text("Demo Title");
-
- auto& content_textbox = msgbox_text_container.add<GUI::TextBox>();
- content_textbox.set_fixed_height(24);
- content_textbox.set_text("Demo text for message box.");
-
- auto& msgbox_button = msgbox_text_container.add<GUI::Button>("Create");
- msgbox_button.on_click = [&](auto) {
- GUI::MessageBox::show(window, content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type);
- };
-
- auto& input_group_box = tab_modals.add<GUI::GroupBox>("Input boxes");
- input_group_box.set_layout<GUI::VerticalBoxLayout>();
- input_group_box.layout()->set_margins({ 4, 12, 4, 4 });
- input_group_box.set_fixed_height(140);
-
- input_group_box.layout()->add_spacer();
-
- auto& input_label = input_group_box.add<GUI::Label>("Valued user input goes here.");
- input_label.set_font(Gfx::FontDatabase::default_bold_font());
-
- input_group_box.layout()->add_spacer();
-
- auto& input_button_container = input_group_box.add<GUI::Widget>();
- input_button_container.set_layout<GUI::VerticalBoxLayout>();
- input_button_container.layout()->set_margins({ 4, 0, 4, 0 });
-
- auto& input_button = input_button_container.add<GUI::Button>("Input...");
- String value;
- input_button.on_click = [&](auto) {
- if (GUI::InputBox::show(window, value, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty())
- input_label.set_text(value);
- };
-
- auto& tab_wizards = tab_widget.add_tab<GUI::Widget>("Wizards");
- tab_wizards.set_layout<GUI::VerticalBoxLayout>();
- tab_wizards.layout()->set_margins({ 8, 8, 8, 8 });
- tab_wizards.layout()->set_spacing(8);
-
- auto& start_wizard_button = tab_wizards.add<GUI::Button>("Start wizard");
- auto& wizard_output_box = tab_wizards.add<GUI::TextEditor>();
- wizard_output_box.set_text("Output from the demo wizard will appear here :^)");
- wizard_output_box.set_mode(GUI::TextEditor::DisplayOnly);
- wizard_output_box.set_font(Gfx::FontDatabase::the().default_font());
-
- start_wizard_button.on_click = [&]() {
- wizard_output_box.set_text("Wizard started.");
-
- auto wizard = DemoWizardDialog::construct(window);
- int result = wizard->exec();
-
- StringBuilder sb;
- sb.append(String::formatted("Wizard execution complete.\nDialog ExecResult code: {}", result));
- if (result == GUI::Dialog::ExecResult::ExecOK)
- sb.append(String::formatted(" (ExecOK)\n'Installation' location: \"{}\"", wizard->page_1_location()));
- wizard_output_box.set_text(sb.string_view());
- };
-
- auto& tab_image = tab_widget.add_tab<GUI::Widget>("Images");
- tab_image.set_layout<GUI::VerticalBoxLayout>();
- tab_image.layout()->set_margins({ 8, 8, 8, 8 });
- tab_image.layout()->set_spacing(8);
-
- auto& banner_image = tab_image.add<GUI::ImageWidget>();
- banner_image.set_frame_thickness(2);
- banner_image.load_from_file("/res/graphics/brand-banner.png");
-
- auto& gif_animation_image = tab_image.add<GUI::ImageWidget>();
- gif_animation_image.load_from_file("/res/graphics/download-animation.gif");
-
- auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors");
- tab_cursors.set_layout<GUI::VerticalBoxLayout>();
- tab_cursors.layout()->set_margins({ 8, 8, 8, 8 });
- tab_cursors.layout()->set_spacing(8);
-
- auto& cursor_group_box = tab_cursors.add<GUI::GroupBox>("Cursor");
- cursor_group_box.set_layout<GUI::VerticalBoxLayout>();
- cursor_group_box.layout()->set_margins({ 4, 12, 4, 4 });
-
- auto& radio_cursor_none = cursor_group_box.add<GUI::RadioButton>("None");
- radio_cursor_none.set_checked(true);
- radio_cursor_none.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::None);
- };
- auto& radio_cursor_arrow = cursor_group_box.add<GUI::RadioButton>("Arrow");
- radio_cursor_arrow.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Arrow);
- };
- auto& radio_crosshair_arrow = cursor_group_box.add<GUI::RadioButton>("Crosshair");
- radio_crosshair_arrow.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Crosshair);
- };
- auto& radio_cursor_i_beam = cursor_group_box.add<GUI::RadioButton>("IBeam");
- radio_cursor_i_beam.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::IBeam);
- };
- auto& radio_cursor_resize_horizontal = cursor_group_box.add<GUI::RadioButton>("ResizeHorizontal");
- radio_cursor_resize_horizontal.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeHorizontal);
- };
- auto& radio_cursor_resize_vertical = cursor_group_box.add<GUI::RadioButton>("ResizeVertical");
- radio_cursor_resize_vertical.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeVertical);
- };
- auto& radio_cursor_resize_diagonal_tlbr = cursor_group_box.add<GUI::RadioButton>("ResizeDiagonalTLBR");
- radio_cursor_resize_diagonal_tlbr.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR);
- };
- auto& radio_cursor_resize_diagonal_bltr = cursor_group_box.add<GUI::RadioButton>("ResizeDiagonalBLTR");
- radio_cursor_resize_diagonal_bltr.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeDiagonalBLTR);
- };
- auto& radio_cursor_resize_column = cursor_group_box.add<GUI::RadioButton>("ResizeColumn");
- radio_cursor_resize_column.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeColumn);
- };
- auto& radio_cursor_resize_row = cursor_group_box.add<GUI::RadioButton>("ResizeRow");
- radio_cursor_resize_row.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::ResizeRow);
- };
- auto& radio_cursor_hand = cursor_group_box.add<GUI::RadioButton>("Hand");
- radio_cursor_hand.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Hand);
- };
- auto& radio_cursor_help = cursor_group_box.add<GUI::RadioButton>("Help");
- radio_cursor_help.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Help);
- };
- auto& radio_cursor_drag = cursor_group_box.add<GUI::RadioButton>("Drag");
- radio_cursor_drag.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Drag);
- };
- auto& radio_cursor_move = cursor_group_box.add<GUI::RadioButton>("Move");
- radio_cursor_move.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Move);
- };
- auto& radio_cursor_wait = cursor_group_box.add<GUI::RadioButton>("Wait");
- radio_cursor_wait.on_checked = [&](bool) {
- window->set_cursor(Gfx::StandardCursor::Wait);
- };
-
app->set_menubar(move(menubar));
window->show();