diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-22 02:49:14 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-22 02:49:45 +0100 |
commit | c3b0c1ba68c79c4df1efed8b6d12b1d60187c9a6 (patch) | |
tree | 9d8f6754eb3779373fb3a6f16bca3c3a53d39232 /Userland | |
parent | 23fe630057473a1e25723429832f818b84ec41aa (diff) | |
download | serenity-c3b0c1ba68c79c4df1efed8b6d12b1d60187c9a6.zip |
LibGUI: Add a GProgressBar widget.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/guitest2.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Userland/guitest2.cpp b/Userland/guitest2.cpp index 4e8e593b67..e96be84bd3 100644 --- a/Userland/guitest2.cpp +++ b/Userland/guitest2.cpp @@ -14,11 +14,14 @@ #include <LibGUI/GLabel.h> #include <LibGUI/GButton.h> #include <LibGUI/GTextBox.h> +#include <LibGUI/GBoxLayout.h> #include <LibGUI/GCheckBox.h> +#include <LibGUI/GProgressBar.h> #include <LibGUI/GApplication.h> #include <signal.h> static GWindow* make_launcher_window(); +static GWindow* make_progress_window(); void handle_sigchld(int) { @@ -38,18 +41,21 @@ int main(int argc, char** argv) launcher_window->set_should_exit_event_loop_on_close(true); launcher_window->show(); + auto* progress_window = make_progress_window(); + progress_window->show(); + return app.exec(); } GWindow* make_launcher_window() { auto* window = new GWindow; - window->set_title("guitest2"); + window->set_title("GUI Test II"); window->set_rect({ 100, 400, 100, 230 }); auto* widget = new GWidget; + widget->set_fill_with_background_color(true); window->set_main_widget(widget); - widget->set_relative_rect({ 0, 0, 100, 230 }); auto* label = new GLabel(widget); label->set_relative_rect({ 0, 0, 100, 20 }); @@ -116,3 +122,30 @@ GWindow* make_launcher_window() return window; } + +static GWindow* make_progress_window() +{ + auto* window = new GWindow; + window->set_title("Progress bar test"); + window->set_rect({ 100, 400, 240, 80 }); + + auto* widget = new GWidget; + widget->set_fill_with_background_color(true); + window->set_main_widget(widget); + + widget->set_layout(make<GBoxLayout>(Orientation::Vertical)); + + widget->layout()->set_margins({ 8, 8, 8, 8 }); + + auto* label = new GLabel("Hi /dpt/", widget); + label->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + + auto* progress_bar = new GProgressBar(widget); + progress_bar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + progress_bar->set_preferred_size({ 200, 20 }); + + progress_bar->set_range(0, 100); + progress_bar->set_value(25); + + return window; +} |