Topbar visibility works now on start as well (no matter the configured screens)

This commit is contained in:
Raphael Coeffic
2021-04-18 07:58:27 +02:00
parent 50d6e113f2
commit e3b1a84343
3 changed files with 17 additions and 11 deletions
+5 -1
View File
@@ -106,6 +106,8 @@ void loadDefaultLayout()
void loadCustomScreens() void loadCustomScreens()
{ {
unsigned i = 0; unsigned i = 0;
auto viewMain = ViewMain::instance();
while (i < MAX_CUSTOM_SCREENS) { while (i < MAX_CUSTOM_SCREENS) {
auto& screen = customScreens[i]; auto& screen = customScreens[i];
@@ -118,12 +120,14 @@ void loadCustomScreens()
} }
// layout is ok, let's add it // layout is ok, let's add it
auto viewMain = ViewMain::instance();
screen->attach(viewMain); screen->attach(viewMain);
viewMain->setMainViewsCount(i + 1); viewMain->setMainViewsCount(i + 1);
screen->setLeft(viewMain->getMainViewLeftPos(i)); screen->setLeft(viewMain->getMainViewLeftPos(i));
i++; i++;
} }
viewMain->setCurrentMainView(0);
viewMain->setTopbarVisible(customScreens[0]->hasTopbar());
} }
// //
+7 -5
View File
@@ -145,11 +145,13 @@ void ViewMain::setScrollPositionX(coord_t value)
auto pageIdx = getPageIndex(); auto pageIdx = getPageIndex();
if (pageIdx != g_model.view) { if (pageIdx != g_model.view) {
g_model.view = pageIdx; g_model.view = pageIdx;
// crude on/off for now if (customScreens[pageIdx]) {
setTopbarVisible(customScreens[pageIdx]->hasTopbar()); // crude on/off for now
customScreens[pageIdx]->decorate(); setTopbarVisible(customScreens[pageIdx]->hasTopbar());
//TODO: compute topbar visibility customScreens[pageIdx]->decorate();
//auto relativeScrollPosition = getScrollPositionX() % pageWidth; //TODO: compute topbar visibility
//auto relativeScrollPosition = getScrollPositionX() % pageWidth;
}
} }
} }
+5 -5
View File
@@ -62,6 +62,11 @@ class ViewMain: public Window
coord_t getMainViewLeftPos(unsigned view) const; coord_t getMainViewLeftPos(unsigned view) const;
unsigned getCurrentMainView() const;
void setCurrentMainView(unsigned view);
void nextMainView();
void previousMainView();
protected: protected:
static ViewMain * _instance; static ViewMain * _instance;
@@ -70,11 +75,6 @@ class ViewMain: public Window
friend class SetupWidgetsPage; friend class SetupWidgetsPage;
unsigned getCurrentMainView() const;
void setCurrentMainView(unsigned view);
void nextMainView();
void previousMainView();
void setScrollPositionX(coord_t value) override; void setScrollPositionX(coord_t value) override;
void setScrollPositionY(coord_t value) override; void setScrollPositionY(coord_t value) override;