11#include "sml/sml_graphics_wrapper.h"
12#include "../events/gui_event_dispatching.h"
13#include "../paint/shadow.h"
20 enum class Orientation
37 INVISIBLE_DISABLED = 0b00,
38 INVISIBLE_INTERACTABLE = 0b01,
39 VISIBLE_DISABLED = 0b10,
40 VISIBLE_INTERACTABLE = 0b11
44 static const int32_t USE_COMPUTED_SIZE = INT32_MIN;
45 static const int32_t UNLIMITED_SIZE = INT32_MAX;
53 virtual Component* getHitComponent(int32_t x, int32_t y);
54 virtual void render(
const Sml::Rectangle<int32_t>& targetRegion) = 0;
55 virtual void layout();
56 virtual void prerender();
57 virtual bool containsComponent(
Component* component);
59 virtual Sml::EventDispatchChain* buildEventDispatchChain(Sml::EventDispatchChain* chain)
override;
61 bool isVisible()
const;
62 void setVisible(
bool visible);
64 bool isInteractable()
const;
65 void setInteractable(
bool interactable);
70 bool isFocused()
const;
71 bool isHovered()
const;
73 virtual bool isResizable()
const = 0;
78 const Shadow& getShadow()
const;
84 void setScene(
Scene* scene);
86 const Parent* getParent()
const;
87 Parent* getModifiableParent();
88 void setParent(
Parent* parent);
90 Sml::Vec2i computeLocalToScenePos(
const Sml::Vec2i& localPos)
const;
91 Sml::Vec2i computeSceneToLocalPos(
const Sml::Vec2i& scenePos)
const;
93 Sml::Rectangle<int32_t> getOriginBounds()
const;
94 const Sml::Rectangle<int32_t>& getLayoutBounds()
const;
95 const Sml::Vec2i& getLayoutPos()
const;
96 int32_t getLayoutX()
const;
97 int32_t getLayoutY()
const;
98 int32_t getLayoutWidth()
const;
99 int32_t getLayoutHeight()
const;
101 void setLayoutX(int32_t x);
102 void setLayoutY(int32_t y);
103 void setLayoutWidth(int32_t width);
104 void setLayoutHeight(int32_t height);
106 Sml::Vec2i computeScenePos();
108 virtual int32_t computePrefWidth(int32_t height = -1)
const = 0;
109 virtual int32_t computePrefHeight(int32_t width = -1)
const = 0;
111 virtual int32_t computeMinWidth(int32_t height = -1)
const = 0;
112 virtual int32_t computeMinHeight(int32_t width = -1)
const = 0;
114 virtual int32_t computeMaxWidth(int32_t height = -1)
const = 0;
115 virtual int32_t computeMaxHeight(int32_t width = -1)
const = 0;
118 Visibility m_Visibility = Visibility::VISIBLE_INTERACTABLE;
119 bool m_Focused =
false;
120 bool m_Hovered =
false;
125 Scene* m_Scene =
nullptr;
126 Parent* m_Parent =
nullptr;
127 Sml::Rectangle<int32_t> m_LayoutBounds = {{0, 0}, 0, 0};
130 void renderShadow(
const Sml::Rectangle<int32_t>& targetRegion);
131 virtual void setSceneInSceneTree(Scene* scene);
Visibility
Used to determine if Component should be rendered and targeted by events.