Merge with latest libopenui changes

This commit is contained in:
Bertrand Songis
2019-10-23 14:49:04 +02:00
parent 303bb7e381
commit 7296241db0
3 changed files with 43 additions and 15 deletions
-10
View File
@@ -104,16 +104,6 @@ class FormGroup: public FormField {
void addField(FormField * field);
inline FormField * getFirstField()
{
return first;
}
inline FormField * getLastField()
{
return last;
}
protected:
FormField * first = nullptr;
FormField * last = nullptr;
+29
View File
@@ -18,6 +18,7 @@
*/
#include "window.h"
#include "touch.h"
Window * Window::focusWindow = nullptr;
std::list<Window *> Window::trash;
@@ -154,13 +155,18 @@ void Window::setScrollPositionY(coord_t value)
void Window::scrollTo(Window * child)
{
coord_t offsetX = 0;
coord_t offsetY = 0;
Window * parent = child->getParent();
while (parent && parent != this) {
offsetX += parent->left();
offsetY += parent->top();
parent = parent->getParent();
}
coord_t left = offsetX + child->left();
coord_t right = offsetX + child->right();
coord_t top = offsetY + child->top();
coord_t bottom = offsetY + child->bottom();
@@ -170,6 +176,13 @@ void Window::scrollTo(Window * child)
else if (bottom > scrollPositionY + height() - 5) {
setScrollPositionY(bottom - height() + 5);
}
if (left < scrollPositionX) {
setScrollPositionX(pageWidth ? left - (left % pageWidth) : left - 5);
}
else if (right > scrollPositionX + width() - 5) {
setScrollPositionX(pageWidth ? left - (left % pageWidth) : right - width() + 5);
}
}
void Window::fullPaint(BitmapBuffer * dc)
@@ -275,6 +288,22 @@ void Window::checkEvents()
if (windowFlags & REFRESH_ALWAYS) {
invalidate();
}
#if defined(HARDWARE_TOUCH)
if (pageWidth && touchState.event != TE_SLIDE) {
coord_t relativeScrollPosition = scrollPositionX % pageWidth;
if (relativeScrollPosition) {
if (relativeScrollPosition > pageWidth / 2) {
setScrollPositionX(getScrollPositionX() - relativeScrollPosition + pageWidth);
invalidate();
}
else {
setScrollPositionX(getScrollPositionX() - relativeScrollPosition);
invalidate();
}
}
}
#endif
}
void Window::onEvent(event_t event)
+14 -5
View File
@@ -164,11 +164,6 @@ class Window {
invalidate();
}
coord_t getHeight()
{
return rect.h;
}
void setLeft(coord_t x)
{
rect.x = x;
@@ -224,6 +219,19 @@ class Window {
}
}
void setPageWidth(coord_t w)
{
pageWidth = w;
}
uint8_t getPageIndex()
{
if (pageWidth)
return (getScrollPositionX() + (pageWidth / 2)) / pageWidth;
else
return 0;
}
void setInnerHeight(coord_t h)
{
innerHeight = h;
@@ -312,6 +320,7 @@ class Window {
rect_t rect;
coord_t innerWidth;
coord_t innerHeight;
coord_t pageWidth = 0;
coord_t scrollPositionX = 0;
coord_t scrollPositionY = 0;
WindowFlags windowFlags;