diff --git a/include/dawn/ui/grid.h b/include/dawn/ui/grid.h index 3645493c..09375356 100644 --- a/include/dawn/ui/grid.h +++ b/include/dawn/ui/grid.h @@ -27,14 +27,6 @@ typedef struct { float gutterY; } gridbreakpoint_t; -/** Callback to receive when a grid child is to be resized */ -typedef void gridchildresizecallback_t( - void *user, uint8_t i, - float screenWidth, float screenHeight, - float x, float y, - float width, float height -); - /** Definition of a grid child's breakpoint */ typedef struct { uint8_t columns; @@ -43,6 +35,14 @@ typedef struct { uint8_t y; } gridchildbreakpoint_t; +/** Callback to receive when a grid child is to be resized */ +typedef void gridchildresizecallback_t( + void *user, uint8_t i, gridchildbreakpoint_t *breakpoint, + float screenWidth, float screenHeight, + float x, float y, + float width, float height +); + /** Definition of a grid child */ typedef struct { gridchildbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT]; diff --git a/include/dawn/ui/textmenu.h b/include/dawn/ui/textmenu.h index 2123abc8..a83f2c24 100644 --- a/include/dawn/ui/textmenu.h +++ b/include/dawn/ui/textmenu.h @@ -5,6 +5,7 @@ #pragma once #include "../libs.h" +#include "../display/font.h" #include "menuv2.h" #include "grid.h" #include "label.h" diff --git a/src/display/font.c b/src/display/font.c index b0781a22..de94c625 100644 --- a/src/display/font.c +++ b/src/display/font.c @@ -190,8 +190,6 @@ void fontTextClamp(font_t *font, fonttextinfo_t *info, char *text, info->width = mathMax(info->width, quad->x1); info->height = mathMax(info->height, quad->y1); } - - printf("Break"); } int32_t fontGetLineCharCount(fonttextinfo_t *info,int32_t start,int32_t count) { diff --git a/src/ui/framedtextmenu.c b/src/ui/framedtextmenu.c index e340a7a2..e1a7149d 100644 --- a/src/ui/framedtextmenu.c +++ b/src/ui/framedtextmenu.c @@ -11,7 +11,6 @@ void framedTextMenuInit(framedtextmenu_t *menu, font_t *font, texture_t *text) { frameInit(&menu->frame); textMenuInit(&menu->menu, font); menu->frame.texture = text; - menu->width = -1; menu->height = -1; } diff --git a/src/ui/grid.c b/src/ui/grid.c index 5c787947..b66134be 100644 --- a/src/ui/grid.c +++ b/src/ui/grid.c @@ -122,7 +122,7 @@ void gridSetSize(grid_t *grid, // Fire the resize event. grid->onResize( - grid->user, i, + grid->user, i, childbp, screenWidth, screenHeight, x + gx, y + gy, gw, gh diff --git a/src/ui/menuv2.c b/src/ui/menuv2.c index 4e5bf227..bf2cd603 100644 --- a/src/ui/menuv2.c +++ b/src/ui/menuv2.c @@ -19,12 +19,13 @@ void menu2Init(menuv2_t *menu) { } void menu2Update(menuv2_t *menu, engine_t *engine) { - uint8_t x, y, i, j; + uint8_t x, y, i, j, cx, cy; gridchild_t *current; gridchildbreakpoint_t *currentbp; gridchild_t *item; gridchildbreakpoint_t *itembp; + current = menu->grid.children + menu->selected; currentbp = gridChildGetBreakpoint(current, menu->grid.breakpointCurrent); @@ -56,15 +57,19 @@ void menu2Update(menuv2_t *menu, engine_t *engine) { // Update cursor positions if(x != 0 || y != 0) { if(x > 0) { - menu->cursorX = (currentbp->x + currentbp->columns - 1) + x; + cx = (currentbp->x + currentbp->columns - 1) + x; } else if(x < 0) { - menu->cursorX = currentbp->x + x; + cx = currentbp->x + x; + } else { + cx = menu->cursorX; } if(y > 0) { - menu->cursorY = (currentbp->y + currentbp->rows - 1) + y; + cy = (currentbp->y + currentbp->rows - 1) + y; } else if(y < 0) { - menu->cursorY = currentbp->y + y; + cy = currentbp->y + y; + } else { + cy = menu->cursorY; } // Get the item selected @@ -75,8 +80,8 @@ void menu2Update(menuv2_t *menu, engine_t *engine) { itembp = gridChildGetBreakpoint(item, menu->grid.breakpointCurrent); if( - itembp->x > menu->cursorX||(itembp->x+itembp->columns-1)cursorX|| - itembp->y > menu->cursorY||(itembp->y+itembp->rows-1) < menu->cursorY + itembp->x > cx || (itembp->x + itembp->columns - 1) < cx || + itembp->y > cy || (itembp->y + itembp->rows - 1) < cy ) continue; j = i; @@ -85,6 +90,8 @@ void menu2Update(menuv2_t *menu, engine_t *engine) { // Was a target found? if(j == GRID_CHILD_COUNT) return; + menu->cursorX = cx; + menu->cursorY = cy; menu->selected = j; } } \ No newline at end of file diff --git a/src/ui/textmenu.c b/src/ui/textmenu.c index 0414a8a5..c289409c 100644 --- a/src/ui/textmenu.c +++ b/src/ui/textmenu.c @@ -16,7 +16,7 @@ void _textMenuOnSelect(menuv2_t *menu, uint8_t i) { } void _textMenuOnResize( - void *user, uint8_t i, + void *user, uint8_t i, gridchildbreakpoint_t *breakpoint, float screenWidth, float screenHeight, float x, float y, float width, float height