Fix
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
|
||||||
CardLayout::CardLayout(GfxRenderer& renderer, Rect contentRect, int startY, Config cfg)
|
CardLayout::CardLayout(GfxRenderer& renderer, Rect contentRect, int startY, CardLayoutConfig cfg)
|
||||||
: renderer_(renderer), contentRect_(contentRect), cfg_(cfg), y_(startY) {
|
: renderer_(renderer), contentRect_(contentRect), cfg_(cfg), y_(startY) {
|
||||||
cardLeft_ = contentRect.x + cfg_.outerMarginX;
|
cardLeft_ = contentRect.x + cfg_.outerMarginX;
|
||||||
cardWidth_ = contentRect.width - cfg_.outerMarginX * 2;
|
cardWidth_ = contentRect.width - cfg_.outerMarginX * 2;
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ class GfxRenderer;
|
|||||||
// - All values use UI_10 font; grid values use UI_12 bold. This is
|
// - All values use UI_10 font; grid values use UI_12 bold. This is
|
||||||
// consistent across stats screens; if a future caller needs another
|
// consistent across stats screens; if a future caller needs another
|
||||||
// font scale we'll add an optional config struct.
|
// font scale we'll add an optional config struct.
|
||||||
class CardLayout {
|
// Card visual / spacing configuration. Lives outside CardLayout so it can
|
||||||
public:
|
// be default-constructed by callers (GCC won't synthesize a default ctor
|
||||||
struct Config {
|
// for a class-nested aggregate inside its own class's default-arg list).
|
||||||
|
struct CardLayoutConfig {
|
||||||
int radius = 4;
|
int radius = 4;
|
||||||
int innerPadX = 10;
|
int innerPadX = 10;
|
||||||
int innerPadY = 6;
|
int innerPadY = 6;
|
||||||
@@ -51,6 +52,10 @@ class CardLayout {
|
|||||||
int outerMarginX = 0;
|
int outerMarginX = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CardLayout {
|
||||||
|
public:
|
||||||
|
using Config = CardLayoutConfig; // backwards-compat alias for call sites.
|
||||||
|
|
||||||
// Inner-card drawing context handed to card body lambdas. Tracks the
|
// Inner-card drawing context handed to card body lambdas. Tracks the
|
||||||
// running y cursor inside the card and exposes the same content geometry
|
// running y cursor inside the card and exposes the same content geometry
|
||||||
// (innerLeft / innerRight / innerWidth) needed for custom layouts.
|
// (innerLeft / innerRight / innerWidth) needed for custom layouts.
|
||||||
@@ -80,7 +85,7 @@ class CardLayout {
|
|||||||
void centeredMessage(const char* msg);
|
void centeredMessage(const char* msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
CardLayout(GfxRenderer& renderer, Rect contentRect, int startY, Config cfg = Config());
|
CardLayout(GfxRenderer& renderer, Rect contentRect, int startY, CardLayoutConfig cfg = {});
|
||||||
|
|
||||||
// Render a single card. `bodyFn` receives a `Body&` and may call its
|
// Render a single card. `bodyFn` receives a `Body&` and may call its
|
||||||
// helpers in any order; the card auto-sizes to whatever the body draws.
|
// helpers in any order; the card auto-sizes to whatever the body draws.
|
||||||
@@ -95,7 +100,7 @@ class CardLayout {
|
|||||||
private:
|
private:
|
||||||
GfxRenderer& renderer_;
|
GfxRenderer& renderer_;
|
||||||
Rect contentRect_;
|
Rect contentRect_;
|
||||||
Config cfg_;
|
CardLayoutConfig cfg_;
|
||||||
|
|
||||||
int cardLeft_;
|
int cardLeft_;
|
||||||
int cardWidth_;
|
int cardWidth_;
|
||||||
|
|||||||
Reference in New Issue
Block a user