From 7c8fccbfbe169c522ccf53d127f77549831b8213 Mon Sep 17 00:00:00 2001 From: Philip Minakov Date: Wed, 1 May 2024 20:23:34 +0400 Subject: [PATCH] Delete UI implementation --- src/freetype/draw_string.c | 2 +- src/freetype/draw_text.c | 2 +- src/freetype/freetype.c | 2 +- src/gui/box.c | 293 ------------------------ src/gui/gui.c | 102 +-------- src/gui/menu/menu.c | 109 --------- src/gui/menu/menu_list.c | 319 --------------------------- src/gui/surface.c | 78 ------- src/include/sie/freetype/cache.h | 5 +- src/include/sie/freetype/freetype.h | 6 +- src/include/sie/gui/box.h | 47 ---- src/include/sie/gui/gui.h | 30 +-- src/include/sie/gui/menu/menu.h | 32 --- src/include/sie/gui/menu/menu_list.h | 59 ----- src/include/sie/gui/stack.h | 6 +- src/include/sie/gui/surface.h | 23 -- 16 files changed, 10 insertions(+), 1105 deletions(-) delete mode 100644 src/gui/box.c delete mode 100644 src/gui/menu/menu.c delete mode 100644 src/gui/menu/menu_list.c delete mode 100644 src/gui/surface.c delete mode 100644 src/include/sie/gui/box.h delete mode 100644 src/include/sie/gui/menu/menu.h delete mode 100644 src/include/sie/gui/menu/menu_list.h delete mode 100644 src/include/sie/gui/surface.h diff --git a/src/freetype/draw_string.c b/src/freetype/draw_string.c index 81b7a6a..3819fcc 100644 --- a/src/freetype/draw_string.c +++ b/src/freetype/draw_string.c @@ -1,6 +1,6 @@ #include #include "../include/sie/gui/gui.h" -#include "../include/sie/freetype/cache.h" +#include "../include/sie/freetype/freetype.h" #define SS_TMR_MS_START (216 / 1.5) #define SS_TMR_MS (16) diff --git a/src/freetype/draw_text.c b/src/freetype/draw_text.c index 48c1efa..ddefc81 100644 --- a/src/freetype/draw_text.c +++ b/src/freetype/draw_text.c @@ -1,7 +1,7 @@ #include #include #include "../include/sie/gui/gui.h" -#include "../include/sie/freetype/cache.h" +#include "../include/sie/freetype/freetype.h" extern FT_Face *FT_FACE_REGULAR; extern IMGHDR *BrushGlyphIMGHDR(IMGHDR *img, const char *color); diff --git a/src/freetype/freetype.c b/src/freetype/freetype.c index becd6ad..cc972e2 100644 --- a/src/freetype/freetype.c +++ b/src/freetype/freetype.c @@ -1,8 +1,8 @@ #include #include #include FT_FREETYPE_H -#include "../include/sie/gui/gui.h" #include "../include/sie/freetype/cache.h" +#include "../include/sie/freetype/freetype.h" extern char SKIN_FONT_REGULAR_PATH[]; diff --git a/src/gui/box.c b/src/gui/box.c deleted file mode 100644 index 6a49d93..0000000 --- a/src/gui/box.c +++ /dev/null @@ -1,293 +0,0 @@ -#include -#include -#include -#include -#include "../include/sie/gui/gui.h" -#include "../include/sie/resources.h" - -extern int SKIN_FONT_SIZE_MSG_BOX, SKIN_FONT_SIZE_MSG_BOX_SOFT_KEYS; - -static RECT canvas; -IMGHDR *IMG_YES; -IMGHDR *IMG_MSG_OK, *IMG_MSG_ERROR, *IMG_MSG_QUESTION; - -static void Close(GBSTMR *tmr) { - SIE_GUI_BOX *box = (SIE_GUI_BOX*)tmr->param6; - Sie_GUI_BoxClose(box); -} - -static void OnRedraw(SIE_GUI_BOX *data) { - const char color_bg[] = SIE_COLOR_BOX_BG; - const char color_border[] = SIE_COLOR_BOX_BORDER; - const char color_surface[] = SIE_COLOR_BOX_SURFACE; - - IMGHDR *scrot = (data->surface->scrot_p) ? data->surface->scrot_p : data->surface->scrot; - if (scrot) { - Sie_GUI_DrawIMGHDR(scrot, 0, 0, scrot->w, scrot->h); - } - Sie_GUI_DrawIconBar(); - DrawRectangle(0, YDISP, SCREEN_X2, SCREEN_Y2, 0, - GetPaletteAdrByColorIndex(23), color_surface); - - const int w_window = ScreenW() - 8; - const int h_window = 170; - const int x = (ScreenW() - w_window) / 2; - const int x2 = x + w_window; - const int y = (YDISP + (ScreenH() - YDISP) / 2) - h_window / 2; - const int y2 = y + h_window; - DrawRectangle(x, y, x2, y2, 0,color_border, color_bg); - - int x_msg = x + 5; - int y_msg = y + 5; - int x2_msg = x2 - 5; - int y2_msg = y2 - 5; - int attr_msg = SIE_FT_TEXT_ALIGN_CENTER + SIE_FT_TEXT_VALIGN_MIDDLE; - const int y2_sk = y2 - 5; - - if (data->type <= SIE_GUI_BOX_TYPE_QUESTION) { - unsigned int w_sk = 0; - unsigned int h_left_sk = 0; - unsigned int h_right_sk = 0; - unsigned int max_h_sk = 0; - int x_img = 0, x2_img = 0; - if (data->left_sk_ws) { - Sie_FT_GetStringSize(data->left_sk_ws, SKIN_FONT_SIZE_MSG_BOX_SOFT_KEYS, - &w_sk, &h_left_sk); - } - if (data->right_sk_ws) { - Sie_FT_GetStringSize(data->right_sk_ws, SKIN_FONT_SIZE_MSG_BOX_SOFT_KEYS, - &w_sk, &h_right_sk); - } - max_h_sk = MAX(h_left_sk, h_right_sk); - if (max_h_sk) { - y2_msg -= (int)max_h_sk + 5; - } - - if (IMG_YES) { - int y_img = 0; - if (max_h_sk) { - x_img = 4 + (w_window / 2) - IMG_YES->w / 2; - y_img = y2_sk - (int) max_h_sk / 2 - IMG_YES->h / 2; - x2_img = x_img + IMG_YES->w; - Sie_GUI_DrawIMGHDR(IMG_YES, x_img, y_img, IMG_YES->w, IMG_YES->h); - } - } - if (data->left_sk_ws) { - const int x_left_sk = x + 10; - int x2_left_sk = x + (x2 - x) / 2 - 5; - if (x_img) { - x2_left_sk -= IMG_YES->w / 2; - } - Sie_FT_DrawBoundingString(data->left_sk_ws, x_left_sk, y, x2_left_sk, y2_sk, - SKIN_FONT_SIZE_MSG_BOX_SOFT_KEYS, - SIE_FT_TEXT_ALIGN_LEFT + SIE_FT_TEXT_VALIGN_BOTTOM, NULL); - } - if (data->right_sk_ws) { - int x_right_sk = x + (x2 - x) / 2 + 5; - const int x2_right_sk = x2 - 10; - if (x2_img) { - x_right_sk += IMG_YES->w / 2; - } - Sie_FT_DrawBoundingString(data->right_sk_ws, x_right_sk, y, x2_right_sk, y2_sk, - SKIN_FONT_SIZE_MSG_BOX_SOFT_KEYS, - SIE_FT_TEXT_ALIGN_RIGHT + SIE_FT_TEXT_VALIGN_BOTTOM, NULL); - } - IMGHDR *img = NULL; - switch (data->type) { - case SIE_GUI_BOX_TYPE_OK: - img = IMG_MSG_OK; - break; - case SIE_GUI_BOX_TYPE_ERROR: - img = IMG_MSG_ERROR; - break; - case SIE_GUI_BOX_TYPE_QUESTION: - img = IMG_MSG_QUESTION; - break; - } - if (img) { - const int x_icon = x_msg + 10; - const int y_icon = y_msg + (y2_msg - y_msg) / 2 - img->h / 2; - x_msg = x_icon + img->w + 10; - attr_msg -= SIE_FT_TEXT_ALIGN_CENTER; - Sie_GUI_DrawIMGHDR(img, x_icon, y_icon, img->w, img->h); - } - } - - Sie_FT_DrawText(data->msg_ws, x_msg, y_msg, x2_msg, y2_msg, - SKIN_FONT_SIZE_MSG_BOX, attr_msg, NULL); -} - -static void OnAfterDrawIconBar() { - const char color_surface_bg[] = SIE_COLOR_BOX_SURFACE; - DrawRectangle(0, 0, SCREEN_X2, YDISP, 0, - GetPaletteAdrByColorIndex(23), color_surface_bg); -} - -static void OnCreate(SIE_GUI_BOX *data, void *(*malloc_adr)(int)) { - if (data->type <= SIE_GUI_BOX_TYPE_ERROR) { - data->tmr_close.param6 = (int)data; - GBS_StartTimerProc(&(data->tmr_close), 216 * 3, Close); - } - IMG_YES = Sie_Resources_LoadIMGHDR(SIE_RESOURCES_TYPE_ACTIONS, 24, "yes"); - switch (data->type) { - case SIE_GUI_BOX_TYPE_OK: - IMG_MSG_OK = Sie_Resources_LoadIMGHDR(SIE_RESOURCES_TYPE_ACTIONS, 48, - "dialog-ok"); - break; - case SIE_GUI_BOX_TYPE_ERROR: - IMG_MSG_ERROR = Sie_Resources_LoadIMGHDR(SIE_RESOURCES_TYPE_ACTIONS, 48, - "dialog-error"); - break; - case SIE_GUI_BOX_TYPE_QUESTION: - IMG_MSG_QUESTION = Sie_Resources_LoadIMGHDR(SIE_RESOURCES_TYPE_ACTIONS, 48, - "dialog-question"); - break; - } - data->gui.state = 1; -} - -static void OnClose(SIE_GUI_BOX *data, void (*mfree_adr)(void *)) { - data->gui.state = 0; - if (data->type <= SIE_GUI_BOX_TYPE_ERROR) { - GBS_DelTimer(&(data->tmr_close)); - } - FreeWS(data->msg_ws); - if (data->left_sk_ws) { - FreeWS(data->left_sk_ws); - } - if (data->right_sk_ws) { - FreeWS(data->right_sk_ws); - } - Sie_GUI_Surface_Destroy(data->surface); -} - -static void OnFocus(SIE_GUI_BOX *data, void *(*malloc_adr)(int), void (*mfree_adr)(void *)) { - data->gui.state = 2; - Sie_GUI_Surface_OnFocus(data->surface); -} - -static void OnUnFocus(SIE_GUI_BOX *data, void (*mfree_adr)(void *)) { - if (data->gui.state != 2) return; - data->gui.state = 1; - Sie_GUI_Surface_OnUnFocus(data->surface); -} - -static int _OnKey(SIE_GUI_BOX *data, GUI_MSG *msg) { - if (msg->gbsmsg->msg == KEY_DOWN || msg->gbsmsg->msg == LONG_PRESS) { - if (data->type <= SIE_GUI_BOX_TYPE_ERROR) { - if (msg->gbsmsg->submess == LEFT_SOFT || msg->gbsmsg->submess == ENTER_BUTTON) { - return 1; - } - } else { - if (data->callback.proc) { - switch (msg->gbsmsg->submess) { - case LEFT_SOFT: case ENTER_BUTTON: - data->callback.proc(SIE_GUI_BOX_CALLBACK_YES, data->callback.data); - return 1; - case RIGHT_SOFT: - data->callback.proc(SIE_GUI_BOX_CALLBACK_NO, data->callback.data); - return 1; - } - } - } - } - return 0; -} - -static int OnKey(SIE_GUI_BOX *data, GUI_MSG *msg) { - return Sie_GUI_Surface_OnKey(data->surface, data, msg); -} - -extern void kill_data(void *p, void (*func_p)(void *)); - -static int method8(void) { return 0; } - -static int method9(void) { return 0; } - -static const void *const gui_methods[11] = { - (void *)OnRedraw, - (void *)OnCreate, - (void *)OnClose, - (void *)OnFocus, - (void *)OnUnFocus, - (void *)OnKey, - 0, - (void *)kill_data, - (void *)method8, - (void *)method9, - 0 -}; - -SIE_GUI_BOX *Sie_GUI_Box(unsigned int type, SIE_GUI_BOX_TEXT *text, SIE_GUI_BOX_CALLBACK *callback, IMGHDR *scrot) { - SIE_GUI_BOX *gui = malloc(sizeof(SIE_GUI_BOX)); - const SIE_GUI_SURFACE_HANDLERS surface_handlers = { - OnAfterDrawIconBar, - (int(*)(void *, GUI_MSG *msg))_OnKey, - }; - zeromem(gui, sizeof(SIE_GUI_BOX)); - gui->type = type; - Sie_GUI_BoxUpdate(gui, text->msg); - if (type <= SIE_GUI_BOX_TYPE_QUESTION) { - if (text->left_sk) { - gui->left_sk_ws = AllocWS((int)strlen(text->left_sk)); - wsprintf(gui->left_sk_ws, "%t", text->left_sk); - } - if (text->right_sk) { - gui->right_sk_ws = AllocWS((int)strlen(text->right_sk)); - wsprintf(gui->right_sk_ws, "%t", text->right_sk); - } - if (callback) { - memcpy(&(gui->callback), callback, sizeof(SIE_GUI_BOX_CALLBACK)); - } - } - LockSched(); - Sie_GUI_InitCanvas(&canvas); - gui->gui.canvas = (RECT*)(&canvas); - gui->gui.methods = (void*)gui_methods; - gui->gui.item_ll.data_mfree = (void (*)(void *))mfree_adr(); - gui->surface = Sie_GUI_Surface_Init(SIE_GUI_SURFACE_TYPE_DEFAULT, &surface_handlers, - CreateGUI(gui)); - gui->surface->scrot_p = scrot; - UnlockSched(); - return gui; -} - -SIE_GUI_BOX *Sie_GUI_MsgBox(const char *msg, IMGHDR *scrot) { - SIE_GUI_BOX_TEXT text = {msg, "Ok", NULL}; - return Sie_GUI_Box(SIE_GUI_BOX_TYPE_STANDARD, &text, NULL, scrot); -} - -SIE_GUI_BOX *Sie_GUI_MsgBoxOk(const char *msg, IMGHDR *scrot) { - SIE_GUI_BOX_TEXT text = {msg,"Ok", NULL}; - return Sie_GUI_Box(SIE_GUI_BOX_TYPE_OK, &text, NULL, scrot); -} - -SIE_GUI_BOX *Sie_GUI_MsgBoxError(const char *msg, IMGHDR *scrot) { - SIE_GUI_BOX_TEXT text = {msg,"Ok", NULL}; - return Sie_GUI_Box(SIE_GUI_BOX_TYPE_ERROR, &text, NULL, scrot); -} - -SIE_GUI_BOX *Sie_GUI_MsgBoxYesNo(const char *msg, SIE_GUI_BOX_CALLBACK *callback, IMGHDR *scrot) { - SIE_GUI_BOX_TEXT text = {msg, "Yes", "No"}; - return Sie_GUI_Box(SIE_GUI_BOX_TYPE_QUESTION, &text, callback, scrot); -} - -SIE_GUI_BOX *Sie_GUI_WaitBox(const char *msg, IMGHDR *scrot) { - SIE_GUI_BOX_TEXT text = {(msg) ? msg : "Wait...", NULL, NULL}; - return Sie_GUI_Box(SIE_GUI_BOX_TYPE_WAIT, &text, NULL, scrot); -} - -void Sie_GUI_BoxUpdate(SIE_GUI_BOX *box, const char *msg) { - size_t len = strlen(msg); - if (box->msg_ws) { - FreeWS(box->msg_ws); - } - box->msg_ws = AllocWS((int)len); - wsprintf(box->msg_ws, "%t", msg); - PendedRedrawGUI(); -} - -void Sie_GUI_BoxClose(SIE_GUI_BOX *box) { - Sie_GUI_CloseGUI(box->surface->gui_id); - Sie_GUI_CloseGUI_GBS(box->surface->gui_id); -} diff --git a/src/gui/gui.c b/src/gui/gui.c index 6638457..34fa472 100644 --- a/src/gui/gui.c +++ b/src/gui/gui.c @@ -1,15 +1,9 @@ #include #include #include -#include "../include/sie/resources.h" #include "../include/sie/gui/gui.h" #define TMR_MS_FOCUS (216 / 8) -#define COLOR_HEADER_BG {0x00, 0x00, 0x00, 0x35} - -extern GBSTMR TMR_REDRAW_ICONBAR; - -extern int SKIN_FONT_SIZE_ICONBAR, SKIN_FONT_SIZE_HEADER; void Focus_GUI(GBSTMR *tmr) { SIE_GUI_FOCUS_DATA *data = (SIE_GUI_FOCUS_DATA*)tmr->param6; @@ -33,8 +27,8 @@ void Sie_GUI_FocusGUI(GBSTMR *tmr, SIE_GUI_FOCUS_DATA *data) { void Sie_GUI_InitCanvas(RECT *canvas) { canvas->x = 0; canvas->y = 0; - canvas->x2 = SCREEN_X2; - canvas->y2 = SCREEN_Y2; + canvas->x2 = (short)(ScreenW() - 1); + canvas->y2 = (short)(ScreenH() - 1); } void Sie_GUI_InitHeader(HEADER_DESC *header_desc) { @@ -93,95 +87,3 @@ void Sie_GUI_DrawBleedIMGHDR(IMGHDR *img, int x, int y, int x2, int y2, int blee SetColor(&drwobj, NULL, NULL); DrawObject(&drwobj); } - -void Sie_GUI_DrawIconBar() { - const SIE_GUI_SURFACE *surface = NULL; - char color_text_warning[] = SIE_COLOR_TEXT_WARNING; - char color_text_error[] = SIE_COLOR_TEXT_ERROR; - - if (TMR_REDRAW_ICONBAR.param6) { - surface = (SIE_GUI_SURFACE*)TMR_REDRAW_ICONBAR.param6; - } - if (IsTimerProc(&TMR_REDRAW_ICONBAR)) { - GBS_StopTimer(&TMR_REDRAW_ICONBAR); - } - - Sie_GUI_DrawIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), 0, 0, ScreenW(), YDISP); - - int x = 0, y = 0; - unsigned int w = 0, h = 0; - WSHDR *ws = AllocWS(64); - char *color = NULL; - - // battery - int cap = *RamCap(); - if (cap < 10) { - color = color_text_error; - } else if (cap < 20) { - color = color_text_warning; - } - wsprintf(ws, "%d%%", cap); - Sie_FT_GetStringSize(ws, SKIN_FONT_SIZE_ICONBAR, &w, &h); - x = SCREEN_X2 - PADDING_ICONBAR - w; - y = 0 + (YDISP - (int)h) / 2; - Sie_FT_DrawString(ws, x, y, SKIN_FONT_SIZE_ICONBAR, color); - - // clock - TTime time; - GetDateTime(NULL, &time); - wsprintf(ws, "%02d:%02d", time.hour, time.min); - Sie_FT_GetStringSize(ws, SKIN_FONT_SIZE_ICONBAR, &w, &h); - x = x - PADDING_ICONBAR - (int)w; - y = 0 + (YDISP - (int)h) / 2; - Sie_FT_DrawString(ws, x, y, SKIN_FONT_SIZE_ICONBAR, NULL); - - FreeWS(ws); - if (surface) { - if (surface->handlers.OnAfterDrawIconBar) { - surface->handlers.OnAfterDrawIconBar(); - } - } - GBS_StartTimerProc(&TMR_REDRAW_ICONBAR, 216, Sie_GUI_DrawIconBar); -} - -void Sie_GUI_DrawHeader(WSHDR *ws) { - const int header_x = 0; - const int header_y = YDISP; - const int header_x2 = SCREEN_X2; - const int header_y2 = header_y + HeaderH(); - const char color_bg[] = COLOR_HEADER_BG; - Sie_GUI_DrawBleedIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), - header_x, header_y, header_x2, header_y2, - 0, YDISP); - DrawRectangle(header_x, header_y, header_x2, header_y2 - 1, 0, color_bg, color_bg); - - char str[64]; - WSHDR *ws_left = AllocWS(64); - WSHDR *ws_right = AllocWS(64); - ws_2str(ws, str, wstrlen(ws)); - char *p = strchr(str, '\t'); - if (p) { - const int len_left = p - str; - if (len_left > 0) { - str_2ws(ws_left, str, len_left); - } - str_2ws(ws_right, p + 1, strlen(str) - (p - str - 1)); - } else { - wstrcpy(ws_left, ws); - } - const int y = YDISP; - const int y2 = YDISP + HeaderH(); - if (wstrlen(ws_left)) { - Sie_FT_DrawBoundingString(ws_left, 0 + PADDING_HEADER, y, ScreenW() / 2 - PADDING_HEADER, y2, - SKIN_FONT_SIZE_HEADER, - SIE_FT_TEXT_ALIGN_LEFT | SIE_FT_TEXT_VALIGN_MIDDLE, NULL); - } - if (wstrlen(ws_right)) { - Sie_FT_DrawBoundingString(ws_right, - ScreenW() / 2 + PADDING_HEADER, y,ScreenW() - PADDING_HEADER, y2, - SKIN_FONT_SIZE_HEADER, - SIE_FT_TEXT_ALIGN_RIGHT | SIE_FT_TEXT_VALIGN_MIDDLE, NULL); - } - FreeWS(ws_left); - FreeWS(ws_right); -} diff --git a/src/gui/menu/menu.c b/src/gui/menu/menu.c deleted file mode 100644 index 6c96cb6..0000000 --- a/src/gui/menu/menu.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include "../../include/sie/resources.h" -#include "../../include/sie/gui/gui.h" - -SIE_MENU *Sie_Menu_Init(SIE_MENU_ITEM *items, int n_items, int col, int row) { - SIE_MENU *menu = malloc(sizeof(SIE_MENU)); - menu->items = items; - menu->n_items = n_items; - menu->col = col; - menu->row = row; - menu->max_cols = MIN(n_items, SIE_MENU_MAX_COLS); - menu->max_rows = (n_items + SIE_MENU_MAX_COLS - 1) / SIE_MENU_MAX_COLS; - return menu; -} - -void Sie_Menu_Destroy(SIE_MENU *menu) { - if (menu) { - if (menu->items) { - SIE_MENU_ITEM *item; - for (int i = 0; i < menu->n_items; i++) { - item = &(menu->items[i]); - FreeWS(item->ws); - mfree(item->icon->bitmap); - mfree(item->icon); - } - } - mfree(menu); - } -} - -void Sie_Menu_Draw(SIE_MENU *menu) { - const int width = ScreenW(); - const int height = ScreenH() - YDISP - HeaderH(); - const int icon_area_width = width / SIE_MENU_MAX_COLS; - const int icon_area_height = height / SIE_MENU_MAX_ROWS; - - Sie_GUI_DrawBleedIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), - 0, YDISP + HeaderH(), ScreenW(), ScreenH(), - 0, YDISP + HeaderH()); - - int x = 0; - int y = 0; - SIE_MENU_ITEM *item = NULL; - for (int i = 0, column = 0, row = 0; i < menu->n_items; i++) { - if (row + 1 >= SIE_MENU_MAX_ROWS + 1) { - break; - } - - item = (SIE_MENU_ITEM *)&menu->items[i]; - x = 0 + column * icon_area_width; - y = YDISP + HeaderH() + row * icon_area_height; - x += (icon_area_width - item->icon->w) / 2; - y += (icon_area_height - item->icon->h) / 2; - - Sie_GUI_DrawIMGHDR(item->icon, x, y, item->icon->w, item->icon->h); - - if ((column + 1) % SIE_MENU_MAX_COLS == 0) { - row += 1; - column = 0; - continue; - } - column += 1; - } -} - -void Sie_Menu_Redraw(SIE_MENU *menu) { - const int id_idle_menu = Sie_Menu_Index(menu->col, menu->row); - Sie_GUI_DrawHeader(menu->items[id_idle_menu].ws); - Sie_Menu_Draw(menu); -} - -void Sie_Menu_OnKey(SIE_MENU *menu, GUI_MSG *msg) { - if (msg->gbsmsg->msg == KEY_DOWN || msg->gbsmsg->msg == LONG_PRESS) { - switch (msg->gbsmsg->submess) { - case UP_BUTTON: - menu->row--; - if (menu->row < 0) { - menu->row = menu->max_rows - 1; - } - Sie_Menu_Redraw(menu); - case RIGHT_BUTTON: - menu->col++; - if (menu->col >= menu->max_cols) { - menu->col = 0; - } - Sie_Menu_Redraw(menu); - break; - case DOWN_BUTTON: - menu->row++; - if (menu->row >= menu->max_rows) { - menu->row = 0; - } - Sie_Menu_Redraw(menu); - break; - case LEFT_BUTTON: - menu->col--; - if (menu->col < 0) { - menu->col = menu->max_cols - 1; - } - Sie_Menu_Redraw(menu); - break; - case ENTER_BUTTON: - menu->items[menu->row].proc(); - break; - } - } -} diff --git a/src/gui/menu/menu_list.c b/src/gui/menu/menu_list.c deleted file mode 100644 index 99ae7ea..0000000 --- a/src/gui/menu/menu_list.c +++ /dev/null @@ -1,319 +0,0 @@ -#include -#include -#include -#include -#include "../../include/sie/gui/gui.h" -#include "../../include/sie/resources.h" - -#define COLOR_SELECT_BG {0x00, 0x00, 0x00, 0x35} -#define COLOR_INDICATOR_BG {0x00, 0x00, 0x00, 0x35} -#define COLOR_INDICATOR {0xFF, 0xFF, 0x00, 0x64} -#define COLOR_EMPTY_TEXT {0xFF, 0xFF, 0xFF} - -extern int SKIN_FONT_SIZE_MENU_LIST_ITEM; - -static void DrawSSBG(int x, int y, int x2, int y2); - -SIE_MENU_LIST *Sie_Menu_List_Init(unsigned int gui_id) { - SIE_MENU_LIST *menu = malloc(sizeof(SIE_MENU_LIST)); - zeromem(menu, sizeof(SIE_MENU_LIST)); - SIE_FT_SCROLL_STRING *ss = malloc(sizeof(SIE_FT_SCROLL_STRING)); - zeromem(ss, sizeof(SIE_FT_SCROLL_STRING)); - ss->attr = SIE_FT_TEXT_ALIGN_LEFT; - ss->color = NULL; - ss->gui_id = gui_id; - ss->OnBeforeDraw = DrawSSBG; - menu->ss = ss; - return menu; -} - -void LoadIcon2(SIE_MENU_LIST_ITEM *item) { - char name[64]; - zeromem(name, 1); - switch (item->type) { - case SIE_MENU_LIST_ITEM_TYPE_CHECKBOX: - if (!item->flag) { - strcpy(name, "checkbox"); - } else { - strcpy(name, "checkbox-checked"); - } - break; - case SIE_MENU_LIST_ITEM_TYPE_RADIO: - if (!item->flag) { - strcpy(name, "radio"); - } else { - strcpy(name, "radio-selected"); - } - break; - } - if (name[0]) { - item->icon2 = Sie_Resources_LoadIMGHDR(SIE_RESOURCES_TYPE_ACTIONS, 24, name); - } -} - -void Sie_Menu_List_AddItem(SIE_MENU_LIST *menu, SIE_MENU_LIST_ITEM *item, const char *name) { - SIE_MENU_LIST_ITEM *menu_item; - menu->items = realloc(menu->items, sizeof(SIE_MENU_LIST_ITEM) * (menu->n_items + 1)); - menu_item = &(menu->items[menu->n_items]); - memcpy(menu_item, item, sizeof(SIE_MENU_LIST_ITEM)); - - // icon2 - LoadIcon2(menu_item); - // ws - size_t len = strlen(name); - menu_item->ws = AllocWS(len); - if (name[0] >= 65) { // cp1251 - wsprintf(menu_item->ws, "%t", name); - } else { // file_name - str_2ws(menu_item->ws, name, len); - } - - zeromem(item, sizeof(SIE_MENU_LIST_ITEM)); - menu->n_items++; -} - -void Sie_Menu_List_AddSeparator(SIE_MENU_LIST *menu) { - if (menu->n_items) { - menu->separators = realloc(menu->separators, sizeof(SIE_MENU_LIST_SEPARATOR) * (menu->n_separators + 1)); - SIE_MENU_LIST_SEPARATOR *separator = &(menu->separators[menu->n_separators]); - separator->row = menu->n_items - 1; - menu->n_separators++; - } -} - -void Sie_Menu_List_Destroy(SIE_MENU_LIST *menu) { - if (menu) { - if (menu->items) { - for (unsigned int i = 0; i < menu->n_items; i++) { - SIE_MENU_LIST_ITEM *item = &(menu->items[i]); - FreeWS(item->ws); - } - mfree(menu->items); - } - if (menu->n_separators) { - mfree(menu->separators); - } - SIE_FT_SCROLL_STRING *ss = menu->ss; - GBS_DelTimer(&(ss->tmr)); - mfree(ss); - mfree(menu); - } -} - -/**********************************************************************************************************************/ - -void Sie_Menu_List_DrawIndicator(SIE_MENU_LIST *menu) { - const char color[] = COLOR_INDICATOR; - const char color_bg[] = COLOR_INDICATOR_BG; - - const int bg_h_offset = 2; - const int bg_v_offset = 2; - const int bg_w = 2; - const int bg_h = ScreenH() - HeaderH() - YDISP - bg_v_offset * 2; - - const int bg_x = SCREEN_X2 - bg_h_offset - bg_w; - const int bg_y = YDISP + HeaderH() + bg_v_offset; - const int bg_x2 = SCREEN_X2 - bg_h_offset; - const int bg_y2 = bg_y + bg_h; - DrawRectangle(bg_x, bg_y, ScreenW() - bg_h_offset, bg_y2, 1, color_bg, color_bg); - - const int indicator_x = bg_x - 1; - const int indicator_x2 = bg_x2 + 1; - const float indicator_h = (float)bg_h / (float)menu->n_items; - const float indicator_y = (float)bg_y + indicator_h * (float)menu->row; - const float indicator_y2 = indicator_y + indicator_h; - DrawRectangle(indicator_x, (int)(indicator_y), indicator_x2, (int)(indicator_y2), 0, color, color); -} - -static void DrawSSBG(int x, int y, int x2, int y2) { - const char color_bg[] = COLOR_SELECT_BG; - Sie_GUI_DrawBleedIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), x, y, x2, y2, x, y); - DrawRectangle(x, y, x2, y2, 0, color_bg, color_bg); -} - -void Sie_Menu_List_DrawMenu(SIE_MENU_LIST *menu) { -#define is_select (i == (menu->row - menu->offset)) - - const char color_select_bg[] = COLOR_SELECT_BG; - const int show_indicator = (menu->n_items > SIE_MENU_LIST_MAX_ITEMS) ? 1 : 0; - - const int h_offset = 3; - const int v_offset = 3; - const int header_h = HeaderH(); - const int width = ScreenW(); - const int height = ScreenH() - YDISP - header_h - 1; - const float item_h = (float)height / SIE_MENU_LIST_MAX_ITEMS - (float)v_offset; - const int item_w = (show_indicator) ? width - 6 - 1 - h_offset : width - 1 - h_offset; - - Sie_GUI_DrawBleedIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), 0, 0 + YDISP + header_h, SCREEN_X2, SCREEN_Y2, - 0, YDISP + header_h); - - float y_start = YDISP + (float)header_h + 1; - const int count = MIN(menu->n_items, SIE_MENU_LIST_MAX_ITEMS); - for (unsigned int i = 0; i < count; i++) { - const SIE_MENU_LIST_ITEM *item = &(menu->items[menu->offset + i]); - const int x = 3; - const int x2 = item_w; - const float y = y_start + (float)v_offset / 2; - const float y2 = y + item_h - (float)v_offset / 2; - - if (menu->n_separators) { - SIE_MENU_LIST_SEPARATOR *separator = NULL; - for (unsigned int j = 0; j < menu->n_separators; j++) { - separator = &(menu->separators[j]); - if (separator->row == (menu->offset + i)) { - const char color[] = SIE_COLOR_MENU_SEPARATOR; - DrawLine(x + 2, (int)(y2 + 2), x2 - 2, (int)(y2 + 2), 1,color); - break; - } - } - } - - int text_x = x + 8; - const int text_y = (int)y; - const int text_x2 = x2 - 8; - const int text_y2 = (int)y2; - IMGHDR *img = (item->type == SIE_MENU_LIST_ITEM_TYPE_DEFAULT) ? item->icon : item->icon2; - if (is_select) { - DrawRoundedFrame(x, (int)y - 1, x2, (int)y2 + 1, - 6, 6, 0, - color_select_bg, color_select_bg); - } - if (img) { - int icon_x = 0; - int icon_y = 0; - icon_x = text_x; - text_x = icon_x + img->w + 6; - icon_y = (int)y + ((int)item_h - img->h) / 2; - Sie_GUI_DrawIMGHDR(img, icon_x, icon_y, img->w, img->h); - } - if (is_select) { - SIE_FT_SCROLL_STRING *ss = menu->ss; - ss->ws = item->ws; - ss->x = text_x; - ss->y = text_y; - ss->x2 = text_x2; - ss->y2 = text_y2; - ss->font_size = SKIN_FONT_SIZE_MENU_LIST_ITEM; - ss->attr = SIE_FT_TEXT_VALIGN_MIDDLE; - ss->color = item->color; - Sie_FT_DrawBoundingScrollString(menu->ss, &(ss->tmr)); - } else { - Sie_FT_DrawBoundingString(item->ws, text_x, text_y, text_x2, text_y2, - SKIN_FONT_SIZE_MENU_LIST_ITEM, SIE_FT_TEXT_VALIGN_MIDDLE, - item->color); - } - y_start += item_h + (float)v_offset; - } - if (show_indicator) { - Sie_Menu_List_DrawIndicator(menu); - } -} - -void Sie_Menu_List_DrawEmpty() { - Sie_GUI_DrawBleedIMGHDR(Sie_Resources_GetWallpaperIMGHDR(), 0, YDISP, SCREEN_X2, SCREEN_Y2, 0, YDISP); - - const int font_size = SKIN_FONT_SIZE_MENU_LIST_ITEM + 4; - const char color[] = COLOR_EMPTY_TEXT; - - WSHDR *ws = AllocWS(16); - wsprintf(ws, "%t", ""); - Sie_FT_DrawText(ws, 0, 0, ScreenW() - 1, ScreenH() - 1, font_size, - SIE_FT_TEXT_ALIGN_CENTER | SIE_FT_TEXT_VALIGN_MIDDLE, color); - FreeWS(ws); -} - -void Sie_Menu_List_Draw(SIE_MENU_LIST *menu) { - if (menu->n_items) { - Sie_Menu_List_DrawMenu(menu); - } else { - Sie_Menu_List_DrawEmpty(); - } -} - -void Sie_Menu_List_OnKey(SIE_MENU_LIST *menu, GUI_MSG *msg) { - if (msg->gbsmsg->msg == KEY_DOWN || msg->gbsmsg->msg == LONG_PRESS) { - if (menu->n_items) { - SIE_MENU_LIST_ITEM *menu_item = &(menu->items[menu->row]); - void (*proc)(void *menu_item, unsigned int row) = menu_item->proc; - - switch (msg->gbsmsg->submess) { - case SIE_MENU_LIST_KEY_PREV: - GBS_DelTimer(&(menu->ss->tmr)); - if (menu->row != 0) { - menu->row--; - } else { - menu->row = menu->n_items - 1; - } - Sie_Menu_List_Refresh(menu); - Sie_Menu_List_Draw(menu); - break; - case SIE_MENU_LIST_KEY_NEXT: - GBS_DelTimer(&(menu->ss->tmr)); - menu->row++; - if (menu->row >= menu->n_items) { - menu->row = 0; - } - Sie_Menu_List_Refresh(menu); - Sie_Menu_List_Draw(menu); - break; - case SIE_MENU_LIST_KEY_ENTER: - if (proc) { - proc(menu_item, menu->row); - } - break; - } - } - } -} - -void Sie_Menu_List_Refresh(SIE_MENU_LIST *menu) { - if (menu->n_items > SIE_MENU_LIST_MAX_ITEMS) { - if (menu->row >= (unsigned int)(SIE_MENU_LIST_MAX_ITEMS / 2)) { - if (menu->row < menu->n_items - (unsigned int)(SIE_MENU_LIST_MAX_ITEMS / 2)) { - menu->offset = menu->row - (unsigned int)(SIE_MENU_LIST_MAX_ITEMS) / 2; - } else { - menu->offset = menu->n_items - SIE_MENU_LIST_MAX_ITEMS; - } - } else { - menu->offset = 0; - } - } -} - -unsigned int Sie_Menu_List_SetRow(SIE_MENU_LIST *menu, unsigned int row) { - if (row < menu->n_items) { - menu->row = row; - } else { - menu->row = menu->n_items - 1; - } - return menu->row; -} - -void Sie_Menu_List_SetItemType(SIE_MENU_LIST_ITEM *item, unsigned int type, unsigned int flag) { - switch (type) { - case SIE_MENU_LIST_ITEM_TYPE_CHECKBOX: - item->type = type; - item->flag = flag; - LoadIcon2(item); - break; - default: - break; - } -} - -SIE_MENU_LIST_ITEM *Sie_Menu_List_GetItem(SIE_MENU_LIST *menu, unsigned int row) { - return (row < menu->n_items) ? &(menu->items[row]) : NULL; -} - -unsigned int Sie_Menu_List_GetRowByName_ws(SIE_MENU_LIST *menu, WSHDR *ws, unsigned int *err) { - unsigned int i = 0; - while (i < menu->n_items) { - if (wstrcmp(menu->items[i].ws, ws) == 0) { - return i; - } - i++; - } - *err = 1; - return 0; -} diff --git a/src/gui/surface.c b/src/gui/surface.c deleted file mode 100644 index 7f43d2a..0000000 --- a/src/gui/surface.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include "../include/sie/gui/gui.h" - -GBSTMR TMR_REDRAW_ICONBAR; - -SIE_GUI_SURFACE *Sie_GUI_Surface_Init(int type, const SIE_GUI_SURFACE_HANDLERS *handlers, unsigned int gui_id) { - SIE_GUI_SURFACE *surface = malloc(sizeof(SIE_GUI_SURFACE)); - zeromem(surface, sizeof(SIE_GUI_SURFACE)); - surface->type = type; - if (handlers) { - memcpy(&(surface->handlers), handlers, sizeof(SIE_GUI_SURFACE_HANDLERS)); - } - surface->gui_id = gui_id; - surface->hdr_ws = AllocWS(256); - return surface; -}; - -void Sie_GUI_Surface_Destroy(SIE_GUI_SURFACE *surface) { - FreeWS(surface->hdr_ws); - Sie_GUI_Surface_DestroyScrot(surface); - mfree(surface); -} - -void Sie_GUI_Surface_SetHeader(SIE_GUI_SURFACE *surface, const char *header) { - wsprintf(surface->hdr_ws, "%t", header); -} - -void Sie_GUI_Surface_TakeScrot(SIE_GUI_SURFACE *surface) { - Sie_GUI_Surface_DestroyScrot(surface); - surface->scrot = Sie_GUI_TakeScrot(); -} - -void Sie_GUI_Surface_DestroyScrot(SIE_GUI_SURFACE *surface) { - LockSched(); - if (surface->scrot) { - mfree(surface->scrot->bitmap); - mfree(surface->scrot); - surface->scrot = NULL; - } - UnlockSched(); -} - -void Sie_GUI_Surface_Draw(const SIE_GUI_SURFACE *surface) { - Sie_GUI_DrawIconBar(); - if (wstrlen(surface->hdr_ws)) { - Sie_GUI_DrawHeader(surface->hdr_ws); - } -} - -void Sie_GUI_Surface_OnFocus(SIE_GUI_SURFACE *surface) { - extern IMGHDR *IMG_WALLPAPER; -#ifdef ELKA - DisableIconBar(1); -#endif - IMG_WALLPAPER = GetIMGHDRFromCanvasCache(0); - TMR_REDRAW_ICONBAR.param6 = (int)surface; - GBS_StartTimerProc(&TMR_REDRAW_ICONBAR, 216, Sie_GUI_DrawIconBar); -} - -void Sie_GUI_Surface_OnUnFocus(SIE_GUI_SURFACE *surface) { -#ifdef ELKA - DisableIconBar(0); -#endif - TMR_REDRAW_ICONBAR.param6 = 0; - GBS_StopTimer(&TMR_REDRAW_ICONBAR); -} - -int Sie_GUI_Surface_OnKey(SIE_GUI_SURFACE *surface, void *data, GUI_MSG *msg) { - if (msg->gbsmsg->msg == KEY_DOWN && msg->gbsmsg->submess == 0xDEAD + surface->gui_id) { - return 1; - } - else if (surface->handlers.OnKey) { - return surface->handlers.OnKey(data, msg); - } - return 0; -} diff --git a/src/include/sie/freetype/cache.h b/src/include/sie/freetype/cache.h index 42bd37f..f1996d4 100644 --- a/src/include/sie/freetype/cache.h +++ b/src/include/sie/freetype/cache.h @@ -1,5 +1,4 @@ -#ifndef __CACHE_H__ -#define __CACHE_H__ +#pragma once #include #include @@ -24,5 +23,3 @@ typedef struct { SIE_FT_CACHE *FT_GetOrCreateCache(const FT_Face *face, int font_size); SIE_FT_GLYPH_CACHE *FT_GlyphGetOrAddCache(FT_Face *face, SIE_FT_CACHE *cache, FT_ULong charcode); - -#endif \ No newline at end of file diff --git a/src/include/sie/freetype/freetype.h b/src/include/sie/freetype/freetype.h index f133dec..0f2120b 100644 --- a/src/include/sie/freetype/freetype.h +++ b/src/include/sie/freetype/freetype.h @@ -1,8 +1,8 @@ -#ifndef __SIE_FREETYPE_H__ -#define __SIE_FREETYPE_H__ +#pragma once #include #include +#include "cache.h" #include "draw_text.h" #include "draw_string.h" @@ -38,5 +38,3 @@ void Sie_FT_GetStringSize(WSHDR *ws, int font_size, unsigned int *w, unsigned in void Sie_FT_DrawBoundingString(WSHDR *ws, int x, int y, int x2, int y2, int font_size, int attr, const char *color); void Sie_FT_DrawBoundingScrollString(SIE_FT_SCROLL_STRING *ss, GBSTMR *tmr); - -#endif diff --git a/src/include/sie/gui/box.h b/src/include/sie/gui/box.h deleted file mode 100644 index eabd589..0000000 --- a/src/include/sie/gui/box.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __SIE_GUI_BOX_H__ -#define __SIE_GUI_BOX_H__ - -#include "surface.h" - -#define SIE_GUI_BOX_TYPE_STANDARD 0x00 -#define SIE_GUI_BOX_TYPE_OK 0x01 -#define SIE_GUI_BOX_TYPE_ERROR 0x02 -#define SIE_GUI_BOX_TYPE_QUESTION 0x05 -#define SIE_GUI_BOX_TYPE_WAIT 0x0A - -#define SIE_GUI_BOX_CALLBACK_NO 0x00 -#define SIE_GUI_BOX_CALLBACK_YES 0x01 - -typedef struct { - const char *msg; - const char *left_sk; - const char *right_sk; -} SIE_GUI_BOX_TEXT; - -typedef struct { - void (*proc)(int, void*); - void *data; -} SIE_GUI_BOX_CALLBACK; - -typedef struct { - GUI gui; - SIE_GUI_SURFACE *surface; - unsigned int type; - GBSTMR tmr_close; - - WSHDR *msg_ws; - WSHDR *left_sk_ws; - WSHDR *right_sk_ws; - SIE_GUI_BOX_CALLBACK callback; -} SIE_GUI_BOX; - -SIE_GUI_BOX *Sie_GUI_Box(unsigned int type, SIE_GUI_BOX_TEXT *text, SIE_GUI_BOX_CALLBACK *callback, IMGHDR *scrot); -SIE_GUI_BOX *Sie_GUI_MsgBox(const char *msg, IMGHDR *scrot); -SIE_GUI_BOX *Sie_GUI_MsgBoxOk(const char *msg, IMGHDR *scrot); -SIE_GUI_BOX *Sie_GUI_MsgBoxError(const char *msg, IMGHDR *scrot); -SIE_GUI_BOX *Sie_GUI_MsgBoxYesNo(const char *msg, SIE_GUI_BOX_CALLBACK *callback, IMGHDR *scrot); -SIE_GUI_BOX *Sie_GUI_WaitBox(const char *msg, IMGHDR *scrot); -void Sie_GUI_BoxUpdate(SIE_GUI_BOX *box, const char *msg); -void Sie_GUI_BoxClose(SIE_GUI_BOX *box); - -#endif diff --git a/src/include/sie/gui/gui.h b/src/include/sie/gui/gui.h index 614f515..ea7a2fb 100644 --- a/src/include/sie/gui/gui.h +++ b/src/include/sie/gui/gui.h @@ -1,14 +1,9 @@ -#ifndef __SIE_GUI_H__ -#define __SIE_GUI_H__ +#pragma once #include #include -#include "box.h" #include "stack.h" #include "colors.h" -#include "surface.h" -#include "menu/menu.h" -#include "menu/menu_list.h" typedef struct { unsigned int gui_id; @@ -16,25 +11,6 @@ typedef struct { void *data; } SIE_GUI_FOCUS_DATA; -SIE_GUI_SURFACE *Sie_GUI_Surface_Init(int type, const SIE_GUI_SURFACE_HANDLERS *handlers, unsigned int gui_id); -void Sie_GUI_Surface_Destroy(SIE_GUI_SURFACE *surface); - -void Sie_GUI_Surface_SetHeader(SIE_GUI_SURFACE *surface, const char *header); -void Sie_GUI_Surface_TakeScrot(SIE_GUI_SURFACE *surface); -void Sie_GUI_Surface_DestroyScrot(SIE_GUI_SURFACE *surface); - -void Sie_GUI_Surface_Draw(const SIE_GUI_SURFACE *surface); -void Sie_GUI_Surface_OnFocus(SIE_GUI_SURFACE *surface); -void Sie_GUI_Surface_OnUnFocus(SIE_GUI_SURFACE *surface); -int Sie_GUI_Surface_OnKey(SIE_GUI_SURFACE *surface, void *data, GUI_MSG *msg); - -#define SCREEN_X2 (ScreenW() - 1) -#define SCREEN_Y2 (ScreenH() - 1) - -#define PADDING_ICONBAR 5 -#define PADDING_HEADER 5 - -#define Sie_GUI_CloseGUI_GBS(id) GBS_SendMessage(MMI_CEPID, KEY_DOWN, 0xDEAD + id); #define Sie_GUI_CloseGUI(id) GeneralFunc_flag1((int)id, 1); void Sie_GUI_FocusGUI(GBSTMR *tmr, SIE_GUI_FOCUS_DATA *data); @@ -46,7 +22,3 @@ IMGHDR *Sie_GUI_TakeScrot(); void Sie_GUI_DrawIMGHDR(IMGHDR *img, int x, int y, int w, int h); void Sie_GUI_DrawBleedIMGHDR(IMGHDR *img, int x, int y, int x2, int y2, int bleed_x, int bleed_y); -void Sie_GUI_DrawIconBar(); -void Sie_GUI_DrawHeader(WSHDR *ws); - -#endif diff --git a/src/include/sie/gui/menu/menu.h b/src/include/sie/gui/menu/menu.h deleted file mode 100644 index a571a4d..0000000 --- a/src/include/sie/gui/menu/menu.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __SIE_MENU_H__ -#define __SIE_MENU_H__ - -#include -#include - -#define SIE_MENU_MAX_COLS 3 -#define SIE_MENU_MAX_ROWS 4 - -typedef struct { - WSHDR *ws; - IMGHDR *icon; - void (*proc)(); -} SIE_MENU_ITEM; - -typedef struct { - SIE_MENU_ITEM *items; - unsigned int n_items; - int col, row; - int max_cols, max_rows; -} SIE_MENU; - -#define Sie_Menu_Index(col, row) (row * SIE_MENU_MAX_COLS + col) - -SIE_MENU *Sie_Menu_Init(SIE_MENU_ITEM *items, int n_items, int col, int row); -void Sie_Menu_Destroy(SIE_MENU *menu); - -void Sie_Menu_Draw(SIE_MENU *menu); -void Sie_Menu_Redraw(SIE_MENU *menu); -void Sie_Menu_OnKey(SIE_MENU *menu, GUI_MSG *msg); - -#endif diff --git a/src/include/sie/gui/menu/menu_list.h b/src/include/sie/gui/menu/menu_list.h deleted file mode 100644 index 637954c..0000000 --- a/src/include/sie/gui/menu/menu_list.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __SIE_MENU_LIST_H__ -#define __SIE_MENU_LIST_H__ - -#include -#include "../../freetype/freetype.h" - -#define SIE_MENU_LIST_MAX_ITEMS 7 -#define SIE_MENU_LIST_KEY_PREV UP_BUTTON -#define SIE_MENU_LIST_KEY_NEXT DOWN_BUTTON -#define SIE_MENU_LIST_KEY_ENTER ENTER_BUTTON - -#define SIE_MENU_LIST_ITEM_TYPE_DEFAULT 0x00 -#define SIE_MENU_LIST_ITEM_TYPE_CHECKBOX 0x01 -#define SIE_MENU_LIST_ITEM_TYPE_RADIO 0x02 - -typedef struct { - unsigned int type; - unsigned int flag; - IMGHDR *icon; // just icon - IMGHDR *icon2; // checkbox or radio - WSHDR *ws; - char *color; - void (*proc)(void *menu_item, unsigned int row); -} SIE_MENU_LIST_ITEM; - -typedef struct { - unsigned int row; -} SIE_MENU_LIST_SEPARATOR; - -typedef struct { - SIE_MENU_LIST_ITEM *items; - SIE_MENU_LIST_SEPARATOR *separators; - unsigned int n_items; - unsigned int n_separators; - unsigned int row; - unsigned int offset; - SIE_FT_SCROLL_STRING *ss; -} SIE_MENU_LIST; - -SIE_MENU_LIST *Sie_Menu_List_Init(unsigned int gui_id); -void Sie_Menu_List_AddItem(SIE_MENU_LIST *menu, SIE_MENU_LIST_ITEM *item, const char *name); -void Sie_Menu_List_AddSeparator(SIE_MENU_LIST *menu); -void Sie_Menu_List_Destroy(SIE_MENU_LIST *menu); - -void Sie_Menu_List_DrawMenu(SIE_MENU_LIST *menu); -void Sie_Menu_List_DrawEmpty(); -void Sie_Menu_List_Draw(SIE_MENU_LIST *menu); -void Sie_Menu_List_OnKey(SIE_MENU_LIST *menu, GUI_MSG *msg); -void Sie_Menu_List_Refresh(SIE_MENU_LIST *menu); - - -unsigned int Sie_Menu_List_SetRow(SIE_MENU_LIST *menu, unsigned int row); - -void Sie_Menu_List_SetItemType(SIE_MENU_LIST_ITEM *item, unsigned int type, unsigned int flag); -SIE_MENU_LIST_ITEM *Sie_Menu_List_GetItem(SIE_MENU_LIST *menu, unsigned int row); -#define Sie_Menu_List_GetCurrentItem(menu) Sie_Menu_List_GetItem(menu, menu->row); -unsigned int Sie_Menu_List_GetRowByName_ws(SIE_MENU_LIST *menu, WSHDR *ws, unsigned int *err); - -#endif diff --git a/src/include/sie/gui/stack.h b/src/include/sie/gui/stack.h index 2d9ad23..8ea00d4 100644 --- a/src/include/sie/gui/stack.h +++ b/src/include/sie/gui/stack.h @@ -1,5 +1,4 @@ -#ifndef __SIE_GUI_STACK_H__ -#define __SIE_GUI_STACK_H__ +#pragma once #include @@ -9,12 +8,9 @@ typedef struct { int gui_id; } SIE_GUI_STACK; - SIE_GUI_STACK *Sie_GUI_Stack_Add(SIE_GUI_STACK *top, int gui_id); void Sie_GUI_Stack_Destroy(SIE_GUI_STACK *stack); SIE_GUI_STACK *Sie_GUI_Stack_FindByGuiID(const SIE_GUI_STACK *top, int gui_id); SIE_GUI_STACK *Sie_GUI_Stack_Delete(SIE_GUI_STACK *top, int gui_id); SIE_GUI_STACK *Sie_GUI_Stack_CloseChildren(SIE_GUI_STACK *top, int gui_id); - -#endif diff --git a/src/include/sie/gui/surface.h b/src/include/sie/gui/surface.h deleted file mode 100644 index b573031..0000000 --- a/src/include/sie/gui/surface.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __SIE_GUI_SURFACE_H__ -#define __SIE_GUI_SURFACE_H__ - -#include - -#define SIE_GUI_SURFACE_TYPE_DEFAULT 0x00 - -typedef struct { - void (*OnAfterDrawIconBar)(); - int (*OnKey)(void *data, GUI_MSG *msg); -} SIE_GUI_SURFACE_HANDLERS; - -typedef struct { - int type; - SIE_GUI_SURFACE_HANDLERS handlers; - unsigned int gui_id; - WSHDR *hdr_ws; - - IMGHDR *scrot; // use for making screenshot - IMGHDR *scrot_p; // use if screenshot is already taken -} SIE_GUI_SURFACE; - -#endif