2023-08-15 10:28:47 +00:00
|
|
|
/**
|
|
|
|
* @file Layout.h
|
|
|
|
* @author apio (cloudapio.eu)
|
|
|
|
* @brief Layout widgets to organize content.
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2023, the Luna authors.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <luna/Vector.h>
|
|
|
|
#include <ui/Widget.h>
|
|
|
|
|
|
|
|
namespace ui
|
|
|
|
{
|
|
|
|
enum class AdjustHeight
|
|
|
|
{
|
|
|
|
No,
|
|
|
|
Yes
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class AdjustWidth
|
|
|
|
{
|
|
|
|
No,
|
|
|
|
Yes
|
|
|
|
};
|
|
|
|
|
|
|
|
class HorizontalLayout final : public Widget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HorizontalLayout(AdjustHeight adjust_height = AdjustHeight::Yes, AdjustWidth adjust_width = AdjustWidth::Yes);
|
|
|
|
|
2023-08-15 13:10:13 +00:00
|
|
|
Result<EventResult> handle_mouse_move(Point position) override;
|
2023-08-29 13:26:34 +00:00
|
|
|
Result<EventResult> handle_mouse_leave() override;
|
2023-08-15 13:10:13 +00:00
|
|
|
Result<EventResult> handle_mouse_down(Point position, int buttons) override;
|
|
|
|
Result<EventResult> handle_mouse_up(Point position, int buttons) override;
|
2023-08-15 10:28:47 +00:00
|
|
|
|
|
|
|
Result<void> draw(Canvas& canvas) override;
|
|
|
|
|
|
|
|
Result<void> add_widget(Widget& widget);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector<Widget*> m_widgets;
|
|
|
|
AdjustHeight m_adjust_height;
|
|
|
|
AdjustWidth m_adjust_width;
|
|
|
|
int m_used_width;
|
|
|
|
};
|
2023-08-15 11:01:41 +00:00
|
|
|
|
|
|
|
class VerticalLayout final : public Widget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VerticalLayout(AdjustHeight adjust_height = AdjustHeight::Yes, AdjustWidth adjust_width = AdjustWidth::Yes);
|
|
|
|
|
2023-08-15 13:10:13 +00:00
|
|
|
Result<EventResult> handle_mouse_move(Point position) override;
|
2023-08-29 13:26:34 +00:00
|
|
|
Result<EventResult> handle_mouse_leave() override;
|
2023-08-15 13:10:13 +00:00
|
|
|
Result<EventResult> handle_mouse_down(Point position, int buttons) override;
|
|
|
|
Result<EventResult> handle_mouse_up(Point position, int buttons) override;
|
2023-08-15 11:01:41 +00:00
|
|
|
|
|
|
|
Result<void> draw(Canvas& canvas) override;
|
|
|
|
|
|
|
|
Result<void> add_widget(Widget& widget);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector<Widget*> m_widgets;
|
|
|
|
AdjustHeight m_adjust_height;
|
|
|
|
AdjustWidth m_adjust_width;
|
|
|
|
int m_used_height;
|
|
|
|
};
|
2023-08-15 10:28:47 +00:00
|
|
|
}
|