55#include < cstdint>
66#include < memory>
77
8+ // Forward declares
9+ class PluginHost ;
10+
811// from reddit
912template <typename T>
1013struct c_deleter ;
@@ -18,10 +21,16 @@ struct c_deleter<SDL_Window> final {
1821 }
1922};
2023
24+ /* *
25+ * Gui is the main abstraction for windowing and graphics.
26+ * Right now we use SDL_Video to manage the window on all platforms, OpenGL for rendering, and imgui as the UI toolkit.
27+ * Future version may make this an abstract class that can have multiple different implementations for different toolkits.
28+ */
2129class Gui {
2230 // constants
2331 public:
2432 enum class WindowingApi {
33+ None = 0 ,
2534 X11,
2635 Wayland,
2736 Win32,
@@ -34,13 +43,19 @@ class Gui {
3443 uint32_t aspectRatioWidth;
3544 uint32_t aspectRatioHeight;
3645 };
46+ static constexpr char kDefaultWindowTitle [] = " Template" ;
47+ static constexpr int32_t kDefaultWindowWidth = 400 ;
48+ static constexpr int32_t kDefaultWindowHeight = 400 ;
3749
3850 // API methods
3951 public:
4052 static bool IsApiSupported (WindowingApi api, bool isFloating);
4153 static bool GetPreferredApi (WindowingApi& outApi, bool & outIsFloating);
4254
43- Gui (WindowingApi api, bool isFloating); // Create
55+ static bool OnAppInit ();
56+ static bool OnAppQuit ();
57+
58+ Gui (PluginHost* host, WindowingApi api, bool isFloating); // Create
4459 ~Gui (); // Destroy
4560
4661 bool SetScale (double scale);
@@ -51,7 +66,8 @@ class Gui {
5166 bool SetSize (uint32_t width, uint32_t height);
5267 bool SetParent (WindowingApi api, void * windowPointer);
5368 bool SetTransient (WindowingApi api, void * windowPointer);
54- void SuggestTitle (std::string_view title);
69+ // _must_ be c-string
70+ void SuggestTitle (const char * title);
5571 bool Show ();
5672 bool Hide ();
5773 void Update (float dt);
@@ -60,7 +76,10 @@ class Gui {
6076 private:
6177 c_unique_ptr<SDL_Window> mWindowHandle ;
6278 c_unique_ptr<SDL_Window> mParentHandle ;
79+ PluginHost* mHost ;
80+ SDL_GLContext mCtx ;
6381
6482 void CreateWindow ();
6583 void CreateParentWindow (WindowingApi api, void * windowPointer);
84+ void OnGui ();
6685};
0 commit comments