1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

Userland: Add a simple GFrame testing window to guitest2.

This commit is contained in:
Andreas Kling 2019-03-28 18:52:03 +01:00
parent 6edcf2f16e
commit f939fb7eb7
2 changed files with 43 additions and 13 deletions

View file

@ -22,6 +22,7 @@
static GWindow* make_launcher_window();
static GWindow* make_progress_window();
static GWindow* make_frames_window();
void handle_sigchld(int)
{
@ -44,6 +45,9 @@ int main(int argc, char** argv)
auto* progress_window = make_progress_window();
progress_window->show();
auto* frames_window = make_frames_window();
frames_window->show();
return app.exec();
}
@ -149,3 +153,37 @@ static GWindow* make_progress_window()
return window;
}
static GWindow* make_frames_window()
{
auto* window = new GWindow;
window->set_title("GFrame styles 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 });
widget->layout()->set_spacing(8);
auto add_label = [widget] (const String& text, GFrame::Shape shape, GFrame::Shadow shadow) {
auto* label = new GLabel(text, widget);
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
label->set_frame_shape(shape);
label->set_frame_shadow(shadow);
if (shape == GFrame::Shape::Container) {
label->set_fill_with_background_color(true);
label->set_background_color(Color::White);
}
};
add_label("Panel + Raised", GFrame::Shape::Panel, GFrame::Shadow::Raised);
add_label("Panel + Sunken", GFrame::Shape::Panel, GFrame::Shadow::Sunken);
add_label("Container + Raised", GFrame::Shape::Container, GFrame::Shadow::Raised);
add_label("Container + Sunken", GFrame::Shape::Container, GFrame::Shadow::Sunken);
return window;
}