8 #ifndef Guit_NativeSDL_hpp
9 #define Guit_NativeSDL_hpp
13 #include <gcursor.hpp>
15 #include <objc/objc-runtime.h>
30 GNatContext(
class GControlImpl&);
34 void subLoop(
const bool& quit);
36 void setMainLoopDelay(
unsigned int ms_delay);
37 void setSwapInterval(
int interval);
39 static uint32_t elapsedTime();
40 GDim
const& screenSize()
const {
return screensize_;}
42 GPoint cursorPos()
const;
43 void moveCursor(GPoint
const&);
44 void setCursorShape(GCursor::Shape);
45 void showCursor(
bool state);
46 void freezeCursor(
bool state);
47 void grabCursor(
bool state);
49 bool getClipboard(GString& text)
const;
50 bool setClipboard(GString
const& text);
52 bool startTimer(GTimer&, GTime delay);
53 bool stopTimer(GTimer&);
54 void pushUserEvent(GFunction* fun);
56 static bool loadFont(GFontResource&);
57 static void deleteFont(GFontResource&);
58 static bool getFontInfo(GString
const& path, GString& family, GString& style);
59 static GTexture createFontTexture(GString
const& text, GFontResource&);
61 static GDim textSize(GFontResource&, GString
const& text);
62 static float textWidth(GFontResource&, GString
const& text);
63 static float fontHeight(GFontResource&);
64 static float fontAscent(GFontResource&);
65 static float fontDescent(GFontResource&);
67 static void readTexture(
const char** xpm, GIconValue&);
68 static void readTexture(GString
const& filename, GIconValue&);
69 static SDL_Surface* readSurface(
const char** xpm);
70 static SDL_Surface* readSurface(GString
const& filename);
71 static void deleteSurface(SDL_Surface*);
75 int waitEvent(SDL_Event*);
76 void processEvent(SDL_Event
const&);
77 void processWindowEvent(SDL_Event
const&, GWindow&);
81 static GTexture surfaceToTexture(SDL_Surface*);
82 class GControlImpl& ctrl_;
83 Uint32 mainloop_delay_{10}, focus_winid_{}, focus_time_{};
91 GNatWindow(GWindow*,
bool with_border,
bool resizable);
94 Uint32 winID()
const {
return winid_;}
95 void setClip(
float x,
float y,
float w,
float h);
96 GLContext* glcontext() {
return (GLContext*)glcontext_;}
97 GLContext* createGLContext();
99 void makeCurrent(GLContext*);
102 void show(
bool state);
108 void move(
float x,
float y);
109 void resize(
float w,
float h);
111 bool setIcon(GString
const& filename);
112 void setTitle(GString
const& title);
113 bool setOpacity(
float opacity);
114 void setResizable(
bool resizable);
115 void setMinSize(
float w,
float h);
116 void setMaxSize(
float w,
float h);
117 void setBordered(
bool bordered);
122 void stayOnTopOf(GNatWindow&);
123 void joinAllSpaces();
124 void setTitlebarTransparent(
bool);
125 void hideCloseButton(
bool);
126 void hideMiniaturizeButton(
bool);
127 void hideZoomButton(
bool);
128 void disallowFullScreen();
131 void createDelegate();
132 void deleteDelegate();
133 void resizeCB(uint32_t time,
int w,
int h);
135 SDL_Window* sdlwin_{};
136 SDL_GLContext glcontext_{};
138 bool usermove_{}, userresize_{};