Working on fixing grid movement.
This commit is contained in:
		@@ -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];
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "../libs.h"
 | 
			
		||||
#include "../display/font.h"
 | 
			
		||||
#include "menuv2.h"
 | 
			
		||||
#include "grid.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->height = mathMax(info->height, quad->y1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  printf("Break");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
  textMenuInit(&menu->menu, font);
 | 
			
		||||
  menu->frame.texture = text;
 | 
			
		||||
 | 
			
		||||
  menu->width = -1;
 | 
			
		||||
  menu->height = -1;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)<menu->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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user