Removed duplicated code
This commit is contained in:
@@ -127,35 +127,7 @@ void Layout::decorate()
|
||||
viewMain->invalidate();
|
||||
}
|
||||
|
||||
rect_t Layout::getMainZone(rect_t zone) const
|
||||
rect_t Layout::getMainZone() const
|
||||
{
|
||||
if (hasTopbar()) {
|
||||
zone.y += MENU_HEADER_HEIGHT;
|
||||
zone.h -= MENU_HEADER_HEIGHT;
|
||||
}
|
||||
|
||||
if (hasFlightMode() || 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;
|
||||
}
|
||||
|
||||
if (zone.w % 2 != 0)
|
||||
zone.w -= 1;
|
||||
|
||||
if (zone.h % 2 != 0)
|
||||
zone.h -= 1;
|
||||
|
||||
return zone;
|
||||
return ViewMain::instance()->getMainZone();
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ class Layout: public LayoutBase
|
||||
// Updates settings for trims, sliders, pots, etc...
|
||||
void decorate();
|
||||
|
||||
// Get the Zone rect without decoration
|
||||
rect_t getMainZone(rect_t zone) const;
|
||||
// Get the available space for widgets
|
||||
rect_t getMainZone() const;
|
||||
};
|
||||
|
||||
void registerLayout(const LayoutFactory * factory);
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "opentx.h"
|
||||
#include "trims.h"
|
||||
|
||||
constexpr coord_t border = 10;
|
||||
|
||||
const uint8_t LBM_LAYOUT_1x1[] = {
|
||||
#include "mask_layout1x1.lbm"
|
||||
};
|
||||
@@ -47,9 +45,7 @@ class Layout1x1: public Layout
|
||||
|
||||
rect_t getZone(unsigned int index) const override
|
||||
{
|
||||
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});
|
||||
|
||||
return zone;
|
||||
return getMainZone();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "sliders.h"
|
||||
#include "trims.h"
|
||||
|
||||
constexpr coord_t border = 10;
|
||||
|
||||
const uint8_t LBM_LAYOUT_2P1[] = {
|
||||
#include "mask_layout2+1.lbm"
|
||||
};
|
||||
@@ -48,7 +46,7 @@ class Layout2P1: public Layout
|
||||
|
||||
rect_t getZone(unsigned int index) const override
|
||||
{
|
||||
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});
|
||||
rect_t zone = getMainZone();
|
||||
|
||||
if (index == 0) {
|
||||
return {isMirrored() ? zone.x : zone.x + zone.w / 2, zone.y,zone.w / 2, zone.h};
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "sliders.h"
|
||||
#include "trims.h"
|
||||
|
||||
constexpr coord_t border = 10;
|
||||
|
||||
const uint8_t LBM_LAYOUT_2x1[] = {
|
||||
#include "mask_layout2x1.lbm"
|
||||
};
|
||||
@@ -48,7 +46,7 @@ class Layout2x1: public Layout
|
||||
|
||||
rect_t getZone(unsigned int index) const override
|
||||
{
|
||||
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});
|
||||
rect_t zone = getMainZone();
|
||||
|
||||
if (index == 0) {
|
||||
return {isMirrored() ? zone.x + zone.w / 2 : zone.x, zone.y, zone.w / 2, zone.h};
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "sliders.h"
|
||||
#include "trims.h"
|
||||
|
||||
constexpr coord_t border = 10;
|
||||
|
||||
const uint8_t LBM_LAYOUT_2x2[] = {
|
||||
#include "mask_layout2x2.lbm"
|
||||
};
|
||||
@@ -48,7 +46,7 @@ class Layout2x2: public Layout
|
||||
|
||||
rect_t getZone(unsigned int index) const override
|
||||
{
|
||||
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});
|
||||
rect_t zone = getMainZone();
|
||||
|
||||
zone.w /= 2;
|
||||
zone.h /= 2;
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
constexpr coord_t border = 10;
|
||||
|
||||
const uint8_t LBM_LAYOUT_2x4[] = {
|
||||
#include "mask_layout2x4.lbm"
|
||||
};
|
||||
@@ -67,7 +65,7 @@ class Layout2x4: public Layout
|
||||
|
||||
rect_t getZone(unsigned int index) const override
|
||||
{
|
||||
rect_t zone = getMainZone({border, border, LCD_W - 2 * border, LCD_H - 2 * border});
|
||||
rect_t zone = getMainZone();
|
||||
|
||||
zone.w /= 2;
|
||||
zone.h /= 4;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "layouts/trims.h"
|
||||
#include "opentx.h"
|
||||
|
||||
constexpr coord_t MAIN_ZONE_BORDER = 10;
|
||||
|
||||
Layout * customScreens[MAX_CUSTOM_SCREENS] = {};
|
||||
|
||||
int getMainViewsCount()
|
||||
@@ -239,6 +241,20 @@ void ViewMain::adjustDecoration()
|
||||
//TODO: find a proper place for the flight-mode text box
|
||||
}
|
||||
|
||||
rect_t ViewMain::getMainZone() const
|
||||
{
|
||||
rect_t zone = {
|
||||
trims[TRIMS_LV]->right() + MAIN_ZONE_BORDER,
|
||||
topbar->bottom() + MAIN_ZONE_BORDER,
|
||||
0, 0 // let's compute them!
|
||||
};
|
||||
|
||||
zone.w = trims[TRIMS_RV]->left() - MAIN_ZONE_BORDER - zone.x;
|
||||
zone.h = trims[TRIMS_LH]->top() - MAIN_ZONE_BORDER - zone.y;
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void ViewMain::onEvent(event_t event)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,10 @@ class ViewMain: public FormWindow
|
||||
|
||||
// Re-calculate positions
|
||||
void adjustDecoration();
|
||||
|
||||
// Get the available space in the middle of the screen
|
||||
// (without decoration)
|
||||
rect_t getMainZone() const;
|
||||
|
||||
protected:
|
||||
static ViewMain * _instance;
|
||||
|
||||
Reference in New Issue
Block a user