Skip to content

Commit e99cb74

Browse files
linusgawesomekling
authored andcommitted
WidgetGallery: Add "Cursors" tab
1 parent 899dcba commit e99cb74

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

Demos/WidgetGallery/main.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3+
* Copyright (c) 2020, Linus Groh <mail@linusgroh.de>
34
* All rights reserved.
45
*
56
* Redistribution and use in source and binary forms, with or without
@@ -243,6 +244,76 @@ int main(int argc, char** argv)
243244
auto& gif_animation_image = tab_image.add<GUI::Image>();
244245
gif_animation_image.load_from_file("/res/download-animation.gif");
245246

247+
auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors");
248+
tab_cursors.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
249+
tab_cursors.set_layout<GUI::VerticalBoxLayout>();
250+
tab_cursors.layout()->set_margins({ 4, 4, 4, 4 });
251+
tab_cursors.layout()->set_spacing(4);
252+
253+
auto& cursor_group_box = tab_cursors.add<GUI::GroupBox>("Cursor");
254+
cursor_group_box.set_layout<GUI::VerticalBoxLayout>();
255+
cursor_group_box.layout()->set_margins({ 5, 15, 5, 5 });
256+
cursor_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
257+
cursor_group_box.set_preferred_size(0, 390);
258+
259+
auto& radio_cursor_none = cursor_group_box.add<GUI::RadioButton>("None");
260+
radio_cursor_none.set_checked(true);
261+
radio_cursor_none.on_checked = [&](bool) {
262+
window->set_override_cursor(GUI::StandardCursor::None);
263+
};
264+
auto& radio_cursor_arrow = cursor_group_box.add<GUI::RadioButton>("Arrow");
265+
radio_cursor_arrow.on_checked = [&](bool) {
266+
window->set_override_cursor(GUI::StandardCursor::Arrow);
267+
};
268+
auto& radio_cursor_i_beam = cursor_group_box.add<GUI::RadioButton>("IBeam");
269+
radio_cursor_i_beam.on_checked = [&](bool) {
270+
window->set_override_cursor(GUI::StandardCursor::IBeam);
271+
};
272+
auto& radio_cursor_resize_horizontal = cursor_group_box.add<GUI::RadioButton>("ResizeHorizontal");
273+
radio_cursor_resize_horizontal.on_checked = [&](bool) {
274+
window->set_override_cursor(GUI::StandardCursor::ResizeHorizontal);
275+
};
276+
auto& radio_cursor_resize_vertical = cursor_group_box.add<GUI::RadioButton>("ResizeVertical");
277+
radio_cursor_resize_vertical.on_checked = [&](bool) {
278+
window->set_override_cursor(GUI::StandardCursor::ResizeVertical);
279+
};
280+
auto& radio_cursor_resize_diagonal_tlbr = cursor_group_box.add<GUI::RadioButton>("ResizeDiagonalTLBR");
281+
radio_cursor_resize_diagonal_tlbr.on_checked = [&](bool) {
282+
window->set_override_cursor(GUI::StandardCursor::ResizeDiagonalTLBR);
283+
};
284+
auto& radio_cursor_resize_diagonal_bltr = cursor_group_box.add<GUI::RadioButton>("ResizeDiagonalBLTR");
285+
radio_cursor_resize_diagonal_bltr.on_checked = [&](bool) {
286+
window->set_override_cursor(GUI::StandardCursor::ResizeDiagonalBLTR);
287+
};
288+
auto& radio_cursor_resize_column = cursor_group_box.add<GUI::RadioButton>("ResizeColumn");
289+
radio_cursor_resize_column.on_checked = [&](bool) {
290+
window->set_override_cursor(GUI::StandardCursor::ResizeColumn);
291+
};
292+
auto& radio_cursor_resize_row = cursor_group_box.add<GUI::RadioButton>("ResizeRow");
293+
radio_cursor_resize_row.on_checked = [&](bool) {
294+
window->set_override_cursor(GUI::StandardCursor::ResizeRow);
295+
};
296+
auto& radio_cursor_hand = cursor_group_box.add<GUI::RadioButton>("Hand");
297+
radio_cursor_hand.on_checked = [&](bool) {
298+
window->set_override_cursor(GUI::StandardCursor::Hand);
299+
};
300+
auto& radio_cursor_help = cursor_group_box.add<GUI::RadioButton>("Help");
301+
radio_cursor_help.on_checked = [&](bool) {
302+
window->set_override_cursor(GUI::StandardCursor::Help);
303+
};
304+
auto& radio_cursor_drag = cursor_group_box.add<GUI::RadioButton>("Drag");
305+
radio_cursor_drag.on_checked = [&](bool) {
306+
window->set_override_cursor(GUI::StandardCursor::Drag);
307+
};
308+
auto& radio_cursor_move = cursor_group_box.add<GUI::RadioButton>("Move");
309+
radio_cursor_move.on_checked = [&](bool) {
310+
window->set_override_cursor(GUI::StandardCursor::Move);
311+
};
312+
auto& radio_cursor_wait = cursor_group_box.add<GUI::RadioButton>("Wait");
313+
radio_cursor_wait.on_checked = [&](bool) {
314+
window->set_override_cursor(GUI::StandardCursor::Wait);
315+
};
316+
246317
window->show();
247318

248319
return app->exec();

0 commit comments

Comments
 (0)