aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.h
blob: 76d9b1fb7d9259029ebd89257d1b60f6510f7620 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "utils.h"

#ifndef UI_H
#define UI_H

#ifndef RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT
#define RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT 24
#endif

#ifndef RAYGUI_WINDOW_CLOSEBUTTON_SIZE
#define RAYGUI_WINDOW_CLOSEBUTTON_SIZE 18
#endif

#define UI_WINDOW_TITLE_MAX 32
#define UI_WINDOW_MAX 4

typedef void (*DrawWindowContentCallback)(Vector2 position, Vector2 scroll);

typedef enum {
  NO_FOCUS_ACTION,
  REQUEST_FOCUS,
  DEMAND_FOCUS
} FocusCommand;

typedef struct {
  char title[UI_WINDOW_TITLE_MAX];
  Rectangle rect;
  bool minimized;
  bool moving;
  bool resizing;
  DrawWindowContentCallback callback;
  Vector2 contentSize;
  Vector2 scroll;
  bool hasFocus;
} FloatingWindow;

typedef struct {
  FloatingWindow windows[UI_WINDOW_MAX];
  int windowCount;
} WindowManager;

FloatingWindow createFloatingWindow(const char* title, Rectangle rect);
FocusCommand updateFloatingWindow(FloatingWindow* window);

void initWindowManager(WindowManager* wm);
void updateWindowManager(WindowManager* wm);
void addWindowToWindowManager(WindowManager* wm, FloatingWindow window);
void focusOnWindow(WindowManager* wm, int windowIndex);

#endif