From 9789a9d8eaaf8174b47bfdd130621964c63f1b08 Mon Sep 17 00:00:00 2001 From: philmoz Date: Sat, 6 Jul 2024 06:55:12 +1000 Subject: [PATCH] fix(color): restore previous 'Fullscreen' functionality and add new 'App mode' layout (#5248) Co-authored-by: philmoz --- .../gui/colorlcd/layouts/layout1x1AppMode.cpp | 52 +++++++++++++++++++ .../colorlcd/layouts/layout_factory_impl.h | 14 ++--- radio/src/gui/colorlcd/view_main.cpp | 3 +- radio/src/storage/storage_common.cpp | 5 ++ 4 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 radio/src/gui/colorlcd/layouts/layout1x1AppMode.cpp diff --git a/radio/src/gui/colorlcd/layouts/layout1x1AppMode.cpp b/radio/src/gui/colorlcd/layouts/layout1x1AppMode.cpp new file mode 100644 index 000000000..7ae0cd230 --- /dev/null +++ b/radio/src/gui/colorlcd/layouts/layout1x1AppMode.cpp @@ -0,0 +1,52 @@ +/* + * 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 ZoneOption OPTIONS_LAYOUT_APPMODE[] = {LAYOUT_OPTIONS_END}; + +class LayoutAppMode : public Layout +{ + public: + LayoutAppMode(Window* parent, const LayoutFactory* factory, + Layout::PersistentData* persistentData, uint8_t zoneCount, + uint8_t* zoneMap) : + Layout(parent, factory, persistentData, zoneCount, zoneMap) + { + } + + bool hasTopbar() const override { return false; } + bool hasFlightMode() const override { return false; } + bool hasSliders() const override { return false; } + bool hasTrims() const override { return false; } + bool isMirrored() const override { return false; } + bool isAppMode() const override { return true; } + + protected: +}; + +static const uint8_t zmap[] = { + LAYOUT_MAP_0, LAYOUT_MAP_0, LAYOUT_MAP_FULL, LAYOUT_MAP_FULL, +}; + +BaseLayoutFactory layoutAppMode("Layout1x1AM", "App mode", OPTIONS_LAYOUT_APPMODE, + 1, (uint8_t*)zmap); diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h index 022c5b41d..5ff0f3adb 100644 --- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.h +++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.h @@ -78,26 +78,28 @@ class Layout: public LayoutBase return factory; } - bool hasTopbar() const { + virtual bool hasTopbar() const { return ((uint8_t*)(&getOptionValue(LAYOUT_OPTION_TOPBAR)->boolValue))[0]; } - bool hasFlightMode() const { + virtual bool hasFlightMode() const { return ((uint8_t*)(&getOptionValue(LAYOUT_OPTION_FM)->boolValue))[0]; } - bool hasSliders() const { + virtual bool hasSliders() const { return ((uint8_t*)(&getOptionValue(LAYOUT_OPTION_SLIDERS)->boolValue))[0]; } - bool hasTrims() const { + virtual bool hasTrims() const { return ((uint8_t*)(&getOptionValue(LAYOUT_OPTION_TRIMS)->boolValue))[0]; } - bool isMirrored() const { + virtual bool isMirrored() const { return ((uint8_t*)(&getOptionValue(LAYOUT_OPTION_MIRRORED)->boolValue))[0]; } + virtual bool isAppMode() const { return false; } + // Set decoration visibility void setTrimsVisible(bool visible); void setSlidersVisible(bool visible); @@ -108,8 +110,6 @@ class Layout: public LayoutBase void show(bool visible = true) override; bool isLayout() override { return true; } - - bool isAppMode() { return decorationSettings == DECORATION_NONE && zoneCount == 1; } static LAYOUT_VAL(MAIN_ZONE_BORDER, 10, 10) diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 3ff1c8c77..bc0271f32 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -353,10 +353,11 @@ bool ViewMain::onLongPress() void ViewMain::show(bool visible) { + if (deleted()) return; isVisible = visible; int view = getCurrentMainView(); setTopbarVisible(visible && ::hasTopbar(view)); - if (visible) + if (visible && (::hasTopbar(view) || isAppMode())) topbar->showEdgeTxButton(); else topbar->hideEdgeTxButton(); diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp index 6e1ea7139..65ed4e83e 100644 --- a/radio/src/storage/storage_common.cpp +++ b/radio/src/storage/storage_common.cpp @@ -25,6 +25,10 @@ #include "mixes.h" #include "switches.h" +#if defined(COLORLCD) +#include "view_main.h" +#endif + #if defined(USBJ_EX) #include "usb_joystick.h" #endif @@ -281,6 +285,7 @@ if(g_model.rssiSource) { #if defined(COLORLCD) LayoutFactory::loadCustomScreens(); + ViewMain::instance()->show(true); #else LOAD_MODEL_BITMAP(); #endif