Luna/apps/gclient.cpp
2023-08-15 13:01:41 +02:00

57 lines
1.1 KiB
C++

#include <ui/App.h>
#include <ui/Layout.h>
struct ColorWidget : public ui::Widget
{
public:
ColorWidget(ui::Color color) : m_color(color)
{
}
Result<ui::EventResult> handle_mousemove(ui::Point) override
{
return ui::EventResult::DidNotHandle;
}
Result<void> draw(ui::Canvas& canvas) override
{
canvas.fill(m_color);
return {};
}
private:
ui::Color m_color;
};
Result<int> luna_main(int argc, char** argv)
{
ui::App app;
TRY(app.init(argc, argv));
auto* window = TRY(ui::Window::create(ui::Rect { 200, 200, 400, 300 }));
app.set_main_window(window);
window->set_title("Main Window");
window->set_background(ui::CYAN);
ui::HorizontalLayout layout;
window->set_main_widget(layout);
ColorWidget green(ui::GREEN);
layout.add_widget(green);
ColorWidget blue(ui::BLUE);
layout.add_widget(blue);
ui::VerticalLayout sublayout;
layout.add_widget(sublayout);
ColorWidget red(ui::RED);
sublayout.add_widget(red);
ColorWidget white(ui::WHITE);
sublayout.add_widget(white);
window->draw();
return app.run();
}