easter: improve easter egg
This commit is contained in:
@@ -22,12 +22,19 @@ class ImageElement : public tsl::elm::ListItem {
|
||||
private:
|
||||
const uint8_t* imgData;
|
||||
uint32_t imgWidth, imgHeight;
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
ImageElement(const uint8_t* data, uint32_t w, uint32_t h)
|
||||
: tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h) {}
|
||||
: tsl::elm::ListItem(""), imgData(data), imgWidth(w), imgHeight(h), visible(true) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
|
||||
// Draw image centered horizontally
|
||||
u16 centerX = this->getX() + (this->getWidth() - imgWidth) / 2;
|
||||
renderer->drawBitmap(
|
||||
@@ -39,6 +46,16 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
// Take up no space when hidden
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
// Normal layout when visible
|
||||
tsl::elm::ListItem::layout(parentX, parentY, parentWidth, parentHeight);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void drawHighlight(tsl::gfx::Renderer *renderer) override {
|
||||
// Do nothing - no highlight
|
||||
}
|
||||
@@ -48,6 +65,62 @@ public:
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr; // Make it non-focusable so it can't be selected
|
||||
return nullptr; // Make it non-focusable
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCategoryHeader : public tsl::elm::CategoryHeader {
|
||||
private:
|
||||
bool visible;
|
||||
|
||||
public:
|
||||
HideableCategoryHeader(const std::string& title)
|
||||
: tsl::elm::CategoryHeader(title), visible(true) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
if (!visible) return;
|
||||
tsl::elm::CategoryHeader::draw(renderer);
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
tsl::elm::CategoryHeader::layout(parentX, parentY, parentWidth, parentHeight);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class HideableCustomDrawer : public tsl::elm::Element {
|
||||
private:
|
||||
bool visible;
|
||||
u32 height;
|
||||
|
||||
public:
|
||||
HideableCustomDrawer(u32 h)
|
||||
: Element(), visible(true), height(h) {}
|
||||
|
||||
void setVisible(bool v) {
|
||||
visible = v;
|
||||
}
|
||||
|
||||
virtual void draw(tsl::gfx::Renderer *renderer) override {
|
||||
// Empty drawer - just for spacing
|
||||
}
|
||||
|
||||
virtual void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
|
||||
if (!visible) {
|
||||
this->setBoundaries(parentX, parentY, 0, 0);
|
||||
} else {
|
||||
this->setBoundaries(parentX, parentY, parentWidth, height);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Element* requestFocus(Element *oldFocus, tsl::FocusDirection direction) override {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user