This commit is contained in:
Raphael Coeffic
2021-04-18 07:58:27 +02:00
parent ceb2a50f76
commit e8829d862f
4 changed files with 34 additions and 18 deletions
+11 -2
View File
@@ -43,9 +43,18 @@ rect_t TopBar::getZone(unsigned int index) const
}; };
} }
void TopBar::setVisible(bool visible) void TopBar::setVisible(float visible) // 0.0 -> 1.0
{ {
setHeight(visible ? MENU_HEADER_HEIGHT : 0); if (visible == 0.0) {
setTop(-(int)MENU_HEADER_HEIGHT);
}
else if (visible == 1.0) {
setTop(0);
}
else if (visible > 0.0 && visible < 1.0){
float top = - (float)MENU_HEADER_HEIGHT * (1.0 - visible);
setTop((coord_t)top);
}
} }
const char * const STR_MONTHS[] = TR_MONTHS; const char * const STR_MONTHS[] = TR_MONTHS;
+1 -1
View File
@@ -45,7 +45,7 @@ class TopBar: public WidgetsContainer<MAX_TOPBAR_ZONES, MAX_TOPBAR_OPTIONS>
rect_t getZone(unsigned int index) const override; rect_t getZone(unsigned int index) const override;
void setVisible(bool visible); void setVisible(float visible);
void paint(BitmapBuffer * dc) override; void paint(BitmapBuffer * dc) override;
+20 -13
View File
@@ -72,7 +72,7 @@ ViewMain::~ViewMain()
{ {
} }
void ViewMain::setTopbarVisible(bool visible) void ViewMain::setTopbarVisible(float visible)
{ {
topbar->setVisible(visible); topbar->setVisible(visible);
} }
@@ -98,8 +98,9 @@ coord_t ViewMain::getMainViewLeftPos(unsigned view) const
rect_t ViewMain::getMainZone(rect_t zone) const rect_t ViewMain::getMainZone(rect_t zone) const
{ {
zone.y += topbar->bottom(); auto visibleHeight = topbar->bottom() - zone.y;
zone.h -= topbar->height(); zone.y += visibleHeight;
zone.h -= visibleHeight;
return zone; return zone;
} }
@@ -142,16 +143,22 @@ void ViewMain::setScrollPositionX(coord_t value)
Window::setScrollPositionX(value); Window::setScrollPositionX(value);
topbar->setLeft(getScrollPositionX()); topbar->setLeft(getScrollPositionX());
auto pageIdx = getPageIndex(); auto newIdx = getPageIndex();
if (pageIdx != g_model.view) { if (newIdx != g_model.view) {
g_model.view = pageIdx;
if (customScreens[pageIdx]) { auto oldIdx = g_model.view;
// crude on/off for now // auto hadTopbar = customScreens[oldIdx]->hasTopbar();
setTopbarVisible(customScreens[pageIdx]->hasTopbar()); // auto willHaveTopbar = customScreens[newIdx]->hasTopbar();
customScreens[pageIdx]->decorate();
//TODO: compute topbar visibility // update current view
//auto relativeScrollPosition = getScrollPositionX() % pageWidth; g_model.view = newIdx;
}
// crude on/off for now
setTopbarVisible(customScreens[pageIdx]->hasTopbar());
customScreens[pageIdx]->decorate();
//TODO: compute topbar visibility
//auto relativeScrollPosition = getScrollPositionX() % pageWidth;
} }
} }
+2 -2
View File
@@ -50,8 +50,8 @@ class ViewMain: public Window
} }
#endif #endif
// Set topbar visibility // Set topbar visibility [0.0 -> 1.0]
void setTopbarVisible(bool visible); void setTopbarVisible(float visible);
// Get the available space in the middle of the screen // Get the available space in the middle of the screen
// (without topbar) // (without topbar)