119 lines
3.2 KiB
C
119 lines
3.2 KiB
C
/*
|
|
* Kangaroo Punch Multi Player Game Server Mark II
|
|
* Copyright (C) 2020-2021 Scott Duensing
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
|
|
#ifndef GUI_H
|
|
#define GUI_H
|
|
|
|
|
|
#include "os.h"
|
|
#include "vesa.h"
|
|
#include "array.h"
|
|
#include "mouse.h"
|
|
#include "font.h"
|
|
|
|
|
|
#define GUI_GET_FLAG(w,f) ((w)->flags & (1 << (f)))
|
|
#define GUI_SET_FLAG(w,f) (w)->flags |= (1 << (f))
|
|
#define GUI_CLEAR_FLAG(w,f) (w)->flags &= (~(1 << (f)))
|
|
|
|
#define W(w) ((WidgetT *)w)
|
|
|
|
|
|
// Widget Magics
|
|
enum MagicE {
|
|
MAGIC_UNKNOWN = 0,
|
|
MAGIC_DESKTOP,
|
|
MAGIC_WINDOW,
|
|
MAGIC_BUTTON,
|
|
MAGIC_COUNT
|
|
};
|
|
|
|
// Widget Metrics
|
|
enum MetricE {
|
|
METRIC_BUTTON_BEZEL_SIZE = 0,
|
|
METRIC_BUTTON_HORIZONTAL_MARGIN,
|
|
METRIC_BUTTON_VERTICAL_MARGIN,
|
|
METRIC_WINDOW_BORDER_WIDTH,
|
|
METRIC_WINDOW_TITLE_HEIGHT,
|
|
METRIC_WINDOW_TITLE_GRAB_HEIGHT,
|
|
METRIC_COUNT
|
|
};
|
|
|
|
// Widget Colors
|
|
enum ColorE {
|
|
COLOR_BUTTON_BACKGROUND = 0,
|
|
COLOR_BUTTON_HIGHLIGHT,
|
|
COLOR_BUTTON_SHADOW,
|
|
COLOR_BUTTON_TEXT,
|
|
COLOR_DESKTOP,
|
|
COLOR_WINDOW_BACKGROUND,
|
|
COLOR_WINDOW_HIGHLIGHT,
|
|
COLOR_WINDOW_SHADOW,
|
|
COLOR_WINDOW_TITLE_ACTIVE,
|
|
COLOR_WINDOW_TITLE_INACTIVE,
|
|
COLOR_WINDOW_TITLE_TEXT_ACTIVE,
|
|
COLOR_WINDOW_TITLE_TEXT_INACTIVE,
|
|
COLOR_COUNT
|
|
};
|
|
|
|
// Mouse Events
|
|
enum MouseE {
|
|
MOUSE_EVENT_NONE = 0,
|
|
MOUSE_EVENT_IN,
|
|
MOUSE_EVENT_OUT,
|
|
MOUSE_EVENT_LEFT_DOWN,
|
|
MOUSE_EVENT_LEFT_HOLD,
|
|
MOUSE_EVENT_LEFT_UP
|
|
};
|
|
|
|
|
|
typedef struct DesktopS DesktopT;
|
|
typedef struct WidgetS WidgetT;
|
|
typedef struct WindowS WindowT;
|
|
|
|
|
|
extern int16_t _guiMetric[METRIC_COUNT];
|
|
extern PixelT _guiColor[COLOR_COUNT];
|
|
extern FontT *_guiFont;
|
|
extern WidgetT *_guiDragWidget;
|
|
extern uint16_t _guiDragOffsetX;
|
|
extern uint16_t _guiDragOffsetY;
|
|
extern WindowT *_guiActiveWindow;
|
|
|
|
|
|
void guiAttach(WidgetT *parent, WidgetT *child);
|
|
void guiComposite(void);
|
|
void guiDelete(WidgetT **widget);
|
|
void guiDrawHighlightFrame(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, PixelT upperLeft, PixelT lowerRight);
|
|
void guiDrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, PixelT pixel);
|
|
void guiDrawFilledRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, PixelT pixel);
|
|
void guiMousePositionOnWidgetGet(WidgetT *widget, MouseT *mouse, uint16_t *x, uint16_t *y);
|
|
void guiPaint(WidgetT *widget);
|
|
void guiProcessMouse(MouseT *mouse);
|
|
WidgetT *guiRootGet(void);
|
|
void guiSetWidgetAndChildrenDirty(WidgetT *widget);
|
|
DesktopT *guiStartup(void);
|
|
void guiShutdown(void);
|
|
void *guiUserDataGet(WidgetT *widget);
|
|
void guiUserDataSet(WidgetT *widget, void *userData);
|
|
void guiWidgetPositionOnScreenGet(WidgetT *widget, uint16_t *x, uint16_t *y);
|
|
|
|
|
|
#endif // GUI_H
|