fixed decorations
This commit is contained in:
@@ -95,15 +95,39 @@ void loadCustomScreens()
|
|||||||
screen->attach(ViewMain::instance);
|
screen->attach(ViewMain::instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//customScreens[g_model.view]->attach(ViewMain::instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
||||||
{
|
{
|
||||||
|
// check if deco setting are still up-to-date
|
||||||
|
uint8_t checkSettings =
|
||||||
|
(topbar ? 1 << 0 : 0) |
|
||||||
|
(sliders ? 1 << 1 : 0) |
|
||||||
|
(trims ? 1 << 2 : 0) |
|
||||||
|
(flightMode ? 1 << 3 : 0);
|
||||||
|
|
||||||
|
if (checkSettings == decorationSettings) {
|
||||||
|
// everything ok, exit!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// kill all decorations & re-decorate
|
||||||
|
for (auto deco: decorations) {
|
||||||
|
deco->deleteLater();
|
||||||
|
}
|
||||||
|
decorations.clear();
|
||||||
|
topBar = nullptr;
|
||||||
|
|
||||||
|
// effect a full redraw
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
// save settings
|
||||||
|
decorationSettings = checkSettings;
|
||||||
|
|
||||||
if (topbar) {
|
if (topbar) {
|
||||||
topBar = new TopBar(this);
|
topBar = new TopBar(this);
|
||||||
topBar->load();
|
topBar->load();
|
||||||
|
decorations.push_back(topBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sliders) {
|
if (sliders) {
|
||||||
@@ -111,49 +135,69 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
|||||||
coord_t yOffset = (trims ? - TRIM_SQUARE_SIZE : 0) + (topbar ? TOPBAR_HEIGHT / 2 : 0);
|
coord_t yOffset = (trims ? - TRIM_SQUARE_SIZE : 0) + (topbar ? TOPBAR_HEIGHT / 2 : 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
new MainViewHorizontalSlider(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
decorations.push_back(
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_POT1]; });
|
new MainViewHorizontalSlider(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
||||||
|
[=] { return calibratedAnalogs[CALIBRATED_POT1]; })
|
||||||
|
);
|
||||||
|
|
||||||
if (IS_POT_MULTIPOS(POT2)) {
|
if (IS_POT_MULTIPOS(POT2)) {
|
||||||
new MainView6POS(this, {LCD_W / 2 - MULTIPOS_W / 2, LCD_H - TRIM_SQUARE_SIZE, MULTIPOS_W + 1, MULTIPOS_H},
|
decorations.push_back(
|
||||||
[=] { return (1 + (potsPos[1] & 0x0f)); });
|
new MainView6POS(this, {LCD_W / 2 - MULTIPOS_W / 2, LCD_H - TRIM_SQUARE_SIZE, MULTIPOS_W + 1, MULTIPOS_H},
|
||||||
|
[=] { return (1 + (potsPos[1] & 0x0f)); })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (IS_POT(POT2)) {
|
else if (IS_POT(POT2)) {
|
||||||
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
decorations.push_back(
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_POT2]; });
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
||||||
|
[=] { return calibratedAnalogs[CALIBRATED_POT2]; })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_POT3)
|
#if defined(HARDWARE_POT3)
|
||||||
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
decorations.push_back(
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_POT3]; });
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
||||||
|
[=] { return calibratedAnalogs[CALIBRATED_POT3]; })
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_EXT1)
|
#if defined(HARDWARE_EXT1)
|
||||||
if (IS_POT_SLIDER_AVAILABLE(EXT1)) {
|
if (IS_POT_SLIDER_AVAILABLE(EXT1)) {
|
||||||
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
decorations.push_back(
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; });
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
||||||
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; })
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT1]; });
|
);
|
||||||
|
decorations.push_back(
|
||||||
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
||||||
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT1]; })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
decorations.push_back(
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; });
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
||||||
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_EXT2)
|
#if defined(HARDWARE_EXT2)
|
||||||
if (IS_POT_SLIDER_AVAILABLE(EXT2)) {
|
if (IS_POT_SLIDER_AVAILABLE(EXT2)) {
|
||||||
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
decorations.push_back(
|
||||||
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
||||||
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; });
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; })
|
||||||
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE,
|
);
|
||||||
|
decorations.push_back(
|
||||||
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE,
|
||||||
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT2]; });
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT2]; })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
decorations.push_back(
|
||||||
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
||||||
VERTICAL_SLIDERS_HEIGHT(topbar)},
|
VERTICAL_SLIDERS_HEIGHT(topbar)},
|
||||||
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; });
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -169,24 +213,35 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
|||||||
// Trim order TRIM_LH, TRIM_LV, TRIM_RV, TRIM_RH
|
// Trim order TRIM_LH, TRIM_LV, TRIM_RV, TRIM_RH
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
new MainViewHorizontalTrim(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
decorations.push_back(
|
||||||
[=] { return getTrimValue(mixerCurrentFlightMode, 0); });
|
new MainViewHorizontalTrim(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
||||||
// Right
|
[=] { return getTrimValue(mixerCurrentFlightMode, 0); })
|
||||||
new MainViewHorizontalTrim(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
);
|
||||||
[=] { return getTrimValue(mixerCurrentFlightMode, 3); });
|
|
||||||
|
|
||||||
|
// Right
|
||||||
|
decorations.push_back(
|
||||||
|
new MainViewHorizontalTrim(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
||||||
|
[=] { return getTrimValue(mixerCurrentFlightMode, 3); })
|
||||||
|
);
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
new MainViewVerticalTrim(this, {HMARGIN + xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
decorations.push_back(
|
||||||
[=] { return getTrimValue(mixerCurrentFlightMode, 1); });
|
new MainViewVerticalTrim(this, {HMARGIN + xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
||||||
|
[=] { return getTrimValue(mixerCurrentFlightMode, 1); })
|
||||||
|
);
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
new MainViewVerticalTrim(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE - xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
decorations.push_back(
|
||||||
[=] { return getTrimValue(mixerCurrentFlightMode, 2); });
|
new MainViewVerticalTrim(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE - xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
||||||
|
[=] { return getTrimValue(mixerCurrentFlightMode, 2); })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flightMode) {
|
if (flightMode) {
|
||||||
new DynamicText(this, {50, LCD_H - 4 - (sliders? 2 * TRIM_SQUARE_SIZE: TRIM_SQUARE_SIZE), LCD_W - 100, 20}, [=] {
|
decorations.push_back(
|
||||||
|
new DynamicText(this, {50, LCD_H - 4 - (sliders? 2 * TRIM_SQUARE_SIZE: TRIM_SQUARE_SIZE), LCD_W - 100, 20}, [=] {
|
||||||
return g_model.flightModeData[mixerCurrentFlightMode].name;
|
return g_model.flightModeData[mixerCurrentFlightMode].name;
|
||||||
}, CENTERED);
|
}, CENTERED)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class Layout: public WidgetsContainer<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
|
|||||||
protected:
|
protected:
|
||||||
const LayoutFactory * factory;
|
const LayoutFactory * factory;
|
||||||
TopBar * topBar = nullptr;
|
TopBar * topBar = nullptr;
|
||||||
|
uint8_t decorationSettings = 0;
|
||||||
|
std::list<Window*> decorations;
|
||||||
};
|
};
|
||||||
|
|
||||||
void registerLayout(const LayoutFactory * factory);
|
void registerLayout(const LayoutFactory * factory);
|
||||||
|
|||||||
@@ -90,14 +90,7 @@ class Layout1x1: public Layout
|
|||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
Layout::checkEvents();
|
Layout::checkEvents();
|
||||||
uint8_t newValue = persistentData->options[4].value.boolValue << 4 | persistentData->options[3].value.boolValue << 3 | persistentData->options[2].value.boolValue << 2
|
decorate();
|
||||||
| persistentData->options[1].value.boolValue << 1 | persistentData->options[0].value.boolValue;
|
|
||||||
if (value != newValue) {
|
|
||||||
value = newValue;
|
|
||||||
// TODO call this from the Layout config window
|
|
||||||
this->clear();
|
|
||||||
decorate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
|
|||||||
@@ -86,13 +86,8 @@ class Layout2P1: public Layout
|
|||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
Layout::checkEvents();
|
Layout::checkEvents();
|
||||||
uint8_t newValue = persistentData->options[4].value.boolValue << 4 | persistentData->options[3].value.boolValue << 3 | persistentData->options[2].value.boolValue << 2
|
// TODO call this from the Layout config window
|
||||||
| persistentData->options[1].value.boolValue << 1 | persistentData->options[0].value.boolValue;
|
decorate();
|
||||||
if (value != newValue) {
|
|
||||||
value = newValue;
|
|
||||||
// TODO call this from the Layout config window
|
|
||||||
decorate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
|
|||||||
@@ -92,14 +92,7 @@ class Layout2x1: public Layout
|
|||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
Layout::checkEvents();
|
Layout::checkEvents();
|
||||||
uint8_t newValue = persistentData->options[4].value.boolValue << 4 | persistentData->options[3].value.boolValue << 3 | persistentData->options[2].value.boolValue << 2
|
decorate();
|
||||||
| persistentData->options[1].value.boolValue << 1 | persistentData->options[0].value.boolValue;
|
|
||||||
if (value != newValue) {
|
|
||||||
value = newValue;
|
|
||||||
// TODO call this from the Layout config window
|
|
||||||
this->clear();
|
|
||||||
decorate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
|
|||||||
@@ -94,15 +94,9 @@ class Layout2x2: public Layout
|
|||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
Layout::checkEvents();
|
Layout::checkEvents();
|
||||||
uint8_t newValue = persistentData->options[4].value.boolValue << 4 | persistentData->options[3].value.boolValue << 3 | persistentData->options[2].value.boolValue << 2
|
decorate();
|
||||||
| persistentData->options[1].value.boolValue << 1 | persistentData->options[0].value.boolValue;
|
|
||||||
if (value != newValue) {
|
|
||||||
value = newValue;
|
|
||||||
// TODO call this from the Layout config window
|
|
||||||
this->clear();
|
|
||||||
decorate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user