50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef BWIDGETS_LAYOUT_HPP
|
|
#define BWIDGETS_LAYOUT_HPP
|
|
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
#include <basic_widgets/core/type/size.hpp>
|
|
#include <basic_widgets/w/base/widget.hpp>
|
|
|
|
namespace bwidgets
|
|
{
|
|
class Renderer;
|
|
}
|
|
|
|
namespace bwidgets
|
|
{
|
|
class Layout : public Widget
|
|
{
|
|
protected:
|
|
std::vector<std::unique_ptr<Widget>> _widgets;
|
|
|
|
void _handle_geometry_change(const SDL_Rect&) override;
|
|
void _handle_renderer_change(const std::shared_ptr<Renderer>&) override;
|
|
void _handle_rendering() override;
|
|
|
|
virtual void _update_layout(const SDL_Rect&) = 0;
|
|
|
|
public:
|
|
static const Size default_margins;
|
|
|
|
Size margins = default_margins;
|
|
|
|
using Widget::Widget;
|
|
|
|
Layout(const Layout&) = delete;
|
|
Layout(Layout&&) = delete;
|
|
~Layout() override = default;
|
|
auto operator=(const Layout&) = delete;
|
|
auto operator=(Layout&&) = delete;
|
|
|
|
void handle_event(const SDL_Event&) override;
|
|
[[nodiscard]] auto size() const noexcept -> Size override = 0;
|
|
|
|
virtual auto add_widget(std::unique_ptr<Widget>) -> Layout*;
|
|
virtual void for_widgets(const std::function<void(Widget*)>&);
|
|
};
|
|
}
|
|
|
|
#endif
|