Inputs & Mixers: tweaks for portrait layout

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 86c72e3a2a
commit 7f3b826b05
2 changed files with 76 additions and 32 deletions
+31 -11
View File
@@ -134,15 +134,19 @@ class InputLineButton : public InputMixButton
const ExpoData &line = g_model.expoData[index]; const ExpoData &line = g_model.expoData[index];
LcdFlags textColor = COLOR_THEME_SECONDARY1; LcdFlags textColor = COLOR_THEME_SECONDARY1;
coord_t border = lv_obj_get_style_border_width(lvobj, LV_PART_MAIN);
coord_t pad_left = lv_obj_get_style_pad_left(lvobj, LV_PART_MAIN);
coord_t left = pad_left + border;
coord_t line_h = lv_obj_get_style_text_line_space(lvobj, LV_PART_MAIN)
+ getFontHeight(FONT(STD));
// first line ... // first line ...
coord_t y = 0; coord_t y = 0;
y += lv_obj_get_style_border_width(lvobj, LV_PART_MAIN); y += border;
y += lv_obj_get_style_pad_top(lvobj, LV_PART_MAIN); y += lv_obj_get_style_pad_top(lvobj, LV_PART_MAIN);
coord_t x = 0; coord_t x = left;
x += lv_obj_get_style_border_width(lvobj, LV_PART_MAIN);
x += lv_obj_get_style_pad_left(lvobj, LV_PART_MAIN);
drawValueOrGVar(dc, x, y, line.weight, -100, 100, textColor); drawValueOrGVar(dc, x, y, line.weight, -100, 100, textColor);
drawSource(dc, x + 65, y, line.srcRaw, textColor); drawSource(dc, x + 65, y, line.srcRaw, textColor);
@@ -152,8 +156,7 @@ class InputLineButton : public InputMixButton
} }
// second line ... // second line ...
y += lv_obj_get_style_text_line_space(lvobj, LV_PART_MAIN); y += line_h;
y += getFontHeight(FONT(STD));
if (line.swtch) { if (line.swtch) {
dc->drawMask(x, y, mixerSetupSwitchIcon, textColor); dc->drawMask(x, y, mixerSetupSwitchIcon, textColor);
@@ -165,8 +168,16 @@ class InputLineButton : public InputMixButton
drawCurveRef(dc, x + 85, y, line.curve, textColor); drawCurveRef(dc, x + 85, y, line.curve, textColor);
} }
#if LCD_H > LCD_W
// third line ...
y += line_h;
x = left;
#else
x = 146;
#endif
if (line.flightModes) { if (line.flightModes) {
drawFlightModes(dc, line.flightModes, textColor, 146, y); drawFlightModes(dc, line.flightModes, textColor, x, y);
} }
} }
@@ -174,11 +185,20 @@ protected:
bool isActive() const override { return isExpoActive(index); } bool isActive() const override { return isExpoActive(index); }
size_t getLines() const override { size_t getLines() const override {
const ExpoData* line = expoAddress(index); const ExpoData* line = expoAddress(index);
size_t lines = 1;
#if LCD_W > LCD_H
if (line->swtch || line->curve.value != 0 || line->flightModes) { if (line->swtch || line->curve.value != 0 || line->flightModes) {
return 2; lines += 1;
} else {
return 1;
} }
#else
if (line->swtch || line->curve.value != 0) {
lines += 1;
}
if (line->flightModes) {
lines += 1;
}
#endif
return lines;
} }
}; };
+45 -21
View File
@@ -244,11 +244,20 @@ MixLineButton::MixLineButton(Window* parent, uint8_t index) :
size_t MixLineButton::getLines() const size_t MixLineButton::getLines() const
{ {
const MixData* mix = mixAddress(index); const MixData* mix = mixAddress(index);
size_t lines = 1;
#if LCD_W > LCD_H
if (mix->swtch || mix->curve.value != 0 || mix->flightModes) { if (mix->swtch || mix->curve.value != 0 || mix->flightModes) {
return 2; lines += 1;
} else {
return 1;
} }
#else
if (mix->swtch || mix->curve.value != 0) {
lines += 1;
}
if (mix->flightModes) {
lines += 1;
}
#endif
return lines;
} }
void MixLineButton::paint(BitmapBuffer* dc) void MixLineButton::paint(BitmapBuffer* dc)
@@ -256,15 +265,20 @@ void MixLineButton::paint(BitmapBuffer* dc)
const MixData& line = g_model.mixData[index]; const MixData& line = g_model.mixData[index];
LcdFlags textColor = COLOR_THEME_SECONDARY1; LcdFlags textColor = COLOR_THEME_SECONDARY1;
coord_t border = lv_obj_get_style_border_width(lvobj, LV_PART_MAIN);
coord_t pad_left = lv_obj_get_style_pad_left(lvobj, LV_PART_MAIN);
coord_t pad_right = lv_obj_get_style_pad_right(lvobj, LV_PART_MAIN);
coord_t left = pad_left + border;
coord_t line_h = lv_obj_get_style_text_line_space(lvobj, LV_PART_MAIN)
+ getFontHeight(FONT(STD));
// first line ... // first line ...
coord_t y = 0; coord_t y = 0;
y += lv_obj_get_style_border_width(lvobj, LV_PART_MAIN); y += border;
y += lv_obj_get_style_pad_top(lvobj, LV_PART_MAIN); y += lv_obj_get_style_pad_top(lvobj, LV_PART_MAIN);
coord_t x = 0; coord_t x = left;
x += lv_obj_get_style_border_width(lvobj, LV_PART_MAIN);
x += lv_obj_get_style_pad_left(lvobj, LV_PART_MAIN);
drawValueOrGVar(dc, x, y, line.weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, drawValueOrGVar(dc, x, y, line.weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX,
textColor); textColor);
drawSource(dc, x + 65, y, line.srcRaw, textColor); drawSource(dc, x + 65, y, line.srcRaw, textColor);
@@ -274,9 +288,21 @@ void MixLineButton::paint(BitmapBuffer* dc)
dc->drawSizedText(166, y, line.name, sizeof(line.name), textColor); dc->drawSizedText(166, y, line.name, sizeof(line.name), textColor);
} }
// Put this icon on the first line, since we have more space there
uint8_t delayslow = 0;
if (line.speedDown || line.speedUp) delayslow = 1;
if (line.delayUp || line.delayDown) delayslow += 2;
if (delayslow) {
BitmapBuffer* delayslowbmp[] = {mixerSetupSlowIcon, mixerSetupDelayIcon,
mixerSetupDelaySlowIcon};
const BitmapBuffer* mask = delayslowbmp[delayslow - 1];
coord_t w = lv_obj_get_width(lvobj);
w -= mask->width();
dc->drawMask(w - border - pad_right, y + border, mask, textColor);
}
// second line ... // second line ...
y += lv_obj_get_style_text_line_space(lvobj, LV_PART_MAIN); y += line_h;
y += getFontHeight(FONT(STD));
if (line.swtch) { if (line.swtch) {
dc->drawMask(x, y, mixerSetupSwitchIcon, textColor); dc->drawMask(x, y, mixerSetupSwitchIcon, textColor);
@@ -288,18 +314,16 @@ void MixLineButton::paint(BitmapBuffer* dc)
drawCurveRef(dc, x + 85, y, line.curve, textColor); drawCurveRef(dc, x + 85, y, line.curve, textColor);
} }
if (line.flightModes) { #if LCD_H > LCD_W
drawFlightModes(dc, line.flightModes, textColor, 146, y); // third line ...
} y += line_h;
x = left;
#else
x = 146;
#endif
// Put this icon on the first line, since we have more space there if (line.flightModes) {
uint8_t delayslow = 0; drawFlightModes(dc, line.flightModes, textColor, x, y);
if (line.speedDown || line.speedUp) delayslow = 1;
if (line.delayUp || line.delayDown) delayslow += 2;
if (delayslow) {
BitmapBuffer* delayslowbmp[] = {mixerSetupSlowIcon, mixerSetupDelayIcon,
mixerSetupDelaySlowIcon};
dc->drawMask(width() - 16, y, delayslowbmp[delayslow - 1], textColor);
} }
} }