Merge pull request #624 from EdgeTX/pfeerick/issue372

More layouts
This commit is contained in:
Peter Feerick
2021-08-25 08:04:49 +10:00
committed by GitHub
9 changed files with 268 additions and 6 deletions
@@ -0,0 +1,70 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "layout.h"
#include "layout_factory_impl.h"
const uint8_t LBM_LAYOUT_1P3[] = {
#include "mask_layout1+3.lbm"
};
const ZoneOption OPTIONS_LAYOUT_1P3[] = {
LAYOUT_COMMON_OPTIONS,
LAYOUT_OPTIONS_END
};
class Layout1P3: public Layout
{
public:
Layout1P3(const LayoutFactory * factory, Layout::PersistentData * persistentData):
Layout(factory, persistentData)
{
}
unsigned int getZonesCount() const override
{
return 4;
}
rect_t getZone(unsigned int index) const override
{
rect_t zone = getMainZone();
zone.w /= 2;
if (index == 0) {
if (isMirrored()) {
zone.x += zone.w;
}
} else {
index--;
zone.h /= 3;
zone.y += zone.h * (int)index;
if (!isMirrored()) {
zone.x += zone.w;
}
}
return zone;
}
};
BaseLayoutFactory<Layout1P3> Layout1P3("Layout1P3", "1 + 3", LBM_LAYOUT_1P3, OPTIONS_LAYOUT_1P3);
+2 -6
View File
@@ -48,12 +48,8 @@ class Layout1x2: public Layout
{
rect_t zone = getMainZone();
if (index == 0) {
return {zone.x, zone.y, zone.w, zone.h / 2};
}
else {
return {zone.x, zone.y + zone.h / 2, zone.w, zone.h / 2};
}
zone.h /= 2;
zone.y += zone.h * index;
return zone;
}
@@ -0,0 +1,58 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "layout.h"
#include "layout_factory_impl.h"
const uint8_t LBM_LAYOUT_1x3[] = {
#include "mask_layout1x3.lbm"
};
const ZoneOption OPTIONS_LAYOUT_1x3[] = {
LAYOUT_COMMON_OPTIONS,
LAYOUT_OPTIONS_END
};
class Layout1x3: public Layout
{
public:
Layout1x3(const LayoutFactory * factory, Layout::PersistentData * persistentData):
Layout(factory, persistentData)
{
}
unsigned int getZonesCount() const override
{
return 3;
}
rect_t getZone(unsigned int index) const override
{
rect_t zone = getMainZone();
zone.h /= 3;
zone.y += zone.h * index;
return zone;
}
};
BaseLayoutFactory<Layout1x3> Layout1x3("Layout1x3", "1 x 3", LBM_LAYOUT_1x3, OPTIONS_LAYOUT_1x3);
@@ -0,0 +1,72 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "layout.h"
#include "layout_factory_impl.h"
const uint8_t LBM_LAYOUT_2P3[] = {
#include "mask_layout2+3.lbm"
};
const ZoneOption OPTIONS_LAYOUT_2P3[] = {
LAYOUT_COMMON_OPTIONS,
LAYOUT_OPTIONS_END
};
class Layout2P3: public Layout
{
public:
Layout2P3(const LayoutFactory * factory, Layout::PersistentData * persistentData):
Layout(factory, persistentData)
{
}
unsigned int getZonesCount() const override
{
return 5;
}
rect_t getZone(unsigned int index) const override
{
rect_t zone = getMainZone();
zone.w /= 2;
if (index == 0 || index == 1) {
zone.h /= 2;
if (index == 1) zone.y += zone.h;
if (isMirrored()) {
zone.x += zone.w;
}
} else {
index -= 2;
zone.h /= 3;
zone.y += zone.h * (int)index;
if (!isMirrored()) {
zone.x += zone.w;
}
}
return zone;
}
};
BaseLayoutFactory<Layout2P3> Layout2P3("Layout2P3", "2 + 3", LBM_LAYOUT_2P3, OPTIONS_LAYOUT_2P3);
@@ -0,0 +1,66 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "layout.h"
#include "layout_factory_impl.h"
const uint8_t LBM_LAYOUT_2x3[] = {
#include "mask_layout2x3.lbm"
};
const ZoneOption OPTIONS_LAYOUT_2x3[] = {
LAYOUT_COMMON_OPTIONS,
LAYOUT_OPTIONS_END
};
class Layout2x3: public Layout
{
public:
Layout2x3(const LayoutFactory * factory, Layout::PersistentData * persistentData):
Layout(factory, persistentData)
{
}
unsigned int getZonesCount() const override
{
return 6;
}
rect_t getZone(unsigned int index) const override
{
rect_t zone = getMainZone();
zone.w /= 2;
zone.h /= 3;
if (index == 1 || index == 3)
zone.y += zone.h;
else if (index == 2 || index == 4)
zone.y += zone.h * 2;
if ((!isMirrored() && index > 2) || (isMirrored() && index < 3))
zone.x += zone.w;
return zone;
}
};
BaseLayoutFactory<Layout2x3> layout2x3("Layout2x3", "2 x 3", LBM_LAYOUT_2x3, OPTIONS_LAYOUT_2x3);
Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B