From e2a6cdff15d98febb0396ce9bd1af582cf44b44d Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Mon, 13 Jun 2016 17:45:54 +0200 Subject: [PATCH] Kandinsky: Get rid of KDCoordinateMax Which is annoying to handle, because once you define it you have to bother with additions overflowing... Change-Id: I50b19858342c5a2909e3078f1a4167be50210db1 --- escher/include/escher/scroll_view.h | 1 + escher/src/scroll_view.cpp | 14 ++++++++------ kandinsky/include/kandinsky/types.h | 1 - kandinsky/src/drawing_area.c | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/escher/include/escher/scroll_view.h b/escher/include/escher/scroll_view.h index 3a7121fcd..0e9bed264 100644 --- a/escher/include/escher/scroll_view.h +++ b/escher/include/escher/scroll_view.h @@ -20,6 +20,7 @@ protected: virtual void logAttributes(std::ostream &os) const override; #endif private: + void setContentViewOrigin(); KDPoint m_offset; View * m_contentView; ScrollViewIndicator m_verticalScrollIndicator; diff --git a/escher/src/scroll_view.cpp b/escher/src/scroll_view.cpp index 95c3ade1c..8c5314845 100644 --- a/escher/src/scroll_view.cpp +++ b/escher/src/scroll_view.cpp @@ -51,12 +51,7 @@ void ScrollView::layoutSubviews() { m_verticalScrollIndicator.setFrame(verticalIndicatorFrame); // Layout contentview - KDRect contentFrame; - contentFrame.origin = m_offset; - //contentFrame.size = m_contentView->bounds().size; - contentFrame.width = KDCoordinateMax; - contentFrame.height = KDCoordinateMax; - m_contentView->setFrame(contentFrame); + setContentViewOrigin(); } void ScrollView::setContentOffset(KDPoint offset) { @@ -72,6 +67,13 @@ void ScrollView::setContentOffset(KDPoint offset) { markAsNeedingRedraw(); } +void ScrollView::setContentViewOrigin() { + KDRect contentFrame; + contentFrame.origin = m_offset; + contentFrame.size = m_contentView->bounds().size; + m_contentView->setFrame(contentFrame); +} + #if ESCHER_VIEW_LOGGING const char * ScrollView::className() const { return "ScrollView"; diff --git a/kandinsky/include/kandinsky/types.h b/kandinsky/include/kandinsky/types.h index f8bd6d8b2..40aa3cafb 100644 --- a/kandinsky/include/kandinsky/types.h +++ b/kandinsky/include/kandinsky/types.h @@ -4,7 +4,6 @@ #include typedef int16_t KDCoordinate; -#define KDCoordinateMax ((KDCoordinate)((1<<15)-1)) typedef struct { KDCoordinate x; diff --git a/kandinsky/src/drawing_area.c b/kandinsky/src/drawing_area.c index 4f871ad66..6b95e00f0 100644 --- a/kandinsky/src/drawing_area.c +++ b/kandinsky/src/drawing_area.c @@ -1,10 +1,11 @@ #include +#include KDRect KDDrawingArea = { .x = 0, .y = 0, - .width = KDCoordinateMax, - .height = KDCoordinateMax + .width = ION_SCREEN_WIDTH, + .height = ION_SCREEN_HEIGHT }; void KDSetDrawingArea(KDRect rect) {