Implement parent component hover state handling.

This commit is contained in:
2023-10-12 19:35:16 -05:00
parent 1c4ec84d75
commit 18db45e6c3
5 changed files with 86 additions and 21 deletions
+10 -3
View File
@@ -8,6 +8,7 @@ class MenuComponent{
MenuType menuDest;
private:
float hoverEffect=0;
virtual bool GetHoverState(Crawler*game);
protected:
geom2d::rect<float>rect;
std::string label;
@@ -15,15 +16,21 @@ protected:
bool draggable=false;
MenuFunc onClick;
MenuType parentMenu=MenuType::ENUM_END;
MenuComponent*parentComponent=nullptr;
bool hovered=false;
bool selectable=true;
bool disabled=false; //If set to true, this component will not be rendered or updated.
bool renderInMain=true; //If set to false, this component is the responsibility of some other windowing system and won't be rendered or updated via the main window loop.
public:
MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable=true);
MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
virtual void Update(Crawler*game);
virtual void Draw(Crawler*game,vf2d parentPos,bool focused);
virtual void DrawDecal(Crawler*game,vf2d parentPos,bool focused);
virtual bool GetHoverState(Crawler*game,MenuComponent*child);
public:
MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable=true);
MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
void _Update(Crawler*game);
void _Draw(Crawler*game,vf2d parentPos,bool focused);
void _DrawDecal(Crawler*game,vf2d parentPos,bool focused);
//We picked up a draggable component, we should make a copy and return it here. If a nullptr is returned here, the pickup is not allowed.
//WARNING!!! This allocates a brand new component when successful!!! Be prepared to clear it!
virtual MenuComponent*PickUpDraggableItem();