diff --git a/client/client.pro b/client/client.pro
index 203f831..2283235 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -70,6 +70,7 @@ HEADERS = \
$$SHARED/primes.h \
$$SHARED/packet.h \
$$SHARED/packets.h \
+ src/browser.h \
src/config.h \
$$SHARED/util.h \
src/file.h \
@@ -125,6 +126,7 @@ SOURCES = \
$$SHARED/thirdparty/tiny-AES-c/aes.c \
$$SHARED/thirdparty/tiny-AES128-C/pkcs7_padding.c \
$$SHARED/memory.c \
+ src/browser.c \
src/file.c \
src/gui/msgbox.c \
src/gui/timer.c \
diff --git a/client/src/browser.c b/client/src/browser.c
new file mode 100644
index 0000000..d89a488
--- /dev/null
+++ b/client/src/browser.c
@@ -0,0 +1,255 @@
+/*
+ * Kangaroo Punch MultiPlayer 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 .
+ *
+ */
+
+
+#include "browser.h"
+
+#include "taglist.h"
+#include "msgbox.h"
+#include "window.h"
+#include "picture.h"
+#include "button.h"
+#include "frame.h"
+#include "listbox.h"
+
+#include "network.h"
+
+
+static WindowT *_winBrowser = NULL;
+static ButtonT *_btnBoxTab = NULL;
+static ButtonT *_btnDescriptionTab = NULL;
+static ButtonT *_btnInfoTab = NULL;
+static ButtonT *_btnScreensTab = NULL;
+static ButtonT *_btnSearchTab = NULL;
+static uint8_t _channel = 0;
+static FrameT *_fraBox = NULL;
+static FrameT *_fraDescription = NULL;
+static FrameT *_fraInfo = NULL;
+static FrameT *_fraScreens = NULL;
+static FrameT *_fraSearch = NULL;
+static ListboxT *_lstDescription = NULL;
+static ListboxT *_lstInfo = NULL;
+static PictureT *_picBanner = NULL;
+static PictureT *_picBox1 = NULL;
+static PictureT *_picBox2 = NULL;
+static PictureT *_picThumb1 = NULL;
+static PictureT *_picThumb2 = NULL;
+static PictureT *_picThumb3 = NULL;
+static PictureT *_picThumb4 = NULL;
+static PictureT *_picThumb5 = NULL;
+static PictureT *_picThumb6 = NULL;
+
+
+static void btnTabClick(WidgetT *widget);
+static void packetHandler(PacketDecodeDataT *packet);
+
+
+void browserShow(void) {
+
+ TagItemT uiBrowser[] = {
+ T_START,
+ T_WINDOW, O(_winBrowser),
+ T_TITLE, P("Game Browser"),
+ T_WIDTH, 525, T_HEIGHT, 323,
+
+ // SEARCH
+ T_BUTTON, O(_btnSearchTab),
+ T_X, 5, T_Y, 5,
+ T_TITLE, P("Search"),
+ T_CLICK, P(btnTabClick),
+ T_BUTTON, T_DONE,
+ T_FRAME, O(_fraSearch),
+ T_X, 5, T_Y, 32,
+ T_WIDTH, 500, T_HEIGHT, 250,
+ T_TITLE, P("Search"),
+ T_VISIBLE, T_FALSE,
+ T_FRAME, T_DONE,
+
+ // GAME
+ T_BUTTON, O(_btnDescriptionTab),
+ T_X, 78, T_Y, 5,
+ T_TITLE, P("Game"),
+ T_CLICK, P(btnTabClick),
+ T_BUTTON, T_DONE,
+ T_FRAME, O(_fraDescription),
+ T_X, 5, T_Y, 32,
+ T_WIDTH, 500, T_HEIGHT, 250,
+ T_TITLE, P("Description"),
+ T_VISIBLE, T_FALSE,
+
+ T_PICTURE, O(_picBanner),
+ T_X, 1, // 490PX wide
+ T_FILENAME, P("banner.png"),
+ T_PICTURE, T_DONE,
+ T_LISTBOX, O(_lstDescription),
+ T_X, 1, T_Y, 105,
+ T_WIDTH, 493, T_HEIGHT, 124, // Works out to 57 characters wide, 8 high.
+ T_LISTBOX, T_DONE,
+
+ T_FRAME, T_DONE,
+
+ // SCREENSHOTS
+ T_BUTTON, O(_btnScreensTab),
+ T_X, 135, T_Y, 5,
+ T_TITLE, P("Screens"),
+ T_CLICK, P(btnTabClick),
+ T_BUTTON, T_DONE,
+ T_FRAME, O(_fraScreens),
+ T_X, 5, T_Y, 32,
+ T_WIDTH, 500, T_HEIGHT, 250,
+ T_TITLE, P("Screenshots"),
+ T_VISIBLE, T_FALSE,
+
+ T_PICTURE, O(_picThumb1), // Thumbs are 160x100
+ T_X, 1, T_Y, 5,
+ T_FILENAME, P("thumb1.png"),
+ T_PICTURE, T_DONE,
+ T_PICTURE, O(_picThumb2),
+ T_X, 167, T_Y, 5,
+ T_FILENAME, P("thumb2.png"),
+ T_PICTURE, T_DONE,
+ T_PICTURE, O(_picThumb3),
+ T_X, 333, T_Y, 5,
+ T_FILENAME, P("thumb3.png"),
+ T_PICTURE, T_DONE,
+
+ T_PICTURE, O(_picThumb4),
+ T_X, 1, T_Y, 116,
+ T_FILENAME, P("thumb4.png"),
+ T_PICTURE, T_DONE,
+ T_PICTURE, O(_picThumb5),
+ T_X, 167, T_Y, 116,
+ T_FILENAME, P("thumb5.png"),
+ T_PICTURE, T_DONE,
+ T_PICTURE, O(_picThumb6),
+ T_X, 333, T_Y, 116,
+ T_FILENAME, P("thumb6.png"),
+ T_PICTURE, T_DONE,
+
+ T_FRAME, T_DONE,
+
+ // BOX
+ T_BUTTON, O(_btnBoxTab),
+ T_X, 216, T_Y, 5,
+ T_TITLE, P("Box"),
+ T_CLICK, P(btnTabClick),
+ T_BUTTON, T_DONE,
+ T_FRAME, O(_fraBox),
+ T_X, 5, T_Y, 32,
+ T_WIDTH, 500, T_HEIGHT, 250,
+ T_TITLE, P("Packaging"),
+ T_VISIBLE, T_FALSE,
+
+ T_PICTURE, O(_picBox1), // Thumbs are 240x210
+ T_X, 1, T_Y, 5,
+ T_FILENAME, P("box1.png"),
+ T_PICTURE, T_DONE,
+ T_PICTURE, O(_picBox2),
+ T_X, 250, T_Y, 5,
+ T_FILENAME, P("box2.png"),
+ T_PICTURE, T_DONE,
+
+ T_FRAME, T_DONE,
+
+ // INFO
+ T_BUTTON, O(_btnInfoTab),
+ T_X, 265, T_Y, 5,
+ T_TITLE, P("Info"),
+ T_CLICK, P(btnTabClick),
+ T_BUTTON, T_DONE,
+ T_FRAME, O(_fraInfo),
+ T_X, 5, T_Y, 32,
+ T_WIDTH, 500, T_HEIGHT, 250,
+ T_TITLE, P("Information"),
+ T_VISIBLE, T_TRUE,
+
+ T_LISTBOX, O(_lstInfo),
+ T_X, 1, T_Y, 5,
+ T_WIDTH, 493, T_HEIGHT, 220, // Works out to 57 characters wide, 15 high.
+ T_LISTBOX, T_DONE,
+
+ T_FRAME, T_DONE,
+
+
+ T_WINDOW, T_DONE,
+ T_END
+ };
+
+ tagListRun(uiBrowser);
+ _channel = netChannelGet(packetHandler);
+
+ guiDebugAreaShow(W(_btnSearchTab));
+ guiDebugAreaShow(W(_btnDescriptionTab));
+ guiDebugAreaShow(W(_btnScreensTab));
+ guiDebugAreaShow(W(_btnBoxTab));
+ guiDebugAreaShow(W(_btnInfoTab));
+
+ // 123456789012345678901234567890123456789012345678901234567
+ listboxItemAdd(_lstDescription, "The Post-Terran Minerals Corporation (PTMC) digs up");
+ listboxItemAdd(_lstDescription, "minerals on all nine planets of the solar system,");
+ listboxItemAdd(_lstDescription, "employing humans and robots to do its job. Unfortunately,");
+ listboxItemAdd(_lstDescription, "the mining robots are now being controlled by a hacker,");
+ listboxItemAdd(_lstDescription, "and have taken the human workers hostage. The PTMC has");
+ listboxItemAdd(_lstDescription, "tried to get the robots back under their control, but");
+ listboxItemAdd(_lstDescription, "communication with the mining stations has been lost. In");
+ listboxItemAdd(_lstDescription, "desperation, the PTMC modifies a Pyro-GX ship for combat");
+ listboxItemAdd(_lstDescription, "and hires a mercenary, codenamed 'Material Defender', to");
+ listboxItemAdd(_lstDescription, "fly it. The mission is to destroy the infected mines and");
+ listboxItemAdd(_lstDescription, "rescue human hostages, destroying any hostile robot that");
+ listboxItemAdd(_lstDescription, "gets in the way.");
+
+ listboxItemAdd(_lstInfo, "123456789012345678901234567890123456789012345678901234567");
+ listboxItemAdd(_lstInfo, "2");
+ listboxItemAdd(_lstInfo, "3");
+ listboxItemAdd(_lstInfo, "4");
+ listboxItemAdd(_lstInfo, "5");
+ listboxItemAdd(_lstInfo, "6");
+ listboxItemAdd(_lstInfo, "7");
+ listboxItemAdd(_lstInfo, "8");
+ listboxItemAdd(_lstInfo, "9");
+ listboxItemAdd(_lstInfo, "10");
+ listboxItemAdd(_lstInfo, "11");
+ listboxItemAdd(_lstInfo, "12");
+ listboxItemAdd(_lstInfo, "13");
+ listboxItemAdd(_lstInfo, "14");
+ listboxItemAdd(_lstInfo, "15");
+ listboxItemAdd(_lstInfo, "16");
+ listboxItemAdd(_lstInfo, "17");
+}
+
+
+static void btnTabClick(WidgetT *widget) {
+
+ widgetVisibleSet(W(_fraBox), 0);
+ widgetVisibleSet(W(_fraDescription), 0);
+ widgetVisibleSet(W(_fraInfo), 0);
+ widgetVisibleSet(W(_fraScreens), 0);
+ widgetVisibleSet(W(_fraSearch), 0);
+
+ if (widget == W(_btnBoxTab)) widgetVisibleSet(W(_fraBox), 1);
+ if (widget == W(_btnDescriptionTab)) widgetVisibleSet(W(_fraDescription), 1);
+ if (widget == W(_btnInfoTab)) widgetVisibleSet(W(_fraInfo), 1);
+ if (widget == W(_btnScreensTab)) widgetVisibleSet(W(_fraScreens), 1);
+ if (widget == W(_btnSearchTab)) widgetVisibleSet(W(_fraSearch), 1);
+}
+
+
+static void packetHandler(PacketDecodeDataT *packet) {
+
+}
diff --git a/client/src/browser.h b/client/src/browser.h
new file mode 100644
index 0000000..36ba7d4
--- /dev/null
+++ b/client/src/browser.h
@@ -0,0 +1,31 @@
+/*
+ * Kangaroo Punch MultiPlayer 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 .
+ *
+ */
+
+
+#ifndef BROWSER_H
+#define BROWSER_H
+
+
+#include "os.h"
+
+
+void browserShow(void);
+
+
+#endif // BROWSER_H
diff --git a/client/src/gui/button.c b/client/src/gui/button.c
index 9c87cb7..c3899ab 100644
--- a/client/src/gui/button.c
+++ b/client/src/gui/button.c
@@ -85,7 +85,7 @@ static void buttonMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
ButtonT *buttonNew(uint16_t x, uint16_t y, char *title, widgetCallback callback) {
ButtonT *button = (ButtonT *)malloc(sizeof(ButtonT));
WidgetT *widget = NULL;
- uint16_t h = fontHeightGet(_guiFont) + (_guiMetric[METRIC_BUTTON_VERTICAL_PADDING] * 2) + (_guiMetric[METRIC_BUTTON_BEZEL_SIZE] * 2);
+ uint16_t h = fontHeightGet(__guiFont) + (__guiMetric[METRIC_BUTTON_VERTICAL_PADDING] * 2) + (__guiMetric[METRIC_BUTTON_BEZEL_SIZE] * 2);
if (!button) return NULL;
@@ -116,19 +116,19 @@ static void buttonPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
active = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE);
if (enabled) {
- highlight = active ? _guiColor[COLOR_BUTTON_SHADOW] : _guiColor[COLOR_BUTTON_HIGHLIGHT];
- shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT] : _guiColor[COLOR_BUTTON_SHADOW];
- background = _guiColor[COLOR_BUTTON_BACKGROUND];
- text = _guiColor[COLOR_BUTTON_TEXT];
+ highlight = active ? __guiColor[COLOR_BUTTON_SHADOW] : __guiColor[COLOR_BUTTON_HIGHLIGHT];
+ shadow = active ? __guiColor[COLOR_BUTTON_HIGHLIGHT] : __guiColor[COLOR_BUTTON_SHADOW];
+ background = __guiColor[COLOR_BUTTON_BACKGROUND];
+ text = __guiColor[COLOR_BUTTON_TEXT];
} else {
- highlight = active ? _guiColor[COLOR_BUTTON_SHADOW_DISABLED] : _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED];
- shadow = active ? _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_BUTTON_SHADOW_DISABLED];
- background = _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED];
- text = _guiColor[COLOR_BUTTON_TEXT_DISABLED];
+ highlight = active ? __guiColor[COLOR_BUTTON_SHADOW_DISABLED] : __guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED];
+ shadow = active ? __guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] : __guiColor[COLOR_BUTTON_SHADOW_DISABLED];
+ background = __guiColor[COLOR_BUTTON_BACKGROUND_DISABLED];
+ text = __guiColor[COLOR_BUTTON_TEXT_DISABLED];
}
// Draw bezel.
- for (i=0; i<_guiMetric[METRIC_BUTTON_BEZEL_SIZE]; i++) {
+ for (i=0; i<__guiMetric[METRIC_BUTTON_BEZEL_SIZE]; i++) {
surfaceHighlightFrameDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, highlight, shadow);
}
@@ -136,13 +136,13 @@ static void buttonPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
surfaceRectangleFilledDraw(pos.x + i, pos.y + i, pos.x + pos.w - i, pos.y + pos.h - i, background);
// Draw title (depends on x from above).
- fontRender(_guiFont, b->title, text, background, pos.x + i + _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active);
+ fontRender(__guiFont, b->title, text, background, pos.x + i + __guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] + active, pos.y + i + __guiMetric[METRIC_BUTTON_VERTICAL_PADDING] + active);
}
void buttonTitleSet(ButtonT *button, char *title) {
if (button->title) free(button->title);
button->title = strdup(title);
- button->base.pos.w = (strlen(title) * fontWidthGet(_guiFont)) + (_guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] * 2) + (_guiMetric[METRIC_BUTTON_BEZEL_SIZE] * 2);
+ button->base.pos.w = (strlen(title) * fontWidthGet(__guiFont)) + (__guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] * 2) + (__guiMetric[METRIC_BUTTON_BEZEL_SIZE] * 2);
GUI_SET_FLAG((WidgetT *)button, WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/checkbox.c b/client/src/gui/checkbox.c
index dd399b0..0dd0c46 100644
--- a/client/src/gui/checkbox.c
+++ b/client/src/gui/checkbox.c
@@ -72,7 +72,7 @@ static void checkboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint1
CheckboxT *checkboxNew(uint16_t x, uint16_t y, char *title) {
CheckboxT *checkbox = (CheckboxT *)malloc(sizeof(CheckboxT));
WidgetT *widget = NULL;
- uint16_t h = fontHeightGet(_guiFont);
+ uint16_t h = fontHeightGet(__guiFont);
if (!checkbox) return NULL;
@@ -101,21 +101,21 @@ static void checkboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
active = checkboxValueGet(c);
if (enabled) {
- highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT];
- shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT] : _guiColor[COLOR_CHECKBOX_SHADOW];
- fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE] : _guiColor[COLOR_CHECKBOX_INACTIVE];
- text = _guiColor[COLOR_CHECKBOX_TEXT];
- background = _guiColor[COLOR_WINDOW_BACKGROUND];
+ highlight = active ? __guiColor[COLOR_CHECKBOX_SHADOW] : __guiColor[COLOR_CHECKBOX_HIGHLIGHT];
+ shadow = active ? __guiColor[COLOR_CHECKBOX_HIGHLIGHT] : __guiColor[COLOR_CHECKBOX_SHADOW];
+ fill = active ? __guiColor[COLOR_CHECKBOX_ACTIVE] : __guiColor[COLOR_CHECKBOX_INACTIVE];
+ text = __guiColor[COLOR_CHECKBOX_TEXT];
+ background = __guiColor[COLOR_WINDOW_BACKGROUND];
} else {
- highlight = active ? _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] : _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED];
- shadow = active ? _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] : _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED];
- fill = active ? _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] : _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED];
- text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED];
- background = _guiColor[COLOR_WINDOW_BACKGROUND];
+ highlight = active ? __guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] : __guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED];
+ shadow = active ? __guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] : __guiColor[COLOR_CHECKBOX_SHADOW_DISABLED];
+ fill = active ? __guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] : __guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED];
+ text = __guiColor[COLOR_CHECKBOX_TEXT_DISABLED];
+ background = __guiColor[COLOR_WINDOW_BACKGROUND];
}
// Checkbox is 10x10 pixels. Find offset based on font height.
- o = (_guiFont->height - 10) * 0.5;
+ o = (__guiFont->height - 10) * 0.5;
// Draw outline of checkbox.
surfaceHighlightFrameDraw(pos.x, pos.y + o, pos.x + 10, pos.y + 10 + o, highlight, shadow);
@@ -124,14 +124,14 @@ static void checkboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
surfaceRectangleFilledDraw(pos.x + 1, pos.y + o + 1, pos.x + 9, pos.y + + o + 9, fill);
// Draw title.
- fontRender(_guiFont, c->title, text, background, pos.x + 10 + _guiMetric[METRIC_CHECKBOX_PADDING], pos.y);
+ fontRender(__guiFont, c->title, text, background, pos.x + 10 + __guiMetric[METRIC_CHECKBOX_PADDING], pos.y);
}
void checkboxTitleSet(CheckboxT *checkbox, char *title) {
if (checkbox->title) free(checkbox->title);
checkbox->title = strdup(title);
- checkbox->base.pos.w = (strlen(title) * fontWidthGet(_guiFont)) + 10 + _guiMetric[METRIC_CHECKBOX_PADDING];
+ checkbox->base.pos.w = (strlen(title) * fontWidthGet(__guiFont)) + 10 + __guiMetric[METRIC_CHECKBOX_PADDING];
GUI_SET_FLAG((WidgetT *)checkbox, WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/desktop.c b/client/src/gui/desktop.c
index ce34f03..bfbcc47 100644
--- a/client/src/gui/desktop.c
+++ b/client/src/gui/desktop.c
@@ -65,5 +65,5 @@ static void desktopPaint(WidgetT *desktop, uint8_t enabled, RectT pos) {
(void)pos;
(void)enabled;
- surfaceClear(_guiColor[COLOR_DESKTOP]);
+ surfaceClear(__guiColor[COLOR_DESKTOP]);
}
diff --git a/client/src/gui/frame.c b/client/src/gui/frame.c
index 5ef6de9..c85a12e 100644
--- a/client/src/gui/frame.c
+++ b/client/src/gui/frame.c
@@ -67,10 +67,10 @@ static void framePaint(WidgetT *widget, uint8_t enabled, RectT pos) {
FrameT *f = (FrameT *)widget;
// Draw frame.
- surfaceHighlightFrameDraw(pos.x, pos.y + (fontHeightGet(_guiFont) * 0.5), pos.x + pos.w, pos.y + pos.h, _guiColor[COLOR_FRAME_SHADOW], _guiColor[COLOR_FRAME_HIGHLIGHT]);
+ surfaceHighlightFrameDraw(pos.x, pos.y + (fontHeightGet(__guiFont) * 0.5), pos.x + pos.w, pos.y + pos.h, __guiColor[COLOR_FRAME_SHADOW], __guiColor[COLOR_FRAME_HIGHLIGHT]);
// Draw title.
- fontRender(_guiFont, f->title, _guiColor[COLOR_FRAME_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10, pos.y);
+ fontRender(__guiFont, f->title, __guiColor[COLOR_FRAME_TEXT], __guiColor[COLOR_WINDOW_BACKGROUND], pos.x + 10, pos.y);
}
diff --git a/client/src/gui/gui.c b/client/src/gui/gui.c
index bb04632..c0609de 100644
--- a/client/src/gui/gui.c
+++ b/client/src/gui/gui.c
@@ -25,6 +25,7 @@
#include "widget.h"
#include "desktop.h"
#include "window.h"
+#include "msgbox.h"
typedef struct PendingEventsS {
@@ -33,13 +34,32 @@ typedef struct PendingEventsS {
} PendingEventsT;
-int16_t _guiMetric[METRIC_COUNT];
-ColorT _guiColor[COLOR_COUNT];
-FontT *_guiFont = NULL;
-WidgetT *_guiDragWidget = NULL;
+// Widget Magic Debug Info. Don't forget to change MagicE!
+char *__guiMagicDebugNames[MAGIC_COUNT] = {
+ "Unknown",
+ "Desktop",
+ "Window",
+ "Button",
+ "Label",
+ "Checkbox",
+ "RadioButton",
+ "Picture",
+ "Frame",
+ "Textbox",
+ "Updown",
+ "Listbox",
+ "Terminal",
+ "Timer"
+};
+
+
+int16_t __guiMetric[METRIC_COUNT];
+ColorT __guiColor[COLOR_COUNT];
+FontT *__guiFont = NULL;
+WidgetT *__guiDragWidget = NULL;
uint16_t _guiDragOffsetX = 0;
-uint16_t _guiDragOffsetY = 0;
-WindowT *_guiActiveWindow = NULL;
+uint16_t __guiDragOffsetY = 0;
+WindowT *__guiActiveWindow = NULL;
static DesktopT *_guiDesktop = NULL;
@@ -59,23 +79,7 @@ static uint32_t _guiTimerQuarterSecondOn = 0;
static uint32_t _guiTimerHalfSecondOn = 0;
static uint32_t _guiTimerSecondOn = 0;
static PendingEventsT **_guiPendingEvents = NULL;
-
-// Widget Magic Debug Info. Don't forget to change MagicE!
-static char *_magicDebugNames[MAGIC_COUNT] = {
- "Unknown",
- "Desktop",
- "Window",
- "Button",
- "Label",
- "Checkbox",
- "RadioButton",
- "Picture",
- "Frame",
- "Textbox",
- "Updown",
- "Listbox",
- "Terminal"
-};
+static void **_guiPendingFrees = NULL;
static void guiDeleteList(void);
@@ -161,6 +165,13 @@ void guiComposite() {
}
}
}
+
+ // Process any pending delayed free events.
+ while (arrlen(_guiPendingFrees)) {
+ DEL(_guiPendingFrees[0]);
+ arrdel(_guiPendingFrees, 0);
+ }
+ arrfree(_guiPendingFrees);
}
@@ -169,7 +180,7 @@ void guiDebugAreaShow(WidgetT *widget) {
guiWidgetBoundsDrawableOnScreenGet(widget, &r);
logWrite("%s: Size %dx%d Area %dx%d TL %dx%d BR %dx%d\n",
- _magicDebugNames[widget->magic],
+ __guiMagicDebugNames[widget->magic],
widget->pos.w, widget->pos.h,
r.w, r.h,
widget->margin.x, widget->margin.y,
@@ -187,7 +198,7 @@ void guiDebugWidgetTreeDump(WidgetT *widget, uint16_t depth) {
logWrite("%s %s P:%dx%d-%dx%d M:%dx%d-%dx%d C:%dx%d-%dx%d F:%d\n",
line,
- _magicDebugNames[widget->magic],
+ __guiMagicDebugNames[widget->magic],
widget->pos.x, widget->pos.y, widget->pos.w, widget->pos.h,
widget->margin.x, widget->margin.y, widget->margin.w, widget->margin.h,
widget->clip.x, widget->clip.y, widget->clip.w, widget->clip.h,
@@ -202,6 +213,13 @@ void guiDebugWidgetTreeDump(WidgetT *widget, uint16_t depth) {
}
+void guiDelayedFree(void **pointer) {
+ // Delayed Free allows freeing of data that may be in use by the
+ // GUI system at a safe time. (After compositing.)
+ arrput(_guiPendingFrees, *pointer);
+}
+
+
void guiDelete(WidgetT **widget) {
// Since deleting happens in widget events, it's not safe to do it
// immediately. Instead, we make a list of what to delete and
@@ -316,6 +334,7 @@ void guiFocusSet(WidgetT *widget) {
}
// Change focus.
_guiFocused = widget;
+ logWrite("Focus is now on %s\n", __guiMagicDebugNames[widget->magic]);
// Tell new control it has focus.
if (_guiFocused) {
if (_guiFocused->focusMethod) _guiFocused->focusMethod(_guiFocused, 1);
@@ -390,12 +409,12 @@ static uint8_t guiMouseChildrenProcess(WidgetT *widget, MouseT *mouse) {
sy = r.y;
guiMousePositionOnWidgetGet(widget, mouse, &mx, &my);
- //logWrite("Mouse %dx%d Widget %s %dx%d Screen %dx%d\n", mouse->x, mouse->y, _magicDebugNames[widget->magic], mx, my, sx, sy);
+ //logWrite("Mouse %dx%d Widget %s %dx%d Screen %dx%d\n", mouse->x, mouse->y, __guiMagicDebugNames[widget->magic], mx, my, sx, sy);
// Serious hack to make window dragging work better.
// This is because it's possible to move the mouse faster than METRIC_WINDOW_TITLE_GRAB_HEIGHT pixels
// which causes it to switch widgets. So this prevents that.
- if (widget->magic == MAGIC_WINDOW && widget == _guiDragWidget && mouse->buttonLeft && mouse->buttonLeftWasDown) {
+ if (widget->magic == MAGIC_WINDOW && widget == __guiDragWidget && mouse->buttonLeft && mouse->buttonLeftWasDown) {
widget->mouseEventMethod(widget, mouse, mx, my, MOUSE_EVENT_LEFT_HOLD);
return 1;
}
@@ -408,8 +427,8 @@ static uint8_t guiMouseChildrenProcess(WidgetT *widget, MouseT *mouse) {
}
}
- // Is the mouse inside this widget?
- if (mouse->x >= sx && mouse->y >= sy && mouse->x < sx + widget->pos.w && mouse->y < sy + widget->pos.h) {
+ // Is the mouse inside this widget? (Ignore frames.)
+ if (mouse->x >= sx && mouse->y >= sy && mouse->x < sx + widget->pos.w && mouse->y < sy + widget->pos.h && widget->magic != MAGIC_FRAME) {
// Is this the same widget we were over before?
if (_guiLastWidgetLeft != widget) {
@@ -444,8 +463,8 @@ static uint8_t guiMouseChildrenProcess(WidgetT *widget, MouseT *mouse) {
// Is there an event?
if (event != MOUSE_EVENT_NONE) {
- // Does it belong to the active window? Or does it target a window? A desktop?
- if (widget->window == _guiActiveWindow || widget->magic == MAGIC_WINDOW || widget->magic == MAGIC_DESKTOP) {
+ // Does it belong to the active window? Or does it target a window? A desktop? Something on the desktop?
+ if (widget->window == __guiActiveWindow || widget->magic == MAGIC_WINDOW || widget->magic == MAGIC_DESKTOP || widget->window == NULL) {
// Is there a mouse handler?
if (widget->mouseEventMethod) {
if (!GUI_GET_FLAG(widget, WIDGET_FLAG_DISABLED) && !GUI_GET_FLAG(widget, WIDGET_FLAG_HIDDEN)) {
@@ -505,13 +524,13 @@ static void guiPaintChildren(WidgetT *widget) {
GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY);
}
}
- }
- // Paint all children.
- len = arrlenu(widget->children);
- if (len > 0) {
- for (x=0; xchildren[x]);
+ // Paint all children.
+ len = arrlenu(widget->children);
+ if (len > 0) {
+ for (x=0; xchildren[x]);
+ }
}
}
}
@@ -556,116 +575,117 @@ WidgetT *guiRootGet(void) {
void guiShutdown(void) {
- // Unload fonts.
- fontUnload(&_guiFont);
// Delete all widgets in GUI tree.
guiDelete((WidgetT **)&_guiDesktop);
guiDeleteList();
+
+ // Unload font.
+ fontUnload(&__guiFont);
}
DesktopT *guiStartup(void) {
- _guiMetric[METRIC_BUTTON_BEZEL_SIZE] = 2;
- _guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] = 8;
- _guiMetric[METRIC_BUTTON_VERTICAL_PADDING] = 2;
+ __guiMetric[METRIC_BUTTON_BEZEL_SIZE] = 2;
+ __guiMetric[METRIC_BUTTON_HORIZONTAL_PADDING] = 8;
+ __guiMetric[METRIC_BUTTON_VERTICAL_PADDING] = 2;
- _guiMetric[METRIC_WINDOW_BORDER_WIDTH] = 4; // Does not include highlight or shadow lines.
- _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] = 17; // Does not include highlight or shadow lines.
- _guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT] = _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 5; // Border, highlights, titlebar.
+ __guiMetric[METRIC_WINDOW_BORDER_WIDTH] = 4; // Does not include highlight or shadow lines.
+ __guiMetric[METRIC_WINDOW_TITLE_HEIGHT] = 17; // Does not include highlight or shadow lines.
+ __guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT] = __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + __guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 5; // Border, highlights, titlebar.
- _guiMetric[METRIC_CHECKBOX_PADDING] = 6; // Makes the 10 wide checkbox fill two character cells by padding it out to 16.
+ __guiMetric[METRIC_CHECKBOX_PADDING] = 6; // Makes the 10 wide checkbox fill two character cells by padding it out to 16.
- _guiMetric[METRIC_RADIOBUTTON_PADDING] = 6; // Makes the 10 wide radio button fill two character cells by padding it out to 16.
+ __guiMetric[METRIC_RADIOBUTTON_PADDING] = 6; // Makes the 10 wide radio button fill two character cells by padding it out to 16.
- _guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] = 2;
- _guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING] = 2;
- _guiMetric[METRIC_TEXTBOX_PADDING] = 6; // Matches other label / widget padding.
+ __guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] = 2;
+ __guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING] = 2;
+ __guiMetric[METRIC_TEXTBOX_PADDING] = 6; // Matches other label / widget padding.
- _guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] = 2;
- _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING] = 2;
- _guiMetric[METRIC_UPDOWN_PADDING] = 6; // Matches other label / widget padding.
- _guiMetric[METRIC_UPDOWN_ARROW_PADDING] = 2;
+ __guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] = 2;
+ __guiMetric[METRIC_UPDOWN_VERTICAL_PADDING] = 2;
+ __guiMetric[METRIC_UPDOWN_PADDING] = 6; // Matches other label / widget padding.
+ __guiMetric[METRIC_UPDOWN_ARROW_PADDING] = 2;
- _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] = 2;
- _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] = 2;
+ __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] = 2;
+ __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] = 2;
- _guiColor[COLOR_BUTTON_BACKGROUND] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_BUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_BUTTON_SHADOW] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_BUTTON_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_BUTTON_BACKGROUND] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_BUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_BUTTON_SHADOW] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_BUTTON_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_BUTTON_BACKGROUND_DISABLED] = vbeColorMake(124, 126, 124);
- _guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
- _guiColor[COLOR_BUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_BUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
+ __guiColor[COLOR_BUTTON_BACKGROUND_DISABLED] = vbeColorMake(124, 126, 124);
+ __guiColor[COLOR_BUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
+ __guiColor[COLOR_BUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_BUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
- _guiColor[COLOR_DESKTOP] = vbeColorMake( 51, 153, 255);
+ __guiColor[COLOR_DESKTOP] = vbeColorMake( 51, 153, 255);
- _guiColor[COLOR_WINDOW_BACKGROUND] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_WINDOW_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_WINDOW_SHADOW] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_WINDOW_TITLE_ACTIVE] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_WINDOW_TITLE_INACTIVE] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_WINDOW_BACKGROUND] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_WINDOW_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_WINDOW_SHADOW] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_WINDOW_TITLE_ACTIVE] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_WINDOW_TITLE_INACTIVE] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_LABEL_TEXT_INACTIVE] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_CHECKBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_CHECKBOX_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_CHECKBOX_ACTIVE] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_CHECKBOX_INACTIVE] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_CHECKBOX_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
- _guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124);
- _guiColor[COLOR_CHECKBOX_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
+ __guiColor[COLOR_CHECKBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_CHECKBOX_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_CHECKBOX_ACTIVE] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_CHECKBOX_INACTIVE] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_CHECKBOX_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_CHECKBOX_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
+ __guiColor[COLOR_CHECKBOX_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_CHECKBOX_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_CHECKBOX_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124);
+ __guiColor[COLOR_CHECKBOX_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
- _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_RADIOBUTTON_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_RADIOBUTTON_ACTIVE] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_RADIOBUTTON_INACTIVE] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_RADIOBUTTON_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
- _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124);
- _guiColor[COLOR_RADIOBUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
+ __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_RADIOBUTTON_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_RADIOBUTTON_ACTIVE] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_RADIOBUTTON_INACTIVE] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_RADIOBUTTON_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] = vbeColorMake(200, 200, 200);
+ __guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED] = vbeColorMake(124, 126, 124);
+ __guiColor[COLOR_RADIOBUTTON_TEXT_DISABLED] = vbeColorMake( 84, 84, 84);
- _guiColor[COLOR_FRAME_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_FRAME_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_FRAME_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_FRAME_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_FRAME_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_FRAME_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_TEXTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_TEXTBOX_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_TEXTBOX_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_TEXTBOX_BACKGROUND] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_TEXTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_TEXTBOX_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_TEXTBOX_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_TEXTBOX_BACKGROUND] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_UPDOWN_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_UPDOWN_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_UPDOWN_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_UPDOWN_BACKGROUND] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124);
- _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_UPDOWN_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_UPDOWN_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_UPDOWN_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_UPDOWN_BACKGROUND] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124);
+ __guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_UPDOWN_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80);
- _guiColor[COLOR_LISTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_LISTBOX_SHADOW] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_LISTBOX_TEXT] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_LISTBOX_BACKGROUND] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_LISTBOX_SELECTED_TEXT] = vbeColorMake(248, 252, 248);
- _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND] = vbeColorMake( 0, 0, 0);
- _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124);
- _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168);
- _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80);
+ __guiColor[COLOR_LISTBOX_HIGHLIGHT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_LISTBOX_SHADOW] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_LISTBOX_TEXT] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_LISTBOX_BACKGROUND] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_LISTBOX_SELECTED_TEXT] = vbeColorMake(248, 252, 248);
+ __guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND] = vbeColorMake( 0, 0, 0);
+ __guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND] = vbeColorMake(124, 126, 124);
+ __guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] = vbeColorMake(168, 168, 168);
+ __guiColor[COLOR_LISTBOX_ARROWS_INACTIVE] = vbeColorMake( 80, 84, 80);
// Load font. ***TODO*** This should probably be provided by an API call to remove it from in here.
- _guiFont = fontLoad(cacheFilenameGet("gui:vga8x14.dat"));
+ __guiFont = fontLoad(cacheFilenameGet("gui:vga8x14.dat"));
// Create desktop and return it. Remember it for later.
_guiDesktop = desktopNew();
diff --git a/client/src/gui/gui.h b/client/src/gui/gui.h
index 1d2b246..cc6e0f5 100644
--- a/client/src/gui/gui.h
+++ b/client/src/gui/gui.h
@@ -180,19 +180,21 @@ typedef struct WidgetS WidgetT;
typedef struct WindowS WindowT;
-extern int16_t _guiMetric[METRIC_COUNT];
-extern ColorT _guiColor[COLOR_COUNT];
-extern FontT *_guiFont;
-extern WidgetT *_guiDragWidget;
+extern int16_t __guiMetric[METRIC_COUNT];
+extern ColorT __guiColor[COLOR_COUNT];
+extern FontT *__guiFont;
+extern WidgetT *__guiDragWidget;
extern uint16_t _guiDragOffsetX;
-extern uint16_t _guiDragOffsetY;
-extern WindowT *_guiActiveWindow;
+extern uint16_t __guiDragOffsetY;
+extern WindowT *__guiActiveWindow;
+extern char *__guiMagicDebugNames[MAGIC_COUNT];
void guiAttach(WidgetT *parent, WidgetT *child);
void guiComposite(void);
void guiDebugAreaShow(WidgetT *widget);
void guiDebugWidgetTreeDump(WidgetT *widget, uint16_t depth);
+void guiDelayedFree(void **pointer);
void guiDelete(WidgetT **widget);
WidgetT *guiFocusGet(void);
void guiFocusSet(WidgetT *widget);
diff --git a/client/src/gui/image.c b/client/src/gui/image.c
index 027ec47..a53668c 100644
--- a/client/src/gui/image.c
+++ b/client/src/gui/image.c
@@ -180,6 +180,24 @@ void imageRender(ImageT *image, uint16_t x, uint16_t y) {
}
+void imageRenderHalf(ImageT *image, uint16_t x, uint16_t y) {
+ uint16_t x1;
+ uint16_t y1;
+ uint16_t x2 = image->width / 2;
+ uint16_t y2 = image->height / 2;
+
+ // Clip on right and bottom
+ if (x + x2 > surfaceWidthGet()) x2 -= x + x2 - surfaceWidthGet();
+ if (y + y2 > surfaceHeightGet()) y2 -= y + y2 - surfaceHeightGet();
+
+ for (y1=0; y1pixels[x1 * 2][y1 * 2]);
+ }
+ }
+}
+
+
void imageRenderWithAlpha(ImageT *image, uint16_t x, uint16_t y, ColorT alpha) {
uint16_t x1;
uint16_t y1;
diff --git a/client/src/gui/image.h b/client/src/gui/image.h
index 5ebac64..4c943c3 100644
--- a/client/src/gui/image.h
+++ b/client/src/gui/image.h
@@ -43,6 +43,7 @@ uint8_t imageInfoGet(char *filename, uint16_t *width, uint16_t *height);
ImageT *imageLoad(char *filename);
ColorT imagePixelGet(ImageT *image, uint16_t x, uint16_t y);
void imageRender(ImageT *image, uint16_t x, uint16_t y);
+void imageRenderHalf(ImageT *image, uint16_t x, uint16_t y);
void imageRenderWithAlpha(ImageT *image, uint16_t x, uint16_t y, ColorT alpha);
void imageUnload(ImageT **image);
uint16_t imageWidthGet(ImageT *image);
diff --git a/client/src/gui/label.c b/client/src/gui/label.c
index de75bc1..21ff627 100644
--- a/client/src/gui/label.c
+++ b/client/src/gui/label.c
@@ -63,8 +63,8 @@ WidgetT *labelInit(WidgetT *widget, char *title) {
l->base.paintMethod = labelPaint;
l->base.mouseEventMethod = labelMouseEvent;
l->title = NULL;
- l->background = _guiColor[COLOR_WINDOW_BACKGROUND];
- l->foreground = _guiColor[COLOR_LABEL_TEXT_INACTIVE];
+ l->background = __guiColor[COLOR_WINDOW_BACKGROUND];
+ l->foreground = __guiColor[COLOR_LABEL_TEXT_INACTIVE];
l->clicked = NULL;
labelTitleSet(l, title);
@@ -103,7 +103,7 @@ static void labelMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_t
LabelT *labelNew(uint16_t x, uint16_t y, char *title) {
LabelT *label = (LabelT *)malloc(sizeof(LabelT));
WidgetT *widget = NULL;
- uint16_t h = fontHeightGet(_guiFont);
+ uint16_t h = fontHeightGet(__guiFont);
if (!label) return NULL;
@@ -125,13 +125,13 @@ static void labelPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
ColorT text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? l->active : l->foreground;
// Draw title.
- fontRender(_guiFont, l->title, text, l->background, pos.x, pos.y);
+ fontRender(__guiFont, l->title, text, l->background, pos.x, pos.y);
}
void labelTitleSet(LabelT *label, char *title) {
if (label->title) free(label->title);
label->title = strdup(title);
- label->base.pos.w = (strlen(title) * fontWidthGet(_guiFont));
+ label->base.pos.w = (strlen(title) * fontWidthGet(__guiFont));
GUI_SET_FLAG((WidgetT *)label, WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/listbox.c b/client/src/gui/listbox.c
index 586dd72..ae50147 100644
--- a/client/src/gui/listbox.c
+++ b/client/src/gui/listbox.c
@@ -30,6 +30,7 @@ static uint16_t _valueTop = 0;
static uint16_t _valueBottom = 0;
static uint16_t _arrowWidth = 0;
static uint16_t _arrowStart = 0;
+static uint8_t _hasTitle = 0;
static void listboxDel(WidgetT **widget);
@@ -185,25 +186,29 @@ static void listboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16
len = arrlenu(l->values);
// Clicked item in listbox.
- valueStart = 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING];
+ valueStart = 1 + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING];
if (x > valueStart && x < valueStart + _valueWidth - 1 && y > _valueTop + 1 && y < _valueBottom - 1) {
- o = (y - _valueTop) / fontHeightGet(_guiFont);
+ o = (y - _valueTop) / fontHeightGet(__guiFont);
if (o < len) l->selected = o;
- if (l->selected > _visibleY - 2) l->selected = _visibleY - 2; // Two because 1 is to correct _visibleY and the other 1 is because selected is zero based.
+ if (_hasTitle) {
+ if (l->selected > _visibleY - 2) l->selected = _visibleY - 2; // Two because 1 is to correct _visibleY and the other 1 is because selected is zero based.
+ } else {
+ if (l->selected > _visibleY - 1) l->selected = _visibleY - 1; // One is because selected is zero based.
+ }
GUI_SET_FLAG(widget, WIDGET_FLAG_DIRTY);
}
- _arrowStart += 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Left of up arrow
- o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of arrows
+ _arrowStart += 1 + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Left of up arrow
+ o = _valueTop + 1 + __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of arrows
// Did they click the up arrow?
- if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(_guiFont) && y >= o && y <= o + fontHeightGet(_guiFont)) {
+ if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(__guiFont) && y >= o && y <= o + fontHeightGet(__guiFont)) {
listboxScrollUp(l);
}
// Did they click the down arrow?
- o = _valueBottom - 1 - _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow
- if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(_guiFont) && y >= o - fontHeightGet(_guiFont) && y <= o) {
+ o = _valueBottom - 1 - __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow
+ if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(__guiFont) && y >= o - fontHeightGet(__guiFont) && y <= o) {
listboxScrollDown(l);
}
@@ -248,55 +253,59 @@ static void listboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
// How many items can we draw?
items = len - l->offset;
- if (items > _visibleY - 1) items = _visibleY - 1;
+ if (_hasTitle) {
+ if (items > _visibleY - 1) items = _visibleY - 1;
+ } else {
+ if (items > _visibleY) items = _visibleY;
+ }
- // Draw title.
- fontRender(_guiFont, l->title, _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y);
+ // Draw title, if it exists.
+ if (_hasTitle) fontRender(__guiFont, l->title, __guiColor[COLOR_LISTBOX_TEXT], __guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y);
// Draw outline of listbox.
- surfaceHighlightFrameDraw(pos.x, _valueTop, pos.x + _valueWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]);
+ surfaceHighlightFrameDraw(pos.x, _valueTop, pos.x + _valueWidth, _valueBottom, __guiColor[COLOR_LISTBOX_SHADOW], __guiColor[COLOR_LISTBOX_HIGHLIGHT]);
// Draw background of listbox.
- surfaceRectangleFilledDraw(pos.x + 1, _valueTop + 1, pos.x + _valueWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_BACKGROUND]);
+ surfaceRectangleFilledDraw(pos.x + 1, _valueTop + 1, pos.x + _valueWidth - 1, _valueBottom - 1, __guiColor[COLOR_LISTBOX_BACKGROUND]);
// Draw listbox contents.
- o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING];
+ o = _valueTop + 1 + __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING];
for (i=0; iselected) {
- surfaceRectangleFilledDraw(pos.x + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o, pos.x + _valueWidth - _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o + fontHeightGet(_guiFont) - 1, _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND]);
- fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_SELECTED_TEXT], _guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o);
+ surfaceRectangleFilledDraw(pos.x + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o, pos.x + _valueWidth - __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o + fontHeightGet(__guiFont) - 1, __guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND]);
+ fontRender(__guiFont, l->values[l->offset + i], __guiColor[COLOR_LISTBOX_SELECTED_TEXT], __guiColor[COLOR_LISTBOX_SELECTED_BACKGROUND], pos.x + 1 + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o);
} else {
- fontRender(_guiFont, l->values[l->offset + i], _guiColor[COLOR_LISTBOX_TEXT], _guiColor[COLOR_LISTBOX_BACKGROUND], pos.x + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o);
+ fontRender(__guiFont, l->values[l->offset + i], __guiColor[COLOR_LISTBOX_TEXT], __guiColor[COLOR_LISTBOX_BACKGROUND], pos.x + 1 + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING], o);
}
- o += fontHeightGet(_guiFont);
+ o += fontHeightGet(__guiFont);
}
// Draw outline of arrows.
- surfaceHighlightFrameDraw(_arrowStart, _valueTop, _arrowStart + _arrowWidth, _valueBottom, _guiColor[COLOR_LISTBOX_SHADOW], _guiColor[COLOR_LISTBOX_HIGHLIGHT]);
+ surfaceHighlightFrameDraw(_arrowStart, _valueTop, _arrowStart + _arrowWidth, _valueBottom, __guiColor[COLOR_LISTBOX_SHADOW], __guiColor[COLOR_LISTBOX_HIGHLIGHT]);
// Draw background of arrows.
- surfaceRectangleFilledDraw(_arrowStart + 1, _valueTop + 1, _arrowStart + _arrowWidth - 1, _valueBottom - 1, _guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND]);
+ surfaceRectangleFilledDraw(_arrowStart + 1, _valueTop + 1, _arrowStart + _arrowWidth - 1, _valueBottom - 1, __guiColor[COLOR_LISTBOX_ARROWS_BACKGROUND]);
// Draw up arrow
- _arrowStart += _halfFont + 1 + _guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Center of up arrow
- o = _valueTop + 1 + _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of up arrow
- color = l->offset + l->selected > 0 ? _guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] : _guiColor[COLOR_LISTBOX_ARROWS_INACTIVE];
- for (i=0; i<=fontHeightGet(_guiFont); i++) {
+ _arrowStart += _halfFont + 1 + __guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING]; // Center of up arrow
+ o = _valueTop + 1 + __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Top of up arrow
+ color = l->offset + l->selected > 0 ? __guiColor[COLOR_LISTBOX_ARROWS_ACTIVE] : __guiColor[COLOR_LISTBOX_ARROWS_INACTIVE];
+ for (i=0; i<=fontHeightGet(__guiFont); i++) {
surfaceLineDraw(_arrowStart - i * 0.5, o + i, _arrowStart + i * 0.5, o + i, color);
}
- surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]);
- surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(_guiFont), _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_SHADOW]);
- surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_LISTBOX_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_LISTBOX_SHADOW]);
+ surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(__guiFont), _arrowStart + _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_LISTBOX_SHADOW]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_LISTBOX_HIGHLIGHT]);
// Draw down arrow
- o = _valueBottom - 1 - _guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow
- color = l->offset + l->selected < len - 1 ? _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
- for (i=0; i<=fontHeightGet(_guiFont); i++) {
+ o = _valueBottom - 1 - __guiMetric[METRIC_LISTBOX_VERTICAL_PADDING]; // Bottom of down arrow
+ color = l->offset + l->selected < len - 1 ? __guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : __guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
+ for (i=0; i<=fontHeightGet(__guiFont); i++) {
surfaceLineDraw(_arrowStart - i * 0.5, o - i, _arrowStart + i * 0.5, o - i, color);
}
- surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]);
- surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(_guiFont), _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
- surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_SHADOW]);
+ surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(__guiFont), _arrowStart + _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
}
@@ -304,7 +313,7 @@ static void listboxScrollDown(ListboxT *listbox) {
int16_t len = arrlenu(listbox->values);
// Can we increment?
- if (listbox->selected < _visibleY - 2) {
+ if (listbox->selected < _visibleY - (_hasTitle ? 2 : 1)) {
// Is it off the end of the list?
if (listbox->offset + listbox->selected < len - 1) {
listbox->selected++;
@@ -346,18 +355,18 @@ static void listboxSizesRecalculate(ListboxT *listbox) {
// arrowStart is x+1+valueWidth
// Set global stuff that isn't actually part of the widget state.
- _halfFont = fontHeightGet(_guiFont) * 0.5;
- _arrowWidth = 2 + (_guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2) + fontHeightGet(_guiFont); // Arrow width = font height
- _valueWidth = listbox->base.pos.w - 1 - 1 - (_guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2) - _arrowWidth;
- _valueHeight = listbox->base.pos.h - 2 - (_guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] * 2);
- _valueTop = fontHeightGet(_guiFont) + 1;
+ _hasTitle = (listbox->title != NULL);
+ _halfFont = fontHeightGet(__guiFont) * 0.5;
+ _arrowWidth = 2 + (__guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2) + fontHeightGet(__guiFont); // Arrow width = font height
+ _valueWidth = listbox->base.pos.w - 1 - 1 - (__guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2) - _arrowWidth;
+ _valueHeight = listbox->base.pos.h - 2 - (__guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] * 2);
+ _valueTop = (fontHeightGet(__guiFont) + 1) * _hasTitle;
_valueBottom = _valueHeight;
_arrowStart = 2 + _valueWidth;
// Figure out how many characters we have room to display.
- _visibleX = (_valueWidth - 2 + (_guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2)) / fontWidthGet(_guiFont);
- _visibleY = (_valueHeight - 2 + (_guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] * 2)) / fontHeightGet(_guiFont);
-
+ _visibleX = (_valueWidth - 2 + (__guiMetric[METRIC_LISTBOX_HORIZONTAL_PADDING] * 2)) / fontWidthGet(__guiFont);
+ _visibleY = (_valueHeight - 2 + (__guiMetric[METRIC_LISTBOX_VERTICAL_PADDING] * 2)) / fontHeightGet(__guiFont);
}
diff --git a/client/src/gui/msgbox.c b/client/src/gui/msgbox.c
index f1f9d8f..be49329 100644
--- a/client/src/gui/msgbox.c
+++ b/client/src/gui/msgbox.c
@@ -43,16 +43,17 @@
#define ICN_SIZE 32
-static msgBoxCallback _cbOne = NULL;
-static msgBoxCallback _cbTwo = NULL;
-static msgBoxCallback _cbThree = NULL;
-
-static WindowT *_winDialog = NULL;
-static PictureT *_picIcon = NULL;
-static LabelT *_lblText = NULL;
-static ButtonT *_btnOne = NULL;
-static ButtonT *_btnTwo = NULL;
-static ButtonT *_btnThree = NULL;
+typedef struct MessageBoxContextS {
+ msgBoxCallback cbOne;
+ msgBoxCallback cbTwo;
+ msgBoxCallback cbThree;
+ WindowT *winDialog;
+ PictureT *picIcon;
+ LabelT *lblText;
+ ButtonT *btnOne;
+ ButtonT *btnTwo;
+ ButtonT *btnThree;
+} MessageBoxContextT;
//***TODO*** This depends on the cache system which isn't really part of the GUI.
@@ -69,18 +70,24 @@ static void btnMsgBox(WidgetT *widget);
static void btnMsgBox(WidgetT *widget) {
+ MessageBoxContextT *context = guiUserDataGet(widget);
+
// Remove us from the display.
- guiDelete(D(_winDialog));
+ guiDelete(D(context->winDialog));
+
// Call whoever wanted called.
- if (widget == W(_btnOne)) {
- if (_cbOne) _cbOne(MSGBOX_BUTTON_ONE);
+ if (widget == W(context->btnOne)) {
+ if (context->cbOne) context->cbOne(MSGBOX_BUTTON_ONE);
}
- if (widget == W(_btnTwo)) {
- if (_cbTwo) _cbTwo(MSGBOX_BUTTON_TWO);
+ if (widget == W(context->btnTwo)) {
+ if (context->cbTwo) context->cbTwo(MSGBOX_BUTTON_TWO);
}
- if (widget == W(_btnThree)) {
- if (_cbThree) _cbThree(MSGBOX_BUTTON_THREE);
+ if (widget == W(context->btnThree)) {
+ if (context->cbThree) context->cbThree(MSGBOX_BUTTON_THREE);
}
+
+ // Delayed Free allows freeing of data that may be in use by the GUI system at a safe time.
+ guiDelayedFree((void **)&context);
}
@@ -102,37 +109,40 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne,
uint16_t cursorH = 0;
char *token = NULL;
char *text = NULL;
+ MessageBoxContextT *context = NULL;
+
+ NEW(MessageBoxContextT, context);
// Null these for later.
- _btnOne = NULL;
- _btnTwo = NULL;
- _btnThree = NULL;
+ context->btnOne = NULL;
+ context->btnTwo = NULL;
+ context->btnThree = NULL;
// Remember callbacks for later.
- _cbOne = callbackOne;
- _cbTwo = callbackTwo;
- _cbThree = callbackThree;
+ context->cbOne = callbackOne;
+ context->cbTwo = callbackTwo;
+ context->cbThree = callbackThree;
// Calculate size of dialog box window.
// Initial minimum window width is the left and right margins + font width * (title length + 3).
- w = WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * (strlen(title) + 3));
+ w = WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * (strlen(title) + 3));
// Initial minimum window height is the top and bottom margins + font height + button height + (padding * 2).
- h = WIN_MARGIN_TOP + WIN_MARGIN_BOTTOM + fontHeightGet(_guiFont) + (BTN_MARGIN_TOP + BTN_MARGIN_BOTTOM + fontHeightGet(_guiFont)) + (MSG_PADDING * 2);
+ h = WIN_MARGIN_TOP + WIN_MARGIN_BOTTOM + fontHeightGet(__guiFont) + (BTN_MARGIN_TOP + BTN_MARGIN_BOTTOM + fontHeightGet(__guiFont)) + (MSG_PADDING * 2);
// Count lines of text and add up height. Find widest line.
text = strdup(message);
token = strtok(text, "\n");
while (token) {
- textH += fontHeightGet(_guiFont);
+ textH += fontHeightGet(__guiFont);
if (strlen(token) > textW) {
textW = strlen(token);
}
token = strtok(NULL, "\n");
}
free(text);
- textW *= fontWidthGet(_guiFont);
+ textW *= fontWidthGet(__guiFont);
// Initial cursor move and window sizing are based on text height.
cursorH = textH;
@@ -155,16 +165,16 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne,
if (newW > w) w = newW;
// Do we need to make the dialog wider to contain the buttons?
- newW = WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonOne));
- if (buttonTwo) newW += MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonTwo));
- if (buttonThree) newW += MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonThree));
+ newW = WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonOne));
+ if (buttonTwo) newW += MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonTwo));
+ if (buttonThree) newW += MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonThree));
if (newW > w) w = newW;
// Draw dialog.
h -= 5; // Height is off for some reason. At least, to me, it doesn't look right.
- _winDialog = windowNew(vbeDisplayWidthGet() / 2 - w / 2, vbeDisplayHeightGet() / 2 - h / 2, w, h, title);
- guiAttach(guiRootGet(), W(_winDialog));
+ context->winDialog = windowNew(vbeDisplayWidthGet() / 2 - w / 2, vbeDisplayHeightGet() / 2 - h / 2, w, h, title);
+ guiAttach(guiRootGet(), W(context->winDialog));
// Initial x cursor is the (implied window left margin +) padding
x = MSG_PADDING;
@@ -174,8 +184,8 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne,
// Load proper icon, if desired.
if (icon > MSGBOX_ICON_NONE && icon < MSGBOX_ICON_COUNT) {
- _picIcon = pictureNew(x, y, cacheFilenameGet(_iconFiles[icon - 1]));
- guiAttach(W(_winDialog), W(_picIcon));
+ context->picIcon = pictureNew(x, y, cacheFilenameGet(_iconFiles[icon - 1]));
+ guiAttach(W(context->winDialog), W(context->picIcon));
}
// Draw message text.
@@ -184,33 +194,36 @@ void msgBoxThree(char *title, MsgBoxIconT icon, char *message, char *buttonOne,
text = strdup(message);
token = strtok(text, "\n");
while (token) {
- _lblText = labelNew(x, t, token);
- guiAttach(W(_winDialog), W(_lblText));
- t += fontHeightGet(_guiFont);
+ context->lblText = labelNew(x, t, token);
+ guiAttach(W(context->winDialog), W(context->lblText));
+ t += fontHeightGet(__guiFont);
token = strtok(NULL, "\n");
}
free(text);
// Move to where buttons belong.
- x = w - (WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonOne)));
+ x = w - (WIN_MARGIN_LEFT + WIN_MARGIN_RIGHT + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonOne)));
y += cursorH + MSG_PADDING;
// We always have at least one button.
- _btnOne = buttonNew(x, y, buttonOne, btnMsgBox);
- guiAttach(W(_winDialog), W(_btnOne));
+ context->btnOne = buttonNew(x, y, buttonOne, btnMsgBox);
+ guiUserDataSet(W(context->btnOne), context);
+ guiAttach(W(context->winDialog), W(context->btnOne));
// Two buttons?
if (buttonTwo) {
- x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonTwo)));
- _btnTwo = buttonNew(x, y, buttonTwo, btnMsgBox);
- guiAttach(W(_winDialog), W(_btnTwo));
+ x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonTwo)));
+ context->btnTwo = buttonNew(x, y, buttonTwo, btnMsgBox);
+ guiUserDataSet(W(context->btnTwo), context);
+ guiAttach(W(context->winDialog), W(context->btnTwo));
}
// Three buttons?
if (buttonThree) {
- x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(_guiFont) * strlen(buttonThree)));
- _btnThree = buttonNew(x, y, buttonThree, btnMsgBox);
- guiAttach(W(_winDialog), W(_btnThree));
+ x -= (MSG_PADDING + BTN_MARGIN_LEFT + BTN_MARGIN_RIGHT + (fontWidthGet(__guiFont) * strlen(buttonThree)));
+ context->btnThree = buttonNew(x, y, buttonThree, btnMsgBox);
+ guiUserDataSet(W(context->btnThree), context);
+ guiAttach(W(context->winDialog), W(context->btnThree));
}
}
diff --git a/client/src/gui/picture.c b/client/src/gui/picture.c
index 6cc5077..99a0bde 100644
--- a/client/src/gui/picture.c
+++ b/client/src/gui/picture.c
@@ -47,6 +47,7 @@ WidgetT *pictureInit(WidgetT *widget, char *filename) {
l->base.mouseEventMethod = pictureMouseEvent;
l->filename = strdup(filename);
l->clicked = NULL;
+ l->zoom = PICTURE_FULL;
l->image = imageLoad(l->filename);
if (!l->image) {
@@ -104,5 +105,19 @@ PictureT *pictureNew(uint16_t x, uint16_t y, char *filename) {
static void picturePaint(WidgetT *widget, uint8_t enabled, RectT pos) {
PictureT *p = (PictureT *)widget;
- imageRender(p->image, pos.x, pos.y);
+ switch (p->zoom) {
+ case PICTURE_FULL:
+ imageRender(p->image, pos.x, pos.y);
+ break;
+
+ case PICTURE_HALF:
+ imageRenderHalf(p->image, pos.x, pos.y);
+ break;
+ }
+}
+
+
+void pictureZoomSet(PictureT *picture, PictureZoomT zoom) {
+ picture->zoom = zoom;
+ GUI_SET_FLAG(W(picture), WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/picture.h b/client/src/gui/picture.h
index 30d242c..48ec614 100644
--- a/client/src/gui/picture.h
+++ b/client/src/gui/picture.h
@@ -27,17 +27,25 @@
#include "image.h"
+typedef enum PictureZoomE {
+ PICTURE_FULL = 0,
+ PICTURE_HALF
+} PictureZoomT;
+
+
typedef struct PictureS {
WidgetT base; // Must be first in every widget
char *filename;
widgetCallback clicked;
ImageT *image;
+ int8_t zoom;
} PictureT;
void pictureClickHandlerSet(PictureT *picture, widgetCallback callback);
WidgetT *pictureInit(WidgetT *widget, char *filename);
PictureT *pictureNew(uint16_t x, uint16_t y, char *filename);
+void pictureZoomSet(PictureT *picture, PictureZoomT zoom);
#endif // PICTURE_H
diff --git a/client/src/gui/radio.c b/client/src/gui/radio.c
index 3c42180..4b16163 100644
--- a/client/src/gui/radio.c
+++ b/client/src/gui/radio.c
@@ -53,7 +53,7 @@ WidgetT *radioInit(WidgetT *widget, char *title, uint16_t group) {
radioTitleSet(r, title);
// Width is set in radioSetTitle
- r->base.pos.h = fontHeightGet(_guiFont);
+ r->base.pos.h = fontHeightGet(__guiFont);
return widget;
}
@@ -107,21 +107,21 @@ static void radioPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
active = (radioSelectedGet(r) == r);
if (enabled) {
- highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT];
- shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : _guiColor[COLOR_RADIOBUTTON_SHADOW];
- fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE] : _guiColor[COLOR_RADIOBUTTON_INACTIVE];
- text = _guiColor[COLOR_CHECKBOX_TEXT];
- background = _guiColor[COLOR_WINDOW_BACKGROUND];
+ highlight = active ? __guiColor[COLOR_RADIOBUTTON_SHADOW] : __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT];
+ shadow = active ? __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT] : __guiColor[COLOR_RADIOBUTTON_SHADOW];
+ fill = active ? __guiColor[COLOR_RADIOBUTTON_ACTIVE] : __guiColor[COLOR_RADIOBUTTON_INACTIVE];
+ text = __guiColor[COLOR_CHECKBOX_TEXT];
+ background = __guiColor[COLOR_WINDOW_BACKGROUND];
} else {
- highlight = active ? _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] : _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED];
- shadow = active ? _guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] : _guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED];
- fill = active ? _guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] : _guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED];
- text = _guiColor[COLOR_CHECKBOX_TEXT_DISABLED];
- background = _guiColor[COLOR_WINDOW_BACKGROUND];
+ highlight = active ? __guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED] : __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED];
+ shadow = active ? __guiColor[COLOR_RADIOBUTTON_HIGHLIGHT_DISABLED] : __guiColor[COLOR_RADIOBUTTON_SHADOW_DISABLED];
+ fill = active ? __guiColor[COLOR_RADIOBUTTON_ACTIVE_DISABLED] : __guiColor[COLOR_RADIOBUTTON_INACTIVE_DISABLED];
+ text = __guiColor[COLOR_CHECKBOX_TEXT_DISABLED];
+ background = __guiColor[COLOR_WINDOW_BACKGROUND];
}
// Radio button is 10x10 pixels. Find offset based on font height.
- o = (_guiFont->height - 10) * 0.5;
+ o = (__guiFont->height - 10) * 0.5;
// Draw outline of radio button.
surfaceLineDraw(pos.x, pos.y + o + 5, pos.x + 5, pos.y + o, highlight);
@@ -136,7 +136,7 @@ static void radioPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
}
// Draw title.
- fontRender(_guiFont, r->title, text, background, pos.x + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y);
+ fontRender(__guiFont, r->title, text, background, pos.x + 10 + __guiMetric[METRIC_RADIOBUTTON_PADDING], pos.y);
}
@@ -210,6 +210,6 @@ void radioSelectedSet(RadioT *radio) {
void radioTitleSet(RadioT *radio, char *title) {
if (radio->title) free(radio->title);
radio->title = strdup(title);
- radio->base.pos.w = (strlen(title) * fontWidthGet(_guiFont)) + 10 + _guiMetric[METRIC_RADIOBUTTON_PADDING];
+ radio->base.pos.w = (strlen(title) * fontWidthGet(__guiFont)) + 10 + __guiMetric[METRIC_RADIOBUTTON_PADDING];
GUI_SET_FLAG((WidgetT *)radio, WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/taglist.c b/client/src/gui/taglist.c
index eeb15e1..0186f9b 100644
--- a/client/src/gui/taglist.c
+++ b/client/src/gui/taglist.c
@@ -110,6 +110,7 @@ static void tagListWidgetAttributeHandle(void) {
uint8_t enabled;
uint8_t visible;
char mask;
+ PictureZoomT zoom;
// Process generated lists in reverse.
while (arrlen(_widgetList) > 0) {
@@ -147,6 +148,7 @@ static void tagListWidgetAttributeHandle(void) {
enabled = 1;
visible = 1;
mask = 0;
+ zoom = PICTURE_FULL;
// Parse provided attributes.
for (i=0; itagList); i+=2) {
@@ -256,6 +258,9 @@ static void tagListWidgetAttributeHandle(void) {
pos.y = v;
break;
+ case T_ZOOM:
+ zoom = v;
+ break;
}
}
@@ -316,6 +321,7 @@ static void tagListWidgetAttributeHandle(void) {
case T_PICTURE:
widget = W(pictureNew(pos.x, pos.y, filename));
+ pictureZoomSet((PictureT *)widget, zoom);
if (click != NULL) pictureClickHandlerSet((PictureT *)widget, click);
break;
diff --git a/client/src/gui/taglist.h b/client/src/gui/taglist.h
index 9f2db1f..883bf86 100644
--- a/client/src/gui/taglist.h
+++ b/client/src/gui/taglist.h
@@ -85,6 +85,7 @@ enum TagItemsE {
T_WIDTH,
T_X,
T_Y,
+ T_ZOOM,
T_META_END_OF_ATTRIBUTES
};
diff --git a/client/src/gui/terminal.c b/client/src/gui/terminal.c
index 421a9e0..6e9480a 100644
--- a/client/src/gui/terminal.c
+++ b/client/src/gui/terminal.c
@@ -539,7 +539,7 @@ WidgetT *terminalInit(WidgetT *widget, uint16_t cols, uint16_t rows) {
t->base.paintMethod = terminalPaint;
t->base.keyboardEventMethod = terminalKeyboardEvent;
t->base.mouseEventMethod = terminalMouseEvent;
- t->font = _guiFont; // Default font. Also see terminalNew.
+ t->font = __guiFont; // Default font. Also see terminalNew.
t->cols = cols;
t->rows = rows;
t->cursorX = 1;
@@ -641,8 +641,8 @@ TerminalT *terminalNew(uint16_t x, uint16_t y, uint16_t cols, uint16_t rows) {
if (!terminal) return NULL;
// Default font. Also see terminalInit.
- w = fontWidthGet(_guiFont) * cols;
- h = fontHeightGet(_guiFont) * rows;
+ w = fontWidthGet(__guiFont) * cols;
+ h = fontHeightGet(__guiFont) * rows;
widget = widgetInit(W(terminal), MAGIC_TERMINAL, x, y, w, h, 0, 0, 0, 0);
if (!widget) {
diff --git a/client/src/gui/textbox.c b/client/src/gui/textbox.c
index 6fc8dba..db1d755 100644
--- a/client/src/gui/textbox.c
+++ b/client/src/gui/textbox.c
@@ -226,14 +226,14 @@ static void textboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16
// Allow dragging/positioning text cursor with mouse.
if (event == MOUSE_EVENT_LEFT_HOLD) {
// Where's the text display?
- textArea.x = (strlen(t->title) * fontWidthGet(_guiFont)) + _guiMetric[METRIC_TEXTBOX_PADDING] + 2 + _guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING];
- textArea.y = 2 + _guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING];
- textArea.w = textArea.x + t->visible * fontWidthGet(_guiFont);
- textArea.h = textArea.y + fontHeightGet(_guiFont);
+ textArea.x = (strlen(t->title) * fontWidthGet(__guiFont)) + __guiMetric[METRIC_TEXTBOX_PADDING] + 2 + __guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING];
+ textArea.y = 2 + __guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING];
+ textArea.w = textArea.x + t->visible * fontWidthGet(__guiFont);
+ textArea.h = textArea.y + fontHeightGet(__guiFont);
// Is the pointer over it?
if (x >= textArea.x && x < textArea.w && y >= textArea.y && y < textArea.h) {
// Move caret.
- t->caret = (x - textArea.x) / fontWidthGet(_guiFont);
+ t->caret = (x - textArea.x) / fontWidthGet(__guiFont);
// Did we go too far?
if (t->caret + t->offset > strlen(t->value)) {
t->caret = strlen(t->value) - t->offset;
@@ -248,7 +248,7 @@ static void textboxMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16
TextboxT *textboxNew(uint16_t x, uint16_t y, uint16_t w, char *title) {
TextboxT *textbox = (TextboxT *)malloc(sizeof(TextboxT));
WidgetT *widget = NULL;
- uint16_t h = fontHeightGet(_guiFont) + 4 + (_guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING] * 2);
+ uint16_t h = fontHeightGet(__guiFont) + 4 + (__guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING] * 2);
if (!textbox) return NULL;
@@ -276,34 +276,34 @@ static void textboxPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
if (GUI_GET_FLAG(widget, WIDGET_FLAG_DIRTY) || guiFocusGet() == widget) {
- labelWidth = (strlen(t->title) * fontWidthGet(_guiFont)) + _guiMetric[METRIC_TEXTBOX_PADDING];
- valueWidth = (t->visible * fontWidthGet(_guiFont)) + (_guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] * 2);
+ labelWidth = (strlen(t->title) * fontWidthGet(__guiFont)) + __guiMetric[METRIC_TEXTBOX_PADDING];
+ valueWidth = (t->visible * fontWidthGet(__guiFont)) + (__guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] * 2);
// Draw title.
- fontRender(_guiFont, t->title, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y + 2 + _guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING]);
+ fontRender(__guiFont, t->title, __guiColor[COLOR_TEXTBOX_TEXT], __guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y + 2 + __guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING]);
// Draw outline of textbox.
- surfaceHighlightFrameDraw( pos.x + labelWidth, pos.y, pos.x + labelWidth + valueWidth + 2, pos.y + pos.h, _guiColor[COLOR_TEXTBOX_SHADOW], _guiColor[COLOR_TEXTBOX_HIGHLIGHT]);
- surfaceRectangleDraw( pos.x + labelWidth + 1, pos.y + 1, pos.x + labelWidth + valueWidth + 1, pos.y + pos.h - 1, _guiColor[COLOR_WINDOW_BACKGROUND]);
+ surfaceHighlightFrameDraw( pos.x + labelWidth, pos.y, pos.x + labelWidth + valueWidth + 2, pos.y + pos.h, __guiColor[COLOR_TEXTBOX_SHADOW], __guiColor[COLOR_TEXTBOX_HIGHLIGHT]);
+ surfaceRectangleDraw( pos.x + labelWidth + 1, pos.y + 1, pos.x + labelWidth + valueWidth + 1, pos.y + pos.h - 1, __guiColor[COLOR_WINDOW_BACKGROUND]);
// Draw background.
- surfaceRectangleFilledDraw(pos.x + labelWidth + 2, pos.y + 2, pos.x + labelWidth + valueWidth, pos.y + pos.h - 2, _guiColor[COLOR_TEXTBOX_BACKGROUND]);
+ surfaceRectangleFilledDraw(pos.x + labelWidth + 2, pos.y + 2, pos.x + labelWidth + valueWidth, pos.y + pos.h - 2, __guiColor[COLOR_TEXTBOX_BACKGROUND]);
// Where's the text display start?
- textX = pos.x + labelWidth + 2 + _guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING];
- textY = pos.y + 2 + _guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING];
+ textX = pos.x + labelWidth + 2 + __guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING];
+ textY = pos.y + 2 + __guiMetric[METRIC_TEXTBOX_VERTICAL_PADDING];
// Draw value.
draw = strdup(&t->value[t->offset]);
if (strlen(draw) > t->visible) draw[t->visible] = 0;
if (t->password != 0) memset(draw, t->password, strlen(draw));
- fontRender(_guiFont, draw, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_TEXTBOX_BACKGROUND], textX, textY);
+ fontRender(__guiFont, draw, __guiColor[COLOR_TEXTBOX_TEXT], __guiColor[COLOR_TEXTBOX_BACKGROUND], textX, textY);
free(draw);
// Draw cursor.
if (guiFocusGet() == widget && guiTimerQuarterSecondOn()) {
- caretPos = textX + fontWidthGet(_guiFont) * t->caret;
- fontRender(_guiFont, cursor, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_TEXTBOX_BACKGROUND], caretPos, textY);
+ caretPos = textX + fontWidthGet(__guiFont) * t->caret;
+ fontRender(__guiFont, cursor, __guiColor[COLOR_TEXTBOX_TEXT], __guiColor[COLOR_TEXTBOX_BACKGROUND], caretPos, textY);
}
GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY);
@@ -321,7 +321,7 @@ void textboxTitleSet(TextboxT *textbox, char *title) {
textbox->title = strdup(title);
// Figure out how many characters we have room to display.
- textbox->visible = (textbox->base.pos.w - ((strlen(title) * fontWidthGet(_guiFont)) + _guiMetric[METRIC_TEXTBOX_PADDING] + 4 + (_guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] * 2))) / fontWidthGet(_guiFont);
+ textbox->visible = (textbox->base.pos.w - ((strlen(title) * fontWidthGet(__guiFont)) + __guiMetric[METRIC_TEXTBOX_PADDING] + 4 + (__guiMetric[METRIC_TEXTBOX_HORIZONTAL_PADDING] * 2))) / fontWidthGet(__guiFont);
GUI_SET_FLAG((WidgetT *)textbox, WIDGET_FLAG_DIRTY);
}
diff --git a/client/src/gui/updown.c b/client/src/gui/updown.c
index d33b6ca..b3fa9bd 100644
--- a/client/src/gui/updown.c
+++ b/client/src/gui/updown.c
@@ -191,11 +191,11 @@ static void updownMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
if (event == MOUSE_EVENT_LEFT_UP) {
updownSizesRecalculate(u);
- _arrowStart += 1 + _guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING]; // Left of up arrow
- o = 1 + _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]; // Top of arrows
+ _arrowStart += 1 + __guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING]; // Left of up arrow
+ o = 1 + __guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]; // Top of arrows
// Did they click the up arrow?
- if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(_guiFont) && y >= o && y <= o + fontHeightGet(_guiFont)) {
+ if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(__guiFont) && y >= o && y <= o + fontHeightGet(__guiFont)) {
// Can we increment?
if (u->value < u->maximum) {
// Clamp.
@@ -209,8 +209,8 @@ static void updownMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
}
// Did they click the down arrow?
- _arrowStart += fontHeightGet(_guiFont) + 1; // Left of down arrow
- if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(_guiFont) && y >= o && y <= o + fontHeightGet(_guiFont)) {
+ _arrowStart += fontHeightGet(__guiFont) + 1; // Left of down arrow
+ if (x >= _arrowStart && x <= _arrowStart + fontHeightGet(__guiFont) && y >= o && y <= o + fontHeightGet(__guiFont)) {
// Can we decrement?
if (u->value > u->minimum) {
// Clamp.
@@ -230,7 +230,7 @@ static void updownMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
UpdownT *updownNew(uint16_t x, uint16_t y, int32_t min, int32_t max, int32_t step, char *title) {
UpdownT *updown = (UpdownT *)malloc(sizeof(UpdownT));
WidgetT *widget = NULL;
- uint16_t h = fontHeightGet(_guiFont) + 4 + (_guiMetric[METRIC_UPDOWN_VERTICAL_PADDING] * 2);
+ uint16_t h = fontHeightGet(__guiFont) + 4 + (__guiMetric[METRIC_UPDOWN_VERTICAL_PADDING] * 2);
if (!updown) return NULL;
@@ -263,56 +263,56 @@ static void updownPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
_arrowStart += pos.x; // This method expects the start in screen space, not widget space.
// Draw title.
- fontRender(_guiFont, u->title, _guiColor[COLOR_UPDOWN_TEXT], _guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y + 2 + _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]);
+ fontRender(__guiFont, u->title, __guiColor[COLOR_UPDOWN_TEXT], __guiColor[COLOR_WINDOW_BACKGROUND], pos.x, pos.y + 2 + __guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]);
// Draw outline of text.
- surfaceHighlightFrameDraw( pos.x + _labelWidth, pos.y, pos.x + _labelWidth + _valueWidth + 2, pos.y + pos.h, _guiColor[COLOR_UPDOWN_SHADOW], _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
- surfaceRectangleDraw( pos.x + _labelWidth + 1, pos.y + 1, pos.x + _labelWidth + _valueWidth + 1, pos.y + pos.h - 1, _guiColor[COLOR_WINDOW_BACKGROUND]);
+ surfaceHighlightFrameDraw( pos.x + _labelWidth, pos.y, pos.x + _labelWidth + _valueWidth + 2, pos.y + pos.h, __guiColor[COLOR_UPDOWN_SHADOW], __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceRectangleDraw( pos.x + _labelWidth + 1, pos.y + 1, pos.x + _labelWidth + _valueWidth + 1, pos.y + pos.h - 1, __guiColor[COLOR_WINDOW_BACKGROUND]);
// Draw text background.
- surfaceRectangleFilledDraw(pos.x + _labelWidth + 2, pos.y + 2, pos.x + _labelWidth + _valueWidth, pos.y + pos.h - 2, _guiColor[COLOR_UPDOWN_BACKGROUND]);
+ surfaceRectangleFilledDraw(pos.x + _labelWidth + 2, pos.y + 2, pos.x + _labelWidth + _valueWidth, pos.y + pos.h - 2, __guiColor[COLOR_UPDOWN_BACKGROUND]);
// Draw arrows outline
- surfaceHighlightFrameDraw(_arrowStart, pos.y, _arrowStart + _arrowWidth + 1, pos.y + pos.h, _guiColor[COLOR_UPDOWN_SHADOW], _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceHighlightFrameDraw(_arrowStart, pos.y, _arrowStart + _arrowWidth + 1, pos.y + pos.h, __guiColor[COLOR_UPDOWN_SHADOW], __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
// Draw arrows background
- surfaceRectangleFilledDraw(_arrowStart + 1, pos.y + 1, _arrowStart + _arrowWidth, pos.y + pos.h - 1, _guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND]);
+ surfaceRectangleFilledDraw(_arrowStart + 1, pos.y + 1, _arrowStart + _arrowWidth, pos.y + pos.h - 1, __guiColor[COLOR_UPDOWN_ARROWS_BACKGROUND]);
// Draw up arrow
- _arrowStart += _halfFont + 1 + _guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING]; // Center of up arrow
- o = pos.y + 1 + _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]; // Top of up arrow
- color = u->value < u->maximum ? _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
- for (i=0; i<=fontHeightGet(_guiFont); i++) {
+ _arrowStart += _halfFont + 1 + __guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING]; // Center of up arrow
+ o = pos.y + 1 + __guiMetric[METRIC_UPDOWN_VERTICAL_PADDING]; // Top of up arrow
+ color = u->value < u->maximum ? __guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : __guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
+ for (i=0; i<=fontHeightGet(__guiFont); i++) {
surfaceLineDraw(_arrowStart - i * 0.5, o + i, _arrowStart + i * 0.5, o + i, color);
}
- surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]);
- surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(_guiFont), _arrowStart + _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]);
- surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_SHADOW]);
+ surfaceLineDraw(_arrowStart - _halfFont, o + fontHeightGet(__guiFont), _arrowStart + _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_SHADOW]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o + fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
// Draw down arrow
- _arrowStart += fontHeightGet(_guiFont) + 1; // Center of down arrow
- o += fontHeightGet(_guiFont); // Bottom of down arrow
- color = u->value > u->minimum ? _guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : _guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
- for (i=0; i<=fontHeightGet(_guiFont); i++) {
+ _arrowStart += fontHeightGet(__guiFont) + 1; // Center of down arrow
+ o += fontHeightGet(__guiFont); // Bottom of down arrow
+ color = u->value > u->minimum ? __guiColor[COLOR_UPDOWN_ARROWS_ACTIVE] : __guiColor[COLOR_UPDOWN_ARROWS_INACTIVE];
+ for (i=0; i<=fontHeightGet(__guiFont); i++) {
surfaceLineDraw(_arrowStart - i * 0.5, o - i, _arrowStart + i * 0.5, o - i, color);
}
- surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_SHADOW]);
- surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(_guiFont), _arrowStart + _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
- surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(_guiFont), _guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart + _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_SHADOW]);
+ surfaceLineDraw(_arrowStart - _halfFont, o - fontHeightGet(__guiFont), _arrowStart + _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
+ surfaceLineDraw(_arrowStart, o, _arrowStart - _halfFont, o - fontHeightGet(__guiFont), __guiColor[COLOR_UPDOWN_HIGHLIGHT]);
// Where's the text display start?
- textX = pos.x + _labelWidth + 2 + _guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING];
- textY = pos.y + 2 + _guiMetric[METRIC_UPDOWN_VERTICAL_PADDING];
+ textX = pos.x + _labelWidth + 2 + __guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING];
+ textY = pos.y + 2 + __guiMetric[METRIC_UPDOWN_VERTICAL_PADDING];
// Draw value.
snprintf(draw, UPDOWN_MAX_DIGITS, "%ld", (long)u->value); // Weird typecasting prevents warnings in both DOS and Linux (32 and 64 bit)
- textX += (u->visible - strlen(draw)) * fontWidthGet(_guiFont);
- fontRender(_guiFont, draw, _guiColor[COLOR_UPDOWN_TEXT], _guiColor[COLOR_UPDOWN_BACKGROUND], textX, textY);
+ textX += (u->visible - strlen(draw)) * fontWidthGet(__guiFont);
+ fontRender(__guiFont, draw, __guiColor[COLOR_UPDOWN_TEXT], __guiColor[COLOR_UPDOWN_BACKGROUND], textX, textY);
// Draw cursor.
if (guiFocusGet() == widget && guiTimerQuarterSecondOn()) {
- textX += (strlen(draw) - 1) * fontWidthGet(_guiFont);
- fontRender(_guiFont, cursor, _guiColor[COLOR_TEXTBOX_TEXT], _guiColor[COLOR_TEXTBOX_BACKGROUND], textX, textY);
+ textX += (strlen(draw) - 1) * fontWidthGet(__guiFont);
+ fontRender(__guiFont, cursor, __guiColor[COLOR_TEXTBOX_TEXT], __guiColor[COLOR_TEXTBOX_BACKGROUND], textX, textY);
}
GUI_CLEAR_FLAG(widget, WIDGET_FLAG_DIRTY);
@@ -329,11 +329,11 @@ static void updownSizesRecalculate(UpdownT *updown) {
// = - arrowStart (start of box surrounding arrows, including border).
// Set global stuff that isn't actually part of the widget state.
- _halfFont = fontHeightGet(_guiFont) * 0.5;
- _labelWidth = (strlen(updown->title) * fontWidthGet(_guiFont)) + _guiMetric[METRIC_UPDOWN_PADDING];
- _valueWidth = (updown->visible * fontWidthGet(_guiFont)) + (_guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] * 2);
- _arrowWidth = (fontHeightGet(_guiFont) * 2) + 1 + 2 + (_guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] * 2); // Arrow width = font height
- _arrowStart = _labelWidth + _valueWidth + 2 + _guiMetric[METRIC_UPDOWN_ARROW_PADDING];
+ _halfFont = fontHeightGet(__guiFont) * 0.5;
+ _labelWidth = (strlen(updown->title) * fontWidthGet(__guiFont)) + __guiMetric[METRIC_UPDOWN_PADDING];
+ _valueWidth = (updown->visible * fontWidthGet(__guiFont)) + (__guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] * 2);
+ _arrowWidth = (fontHeightGet(__guiFont) * 2) + 1 + 2 + (__guiMetric[METRIC_UPDOWN_HORIZONTAL_PADDING] * 2); // Arrow width = font height
+ _arrowStart = _labelWidth + _valueWidth + 2 + __guiMetric[METRIC_UPDOWN_ARROW_PADDING];
}
diff --git a/client/src/gui/window.c b/client/src/gui/window.c
index 9b390e7..c8bc965 100644
--- a/client/src/gui/window.c
+++ b/client/src/gui/window.c
@@ -52,7 +52,7 @@ void windowActiveSet(WindowT *window) {
}
// Tell the GUI.
- _guiActiveWindow = window;
+ __guiActiveWindow = window;
}
@@ -118,19 +118,19 @@ static void windowMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
// Start dragging?
if (event == MOUSE_EVENT_LEFT_DOWN && GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE)) {
// Are we on the draggable area of the titlebar / borders?
- if (y < _guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT]) {
+ if (y < __guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT]) {
// Start dragging.
- _guiDragWidget = widget;
+ __guiDragWidget = widget;
_guiDragOffsetX = mouse->x - window->base.pos.x;
- _guiDragOffsetY = mouse->y - window->base.pos.y;
+ __guiDragOffsetY = mouse->y - window->base.pos.y;
}
}
// Still dragging? We use raw mouse data here because it's possible to drag too quickly and trigger "OUT" events.
- if (_guiDragWidget == widget && mouse->buttonLeft && GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE)) {
+ if (__guiDragWidget == widget && mouse->buttonLeft && GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE)) {
// Move window.
window->base.pos.x = mouse->x - _guiDragOffsetX;
- window->base.pos.y = mouse->y - _guiDragOffsetY;
+ window->base.pos.y = mouse->y - __guiDragOffsetY;
// Keep it on the screen.
if (window->base.pos.x < 0) window->base.pos.x = 0;
if (window->base.pos.x + window->base.pos.w > vbeDisplayWidthGet()) window->base.pos.x = vbeDisplayWidthGet() - window->base.pos.w;
@@ -139,8 +139,8 @@ static void windowMouseEvent(WidgetT *widget, MouseT *mouse, uint16_t x, uint16_
}
// Be sure we stop dragging on mouse up or move out.
- if (_guiDragWidget == widget && event == MOUSE_EVENT_LEFT_UP) {
- _guiDragWidget = NULL;
+ if (__guiDragWidget == widget && event == MOUSE_EVENT_LEFT_UP) {
+ __guiDragWidget = NULL;
}
}
@@ -152,10 +152,10 @@ WindowT *windowNew(uint16_t x, uint16_t y, uint16_t w, uint16_t h, char *title)
if (!window) return NULL;
widget = widgetInit(W(window), MAGIC_WINDOW, x, y, w, h,
- _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3,
- _guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT],
- _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4,
- _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4);
+ __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3,
+ __guiMetric[METRIC_WINDOW_TITLE_GRAB_HEIGHT],
+ __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4,
+ __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4);
if (!widget) {
free(window);
return NULL;
@@ -176,23 +176,23 @@ static void windowPaint(WidgetT *widget, uint8_t enabled, RectT pos) {
x2 = pos.w - 1;
y2 = pos.h - 1;
- background = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_INACTIVE];
- text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? _guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] : _guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE];
+ background = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? __guiColor[COLOR_WINDOW_TITLE_ACTIVE] : __guiColor[COLOR_WINDOW_TITLE_INACTIVE];
+ text = GUI_GET_FLAG(widget, WIDGET_FLAG_ACTIVE) ? __guiColor[COLOR_WINDOW_TITLE_TEXT_ACTIVE] : __guiColor[COLOR_WINDOW_TITLE_TEXT_INACTIVE];
// Background.
- surfaceClear(_guiColor[COLOR_WINDOW_BACKGROUND]);
+ surfaceClear(__guiColor[COLOR_WINDOW_BACKGROUND]);
// Outer edge.
- surfaceHighlightFrameDraw(0, 0, x2, y2, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]);
+ surfaceHighlightFrameDraw(0, 0, x2, y2, __guiColor[COLOR_WINDOW_HIGHLIGHT], __guiColor[COLOR_WINDOW_SHADOW]);
// Inner edge - skip METRIC_WINDOW_BORDER_WIDTH pixels. Be sure shadow and highlight are not included in the width.
- surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, y2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, _guiColor[COLOR_WINDOW_SHADOW], _guiColor[COLOR_WINDOW_HIGHLIGHT]);
+ surfaceHighlightFrameDraw(__guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 2, x2 - __guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, y2 - __guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 2, __guiColor[COLOR_WINDOW_SHADOW], __guiColor[COLOR_WINDOW_HIGHLIGHT]);
// Title bar - METRIC_WINDOW_TITLE_HEIGHT pixels high. Be sure shadow and highlight are not included in the width.
- surfaceHighlightFrameDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 3, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 4, _guiColor[COLOR_WINDOW_HIGHLIGHT], _guiColor[COLOR_WINDOW_SHADOW]);
- surfaceRectangleFilledDraw(_guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, x2 - _guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 4, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + _guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 2, background);
+ surfaceHighlightFrameDraw(__guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 3, x2 - __guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 3, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + __guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 4, __guiColor[COLOR_WINDOW_HIGHLIGHT], __guiColor[COLOR_WINDOW_SHADOW]);
+ surfaceRectangleFilledDraw(__guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 4, x2 - __guiMetric[METRIC_WINDOW_BORDER_WIDTH] - 4, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + __guiMetric[METRIC_WINDOW_TITLE_HEIGHT] + 2, background);
- fontRender(_guiFont, w->title, text, background, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 16, _guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 5);
+ fontRender(__guiFont, w->title, text, background, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 16, __guiMetric[METRIC_WINDOW_BORDER_WIDTH] + 5);
}
diff --git a/client/src/linux/linux.c b/client/src/linux/linux.c
index 025b3d4..b6e24ea 100644
--- a/client/src/linux/linux.c
+++ b/client/src/linux/linux.c
@@ -75,7 +75,6 @@ static uint8_t _takeScreenshot = 0;
static void comAddToBuffer(char *data, uint16_t len);
-//static void comBufferShow(void);
static void comModem(uint8_t c);
static void processEvent(void);
static void processNetworkEvent(void);
@@ -98,21 +97,6 @@ static void comAddToBuffer(char *data, uint16_t len) {
}
-/*
-static void comBufferShow(void) {
- uint16_t x = _bufferTail;
-
- logWrite("={");
- while (x != _bufferHead) {
- if (_buffer[x] != '\r' && _buffer[x] != '\n') logWrite("%c ", _buffer[x]);
- logWrite("%02x ", (uint8_t)_buffer[x++]);
- if (x >= COM_BUFFER_SIZE) x = 0;
- }
- logWrite("}\n");
-}
-*/
-
-
int comClose(int com) {
// We only pretend to support one COM port.
if (com != 0) return SER_ERR_UNKNOWN;
@@ -496,7 +480,6 @@ static void processNetworkEvent(void) {
break;
case ENET_EVENT_TYPE_RECEIVE:
- //logWrite(" IN: "); packetDebugPrint((uint8_t *)event.packet->data, event.packet->dataLength);
comAddToBuffer((char *)event.packet->data, event.packet->dataLength);
break;
diff --git a/client/src/main.c b/client/src/main.c
index 3494ba8..0e607d8 100644
--- a/client/src/main.c
+++ b/client/src/main.c
@@ -292,6 +292,8 @@ static void tableSave(void) {
}
+extern void browserShow(void);
+
int main(int argc, char *argv[]) {
if (startup(argc, argv)) return 1;
@@ -299,34 +301,13 @@ int main(int argc, char *argv[]) {
// Perform "first run" setup tasks or start the client?
if (hasValidSettings()) {
// We have what we need, start the client.
- welcomeShow();
+ //welcomeShow();
+ browserShow();
eventLoop();
} else {
// Run the setup.
settingsShow(checkSettings);
}
- /*
- uint8_t length = 79;
- uint8_t packet[] = {
- 0x00, 0x0b, 0x01, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x0c, 0x00, 0x00, 0x32, 0x64,
- 0x64, 0x38, 0x37, 0x61, 0x39, 0x65, 0x62, 0x37, 0x62, 0x30, 0x35, 0x62, 0x33,
- 0x38, 0x61, 0x66, 0x30, 0x33, 0x39, 0x36, 0x61, 0x38, 0x33, 0x32, 0x62, 0x35,
- 0x63, 0x61, 0x66, 0x63, 0x35, 0x31, 0x65, 0x61, 0x33, 0x36, 0x64, 0x33, 0x35,
- 0x32, 0x33, 0x37, 0x36, 0x33, 0x38, 0x64, 0x62, 0x33, 0x32, 0x35, 0x33, 0x30,
- 0x33, 0x37, 0x35, 0x36, 0x32, 0x32, 0x36, 0x32, 0x63, 0x34, 0x00, 0x44, 0x7e,
- 0x00
- };
- PacketDecodeDataT decoded;
-
- if (packetDecode(__packetThreadData, &decoded, (char *)packet, length)) {
- logWrite("Packet decoded: %d\n", decoded.packetType);
- } else {
- logWrite("Packet NOT decoded.\n");
- }
-
- shutdown();
- */
-
return 0;
}
diff --git a/client/src/menu.c b/client/src/menu.c
index 58a23a0..02ed159 100644
--- a/client/src/menu.c
+++ b/client/src/menu.c
@@ -34,6 +34,8 @@
static void btnMsgBoxLogoff(MsgBoxButtonT button);
+static void btnMsgBoxOkay(MsgBoxButtonT button);
+static void menuEnable(uint8_t enable);
static void menuFilesReady(void);
static void picChatClick(WidgetT *widget);
static void picEmailClick(WidgetT *widget);
@@ -63,6 +65,27 @@ static void btnMsgBoxLogoff(MsgBoxButtonT button) {
// ***TODO*** Need a way to close all other windows.
hangupShow(welcomeShow);
}
+
+ menuEnable(1);
+}
+
+
+static void btnMsgBoxOkay(MsgBoxButtonT button) {
+ (void)(button);
+
+ menuEnable(1);
+}
+
+
+static void menuEnable(uint8_t enable) {
+ /*
+ widgetEnableSet(W(_picProfile), enable);
+ widgetEnableSet(W(_picLogoff), enable);
+ widgetEnableSet(W(_picGames), enable);
+ widgetEnableSet(W(_picForums), enable);
+ widgetEnableSet(W(_picEmail), enable);
+ widgetEnableSet(W(_picChat), enable);
+ */
}
@@ -118,33 +141,38 @@ void menuShow(void) {
static void picChatClick(WidgetT *widget) {
(void)widget;
// ***TODO***
- msgBoxOne("Chat", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL);
+ menuEnable(0);
+ msgBoxOne("Chat", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", btnMsgBoxOkay);
}
static void picEmailClick(WidgetT *widget) {
(void)widget;
// ***TODO***
- msgBoxOne("E-Mail", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL);
+ menuEnable(0);
+ msgBoxOne("E-Mail", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", btnMsgBoxOkay);
}
static void picForumsClick(WidgetT *widget) {
(void)widget;
// ***TODO***
- msgBoxOne("Forums", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL);
+ menuEnable(0);
+ msgBoxOne("Forums", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", btnMsgBoxOkay);
}
static void picGamesClick(WidgetT *widget) {
(void)widget;
// ***TODO***
- msgBoxOne("Games", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL);
+ menuEnable(0);
+ msgBoxOne("Games", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", btnMsgBoxOkay);
}
static void picLogoffClick(WidgetT *widget) {
(void)widget;
+ menuEnable(0);
msgBoxTwo("Logoff?", MSGBOX_ICON_QUESTION, "This will disconnect you from the server.", "Okay", btnMsgBoxLogoff, "Cancel", btnMsgBoxLogoff);
}
@@ -152,5 +180,6 @@ static void picLogoffClick(WidgetT *widget) {
static void picProfileClick(WidgetT *widget) {
(void)widget;
// ***TODO***
- msgBoxOne("Options", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL);
+ menuEnable(0);
+ msgBoxOne("Options", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", btnMsgBoxOkay);
}
diff --git a/client/src/system/cache.c b/client/src/system/cache.c
index d2e4164..066b350 100644
--- a/client/src/system/cache.c
+++ b/client/src/system/cache.c
@@ -112,8 +112,6 @@ uint8_t cacheEntryAdd(char *sha256, char *entryName, char *virtualPath) {
// Index format is: SHA256 ENTRYNAME VIRTUALPATH
- logWrite("Adding SHA [%s] Entry [%s] VPath [%s]\n", sha256, entryName, virtualPath);
-
sprintf(index, "CACHE%cINDEX.DAT", OS_PATH_SLASH);
sprintf(indexNew, "CACHE%cINDEX.NEW", OS_PATH_SLASH);
diff --git a/client/src/system/comport.c b/client/src/system/comport.c
index c03fe42..ede29e9 100644
--- a/client/src/system/comport.c
+++ b/client/src/system/comport.c
@@ -25,9 +25,6 @@
void comPacketSender(uint8_t *data, uint32_t length, void *userData) {
(void)userData;
-
- //logWrite("OUT: "); packetDebugPrint((uint8_t *)data, length);
-
comWrite(__configData.serialCom - 1, (char *)data, length);
}
diff --git a/client/src/system/network.c b/client/src/system/network.c
index f32ab20..902a22f 100644
--- a/client/src/system/network.c
+++ b/client/src/system/network.c
@@ -117,7 +117,6 @@ void netProcess(void) {
r = comRead(__configData.serialCom - 1, (char *)buffer, 1024);
// New data or not, process anything in the queue.
if (packetDecode(__packetThreadData, &decoded, buffer, r)) {
- logWrite("network.c - Packet In: %d Length: %d Channel: %d\n", decoded.packetType, decoded.length, decoded.channel);
//packetDebugPrint((uint8_t *)decoded.data, decoded.length);
switch (decoded.packetType) {
case PACKET_TYPE_PING:
@@ -158,7 +157,6 @@ void netProcess(void) {
packet->data = (uint8_t *)malloc(decoded.length);
memcpy(packet->data, decoded.data, decoded.length);
// Send it to the subscriber.
- logWrite("Delivering to subscriber %p\n", _channels[r].value);
_channels[r].value(packet);
}
}
diff --git a/server/src/client.c b/server/src/client.c
index 52833c6..1846281 100644
--- a/server/src/client.c
+++ b/server/src/client.c
@@ -145,7 +145,6 @@ void *clientThread(void *data) {
packetSend(client->packetThreadData, &encoded);
DEL(packetData);
versionSent = 1;
- consoleMessageQueue("PACKET_TYPE_VERSION sent.\n");
}
}
diff --git a/server/src/client/version.c b/server/src/client/version.c
index b4e1d1e..8e628f2 100644
--- a/server/src/client/version.c
+++ b/server/src/client/version.c
@@ -122,5 +122,4 @@ void clientApiVersionOkay(ClientThreadT *client, PacketDecodeDataT *data) {
packetEncode(client->packetThreadData, &encoded, NULL, 0);
// Send it.
packetSend(client->packetThreadData, &encoded);
- consoleMessageQueue("PACKET_TYPE_PROCEED sent.\n");
}