Luna/libui/include/ui/Layout.h

64 lines
1.4 KiB
C
Raw Normal View History

/**
* @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);
Result<EventResult> handle_mousemove(Point position) override;
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);
Result<EventResult> handle_mousemove(Point position) override;
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;
};
}