51#if defined(__GNUC__) && !ANDROID
52#pragma GCC diagnostic ignored "-Wnonnull-compare"
66#define UI_BUTTONS_HEIGHT 64
67#define UI_BUTTONS_SPACE 8
69#define UI_BUTTONS_RECT Rect (0, UI_RES_Y - UI_BUTTONS_HEIGHT, UI_RES_X, UI_BUTTONS_HEIGHT)
71#define UI_BUTTONS_BACKWIDTH (UI_BUTTONS_HEIGHT + UI_BUTTONS_HEIGHT/2)
74#define UI_USER_RECT Rect (0, 0, UI_RES_X, UI_RES_Y - UI_BUTTONS_HEIGHT - UI_BUTTONS_SPACE)
101 void Set (SDL_Surface *_surf,
int x0,
int y0) {
102 SetArea (Rect (_surf)); RectMove (&area, x0, y0);
SetSurface (_surf);
105 void SetArea (SDL_Rect _area) { area = _area; }
106 SDL_Rect *GetArea () {
return &area; }
108 class CScreen *GetScreen () {
return screen; }
109 bool IsOnScreen (
class CScreen *_screen) {
return screen == _screen; }
110 class CCanvas *GetCanvas () {
return canvas; }
115 void LocalToScreenCoords (
int *x,
int *y);
116 void ScreenToLocalCoords (
int *x,
int *y);
118 void GetMouseEventPos (SDL_Event *ev,
int *x,
int *y);
134 void GetRenderArea (SDL_Rect *ra) { *ra = area; LocalToScreenCoords (&ra->x, &ra->y); }
174 SDL_Surface *surface;
175 SDL_Texture *texture;
176 SDL_BlendMode sdlBlendMode;
192 static void RenderList (
CWidget *list, SDL_Renderer *ren);
221 void SetColors (TColor _backColor = BLACK, TColor _scrollbarColor = ToColor (255, 255, 255, 32)) {
222 backColor = _backColor; scrollbarColor = _scrollbarColor;
Changed ();
224 void SetScrollbarWidth (
int width = 8) { scrollbarWidth = width;
Changed (); }
226 void SetArea (SDL_Rect _area) { CWidget::SetArea (_area);
SetVirtArea (_area); }
234 SDL_Rect *GetVirtArea () {
return &virtArea; }
235 void MoveVirtArea (
int toX0,
int toY0) {
SetVirtArea (Rect (toX0, toY0, virtArea.w, virtArea.h)); }
238 void ScrollTo (SDL_Rect r,
int hAlign = 0,
int vAlign = -1);
246 void WidgetToScreenCoords (
int *x,
int *y);
247 void ScreenToWidgetCoords (
int *x,
int *y);
253 void AddWidget (
CWidget *widget) { DoAddWidget (&firstWidget, widget); }
254 void DelWidget (
CWidget *widget) { DoDelWidget (&firstWidget, widget); }
255 void DelAllWidgets ();
260 bool IsVisible (SDL_Rect *r);
261 bool IsVisible (
CWidget *w) {
return IsVisible (w->GetArea ()); }
274 TColor backColor, scrollbarColor;
295 CScreen () { firstWidget = NULL; changed =
true; withKeyboard =
false; }
301 static void ClassInit () { }
302 static void ClassDone () {}
307 static void EmulateOff (
bool off) { emulateOff = off; Changed (); }
309 static void EmulateStandby (
bool standby) { emulateStandby = standby; Changed (); }
315 bool IsActive () {
return this == activeScreen; }
316 static class CScreen *ActiveScreen () {
return activeScreen; }
317 virtual void Activate (
bool on =
true);
318 void Deactivate () { Activate (
false); }
325 void AddWidget (
CWidget *widget,
int layer = 0) { DoAddWidget (&firstWidget, widget, layer); }
326 void DelWidget (
CWidget *widget) { DoDelWidget (&firstWidget, widget); }
327 void DelAllWidgets ();
344 void SetKeyboard (
bool on);
345 bool HasKeyboard () {
return withKeyboard; }
352 static class CScreen *activeScreen;
354 static bool emulateOff, emulateStandby;
355 static bool keyboardOn;
358 bool running, withKeyboard;
361 virtual bool HandleEvent (SDL_Event *ev);
364 static void Changed () { changed =
true; }
365 static void RenderUpdate ();
446static inline void ScreenInit () { CScreen::ClassInit (); }
447static inline void ScreenDone () { CScreen::ClassDone (); }
void SetVirtArea(SDL_Rect r)
Set the virtual area in screen coordinates; ('virtArea' == 'area' represents no displacement); The ar...
virtual void Render(SDL_Renderer *ren)
Render this widget.
virtual bool HandleEvent(SDL_Event *ev)
Handle wiping/scrolling events, if virtual area is wider (higher) than physical area.
void LimitVirtArea(SDL_Rect *r=NULL)
Move virtual area (or 'r') so that the visible area is completely filled.
void ScrollTo(SDL_Rect r, int hAlign=0, int vAlign=-1)
Scroll such that 'r' is aligned according to '[vh]Align' (-1 = left/up, 0 = center,...
void ScrollIn(SDL_Rect r)
Scroll just enough to get 'r' fully visible.
void SetDefaults()
Set default colors and scrollbar appearance.
void Run()
Activate the screen, iterate until Return() is called and then return to the previously active screen...
static void EmulateStandby(bool standby)
Emulate screen standby mode.
static void EmulateOff(bool off)
Emulate screen off.
static void Refresh()
Refresh screen (e.g. after the app has been woken up in Android).
friend void UiIterate(bool noWait)
void Return()
Let Run() return at next occasion.
static SDL_Rect * LayoutColEqually(SDL_Rect container, int items, int space=UI_BUTTONS_SPACE)
Layout a column of 'items' rectangles with equal width.
SDL_Rect * LayoutCol(SDL_Rect container, const int *format, int items=-1, int space=UI_BUTTONS_SPACE)
Layout a column of rectangles.
SDL_Rect * LayoutRow(SDL_Rect container, const int *format, int items=-1, int space=UI_BUTTONS_SPACE)
Layout a row of rectangles.
SDL_Rect * LayoutMatrix(SDL_Rect container, const int *hFormat, const int *vFormat, int hItems=-1, int vItems=-1, int hSpace=UI_BUTTONS_SPACE, int vSpace=UI_BUTTONS_SPACE)
Layout a matrix of variable-size elements.
#define UI_BUTTONS_SPACE
Standard spacing between buttons.
static SDL_Rect * LayoutRowEqually(SDL_Rect container, int items, int space=UI_BUTTONS_SPACE)
Layout a row of 'items' rectangles with equal width.