fix(gui): stack vertical slider display instead of drawing them next to each other (#2623)

fixes #2600
This commit is contained in:
Malte Langermann
2022-10-24 11:37:55 +10:00
committed by GitHub
parent d7598c8ed8
commit 50c81670f6
2 changed files with 19 additions and 18 deletions
+3 -10
View File
@@ -23,7 +23,6 @@
#include "opentx.h" #include "opentx.h"
enum slider_type { enum slider_type {
SLIDER_VERT,
SLIDER_HORIZ, SLIDER_HORIZ,
SLIDER_6POS, SLIDER_6POS,
}; };
@@ -33,10 +32,6 @@ static void slider_self_size(lv_event_t* e)
lv_point_t* s = (lv_point_t*)lv_event_get_param(e); lv_point_t* s = (lv_point_t*)lv_event_get_param(e);
slider_type t = (slider_type)(intptr_t)lv_event_get_user_data(e); slider_type t = (slider_type)(intptr_t)lv_event_get_user_data(e);
switch(t) { switch(t) {
case SLIDER_VERT:
s->y = VERTICAL_SLIDERS_HEIGHT;
s->x = TRIM_SQUARE_SIZE;
break;
case SLIDER_HORIZ: case SLIDER_HORIZ:
s->x = HORIZONTAL_SLIDERS_WIDTH; s->x = HORIZONTAL_SLIDERS_WIDTH;
s->y = TRIM_SQUARE_SIZE; s->y = TRIM_SQUARE_SIZE;
@@ -111,11 +106,9 @@ void MainView6POS::paint(BitmapBuffer * dc)
MainViewVerticalSlider::MainViewVerticalSlider(Window* parent, uint8_t idx) : MainViewVerticalSlider::MainViewVerticalSlider(Window* parent, uint8_t idx) :
MainViewSlider(parent, rect_t{}, idx) MainViewSlider(parent, rect_t{}, idx)
{ {
void* user_data = (void*)SLIDER_VERT; lv_obj_set_style_max_height(lvobj, VERTICAL_SLIDERS_HEIGHT, 0);
lv_obj_add_event_cb(lvobj, slider_self_size, LV_EVENT_GET_SELF_SIZE, lv_obj_set_style_min_height(lvobj, VERTICAL_SLIDERS_HEIGHT/2, 0);
user_data); lv_obj_set_style_flex_grow(lvobj, 1, 0);
setHeight(VERTICAL_SLIDERS_HEIGHT);
setWidth(TRIM_SQUARE_SIZE); setWidth(TRIM_SQUARE_SIZE);
} }
@@ -144,17 +144,23 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo
#endif #endif
#if NUM_SLIDERS > 0 #if NUM_SLIDERS > 0
sl = new MainViewVerticalSlider(ml, CALIBRATED_SLIDER_REAR_LEFT); // create containers for the sliders, so that they are at the borders of the display
sl->updateSize(); // only pos... // on top of each other, when there are two sliders to display per side
sliders[SLIDERS_REAR_LEFT] = sl; auto leftPots = create_layout_box(ml, LV_ALIGN_LEFT_MID, LV_FLEX_FLOW_COLUMN);
leftPots->setHeight(VERTICAL_SLIDERS_HEIGHT);
sl = new MainViewVerticalSlider(mr, CALIBRATED_SLIDER_REAR_RIGHT); auto rightPots = create_layout_box(mr, LV_ALIGN_RIGHT_MID, LV_FLEX_FLOW_COLUMN);
sl->updateSize(); // only pos... rightPots->setHeight(VERTICAL_SLIDERS_HEIGHT);
sliders[SLIDERS_REAR_RIGHT] = sl;
auto vertSlLeft1 = new MainViewVerticalSlider(leftPots, CALIBRATED_SLIDER_REAR_LEFT);
sliders[SLIDERS_REAR_LEFT] = vertSlLeft1;
auto vertSlRight1 = new MainViewVerticalSlider(rightPots, CALIBRATED_SLIDER_REAR_RIGHT);
sliders[SLIDERS_REAR_RIGHT] = vertSlRight1;
#if defined(HARDWARE_EXT1) || defined(PCBX12S) #if defined(HARDWARE_EXT1) || defined(PCBX12S)
if (IS_POT_SLIDER_AVAILABLE(EXT1)) { if (IS_POT_SLIDER_AVAILABLE(EXT1)) {
sl = new MainViewVerticalSlider(ml, CALIBRATED_POT_EXT1); sl = new MainViewVerticalSlider(leftPots, CALIBRATED_POT_EXT1);
sl->updateSize(); sl->updateSize();
sliders[SLIDERS_EXT1] = sl; sliders[SLIDERS_EXT1] = sl;
} }
@@ -162,11 +168,13 @@ void ViewMainDecoration::createSliders(Window* ml, Window* mr, Window* bl, Windo
#if defined(HARDWARE_EXT2) || defined(PCBX12S) #if defined(HARDWARE_EXT2) || defined(PCBX12S)
if (IS_POT_SLIDER_AVAILABLE(EXT2)) { if (IS_POT_SLIDER_AVAILABLE(EXT2)) {
sl = new MainViewVerticalSlider(mr, CALIBRATED_POT_EXT2); sl = new MainViewVerticalSlider(rightPots, CALIBRATED_POT_EXT2);
sl->updateSize(); sl->updateSize();
sliders[SLIDERS_EXT2] = sl; sliders[SLIDERS_EXT2] = sl;
} }
#endif #endif
vertSlLeft1->updateSize();
vertSlRight1->updateSize();
#endif // NUM_SLIDERS > 0 #endif // NUM_SLIDERS > 0
} }