28 # error This is a userspace-only header, not allowed by the current build.
31 #ifdef MENU_LOGS_ENABLED
32 # define MENU_LOG(...) LOG(__VA_ARGS__)
34 # define MENU_LOG(...)
37 #include <sifteo/cube.h>
38 #include <sifteo/asset.h>
39 #include <sifteo/video.h>
60 const PinnedAssetImage *background;
61 const AssetImage *footer;
62 const AssetImage *header;
63 const AssetImage *tips[8];
64 const AssetImage *overflowIcon;
68 const AssetImage *icon;
69 const AssetImage *label;
73 bool operator==(
const struct MenuNeighbor& rhs)
const
75 return (masterSide == rhs.masterSide)
76 && (neighbor == rhs.neighbor)
77 && (neighborSide == rhs.neighborSide);
80 bool operator!=(
const struct MenuNeighbor& rhs)
const
82 return !operator==(rhs);
93 struct MenuNeighbor neighbor;
115 MENU_STATE_PAN_TARGET
125 Menu(VideoBuffer&,
const MenuAssets*, MenuItem*);
128 void init(VideoBuffer&,
const MenuAssets*, MenuItem*);
130 bool pollEvent(
struct MenuEvent *);
131 void performDefault();
133 void replaceIcon(uint8_t item,
const AssetImage *icon,
const AssetImage *label = 0);
134 bool itemVisible(uint8_t item);
135 void setIconYOffset(uint8_t px);
136 void setPeekTiles(uint8_t numTiles);
137 void anchor(uint8_t item,
bool hopUp =
false, int8_t panTarget=-1);
142 bool isTiltingAtEdge();
143 void setNumTips(uint8_t nt);
145 void drawFooter(
bool force =
false);
147 VideoBuffer *videoBuffer()
const;
151 static const float kTimeDilator = 13.1f;
152 static const float kMaxSpeedMultiplier = 2.f;
153 static const float kAccelScalingFactor = -0.25f;
154 static const uint8_t kNumTilesX = 18;
155 static const uint8_t kNumVisibleTilesX = 16;
156 static const uint8_t kNumTilesY = 18;
157 static const uint8_t kNumVisibleTilesY = 16;
158 static const float kAccelThresholdOn = 4.15f;
159 static const float kAccelThresholdOff = 0.85f;
160 static const float kAccelThresholdStep = 9.5f;
161 static const uint8_t kDefaultIconYOffset = 16;
162 static const uint8_t kDefaultPeekTiles = 1;
163 static const float kPanEasingRate = 0.05f;
165 static const unsigned kPanDelayMilliseconds = 800;
168 uint8_t kHeaderHeight;
169 uint8_t kFooterHeight;
171 uint8_t kIconTileWidth;
172 uint8_t kIconTileHeight;
173 int8_t kEndCapPadding;
177 unsigned kIconPixelWidth()
const {
return kIconTileWidth * TILE; }
178 unsigned kIconPixelHeight()
const {
return kIconTileHeight * TILE; }
179 unsigned kItemTileWidth()
const {
return ((kEndCapPadding + TILE - 1) / TILE) + kIconTileWidth - kPeekTiles; }
180 unsigned kItemPixelWidth()
const {
return kItemTileWidth() * TILE; }
181 float kOneG()
const {
return abs(64 * kAccelScalingFactor); }
185 const struct MenuAssets *assets;
187 struct MenuItem *items;
189 uint8_t startingItem;
192 struct MenuEvent currentEvent;
199 SystemTime prevTipTime;
203 int stopping_position;
222 void transFromStart();
223 void transToStatic();
225 void transFromStatic();
226 void transToTilting();
228 void transFromTilting();
229 void transToInertia();
231 void transFromInertia();
232 void transToFinish();
234 void transFromFinish();
237 void transFromHopUp();
239 void transToPanTarget();
240 void statePanTarget();
241 void transFromPanTarget();
244 bool dispatchEvent(
struct MenuEvent *ev);
246 void handleNeighborAdd();
247 void handleNeighborRemove();
248 void handleItemArrive();
249 void handleItemDepart();
250 void handleItemPress();
252 void handlePrepaint();
255 void detectNeighbors();
256 uint8_t computeSelected();
257 void checkForPress();
258 void drawColumn(
int);
259 int stoppingPositionFor(
int);
260 float velocityMultiplier();
262 static float lerp(
float min,
float max,
float u);
264 bool itemVisibleAtCol(uint8_t item,
int column);
265 uint8_t itemAtCol(
int column);
266 int computeCurrentTile();
Side
An enumeration which names the four sides of a Sifteo cube.
Definition: cube.h:54
Vector2< float > Float2
Typedef for a 2-vector of floats.
Definition: math.h:647
T abs(const T &value)
For any type, return the absolute value.
Definition: math.h:90
_SYSCubeID PCubeID
Alternate POD type for CubeID storage.
Definition: cube.h:70
Total number of sides (4)
Definition: cube.h:59