Merge with latest libopenui changes
This commit is contained in:
-10
@@ -104,16 +104,6 @@ class FormGroup: public FormField {
|
|||||||
|
|
||||||
void addField(FormField * field);
|
void addField(FormField * field);
|
||||||
|
|
||||||
inline FormField * getFirstField()
|
|
||||||
{
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FormField * getLastField()
|
|
||||||
{
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FormField * first = nullptr;
|
FormField * first = nullptr;
|
||||||
FormField * last = nullptr;
|
FormField * last = nullptr;
|
||||||
|
|||||||
+29
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
#include "touch.h"
|
||||||
|
|
||||||
Window * Window::focusWindow = nullptr;
|
Window * Window::focusWindow = nullptr;
|
||||||
std::list<Window *> Window::trash;
|
std::list<Window *> Window::trash;
|
||||||
@@ -154,13 +155,18 @@ void Window::setScrollPositionY(coord_t value)
|
|||||||
|
|
||||||
void Window::scrollTo(Window * child)
|
void Window::scrollTo(Window * child)
|
||||||
{
|
{
|
||||||
|
coord_t offsetX = 0;
|
||||||
coord_t offsetY = 0;
|
coord_t offsetY = 0;
|
||||||
|
|
||||||
Window * parent = child->getParent();
|
Window * parent = child->getParent();
|
||||||
while (parent && parent != this) {
|
while (parent && parent != this) {
|
||||||
|
offsetX += parent->left();
|
||||||
offsetY += parent->top();
|
offsetY += parent->top();
|
||||||
parent = parent->getParent();
|
parent = parent->getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coord_t left = offsetX + child->left();
|
||||||
|
coord_t right = offsetX + child->right();
|
||||||
coord_t top = offsetY + child->top();
|
coord_t top = offsetY + child->top();
|
||||||
coord_t bottom = offsetY + child->bottom();
|
coord_t bottom = offsetY + child->bottom();
|
||||||
|
|
||||||
@@ -170,6 +176,13 @@ void Window::scrollTo(Window * child)
|
|||||||
else if (bottom > scrollPositionY + height() - 5) {
|
else if (bottom > scrollPositionY + height() - 5) {
|
||||||
setScrollPositionY(bottom - 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)
|
void Window::fullPaint(BitmapBuffer * dc)
|
||||||
@@ -275,6 +288,22 @@ void Window::checkEvents()
|
|||||||
if (windowFlags & REFRESH_ALWAYS) {
|
if (windowFlags & REFRESH_ALWAYS) {
|
||||||
invalidate();
|
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)
|
void Window::onEvent(event_t event)
|
||||||
|
|||||||
+14
-5
@@ -164,11 +164,6 @@ class Window {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
coord_t getHeight()
|
|
||||||
{
|
|
||||||
return rect.h;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLeft(coord_t x)
|
void setLeft(coord_t x)
|
||||||
{
|
{
|
||||||
rect.x = 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)
|
void setInnerHeight(coord_t h)
|
||||||
{
|
{
|
||||||
innerHeight = h;
|
innerHeight = h;
|
||||||
@@ -312,6 +320,7 @@ class Window {
|
|||||||
rect_t rect;
|
rect_t rect;
|
||||||
coord_t innerWidth;
|
coord_t innerWidth;
|
||||||
coord_t innerHeight;
|
coord_t innerHeight;
|
||||||
|
coord_t pageWidth = 0;
|
||||||
coord_t scrollPositionX = 0;
|
coord_t scrollPositionX = 0;
|
||||||
coord_t scrollPositionY = 0;
|
coord_t scrollPositionY = 0;
|
||||||
WindowFlags windowFlags;
|
WindowFlags windowFlags;
|
||||||
|
|||||||
Reference in New Issue
Block a user