feat(color): initial full screen widget "app mode" (#4655)
This commit is contained in:
@@ -109,6 +109,8 @@ class Layout: public LayoutBase
|
|||||||
|
|
||||||
bool isLayout() override { return true; }
|
bool isLayout() override { return true; }
|
||||||
|
|
||||||
|
bool isAppMode() { return decorationSettings == DECORATION_NONE && zoneCount == 1; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const LayoutFactory * factory = nullptr;
|
const LayoutFactory * factory = nullptr;
|
||||||
std::unique_ptr<ViewMainDecoration> decoration;
|
std::unique_ptr<ViewMainDecoration> decoration;
|
||||||
|
|||||||
@@ -22,15 +22,30 @@
|
|||||||
#include "topbar_impl.h"
|
#include "topbar_impl.h"
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
#include "view_main.h"
|
||||||
|
|
||||||
constexpr uint32_t TOPBAR_REFRESH = 1000 / 10; // 10 Hz
|
constexpr uint32_t TOPBAR_REFRESH = 1000 / 10; // 10 Hz
|
||||||
|
|
||||||
|
class TopBarEdgeTx : public HeaderIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TopBarEdgeTx(Window* parent) : HeaderIcon(parent, ICON_EDGETX)
|
||||||
|
{
|
||||||
|
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onClicked() override
|
||||||
|
{
|
||||||
|
ViewMain::instance()->openMenu();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TopBar::TopBar(Window * parent) :
|
TopBar::TopBar(Window * parent) :
|
||||||
TopBarBase(parent, {0, 0, LCD_W, MENU_HEADER_HEIGHT}, &g_model.topbarData)
|
TopBarBase(parent, {0, 0, LCD_W, MENU_HEADER_HEIGHT}, &g_model.topbarData)
|
||||||
{
|
{
|
||||||
etx_solid_bg(lvobj, COLOR_THEME_SECONDARY1_INDEX);
|
etx_solid_bg(lvobj, COLOR_THEME_SECONDARY1_INDEX);
|
||||||
|
|
||||||
headerIcon = new HeaderIcon(this, ICON_EDGETX);
|
headerIcon = new TopBarEdgeTx(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int TopBar::getZonesCount() const
|
unsigned int TopBar::getZonesCount() const
|
||||||
@@ -82,6 +97,16 @@ coord_t TopBar::getVisibleHeight(float visible) const // 0.0 -> 1.0
|
|||||||
return (coord_t)h;
|
return (coord_t)h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TopBar::showEdgeTxButton()
|
||||||
|
{
|
||||||
|
headerIcon->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TopBar::hideEdgeTxButton()
|
||||||
|
{
|
||||||
|
headerIcon->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void TopBar::checkEvents()
|
void TopBar::checkEvents()
|
||||||
{
|
{
|
||||||
uint32_t now = RTOS_GET_MS();
|
uint32_t now = RTOS_GET_MS();
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ class TopBar: public TopBarBase
|
|||||||
|
|
||||||
void setVisible(float visible);
|
void setVisible(float visible);
|
||||||
coord_t getVisibleHeight(float visible) const; // 0.0 -> 1.0
|
coord_t getVisibleHeight(float visible) const; // 0.0 -> 1.0
|
||||||
|
void showEdgeTxButton();
|
||||||
|
void hideEdgeTxButton();
|
||||||
|
|
||||||
void checkEvents() override;
|
void checkEvents() override;
|
||||||
|
|
||||||
|
|||||||
@@ -107,10 +107,10 @@ void HeaderDateTime::setColor(uint32_t color)
|
|||||||
lv_obj_set_style_text_color(time, makeLvColor(color), LV_PART_MAIN);
|
lv_obj_set_style_text_color(time, makeLvColor(color), LV_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderIcon::HeaderIcon(Window* parent, EdgeTxIcon icon)
|
HeaderIcon::HeaderIcon(Window* parent, EdgeTxIcon icon) :
|
||||||
|
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS)
|
||||||
{
|
{
|
||||||
auto bg = new StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS);
|
(new StaticIcon(this, 0, 0, icon, COLOR_THEME_PRIMARY2))->center(width(), height());
|
||||||
(new StaticIcon(parent, 0, 0, icon, COLOR_THEME_PRIMARY2))->center(bg->width(), bg->height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbSDConnected::UsbSDConnected() :
|
UsbSDConnected::UsbSDConnected() :
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "bitmaps.h"
|
#include "bitmaps.h"
|
||||||
|
#include "static.h"
|
||||||
|
|
||||||
class BitmapBuffer;
|
class BitmapBuffer;
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ class HeaderDateTime
|
|||||||
int8_t lastMinute = -1;
|
int8_t lastMinute = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HeaderIcon
|
class HeaderIcon : public StaticIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HeaderIcon(Window *parent, EdgeTxIcon icon);
|
HeaderIcon(Window *parent, EdgeTxIcon icon);
|
||||||
|
|||||||
@@ -200,12 +200,12 @@ void ViewMain::updateTopbarVisibility()
|
|||||||
int leftScroll = scrollPos % width();
|
int leftScroll = scrollPos % width();
|
||||||
if (leftScroll == 0) {
|
if (leftScroll == 0) {
|
||||||
int view = scrollPos / pageWidth;
|
int view = scrollPos / pageWidth;
|
||||||
setTopbarVisible(hasTopbar(view));
|
setTopbarVisible(::hasTopbar(view));
|
||||||
if (customScreens[view]) customScreens[view]->adjustLayout();
|
if (customScreens[view]) customScreens[view]->adjustLayout();
|
||||||
} else {
|
} else {
|
||||||
int leftIdx = scrollPos / pageWidth;
|
int leftIdx = scrollPos / pageWidth;
|
||||||
bool leftTopbar = hasTopbar(leftIdx);
|
bool leftTopbar = ::hasTopbar(leftIdx);
|
||||||
bool rightTopbar = hasTopbar(leftIdx + 1);
|
bool rightTopbar = ::hasTopbar(leftIdx + 1);
|
||||||
|
|
||||||
if (leftTopbar != rightTopbar) {
|
if (leftTopbar != rightTopbar) {
|
||||||
float ratio = (float)leftScroll / (float)pageWidth;
|
float ratio = (float)leftScroll / (float)pageWidth;
|
||||||
@@ -342,32 +342,64 @@ void ViewMain::ws_timer(lv_timer_t* t)
|
|||||||
view->enableWidgetSelect(false);
|
view->enableWidgetSelect(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewMain::longPress()
|
||||||
|
{
|
||||||
|
if (isAppMode()) {
|
||||||
|
int view = getCurrentMainView();
|
||||||
|
customScreens[view]->getWidget(0)->setFullscreen(true);
|
||||||
|
} else {
|
||||||
|
enableWidgetSelect(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ViewMain::long_pressed(lv_event_t* e)
|
void ViewMain::long_pressed(lv_event_t* e)
|
||||||
{
|
{
|
||||||
auto obj = lv_event_get_target(e);
|
auto obj = lv_event_get_target(e);
|
||||||
auto view = (ViewMain*)lv_obj_get_user_data(obj);
|
// kill subsequent CLICKED event
|
||||||
if (!view) return;
|
lv_obj_clear_state(obj, LV_STATE_PRESSED);
|
||||||
|
lv_indev_wait_release(lv_indev_get_act());
|
||||||
|
|
||||||
if (view->enableWidgetSelect(true)) {
|
auto view = (ViewMain*)lv_obj_get_user_data(obj);
|
||||||
// kill subsequent CLICKED event
|
if (view) view->longPress();
|
||||||
lv_obj_clear_state(obj, LV_STATE_PRESSED);
|
|
||||||
lv_indev_wait_release(lv_indev_get_act());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewMain::show(bool visible)
|
void ViewMain::show(bool visible)
|
||||||
{
|
{
|
||||||
isVisible = visible;
|
isVisible = visible;
|
||||||
coord_t scrollPos = lv_obj_get_scroll_x(tile_view);
|
int view = getCurrentMainView();
|
||||||
coord_t pageWidth = width();
|
setTopbarVisible(visible && ::hasTopbar(view));
|
||||||
int view = scrollPos / pageWidth;
|
if (visible)
|
||||||
setTopbarVisible(visible && hasTopbar(view));
|
topbar->showEdgeTxButton();
|
||||||
|
else
|
||||||
|
topbar->hideEdgeTxButton();
|
||||||
if (customScreens[view]) {
|
if (customScreens[view]) {
|
||||||
customScreens[view]->show(visible);
|
customScreens[view]->show(visible);
|
||||||
customScreens[view]->showWidgets(visible);
|
customScreens[view]->showWidgets(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewMain::isAppMode()
|
||||||
|
{
|
||||||
|
int view = getCurrentMainView();
|
||||||
|
return ((Layout*)customScreens[view])->isAppMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ViewMain::hasTopbar()
|
||||||
|
{
|
||||||
|
int view = getCurrentMainView();
|
||||||
|
return ::hasTopbar(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewMain::showTopBarEdgeTxButton()
|
||||||
|
{
|
||||||
|
topbar->showEdgeTxButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewMain::hideTopBarEdgeTxButton()
|
||||||
|
{
|
||||||
|
topbar->hideEdgeTxButton();
|
||||||
|
}
|
||||||
|
|
||||||
void ViewMain::runBackground()
|
void ViewMain::runBackground()
|
||||||
{
|
{
|
||||||
topbar->runBackground();
|
topbar->runBackground();
|
||||||
|
|||||||
@@ -71,8 +71,15 @@ class ViewMain : public NavWindow
|
|||||||
|
|
||||||
void onClicked() override;
|
void onClicked() override;
|
||||||
void onCancel() override;
|
void onCancel() override;
|
||||||
|
void openMenu();
|
||||||
|
void longPress();
|
||||||
|
|
||||||
void show(bool visible = true) override;
|
void show(bool visible = true) override;
|
||||||
|
void showTopBarEdgeTxButton();
|
||||||
|
void hideTopBarEdgeTxButton();
|
||||||
|
|
||||||
|
bool hasTopbar();
|
||||||
|
bool isAppMode();
|
||||||
|
|
||||||
void runBackground();
|
void runBackground();
|
||||||
void refreshWidgetSelectTimer();
|
void refreshWidgetSelectTimer();
|
||||||
@@ -96,8 +103,6 @@ class ViewMain : public NavWindow
|
|||||||
// Set topbar visibility [0.0 -> 1.0]
|
// Set topbar visibility [0.0 -> 1.0]
|
||||||
void setTopbarVisible(float visible);
|
void setTopbarVisible(float visible);
|
||||||
|
|
||||||
void openMenu();
|
|
||||||
|
|
||||||
static void long_pressed(lv_event_t* e);
|
static void long_pressed(lv_event_t* e);
|
||||||
static void ws_timer(lv_timer_t* t);
|
static void ws_timer(lv_timer_t* t);
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ Widget::Widget(const WidgetFactory* factory, Window* parent, const rect_t& rect,
|
|||||||
|
|
||||||
void Widget::openMenu()
|
void Widget::openMenu()
|
||||||
{
|
{
|
||||||
|
if (fsAllowed && ViewMain::instance()->isAppMode())
|
||||||
|
{
|
||||||
|
setFullscreen(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getOptions() || fsAllowed) {
|
if (getOptions() || fsAllowed) {
|
||||||
// Widgets are placed on a full screen window which is underneath the main
|
// Widgets are placed on a full screen window which is underneath the main
|
||||||
// view menu bar Find the parent of this so that when the popup loads it
|
// view menu bar Find the parent of this so that when the popup loads it
|
||||||
@@ -138,8 +144,6 @@ void Widget::setFullscreen(bool enable)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::disableFullscreen() { fsAllowed = false; }
|
|
||||||
|
|
||||||
void Widget::onLongPress()
|
void Widget::onLongPress()
|
||||||
{
|
{
|
||||||
if (!fullscreen) ButtonBase::onLongPress();
|
if (!fullscreen) ButtonBase::onLongPress();
|
||||||
|
|||||||
@@ -76,10 +76,6 @@ class Widget : public ButtonBase
|
|||||||
// Set/unset fullscreen mode
|
// Set/unset fullscreen mode
|
||||||
void setFullscreen(bool enable);
|
void setFullscreen(bool enable);
|
||||||
|
|
||||||
// Disable setting fullscreen mode
|
|
||||||
void disableFullscreen();
|
|
||||||
bool isFullscreenAllowed() { return fsAllowed; }
|
|
||||||
|
|
||||||
// Called when the widget options have changed
|
// Called when the widget options have changed
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ SetupWidgetsPage::SetupWidgetsPage(uint8_t customScreenIdx) :
|
|||||||
auto viewMain = ViewMain::instance();
|
auto viewMain = ViewMain::instance();
|
||||||
savedView = viewMain->getCurrentMainView();
|
savedView = viewMain->getCurrentMainView();
|
||||||
viewMain->setCurrentMainView(customScreenIdx);
|
viewMain->setCurrentMainView(customScreenIdx);
|
||||||
|
if (!viewMain->hasTopbar()) viewMain->hideTopBarEdgeTxButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupWidgetsPageSlot* firstSlot = nullptr;
|
SetupWidgetsPageSlot* firstSlot = nullptr;
|
||||||
@@ -148,6 +149,7 @@ void SetupWidgetsPage::deleteLater(bool detach, bool trash)
|
|||||||
if (screen) {
|
if (screen) {
|
||||||
auto viewMain = ViewMain::instance();
|
auto viewMain = ViewMain::instance();
|
||||||
viewMain->setCurrentMainView(savedView);
|
viewMain->setCurrentMainView(savedView);
|
||||||
|
viewMain->showTopBarEdgeTxButton();
|
||||||
}
|
}
|
||||||
Window::deleteLater(detach, trash);
|
Window::deleteLater(detach, trash);
|
||||||
new ScreenMenu(customScreenIdx + 1);
|
new ScreenMenu(customScreenIdx + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user