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