Working on fixing grid movement.
This commit is contained in:
@ -27,14 +27,6 @@ typedef struct {
|
|||||||
float gutterY;
|
float gutterY;
|
||||||
} gridbreakpoint_t;
|
} 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 */
|
/** Definition of a grid child's breakpoint */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t columns;
|
uint8_t columns;
|
||||||
@ -43,6 +35,14 @@ typedef struct {
|
|||||||
uint8_t y;
|
uint8_t y;
|
||||||
} gridchildbreakpoint_t;
|
} 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 */
|
/** Definition of a grid child */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gridchildbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT];
|
gridchildbreakpoint_t breakpoints[GRID_BREAKPOINT_COUNT];
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
|
#include "../display/font.h"
|
||||||
#include "menuv2.h"
|
#include "menuv2.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
|
@ -190,8 +190,6 @@ void fontTextClamp(font_t *font, fonttextinfo_t *info, char *text,
|
|||||||
info->width = mathMax(info->width, quad->x1);
|
info->width = mathMax(info->width, quad->x1);
|
||||||
info->height = mathMax(info->height, quad->y1);
|
info->height = mathMax(info->height, quad->y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Break");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t fontGetLineCharCount(fonttextinfo_t *info,int32_t start,int32_t count) {
|
int32_t fontGetLineCharCount(fonttextinfo_t *info,int32_t start,int32_t count) {
|
||||||
|
@ -11,7 +11,6 @@ void framedTextMenuInit(framedtextmenu_t *menu, font_t *font, texture_t *text) {
|
|||||||
frameInit(&menu->frame);
|
frameInit(&menu->frame);
|
||||||
textMenuInit(&menu->menu, font);
|
textMenuInit(&menu->menu, font);
|
||||||
menu->frame.texture = text;
|
menu->frame.texture = text;
|
||||||
|
|
||||||
menu->width = -1;
|
menu->width = -1;
|
||||||
menu->height = -1;
|
menu->height = -1;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void gridSetSize(grid_t *grid,
|
|||||||
|
|
||||||
// Fire the resize event.
|
// Fire the resize event.
|
||||||
grid->onResize(
|
grid->onResize(
|
||||||
grid->user, i,
|
grid->user, i, childbp,
|
||||||
screenWidth, screenHeight,
|
screenWidth, screenHeight,
|
||||||
x + gx, y + gy,
|
x + gx, y + gy,
|
||||||
gw, gh
|
gw, gh
|
||||||
|
@ -19,12 +19,13 @@ void menu2Init(menuv2_t *menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void menu2Update(menuv2_t *menu, engine_t *engine) {
|
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;
|
gridchild_t *current;
|
||||||
gridchildbreakpoint_t *currentbp;
|
gridchildbreakpoint_t *currentbp;
|
||||||
gridchild_t *item;
|
gridchild_t *item;
|
||||||
gridchildbreakpoint_t *itembp;
|
gridchildbreakpoint_t *itembp;
|
||||||
|
|
||||||
|
|
||||||
current = menu->grid.children + menu->selected;
|
current = menu->grid.children + menu->selected;
|
||||||
currentbp = gridChildGetBreakpoint(current, menu->grid.breakpointCurrent);
|
currentbp = gridChildGetBreakpoint(current, menu->grid.breakpointCurrent);
|
||||||
|
|
||||||
@ -56,15 +57,19 @@ void menu2Update(menuv2_t *menu, engine_t *engine) {
|
|||||||
// Update cursor positions
|
// Update cursor positions
|
||||||
if(x != 0 || y != 0) {
|
if(x != 0 || y != 0) {
|
||||||
if(x > 0) {
|
if(x > 0) {
|
||||||
menu->cursorX = (currentbp->x + currentbp->columns - 1) + x;
|
cx = (currentbp->x + currentbp->columns - 1) + x;
|
||||||
} else if(x < 0) {
|
} else if(x < 0) {
|
||||||
menu->cursorX = currentbp->x + x;
|
cx = currentbp->x + x;
|
||||||
|
} else {
|
||||||
|
cx = menu->cursorX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y > 0) {
|
if(y > 0) {
|
||||||
menu->cursorY = (currentbp->y + currentbp->rows - 1) + y;
|
cy = (currentbp->y + currentbp->rows - 1) + y;
|
||||||
} else if(y < 0) {
|
} else if(y < 0) {
|
||||||
menu->cursorY = currentbp->y + y;
|
cy = currentbp->y + y;
|
||||||
|
} else {
|
||||||
|
cy = menu->cursorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the item selected
|
// Get the item selected
|
||||||
@ -75,8 +80,8 @@ void menu2Update(menuv2_t *menu, engine_t *engine) {
|
|||||||
itembp = gridChildGetBreakpoint(item, menu->grid.breakpointCurrent);
|
itembp = gridChildGetBreakpoint(item, menu->grid.breakpointCurrent);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
itembp->x > menu->cursorX||(itembp->x+itembp->columns-1)<menu->cursorX||
|
itembp->x > cx || (itembp->x + itembp->columns - 1) < cx ||
|
||||||
itembp->y > menu->cursorY||(itembp->y+itembp->rows-1) < menu->cursorY
|
itembp->y > cy || (itembp->y + itembp->rows - 1) < cy
|
||||||
) continue;
|
) continue;
|
||||||
|
|
||||||
j = i;
|
j = i;
|
||||||
@ -85,6 +90,8 @@ void menu2Update(menuv2_t *menu, engine_t *engine) {
|
|||||||
|
|
||||||
// Was a target found?
|
// Was a target found?
|
||||||
if(j == GRID_CHILD_COUNT) return;
|
if(j == GRID_CHILD_COUNT) return;
|
||||||
|
menu->cursorX = cx;
|
||||||
|
menu->cursorY = cy;
|
||||||
menu->selected = j;
|
menu->selected = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ void _textMenuOnSelect(menuv2_t *menu, uint8_t i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _textMenuOnResize(
|
void _textMenuOnResize(
|
||||||
void *user, uint8_t i,
|
void *user, uint8_t i, gridchildbreakpoint_t *breakpoint,
|
||||||
float screenWidth, float screenHeight,
|
float screenWidth, float screenHeight,
|
||||||
float x, float y,
|
float x, float y,
|
||||||
float width, float height
|
float width, float height
|
||||||
|
Reference in New Issue
Block a user