Main screen deco layout fine tuning / fixes.

This commit is contained in:
Raphael Coeffic
2021-04-18 07:57:41 +02:00
parent 19ab22e1a4
commit ad845a5d6b
3 changed files with 47 additions and 19 deletions
+8
View File
@@ -95,10 +95,18 @@ set(SRC
storage/modelslist.cpp storage/modelslist.cpp
) )
option(WINDOWS_INSPECT_BORDERS "Draw bounding boxes around windows" OFF)
if(WINDOWS_INSPECT_BORDERS)
add_definitions(-DWINDOWS_INSPECT_BORDERS)
endif()
# includes libopenui # includes libopenui
include(${RADIO_SRC_DIR}/thirdparty/libopenui/src/CMakeLists.txt) include(${RADIO_SRC_DIR}/thirdparty/libopenui/src/CMakeLists.txt)
include_directories(gui/libopenui) include_directories(gui/libopenui)
add_definitions(-DLIBOPENUI) add_definitions(-DLIBOPENUI)
foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC}) foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC})
set(SRC ${SRC} thirdparty/libopenui/src/${LIBOPENUI_FILE}) set(SRC ${SRC} thirdparty/libopenui/src/${LIBOPENUI_FILE})
endforeach() endforeach()
+4
View File
@@ -67,4 +67,8 @@
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX) #define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
#define BATTERY_CHARGE_COLOR COLOR(BATTERY_CHARGE_COLOR_INDEX) #define BATTERY_CHARGE_COLOR COLOR(BATTERY_CHARGE_COLOR_INDEX)
#if defined(WINDOWS_INSPECT_BORDERS)
#define WINDOWS_INSPECT_BORDER_COLOR LINE_COLOR
#endif
#endif // _COLORS_H_ #endif // _COLORS_H_
+35 -19
View File
@@ -145,7 +145,7 @@ void ViewMain::adjustDecoration()
// Topbar does not need any computation // Topbar does not need any computation
// (height() has been set in setTopbarVisible()) // (height() has been set in setTopbarVisible())
// Sliders are closer to the edge and must be computed then // Sliders are closer to the edge and must be computed first
// (vertical sliders depends on topbar) // (vertical sliders depends on topbar)
// These are located on the bottom // These are located on the bottom
@@ -168,22 +168,36 @@ void ViewMain::adjustDecoration()
sliders[SLIDERS_POT3]->setTop(pos); sliders[SLIDERS_POT3]->setTop(pos);
#endif #endif
// Horizontal trims are on top of horizontal sliders
pos -= trims[TRIMS_LH]->height();
trims[TRIMS_LH]->setTop(pos);
trims[TRIMS_RH]->setTop(pos);
// Vertical trims/slider are on top of horizontal sliders with a small margin
auto vertTop = pos - HMARGIN - VERTICAL_SLIDERS_HEIGHT;
// Left side (vertical) // Left side (vertical)
pos = left(); pos = left();
sliders[SLIDERS_REAR_LEFT]->setLeft(pos); sliders[SLIDERS_REAR_LEFT]->setLeft(pos);
sliders[SLIDERS_REAR_LEFT]->setTop(topbar->bottom()); sliders[SLIDERS_REAR_LEFT]->setTop(vertTop);
#if defined(HARDWARE_EXT1) #if defined(HARDWARE_EXT1)
sliders[SLIDERS_EXT1]->setLeft(pos); sliders[SLIDERS_EXT1]->setLeft(pos);
if (IS_POT_SLIDER_AVAILABLE(EXT1)) { if (IS_POT_SLIDER_AVAILABLE(EXT1)) {
auto rl = sliders[SLIDERS_REAR_LEFT]; auto rl = sliders[SLIDERS_REAR_LEFT];
auto e1 = sliders[SLIDERS_EXT1]; auto e1 = sliders[SLIDERS_EXT1];
// If EXT1 is configured as a slider,
// place it bellow rear-left slider (and make them smaller)
rl->setHeight(VERTICAL_SLIDERS_HEIGHT / 2); rl->setHeight(VERTICAL_SLIDERS_HEIGHT / 2);
e1->setTop(topbar->bottom() + rl->height()); e1->setTop(vertTop + rl->height() + HMARGIN/2);
e1->setHeight(rl->height()); e1->setHeight(rl->height());
} }
else { else {
auto rl = sliders[SLIDERS_REAR_LEFT]; auto rl = sliders[SLIDERS_REAR_LEFT];
auto e1 = sliders[SLIDERS_EXT1]; auto e1 = sliders[SLIDERS_EXT1];
// Otherwise hide the extra slider and make rear-left fullsize
rl->setHeight(VERTICAL_SLIDERS_HEIGHT); rl->setHeight(VERTICAL_SLIDERS_HEIGHT);
e1->setHeight(0); e1->setHeight(0);
} }
@@ -192,34 +206,37 @@ void ViewMain::adjustDecoration()
// Right side (vertical) // Right side (vertical)
pos = right() - sliders[SLIDERS_REAR_RIGHT]->width(); pos = right() - sliders[SLIDERS_REAR_RIGHT]->width();
sliders[SLIDERS_REAR_RIGHT]->setLeft(pos); sliders[SLIDERS_REAR_RIGHT]->setLeft(pos);
sliders[SLIDERS_REAR_RIGHT]->setTop(topbar->bottom()); sliders[SLIDERS_REAR_RIGHT]->setTop(vertTop);
#if defined(HARDWARE_EXT2) #if defined(HARDWARE_EXT2)
sliders[SLIDERS_EXT2]->setLeft(pos); sliders[SLIDERS_EXT2]->setLeft(pos);
if (IS_POT_SLIDER_AVAILABLE(EXT2)) { if (IS_POT_SLIDER_AVAILABLE(EXT2)) {
auto rr = sliders[SLIDERS_REAR_RIGHT]; auto rr = sliders[SLIDERS_REAR_RIGHT];
auto e2 = sliders[SLIDERS_EXT2]; auto e2 = sliders[SLIDERS_EXT2];
// If EXT2 is configured as a slider,
// place it bellow rear-left slider (and make them smaller)
rr->setHeight(VERTICAL_SLIDERS_HEIGHT / 2); rr->setHeight(VERTICAL_SLIDERS_HEIGHT / 2);
e2->setTop(topbar->bottom() + rr->height()); e2->setTop(vertTop + rr->height() + HMARGIN/2);
e2->setHeight(rr->height()); e2->setHeight(rr->height());
} }
else { else {
auto rr = sliders[SLIDERS_REAR_RIGHT]; auto rr = sliders[SLIDERS_REAR_RIGHT];
auto e2 = sliders[SLIDERS_EXT2]; auto e2 = sliders[SLIDERS_EXT2];
// Otherwise hide the extra slider and make rear-left fullsize
rr->setHeight(VERTICAL_SLIDERS_HEIGHT); rr->setHeight(VERTICAL_SLIDERS_HEIGHT);
e2->setHeight(0); e2->setHeight(0);
} }
#endif #endif
// Trims are last as they are located more on the inside // Finally place the vertical trims further from the edge
// (depend on everything else)
pos = sliders[SLIDERS_POT1]->top() - TRIM_SQUARE_SIZE;
trims[TRIMS_LH]->setTop(pos);
trims[TRIMS_RH]->setTop(pos);
trims[TRIMS_LV]->setLeft(sliders[SLIDERS_REAR_LEFT]->right()); trims[TRIMS_LV]->setLeft(sliders[SLIDERS_REAR_LEFT]->right());
trims[TRIMS_LV]->setTop(topbar->bottom()); trims[TRIMS_LV]->setTop(vertTop);
trims[TRIMS_RV]->setLeft(sliders[SLIDERS_REAR_RIGHT]->left() - trims[TRIMS_RV]->width()); trims[TRIMS_RV]->setLeft(sliders[SLIDERS_REAR_RIGHT]->left() - trims[TRIMS_RV]->width());
trims[TRIMS_RV]->setTop(topbar->bottom()); trims[TRIMS_RV]->setTop(vertTop);
//TODO: find a proper place for the flight-mode text box
} }
#if defined(HARDWARE_KEYS) #if defined(HARDWARE_KEYS)
@@ -384,20 +401,19 @@ void ViewMain::createTrims()
VERTICAL_SLIDERS_HEIGHT VERTICAL_SLIDERS_HEIGHT
}; };
r.x = left() + HMARGIN + TRIM_SQUARE_SIZE; // DBG //r.x = left() + HMARGIN + TRIM_SQUARE_SIZE; // DBG
trims[TRIMS_LV] = new MainViewVerticalTrim(this, r, 1); trims[TRIMS_LV] = new MainViewVerticalTrim(this, r, 1);
r.x = right() - HMARGIN - TRIM_SQUARE_SIZE; // DBG //r.x = right() - HMARGIN - TRIM_SQUARE_SIZE; // DBG
trims[TRIMS_RV] = new MainViewVerticalTrim(this, r, 2); trims[TRIMS_RV] = new MainViewVerticalTrim(this, r, 2);
} }
void ViewMain::createFlightMode() void ViewMain::createFlightMode()
{ {
rect_t r = { rect_t r = {
50, // centered text box (50 pixels from either edge)
LCD_H - 4 - /*(hasSliders() ?*/ 2 * TRIM_SQUARE_SIZE /*: TRIM_SQUARE_SIZE)*/, // -> re-size once the other components are set
LCD_W - 100, 50, 0, width() - 100, 0
20
}; };
std::function<std::string()> getFM = []() -> std::string { std::function<std::string()> getFM = []() -> std::string {