9 # error This is a userspace-only header, not allowed by the current build.
12 #ifdef MENU_LOGS_ENABLED
13 # define MENU_LOG(...) LOG(__VA_ARGS__)
15 # define MENU_LOG(...)
18 #include <sifteo/cube.h>
19 #include <sifteo/asset.h>
20 #include <sifteo/video.h>
41 const PinnedAssetImage *background;
42 const AssetImage *footer;
43 const AssetImage *header;
44 const AssetImage *tips[8];
45 const AssetImage *overflowIcon;
49 const AssetImage *icon;
50 const AssetImage *label;
54 bool operator==(
const struct MenuNeighbor& rhs)
const
56 return (masterSide == rhs.masterSide)
57 && (neighbor == rhs.neighbor)
58 && (neighborSide == rhs.neighborSide);
61 bool operator!=(
const struct MenuNeighbor& rhs)
const
63 return !operator==(rhs);
74 struct MenuNeighbor neighbor;
105 Menu(VideoBuffer&,
const MenuAssets*, MenuItem*);
108 void init(VideoBuffer&,
const MenuAssets*, MenuItem*);
110 bool pollEvent(
struct MenuEvent *);
111 void performDefault();
113 void replaceIcon(uint8_t item,
const AssetImage *icon,
const AssetImage *label = 0);
114 bool itemVisible(uint8_t item);
115 void setIconYOffset(uint8_t px);
116 void setPeekTiles(uint8_t numTiles);
117 void anchor(uint8_t item,
bool hopUp =
false);
120 VideoBuffer *videoBuffer()
const;
124 static const float kTimeDilator = 13.1f;
125 static const float kMaxSpeedMultiplier = 2.f;
126 static const float kAccelScalingFactor = -0.25f;
127 static const uint8_t kNumTilesX = 18;
128 static const uint8_t kNumVisibleTilesX = 16;
129 static const uint8_t kNumTilesY = 18;
130 static const uint8_t kNumVisibleTilesY = 16;
131 static const float kAccelThresholdOn = 4.15f;
132 static const float kAccelThresholdOff = 0.85f;
133 static const float kAccelThresholdStep = 9.5f;
134 static const uint8_t kDefaultIconYOffset = 16;
135 static const uint8_t kDefaultPeekTiles = 1;
138 uint8_t kHeaderHeight;
139 uint8_t kFooterHeight;
141 uint8_t kIconTileWidth;
142 uint8_t kIconTileHeight;
143 int8_t kEndCapPadding;
147 unsigned kIconPixelWidth()
const {
return kIconTileWidth * TILE; }
148 unsigned kIconPixelHeight()
const {
return kIconTileHeight * TILE; }
149 unsigned kItemTileWidth()
const {
return ((kEndCapPadding + TILE - 1) / TILE) + kIconTileWidth - kPeekTiles; }
150 unsigned kItemPixelWidth()
const {
return kItemTileWidth() * TILE; }
151 float kOneG()
const {
return abs(64 * kAccelScalingFactor); }
155 const struct MenuAssets *assets;
157 struct MenuItem *items;
159 uint8_t startingItem;
161 struct MenuEvent currentEvent;
168 SystemTime prevTipTime;
172 int stopping_position;
190 void transFromStart();
191 void transToStatic();
193 void transFromStatic();
194 void transToTilting();
196 void transFromTilting();
197 void transToInertia();
199 void transFromInertia();
200 void transToFinish();
202 void transFromFinish();
205 void transFromHopUp();
208 bool dispatchEvent(
struct MenuEvent *ev);
210 void handleNeighborAdd();
211 void handleNeighborRemove();
212 void handleItemArrive();
213 void handleItemDepart();
214 void handleItemPress();
216 void handlePrepaint();
219 void detectNeighbors();
220 uint8_t computeSelected();
221 void checkForPress();
222 void drawColumn(
int);
223 void drawFooter(
bool force =
false);
224 int stoppingPositionFor(
int);
225 float velocityMultiplier();
227 static float lerp(
float min,
float max,
float u);
229 bool itemVisibleAtCol(uint8_t item,
int column);
230 uint8_t itemAtCol(
int column);
231 int computeCurrentTile();