From bf9994387d3201f3d63f85f2b34637f2c48af672 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 4 Jan 2016 17:48:56 -0300 Subject: [PATCH 1/5] Add some gfx::Region operators --- src/gfx/region.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gfx/region.h b/src/gfx/region.h index 78e87a731..8678b22c0 100644 --- a/src/gfx/region.h +++ b/src/gfx/region.h @@ -1,5 +1,5 @@ // Aseprite Gfx Library -// Copyright (C) 2001-2013, 2015 David Capello +// Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -99,6 +99,11 @@ namespace gfx { Rect operator[](int i); const Rect operator[](int i) const; + Region& operator+=(const Region& b) { return createUnion(*this, b); } + Region& operator|=(const Region& b) { return createUnion(*this, b); } + Region& operator&=(const Region& b) { return createIntersection(*this, b); } + Region& operator-=(const Region& b) { return createSubtraction(*this, b); } + private: mutable details::Region m_region; }; From 3bad2af2f3b8a8f5d66f6e4fc4781bf490290644 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 4 Jan 2016 17:49:40 -0300 Subject: [PATCH 2/5] Make Widget::offsetWidgets() function public --- src/ui/widget.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ui/widget.h b/src/ui/widget.h index 0d48ac78b..28c0742fb 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2001-2015 David Capello +// Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -246,6 +246,7 @@ namespace ui { // onResize() and want to change the size of the widget without // generating recursive onResize() events. void setBoundsQuietly(const gfx::Rect& rc); + void offsetWidgets(int dx, int dy); const gfx::Size& minSize() const { return m_minSize; } const gfx::Size& maxSize() const { return m_maxSize; } @@ -349,8 +350,6 @@ namespace ui { int mnemonicChar() const; protected: - void offsetWidgets(int dx, int dy); - // =============================================================== // MESSAGE PROCESSING // =============================================================== From e64cc958cee8927be72e5db8a9320160990f3975 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 4 Jan 2016 17:50:21 -0300 Subject: [PATCH 3/5] Minor change/renames in Widget::flushRedraw() --- src/ui/widget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index f5276aca9..3ebcea223 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -894,9 +894,9 @@ void Widget::flushRedraw() if (!widget->m_updateRegion.isEmpty()) { // Intersect m_updateRegion with drawable area. { - Region region; - widget->getDrawableRegion(region, kCutTopWindows); - widget->m_updateRegion.createIntersection(widget->m_updateRegion, region); + Region drawable; + widget->getDrawableRegion(drawable, kCutTopWindows); + widget->m_updateRegion &= drawable; } std::size_t c, nrects = widget->m_updateRegion.size(); From 1260cf12c5627fe0cd02e53a843fdc342e25ebf8 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 5 Jan 2016 16:28:54 -0300 Subject: [PATCH 4/5] Minor comment changes in widget.h --- src/ui/widget.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ui/widget.h b/src/ui/widget.h index 28c0742fb..092290b5c 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -297,12 +297,13 @@ namespace ui { void invalidateRect(const gfx::Rect& rect); void invalidateRegion(const gfx::Region& region); - // Returns the invalid region to being updated with PaintMessages - // and onPaint() events. + // Returns the region to generate PaintMessages. It's cleared + // after flushRedraw() is called. const gfx::Region& getUpdateRegion() const { return m_updateRegion; } + // Generates paint messages for the current update region. void flushRedraw(); void scrollRegion(const gfx::Region& region, const gfx::Point& delta); From b0650f6afea1b860a8593fd4614ca272f8edbfac Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 5 Jan 2016 16:37:52 -0300 Subject: [PATCH 5/5] Generalize View::setViewScroll() to blit valid/scrollable region automatically With this change we are removing specific code to scroll the Editor widget. Now if we use Editor::setEditorScroll() to scroll it should work as View::setViewScroll(). In this way we remove the ugly "blitValidRegion" parameter from setEditorScroll(). Changes: * Removed Widget::scrollRegion() because each widget must control valid/invalid regions after a ui::move_region() in a very specific way (see View::setViewScroll() or Window::moveWindow) * Invalidate the whole widget on Widget::setBoundsQuietly() * Fixed problems blitting invalid regions/not yet updated/painted: using the new ui::Manager::m_invalidRegion. * Added View::onSetViewScroll() and View::onScrollRegion() * Added FileListView to avoid moving the thumbnail region when we scroll --- data/widgets/file_selector.xml | 4 +- src/app/CMakeLists.txt | 3 +- src/app/commands/cmd_scroll.cpp | 2 +- src/app/ui/editor/drawing_state.cpp | 2 +- src/app/ui/editor/editor.cpp | 51 ++---- src/app/ui/editor/editor.h | 5 +- src/app/ui/editor/editor_view.cpp | 31 +++- src/app/ui/editor/editor_view.h | 4 +- src/app/ui/editor/moving_pixels_state.cpp | 2 +- src/app/ui/editor/scrolling_state.cpp | 4 +- .../ui/editor/state_with_wheel_behavior.cpp | 2 +- src/app/ui/file_list.cpp | 64 ++++--- src/app/ui/file_list.h | 10 +- src/app/ui/file_list_view.cpp | 35 ++++ src/app/ui/file_list_view.h | 26 +++ src/app/ui/file_selector.cpp | 9 +- src/app/ui/file_selector.h | 4 +- src/ui/manager.cpp | 7 + src/ui/manager.h | 16 +- src/ui/scroll_region_event.h | 30 ++++ src/ui/view.cpp | 166 ++++++++++++++++-- src/ui/view.h | 5 +- src/ui/widget.cpp | 39 +--- src/ui/widget.h | 2 - 24 files changed, 395 insertions(+), 128 deletions(-) create mode 100644 src/app/ui/file_list_view.cpp create mode 100644 src/app/ui/file_list_view.h create mode 100644 src/ui/scroll_region_event.h diff --git a/data/widgets/file_selector.xml b/data/widgets/file_selector.xml index ccaa28861..8fc3b7cd1 100644 --- a/data/widgets/file_selector.xml +++ b/data/widgets/file_selector.xml @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@