MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / main

Function main

Applications/GUITest/main.cpp:19–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19int main(){
20 Lemon::GUI::Window* win = new Lemon::GUI::Window("Test Window", {640, 480}, WINDOW_FLAGS_RESIZABLE, Lemon::GUI::WindowType::GUI);
21
22 Lemon::GUI::Button* button = new Lemon::GUI::Button("I am a Button", {10, 10, 125, 24});
23 win->AddWidget(button);
24 button->SetLayout(Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::WidgetAlignment::WAlignRight);
25
26 Lemon::GUI::Button* button2 = new Lemon::GUI::Button("I am a Looooong Button", {10, 10, 145, 24});
27 win->AddWidget(button2);
28 button2->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::WidgetAlignment::WAlignLeft);
29
30 Lemon::GUI::TextBox* tBox = new Lemon::GUI::TextBox({10, 40, 10, 20}, false);
31 win->AddWidget(tBox);
32 tBox->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::WidgetAlignment::WAlignLeft);
33
34 Lemon::GUI::Bitmap* drawBox = new Lemon::GUI::Bitmap({10, 70, 400, 100}); // Rectangle clip test
35 win->AddWidget(drawBox);
36 rect_t r1 = {10, 20, 300, 70};
37 rect_t r2 = {50, 10, 100, 60};
38 auto rClips = r1.Split(r2);
39 for(auto rect : rClips){
40 Lemon::Graphics::DrawRect(rect, (rgba_colour_t){255, 255, 0, 255}, &drawBox->surface);
41 Lemon::Graphics::DrawString("r1 clip", rect.x, rect.y, 0, 0, 0, &drawBox->surface);
42 }
43
44 Lemon::Graphics::DrawRect(r2, {0, 255, 255, 255}, &drawBox->surface);
45
46 Lemon::GUI::ListView* lView = new Lemon::GUI::ListView({10, 180, 10, 100});
47 win->AddWidget(lView);
48 lView->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Fixed, Lemon::GUI::WidgetAlignment::WAlignLeft);
49
50 Lemon::GUI::GridView* gridView = new Lemon::GUI::GridView({10, 290, 10, 10});
51 win->AddWidget(gridView);
52 gridView->SetLayout(Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::LayoutSize::Stretch, Lemon::GUI::WidgetAlignment::WAlignLeft);
53
54 surface_t folderIcon;
55 Lemon::Graphics::LoadImage("/initrd/folder.png", &folderIcon);
56 surface_t fileIcon;
57 Lemon::Graphics::LoadImage("/initrd/file.png", &fileIcon);
58
59 Lemon::GUI::GridItem item1;
60 item1.name = "Item";
61 item1.icon = &folderIcon;
62
63 Lemon::GUI::GridItem item2;
64 item2.name = "Another Item";
65 item2.icon = &fileIcon;
66
67 for(int i = 0; i < 16; i++){
68 gridView->AddItem(item1);
69 }
70
71 for(int i = 0; i < 16; i++){
72 gridView->AddItem(item2);
73 }
74
75 Lemon::GUI::ListColumn col1;
76 col1.displayWidth = 220;

Callers

nothing calls this directly

Calls 13

randFunction · 0.85
SetLayoutMethod · 0.80
SplitMethod · 0.80
AddItemMethod · 0.80
AddColumnMethod · 0.80
PollEventMethod · 0.80
GUIHandleEventMethod · 0.80
WaitEventMethod · 0.80
DrawRectFunction · 0.50
DrawStringFunction · 0.50
LoadImageFunction · 0.50
AddWidgetMethod · 0.45

Tested by

no test coverage detected