Add GUI Support

This commit is contained in:
2025-06-12 15:43:58 -05:00
parent dd4527645e
commit 71a2c83e5a
59 changed files with 3114 additions and 103 deletions

View File

@ -0,0 +1,33 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class AbsoluteView : public ContainerView {
std::vector<std::pair<std::pair<View*,bool>,SDL_Rect>> views;
protected:
void OnDraw(SDL_Renderer* renderer, SDL_Rect& myRect);
bool OnEvent(SDL_Event& event, SDL_Rect& myBounds, SDL_Rect& visibleBounds);
public:
size_t ViewCount();
View* GetViewAt(size_t index);
AbsoluteView();
void Add(SDL_Rect rect, View* view, bool owns=true);
void Set(View* view, SDL_Rect rect);
void Remove(View* view);
~AbsoluteView();
};
/* class AbsoluteContainer : public View {
std::vector<std::pair<std::pair<View*,bool>,SDL_Rect>> views;
public:
void Add(SDL_Rect rect, View* view, bool owns=true);
void Set(View* view, SDL_Rect rect);
void Remove(View* view);
~AbsoluteContainer();
};*/
}
#endif

View File

@ -0,0 +1,18 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class ButtonView : public View {
protected:
virtual void OnDraw(SDL_Renderer* renderer, SDL_Rect& r);
virtual bool OnEvent(SDL_Event& event, SDL_Rect& myBounds, SDL_Rect& visibleBounds);
public:
ButtonView();
ButtonView(std::string text);
};
}
#endif

View File

@ -0,0 +1,25 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class CheckView : public View {
protected:
virtual void OnCheckChanged(GUIEventArgs& event);
virtual void OnDraw(SDL_Renderer* renderer, SDL_Rect& r);
virtual bool OnEvent(SDL_Event& event, SDL_Rect& myBounds, SDL_Rect& visibleBounds);
public:
CheckView(bool checked, std::string label);
CheckView();
virtual bool GetChecked();
virtual void SetChecked(bool value);
EventList<View*,GUIEventArgs&> CheckChanged;
};
}
#endif

View File

@ -0,0 +1,15 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class LabelView : public View {
protected:
virtual void OnDraw(SDL_Renderer* renderer, SDL_Rect& r);
public:
LabelView();
LabelView(std::string text);
};
}
#endif

View File

@ -0,0 +1,17 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class ProgressView : public View
{
protected:
virtual void OnDraw(SDL_Renderer* renderer, SDL_Rect& r);
public:
ProgressView();
ProgressView(double value);
double value;
};
};
#endif

View File

@ -0,0 +1,20 @@
#pragma once
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
#include "../GUI.hpp"
namespace Tesses::Framework::SDL2::Views
{
class TextListView : public View {
protected:
virtual void OnDraw(SDL_Renderer* renderer, SDL_Rect& r);
virtual bool OnEvent(SDL_Event& event, SDL_Rect& myBounds, SDL_Rect& visibleBounds);
public:
TextListView();
size_t firstIndex;
int selected;
std::vector<std::string> items;
};
}
#endif