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