getMainZone() moved to Layout

This commit is contained in:
Raphael Coeffic
2021-04-05 19:34:38 +02:00
parent 60084d2c53
commit da83e6b210
4 changed files with 46 additions and 28 deletions
+32
View File
@@ -245,3 +245,35 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
);
}
}
rect_t Layout::getMainZone(rect_t zone) const
{
bool hasTopbar = getOptionValue(OPTION_TOPBAR)->boolValue;
bool hasFM = getOptionValue(OPTION_FM)->boolValue;
bool hasSliders = getOptionValue(OPTION_SLIDERS)->boolValue;
bool hasTrims = getOptionValue(OPTION_TRIMS)->boolValue;
if (hasTopbar) {
zone.y += MENU_HEADER_HEIGHT;
zone.h -= MENU_HEADER_HEIGHT;
}
if (hasFM || hasTrims) {
zone.h -= TRIM_SQUARE_SIZE;
}
if (hasSliders) {
#if NUM_SLIDERS + NUM_POTS > 2
zone.h -= TRIM_SQUARE_SIZE;
#endif
zone.w -= 2 * TRIM_SQUARE_SIZE;
zone.x += TRIM_SQUARE_SIZE;
}
if (hasTrims) {
zone.w -= 2 * TRIM_SQUARE_SIZE;
zone.x += TRIM_SQUARE_SIZE;
}
return zone;
}
+13
View File
@@ -37,6 +37,16 @@ class Layout: public WidgetsContainer<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
friend class LayoutFactory;
public:
// Common 'ZoneOptionValue's among all layouts
enum {
OPTION_TOPBAR = 0,
OPTION_FM,
OPTION_SLIDERS,
OPTION_TRIMS,
OPTION_MIRRORED
};
Layout(const LayoutFactory * factory, PersistentData * persistentData):
WidgetsContainer<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>({0, 0, LCD_W, LCD_H}, persistentData),
factory(factory)
@@ -55,6 +65,9 @@ class Layout: public WidgetsContainer<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
TopBar * topBar = nullptr;
uint8_t decorationSettings = 0;
std::list<Window*> decorations;
// get the Zone rect without decoration
rect_t getMainZone(rect_t zone) const;
};
void registerLayout(const LayoutFactory * factory);
@@ -74,33 +74,6 @@ class Layout1x1: public Layout
return 1;
}
rect_t getMainZone(rect_t zone) const
{
if (HAS_TOPBAR()) {
zone.y += MENU_HEADER_HEIGHT;
zone.h -= MENU_HEADER_HEIGHT;
}
if (HAS_FM() || HAS_TRIMS()) {
zone.h -= TRIM_SQUARE_SIZE;
}
if (HAS_SLIDERS()) {
#if NUM_SLIDERS + NUM_POTS > 2
zone.h -= TRIM_SQUARE_SIZE;
#endif
zone.w -= 2 * TRIM_SQUARE_SIZE;
zone.x += TRIM_SQUARE_SIZE;
}
if (HAS_TRIMS()) {
zone.w -= 2 * TRIM_SQUARE_SIZE;
zone.x += TRIM_SQUARE_SIZE;
}
return zone;
}
rect_t getZone(unsigned int index) const override
{
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});