diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-02 15:07:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-02 15:15:33 +0100 |
commit | c5bd9d4ed1d80ac91d46146565127b0c185f1b43 (patch) | |
tree | b4ee9ba5999778450f8eb4006df89110617b4a10 /Demos | |
parent | 2d39da5405a4527e91e853ddb1e56a539c96c6c1 (diff) | |
download | serenity-c5bd9d4ed1d80ac91d46146565127b0c185f1b43.zip |
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
Diffstat (limited to 'Demos')
-rw-r--r-- | Demos/Fire/Fire.cpp | 46 | ||||
-rw-r--r-- | Demos/HelloWorld/main.cpp | 16 | ||||
-rw-r--r-- | Demos/HelloWorld2/HelloWorld2.frm | 2 | ||||
-rw-r--r-- | Demos/HelloWorld2/main.cpp | 4 | ||||
-rw-r--r-- | Demos/WidgetGallery/main.cpp | 64 |
5 files changed, 66 insertions, 66 deletions
diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index bf2a066012..34ce85efcb 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -89,22 +89,22 @@ static int my_rand(void) /* * Fire Widget */ -class Fire : public GWidget { +class Fire : public GUI::Widget { C_OBJECT(Fire) public: virtual ~Fire() override; - void set_stat_label(GLabel* l) { stats = l; }; + void set_stat_label(RefPtr<GUI::Label> l) { stats = l; }; private: - explicit Fire(GWidget* parent = nullptr); + explicit Fire(GUI::Widget* parent = nullptr); RefPtr<GraphicsBitmap> bitmap; - GLabel* stats; + RefPtr<GUI::Label> stats; - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; virtual void timer_event(Core::TimerEvent&) override; - virtual void mousedown_event(GMouseEvent& event) override; - virtual void mousemove_event(GMouseEvent& event) override; - virtual void mouseup_event(GMouseEvent& event) override; + virtual void mousedown_event(GUI::MouseEvent& event) override; + virtual void mousemove_event(GUI::MouseEvent& event) override; + virtual void mouseup_event(GUI::MouseEvent& event) override; bool dragging; int timeAvg; @@ -112,8 +112,8 @@ private: int phase; }; -Fire::Fire(GWidget* parent) - : GWidget(parent) +Fire::Fire(GUI::Widget* parent) + : GUI::Widget(parent) { bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::Indexed8, { 320, 200 }); @@ -146,12 +146,12 @@ Fire::~Fire() { } -void Fire::paint_event(GPaintEvent& event) +void Fire::paint_event(GUI::PaintEvent& event) { Core::ElapsedTimer timer; timer.start(); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); /* Blit it! */ @@ -201,16 +201,16 @@ void Fire::timer_event(Core::TimerEvent&) /* * Mouse handling events */ -void Fire::mousedown_event(GMouseEvent& event) +void Fire::mousedown_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) dragging = true; - return GWidget::mousedown_event(event); + return GUI::Widget::mousedown_event(event); } /* FIXME: needs to account for the size of the window rect */ -void Fire::mousemove_event(GMouseEvent& event) +void Fire::mousemove_event(GUI::MouseEvent& event) { if (dragging) { if (event.y() >= 2 && event.y() < 398 && event.x() <= 638) { @@ -223,15 +223,15 @@ void Fire::mousemove_event(GMouseEvent& event) } } - return GWidget::mousemove_event(event); + return GUI::Widget::mousemove_event(event); } -void Fire::mouseup_event(GMouseEvent& event) +void Fire::mouseup_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) dragging = false; - return GWidget::mouseup_event(event); + return GUI::Widget::mouseup_event(event); } /* @@ -239,9 +239,9 @@ void Fire::mouseup_event(GMouseEvent& event) */ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_double_buffering_enabled(false); window->set_title("Fire"); window->set_resizable(false); @@ -250,7 +250,7 @@ int main(int argc, char** argv) auto fire = Fire::construct(); window->set_main_widget(fire); - auto time = GLabel::construct(fire); + auto time = GUI::Label::construct(fire); time->set_relative_rect({ 0, 4, 40, 10 }); time->move_by({ window->width() - time->width(), 0 }); time->set_foreground_color(Color::from_rgb(0x444444)); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index 84b8d460f9..1e65f0d413 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -33,27 +33,27 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); - auto main_widget = GWidget::construct(); + auto main_widget = GUI::Widget::construct(); 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<GVBoxLayout>()); + main_widget->set_layout(make<GUI::VBoxLayout>()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto label = GLabel::construct(main_widget); + auto label = GUI::Label::construct(main_widget); label->set_text("Hello\nWorld!"); - auto button = GButton::construct(main_widget); + auto button = GUI::Button::construct(main_widget); button->set_text("Good-bye"); - button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button->set_preferred_size(0, 20); - button->on_click = [&](GButton&) { + button->on_click = [&](GUI::Button&) { app.quit(); }; diff --git a/Demos/HelloWorld2/HelloWorld2.frm b/Demos/HelloWorld2/HelloWorld2.frm index 932975dfe4..f4ae8251e5 100644 --- a/Demos/HelloWorld2/HelloWorld2.frm +++ b/Demos/HelloWorld2/HelloWorld2.frm @@ -1 +1 @@ -{"name":"HelloWorld2","widgets":[{"name":"w1","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Hello world!","class":"GLabel","autofill":true,"enabled":true,"visible":true,"x":5,"height":26,"y":5,"width":121},{"name":"w2","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Lefty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":5,"height":26,"y":40,"width":51},{"name":"w3","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Righty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":80,"height":26,"y":40,"width":51},{"name":"w4","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":91,"y":5,"class":"GCheckBox","text":"Awesome","backcolor":"#d4d0c8ff","visible":true},{"name":"w5","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":51,"y":30,"class":"GCheckBox","text":"Cool","backcolor":"#d4d0c8ff","visible":true}]} +{"name":"HelloWorld2","widgets":[{"name":"w1","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Hello world!","class":"GUI::Label","autofill":true,"enabled":true,"visible":true,"x":5,"height":26,"y":5,"width":121},{"name":"w2","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Lefty","class":"GUI::Button","autofill":false,"enabled":true,"visible":true,"x":5,"height":26,"y":40,"width":51},{"name":"w3","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Righty","class":"GUI::Button","autofill":false,"enabled":true,"visible":true,"x":80,"height":26,"y":40,"width":51},{"name":"w4","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":91,"y":5,"class":"GUI::CheckBox","text":"Awesome","backcolor":"#d4d0c8ff","visible":true},{"name":"w5","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":51,"y":30,"class":"GUI::CheckBox","text":"Cool","backcolor":"#d4d0c8ff","visible":true}]} diff --git a/Demos/HelloWorld2/main.cpp b/Demos/HelloWorld2/main.cpp index c523d872b2..ba0a9a98ef 100644 --- a/Demos/HelloWorld2/main.cpp +++ b/Demos/HelloWorld2/main.cpp @@ -34,9 +34,9 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index 3c260af394..bc5a85f20b 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -42,84 +42,84 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 320, 620); window->set_title("Widget Gallery"); - auto main_widget = GWidget::construct(); + auto main_widget = GUI::Widget::construct(); window->set_main_widget(main_widget); main_widget->set_fill_with_background_color(true); - main_widget->set_layout(make<GVBoxLayout>()); + main_widget->set_layout(make<GUI::VBoxLayout>()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto checkbox1 = GCheckBox::construct("GCheckBox 1", main_widget); + auto checkbox1 = GUI::CheckBox::construct("GCheckBox 1", main_widget); (void)checkbox1; - auto checkbox2 = GCheckBox::construct("GCheckBox 2", main_widget); + auto checkbox2 = GUI::CheckBox::construct("GCheckBox 2", main_widget); checkbox2->set_enabled(false); - auto radio1 = GRadioButton::construct("GRadioButton 1", main_widget); + auto radio1 = GUI::RadioButton::construct("GRadioButton 1", main_widget); (void)radio1; - auto radio2 = GRadioButton::construct("GRadioButton 2", main_widget); + auto radio2 = GUI::RadioButton::construct("GRadioButton 2", main_widget); radio2->set_enabled(false); - auto button1 = GButton::construct("GButton 1", main_widget); + auto button1 = GUI::Button::construct("GButton 1", main_widget); (void)button1; - auto button2 = GButton::construct("GButton 2", main_widget); + auto button2 = GUI::Button::construct("GButton 2", main_widget); button2->set_enabled(false); - auto progress1 = GProgressBar::construct(main_widget); + auto progress1 = GUI::ProgressBar::construct(main_widget); auto timer = Core::Timer::construct(100, [&] { progress1->set_value(progress1->value() + 1); if (progress1->value() == progress1->max()) progress1->set_value(progress1->min()); }); - auto label1 = GLabel::construct("GLabel 1", main_widget); + auto label1 = GUI::Label::construct("GLabel 1", main_widget); (void)label1; - auto label2 = GLabel::construct("GLabel 2", main_widget); + auto label2 = GUI::Label::construct("GLabel 2", main_widget); label2->set_enabled(false); - auto textbox1 = GTextBox::construct(main_widget); + auto textbox1 = GUI::TextBox::construct(main_widget); textbox1->set_text("GTextBox 1"); - auto textbox2 = GTextBox::construct(main_widget); + auto textbox2 = GUI::TextBox::construct(main_widget); textbox2->set_text("GTextBox 2"); textbox2->set_enabled(false); - auto spinbox1 = GSpinBox::construct(main_widget); + auto spinbox1 = GUI::SpinBox::construct(main_widget); (void)spinbox1; - auto spinbox2 = GSpinBox::construct(main_widget); + auto spinbox2 = GUI::SpinBox::construct(main_widget); spinbox2->set_enabled(false); - auto vertical_slider_container = GWidget::construct(main_widget.ptr()); - vertical_slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto vertical_slider_container = GUI::Widget::construct(main_widget.ptr()); + vertical_slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); vertical_slider_container->set_preferred_size(0, 100); - vertical_slider_container->set_layout(make<GHBoxLayout>()); - auto vslider1 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + vertical_slider_container->set_layout(make<GUI::HBoxLayout>()); + auto vslider1 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); (void)vslider1; - auto vslider2 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + auto vslider2 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); vslider2->set_enabled(false); - auto vslider3 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + auto vslider3 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); vslider3->set_max(5); - vslider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional); + vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto slider1 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider1 = GUI::Slider::construct(Orientation::Horizontal, main_widget); (void)slider1; - auto slider2 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider2 = GUI::Slider::construct(Orientation::Horizontal, main_widget); slider2->set_enabled(false); - auto slider3 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider3 = GUI::Slider::construct(Orientation::Horizontal, main_widget); slider3->set_max(5); - slider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional); + slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto scrollbar1 = GScrollBar::construct(Orientation::Horizontal, main_widget); - scrollbar1->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto scrollbar1 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + scrollbar1->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar1->set_preferred_size(0, 16); scrollbar1->set_min(0); scrollbar1->set_max(100); scrollbar1->set_value(50); - auto scrollbar2 = GScrollBar::construct(Orientation::Horizontal, main_widget); - scrollbar2->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto scrollbar2 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar2->set_preferred_size(0, 16); scrollbar2->set_enabled(false); |