diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-07 22:49:27 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-07 22:49:27 +0000 |
commit | f1954ba315f940c46402865763164bceb7537710 (patch) | |
tree | bdca666857e53cd34c4869880ffd4e8bd39c5d31 /NxWidgets | |
parent | 9bc51533db436502b50aaa0014aa272576968df2 (diff) | |
download | nuttx-f1954ba315f940c46402865763164bceb7537710.tar.gz nuttx-f1954ba315f940c46402865763164bceb7537710.tar.bz2 nuttx-f1954ba315f940c46402865763164bceb7537710.zip |
Big NxWidgets simplification. Remove all hierarch logic. Widgets now exist only in a two-dimensional plane
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4712 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets')
-rwxr-xr-x | NxWidgets/ChangeLog.txt | 6 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/Makefile | 6 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cnxwidget.hxx | 190 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/crectcache.hxx | 222 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx | 8 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx | 16 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx | 12 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cnxwidget.cxx | 619 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/crectcache.cxx | 521 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx | 39 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx | 34 |
11 files changed, 22 insertions, 1651 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index a160399a8..c9c17cc83 100755 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -35,3 +35,9 @@ window size is received. * CGraphicsPort and CWidgetControl: If the underlying graphics device is write-only, then we have to render fonts a little differently. +* CNxWidgets, CWidgetControl, and CRectCache: Big change! Remove all support + for widgets in a "vertical" hierarchy. Now widgets exist in a flat, + two-dimensional space and should not overlap. This should greatly + reduce the memory requirements and, since, NuttX already supports + a hierarchical windowing system, does not result in loss of functionality. + diff --git a/NxWidgets/libnxwidgets/Makefile b/NxWidgets/libnxwidgets/Makefile index 9a52087ed..b35039e01 100644 --- a/NxWidgets/libnxwidgets/Makefile +++ b/NxWidgets/libnxwidgets/Makefile @@ -44,9 +44,9 @@ CSRCS = CXXSRCS = cbitmap.cxx cbgwindow.cxx ccallback.cxx cgraphicsport.cxx CXXSRCS += clistdata.cxx clistdataitem.cxx cnxfont.cxx CXXSRCS += cnxserver.cxx cnxstring.cxx cnxtimer.cxx cnxwidget.cxx cnxwindow.cxx -CXXSRCS += cnxtkwindow.cxx cnxtoolbar.cxx crect.cxx crectcache.cxx -CXXSRCS += crlepalettebitmap.cxx cstringiterator.cxx ctext.cxx cwidgetcontrol.cxx -CXXSRCS += cwidgeteventhandlerlist.cxx singletons.cxx +CXXSRCS += cnxtkwindow.cxx cnxtoolbar.cxx crect.cxx crlepalettebitmap.cxx +CXXSRCS += cstringiterator.cxx ctext.cxx cwidgetcontrol.cxx cwidgeteventhandlerlist.cxx +CXXSRCS += singletons.cxx # Widget APIs CXXSRCS += cbutton.cxx cbuttonarray.cxx ccheckbox.cxx ccyclebutton.cxx CXXSRCS += cglyphbutton.cxx cimage.cxx ckeypad.cxx clabel.cxx clatchbutton.cxx diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx index ab44b9d42..d29830c0a 100644 --- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx @@ -111,7 +111,6 @@ namespace NXWidgets class CWidgetControl; class CGraphicsPort; class CNxFont; - class CRectCache; class CWidgetEventHandlerList; /** @@ -206,9 +205,8 @@ namespace NXWidgets CNxWidget *m_focusedChild; /**< Pointer to the child widget that has focus. */ TNxArray<CNxWidget*> m_children; /**< List of child widgets. */ - // Visible regions + // Borders - CRectCache *m_rectCache; /**< List of the widget's visible regions. */ WidgetBorderSize m_borderSize; /**< Size of the widget borders. */ /** @@ -238,18 +236,6 @@ namespace NXWidgets virtual void drawBorder(CGraphicsPort* port) { } /** - * Checks if the supplied coordinates collide with a portion of this widget - * that is not obscured by its siblings, but that may be obscured by - * its children. - * - * @param x X coordinate of the click. - * @param y Y coordinate of the click. - * @return True if a collision occurred; false if not. - */ - - bool checkCollisionWithForegroundRects(nxgl_coord_t x, nxgl_coord_t y) const; - - /** * Draw all visible regions of this widget's children. */ @@ -266,34 +252,6 @@ namespace NXWidgets void closeChild(CNxWidget *widget); /** - * Redraws all regions of child widgets that fall within the invalidRects - * regions. - * - * @param invalidRects List of invalid regions that need to be redrawn. - * @param sender Pointer to the widget that initiated the redraw. - */ - - void redrawDirtyChildren(TNxArray<CRect>* invalidRects, CNxWidget *sender); - - /** - * Get the index of the next visible widget higher up the z-order. - * - * @param startIndex The starting index. - * @return The index of the next highest visible widget. - */ - - const int getHigherVisibleWidget(const int startIndex) const; - - /** - * Get the index of the next visible widget lower down the z-order. - * - * @param startIndex The starting index. - * @return The index of the next lowest visible widget. - */ - - const int getLowerVisibleWidget(const int startIndex) const; - - /** * Notify this widget that it is being dragged, and set its drag point. * * @param x The x coordinate of the drag position relative to this widget. @@ -749,24 +707,6 @@ namespace NXWidgets void getRect(CRect &rect) const; /** - * Clips the supplied rect to the boundaries defined by this widget and - * this widget's parents. - * - * @param rect Reference to a rect to populate with data. - */ - - void getRectClippedToHierarchy(CRect &rect) const; - - /** - * Gets a pointer to the vector of all of the visible regions of this widget, - * including any covered by children. - * - * @return A pointer to a vector of all visible regions. - */ - - TNxArray<CRect> *getForegroundRegions(void); - - /** * Gets a pointer to the widget's font. * * @return A pointer to the widget's font. @@ -1062,13 +1002,6 @@ namespace NXWidgets void redraw(void); /** - * Erases the visible regions of the widget by redrawing the widgets - * behind it. - */ - - void erase(void); - - /** * Enables the widget. * * @return True if the widget was enabled. @@ -1247,42 +1180,6 @@ namespace NXWidgets nxgl_coord_t width, nxgl_coord_t height); /** - * Raises the widget to the top of its parent's widget stack. - * - * @return True if the raise was successful. - */ - - bool raiseToTop(void); - - /** - * Lowers the widget to the bottom of its parent's widget stack. - * - * @return True if the lower was successful. - */ - - bool lowerToBottom(void); - - /** - * Raises the supplied widget to the top of this widget's child stack. - * The supplied widget pointer must be a child of this widget. - * - * @param widget A pointer to the child widget to raise. - * @return True if the raise was successful. - */ - - bool raiseWidgetToTop(CNxWidget *widget); - - /** - * Lowers the supplied widget to the bottom of this widget's child stack. - * The supplied widget pointer must be a child of this widget. - * - * @param widget A pointer to the child widget to lower. - * @return True if the lower was successful. - */ - - bool lowerWidgetToBottom(CNxWidget *widget); - - /** * Moves the supplied child widget to the deletion queue. * For framework use only. * @@ -1334,16 +1231,6 @@ namespace NXWidgets bool checkCollision(CNxWidget *widget) const; /** - * Invalidate the visible region cache for all widgets below the supplied - * widget in this widget's child stack. This will cause those widgets to - * - * recalculate their visible regions next time they try to draw themselves. - * @param widget A pointer to a child widget. - */ - - void invalidateLowerWidgetsVisibleRectCache(CNxWidget *widget); - - /** * Adds a widget to this widget's child stack. The widget is added to the * top of the stack. Note that the widget can only be added if it is not * already a child of another widget. @@ -1378,61 +1265,6 @@ namespace NXWidgets } /** - * Rebuild the list of this widget's visible regions - */ - - void cacheVisibleRects(void) const; - - /** - * Mark this widget's visible region cache as invalid, and do the same - * to its child widgets. - */ - - void invalidateVisibleRectCache(void); - - /** - * Erase a child widget by drawing the widgets behind it. - * - * @param widget The child widget to erase. - */ - - void eraseWidget(CNxWidget *widget); - - /** - * Redraw any visible regions of this widget that have become corrupted. - * - * @param invalidRects A list of corrupt regions. - * @param sender A pointer to the widget that corrupted the regions. - */ - - void redrawDirty(TNxArray<CRect>* invalidRects, CNxWidget *sender); - - /** - * Clips a rectangular region to the dimensions of this widget and its ancestors. - * - * @param rect The region that needs to be clipped. - */ - - void clipRectToHierarchy(CRect &rect) const; - - /** - * Swaps the depth of the supplied child widget. - * - * @param widget A pointer to the child widget that needs to swap depths. - * @return True if the swap was successful. - */ - - virtual bool swapWidgetDepth(CNxWidget *widget); - - /** - * Swap the depth of this widget. - * - * @return True if the swap was successful. - */ - - bool swapDepth(void); - - /** * Delete this widget. This should never be called in user code; widget * deletion is handled internally. */ @@ -1481,15 +1313,6 @@ namespace NXWidgets } /** - * Get the index of the specified child widget. - * - * @param widget The widget to get the index of. - * @return The index of the widget. -1 if the widget is not found. - */ - - const int getWidgetIndex(const CNxWidget *widget) const; - - /** * Get the child widget at the specified index. * * @param index Index of the child to retrieve. @@ -1510,17 +1333,6 @@ namespace NXWidgets } /** - * Get a pointer to the cache of visible rects. - * - * @return A pointer to the cache of visible rects. - */ - - inline CRectCache *getCRectCache(void) const - { - return m_rectCache; - } - - /** * Sets the border size. The border cannot be drawn over in the * drawContents() method. * diff --git a/NxWidgets/libnxwidgets/include/crectcache.hxx b/NxWidgets/libnxwidgets/include/crectcache.hxx deleted file mode 100644 index f38c2313b..000000000 --- a/NxWidgets/libnxwidgets/include/crectcache.hxx +++ /dev/null @@ -1,222 +0,0 @@ -/****************************************************************************
- * NxWidgets/libnxwidgets/include/crectcache.hxx
- *
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <gnutt@nuttx.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
- * me be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************
- *
- * Portions of this package derive from Woopsi (http://woopsi.org/) and
- * portions are original efforts. It is difficult to determine at this
- * point what parts are original efforts and which parts derive from Woopsi.
- * However, in any event, the work of Antony Dzeryn will be acknowledged
- * in most NxWidget files. Thanks Antony!
- *
- * Copyright (c) 2007-2011, Antony Dzeryn
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the names "Woopsi", "Simian Zombie" nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#ifndef __INCLUDE_CRECTCACHE_HXX
-#define __INCLUDE_CRECTCACHE_HXX
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <nuttx/nx/nxglib.h>
-
-#include "cnxwidget.hxx"
-#include "cwidgetstyle.hxx"
-#include "tnxarray.hxx"
-
-/****************************************************************************
- * Pre-Processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Implementation Classes
- ****************************************************************************/
-
-#if defined(__cplusplus)
-
-namespace NXWidgets
-{
- /**
- * Maintains a list of foreground (ie. above children) and background (with
- * child overlapped-rects removed) rectangles representing the visible portions
- * of a widget.
- */
-
- class CRectCache
- {
- private:
- TNxArray<CRect> m_foregroundRegions; /**< List of the widget's visible regions */
- TNxArray<CRect> m_backgroundRegions; /**< List of the widget's visible regions with child rects removed */
- const CNxWidget *m_widget; /**< Owning widget */
- bool m_foregroundInvalid; /**< True if the foreground cache needs refreshing */
- bool m_backgroundInvalid; /**< True if the background cache needs refreshing */
-
- /**
- * Cache the foreground regions.
- */
-
- void cacheForegroundRegions(void);
-
- /**
- * Cache the background regions.
- */
-
- void cacheBackgroundRegions(void);
-
- public:
-
- /**
- * Constructor.
- *
- * @param widget Widget that contains the rect cache.
- */
-
- CRectCache(const CNxWidget *widget);
-
- /**
- * Destructor.
- */
-
- inline ~CRectCache() { }
-
- /**
- * Rebuild the cache if it is invalid.
- */
-
- void cache(void);
-
- /**
- * Invalidates the cache.
- */
-
- inline void invalidate(void)
- {
- m_foregroundInvalid = true;
- m_backgroundInvalid = true;
- };
-
- /**
- * Return the list of background regions. These are regions that are not overlapped by
- * child widgets.
- *
- * @return The list of background regions.
- */
-
- inline TNxArray<CRect> *getBackgroundRegions(void)
- {
- return &m_backgroundRegions;
- }
-
- /**
- * Return the list of foreground regions. These are regions that represent the entire
- * visible surface of the widget - that is, any regions not overlapped by ancestors or
- * sublings of the widget - including any regions that are actually overlapped by
- * child widgets.
- *
- * @return The list of foreground regions.
- */
-
- inline TNxArray<CRect> *getForegroundRegions(void)
- {
- return &m_foregroundRegions;
- }
-
- /**
- * Works out which rectangles in the invalidRects list overlap this
- * widget, then cuts the rectangles into smaller pieces. The overlapping
- * pieces are pushed into validRects, and the non-overlapping pieces are
- * pushed back into the invalidRects vector.
- *
- * @param invalidRects A vector of regions that need to be tested
- * for collisions against this widget; they represent regions that need
- * to be redrawn.
- * @param validRects A vector of regions that represents areas of the
- * display that do not need to be redrawn.
- * @param sender Pointer to the widget that initiated the split.
- */
-
- void splitRectangles(TNxArray<CRect> *invalidRects,
- TNxArray<CRect> *validRects,
- FAR const CNxWidget *sender) const;
-
- /**
- * Move any rectangles from the visibleRects list that overlap this widget
- * into the invisibleRects list. Used during visible region calculations.
- *
- * @param visibleRects A vector of regions that are not overlapped.
- * @param invisibleRects A vector of regions that are overlapped.
- * @param widget The widget that requested the lists.
- * @see splitRectangles()
- */
-
- void removeOverlappedRects(TNxArray<CRect> *visibleRects,
- TNxArray<CRect> *invisibleRects,
- FAR const CNxWidget* widget) const;
- };
-}
-
-#endif // __cplusplus
-
-#endif // __INCLUDE_CRECTCACHE_HXX
-
diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx index db7cb06b6..aedec610e 100644 --- a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx @@ -392,14 +392,6 @@ namespace NXWidgets bool swapWidgetDepth(CNxWidget *widget); /** - * Redraws any dirty regions within the supplied region. - * - * @param rect The region to redraw - */ - - void eraseRect(CRect rect); - - /** * Add another widget to be managed by this control instance * * @param widget The widget to be controlled. diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx index d9f39ddf9..d176d8822 100644 --- a/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx @@ -276,22 +276,6 @@ namespace NXWidgets */ virtual void handleActionEvent(const CWidgetEventArgs &e) { } - - /** - * Handle a widget move forward event. - * - * @param e The event data. - */ - - virtual void handleMoveForwardEvent(const CWidgetEventArgs &e) { } - - /** - * Handle a widget move backward event. - * - * @param e The event data. - */ - - virtual void handleMoveBackwardEvent(const CWidgetEventArgs &e) { } }; } diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx index ae9e17847..8c9ef6738 100644 --- a/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgeteventhandlerlist.hxx @@ -248,18 +248,6 @@ namespace NXWidgets void raiseDropEvent(nxgl_coord_t x, nxgl_coord_t y); /** - * Raise a move forward event to the event handler. - */ - - void raiseMoveForwardEvent(void); - - /** - * Raise a move backward event to the event handler. - */ - - void raiseMoveBackwardEvent(void); - - /** * Raise a key press event to the event handler. * * @param key The character code of the key that caused the event. diff --git a/NxWidgets/libnxwidgets/src/cnxwidget.cxx b/NxWidgets/libnxwidgets/src/cnxwidget.cxx index 483309832..f8eb1efa7 100644 --- a/NxWidgets/libnxwidgets/src/cnxwidget.cxx +++ b/NxWidgets/libnxwidgets/src/cnxwidget.cxx @@ -82,7 +82,6 @@ #include "cnxfont.hxx" #include "cwidgetstyle.hxx" #include "cwidgeteventargs.hxx" -#include "crectcache.hxx" #include "cwidgetcontrol.hxx" #include "singletons.hxx" @@ -195,8 +194,7 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl, m_borderSize.right = 1; m_borderSize.bottom = 1; m_borderSize.left = 1; - - m_rectCache = new CRectCache(this); + m_widgetEventHandlers = new CWidgetEventHandlerList(this); } @@ -237,7 +235,6 @@ CNxWidget::~CNxWidget(void) // Delete instances. NOTE that we do not delete the controlling // widget. It persists until the window is closed. - delete m_rectCache; delete m_widgetEventHandlers; } @@ -467,41 +464,6 @@ void CNxWidget::getRect(CRect &rect) const } /** - * Clips the supplied rect to the boundaries defined by this widget and - * this widget's parents. - * - * @param rect Reference to a rect to populate with data. - */ - -void CNxWidget::getRectClippedToHierarchy(CRect &rect) const -{ - // Copy the widget's properties into the rect. NOTE that if this is - // a child widget, getX() and getY() will return the actual X and Y - // positions (and not the parent-relative X and Y positions). - - rect.setX(getX()); - rect.setY(getY()); - rect.setWidth(getWidth()); - rect.setHeight(getHeight()); - - // And clip it - - clipRectToHierarchy(rect); -} - -/** - * Gets a pointer to the vector of all of the visible regions of this widget, - * including any covered by children. - * - * @return A pointer to a vector of all visible regions. - */ - -TNxArray<CRect> *CNxWidget::getForegroundRegions(void) -{ - return m_rectCache->getForegroundRegions(); -} - -/** * Sets this widget's border state. * * @param isBorderless The border state. @@ -510,7 +472,6 @@ TNxArray<CRect> *CNxWidget::getForegroundRegions(void) void CNxWidget::setBorderless(bool borderless) { m_flags.borderless = borderless; - invalidateVisibleRectCache(); } /** @@ -532,50 +493,22 @@ void CNxWidget::redraw(void) { if (isDrawingEnabled()) { - cacheVisibleRects(); + // Get the graphics port needed to draw on this window - if (m_rectCache->getBackgroundRegions()->size() > 0) - { - // Get the graphics port for drawing in this window + CGraphicsPort *port = m_widgetControl->getGraphicsPort(); - CGraphicsPort *port = m_widgetControl->getGraphicsPort(); + // Draw the Widget - // Draw all visible rectangles - - for (int i = 0; i < m_rectCache->getBackgroundRegions()->size(); i++) - { - drawBorder(port); - drawContents(port); - } - } + drawBorder(port); + drawContents(port); // Remember that the widget is no longer erased m_flags.erased = false; - drawChildren(); - } -} - -/** - * Erases the visible regions of the widget by redrawing the widgets - * behind it. - */ - -void CNxWidget::erase(void) -{ - if (!m_flags.erased) - { - cacheVisibleRects(); - - if (m_parent != (CNxWidget *)NULL) - { - m_parent->eraseWidget(this); - } - - // Remember that the widget has been erased - m_flags.erased = true; - invalidateVisibleRectCache(); + // Draw the children of the widget + + drawChildren(); } } @@ -646,7 +579,6 @@ void CNxWidget::close(void) // Ensure the widget isn't running modally stopModal(); - erase(); if (m_parent != (CNxWidget *)NULL) { @@ -669,10 +601,6 @@ bool CNxWidget::show(void) { m_flags.hidden = false; - // Ensure that widgets behind this do not draw over the - // top of the newly-visible widget - - m_parent->invalidateLowerWidgetsVisibleRectCache(this); m_widgetEventHandlers->raiseShowEvent(); redraw(); return true; @@ -699,7 +627,6 @@ bool CNxWidget::hide(void) stopModal(); m_widgetEventHandlers->raiseHideEvent(); - erase(); return true; } @@ -741,14 +668,6 @@ bool CNxWidget::click(nxgl_coord_t x, nxgl_coord_t y) } } - // Ensure that the click has occurred on a region of this widget - // not obscured by its siblings - - if (!checkCollisionWithForegroundRects(x, y)) - { - return false; - } - // Handle clicks on this m_flags.clicked = true; @@ -834,14 +753,6 @@ bool CNxWidget::doubleClick(nxgl_coord_t x, nxgl_coord_t y) } } - // Ensure that the click has occurred on a region of this widget - // not obscured by its siblings - - if (!checkCollisionWithForegroundRects(x, y)) - { - return false; - } - m_flags.clicked = true; // Record data for double-click @@ -1143,8 +1054,6 @@ bool CNxWidget::moveTo(nxgl_coord_t x, nxgl_coord_t y) if ((m_rect.getX() != x) || (m_rect.getY() != y)) { - erase(); - nxgl_coord_t oldX = m_rect.getX(); nxgl_coord_t oldY = m_rect.getY(); @@ -1205,19 +1114,11 @@ bool CNxWidget::resize(nxgl_coord_t width, nxgl_coord_t height) bool wasDrawEnabled = m_flags.drawingEnabled; m_flags.permeable = true; - erase(); disableDrawing(); m_rect.setWidth(width); m_rect.setHeight(height); - // Handle visible region caching - - if (m_parent != (CNxWidget *)NULL) - { - m_parent->invalidateLowerWidgetsVisibleRectCache(this); - } - onResize(width, height); // Reset the permeable value @@ -1258,117 +1159,6 @@ bool CNxWidget::changeDimensions(nxgl_coord_t x, nxgl_coord_t y, } /** - * Raises the widget to the top of its parent's widget stack. - * - * @return True if the raise was successful. - */ - -bool CNxWidget::raiseToTop(void) -{ - if (m_parent != (CNxWidget *)NULL) - { - if (m_parent->raiseWidgetToTop(this)) - { - m_widgetEventHandlers->raiseMoveForwardEvent(); - return true; - } - } - - return false; -} - -/** - * Lowers the widget to the bottom of its parent's widget stack. - * - * @return True if the lower was successful. - */ - -bool CNxWidget::lowerToBottom(void) -{ - if (m_parent != (CNxWidget *)NULL) - { - if (m_parent->lowerWidgetToBottom(this)) - { - m_widgetEventHandlers->raiseMoveBackwardEvent(); - return true; - } - } - - return false; -} - -/** - * Raises the supplied widget to the top of this widget's child stack. - * The supplied widget pointer must be a child of this widget. - * - * @param widget A pointer to the child widget to raise. - * @return True if the raise was successful. - */ - -bool CNxWidget::raiseWidgetToTop(CNxWidget *widget) -{ - // Locate widget in the stack - - int index = getWidgetIndex(widget); - - if ((index > -1) && (index < m_children.size() - 1)) - { - m_children.erase(index); - m_children.push_back(widget); - - widget->invalidateVisibleRectCache(); - - // Invalidate all widgets that collide with the depth-swapped widget - - for (int i = 0; i < m_children.size(); i++) - { - if (m_children[i]->checkCollision(widget)) - { - m_children[i]->invalidateVisibleRectCache(); - } - } - - widget->redraw(); - return true; - } - - return false; -} - -/** - * Lowers the supplied widget to the bottom of this widget's child stack. - * The supplied widget pointer must be a child of this widget. - * - * @param widget A pointer to the child widget to lower. - * @return True if the lower was successful. - */ - -bool CNxWidget::lowerWidgetToBottom(CNxWidget *widget) -{ - // Locate widget in the stack - - int index = getWidgetIndex(widget); - - if (index > 0) - { - widget->erase(); - - // Handle visible region caching - - widget->invalidateVisibleRectCache(); - invalidateLowerWidgetsVisibleRectCache(widget); - - m_children.erase(index); - m_children.insert(0, widget); - - widget->redraw(); - return true; - } - - return false; -} - -/** * Moves the supplied child widget to the deletion queue. * For framework use only. * @@ -1446,7 +1236,7 @@ bool CNxWidget::checkCollision(nxgl_coord_t x, nxgl_coord_t y) const // Get the clipped rect CRect rect; - getRectClippedToHierarchy(rect); + getRect(rect); return rect.contains(x, y); } @@ -1471,7 +1261,7 @@ bool CNxWidget::checkCollision(nxgl_coord_t x, nxgl_coord_t y, // Get the clipped rect CRect rect; - getRectClippedToHierarchy(rect); + getRect(rect); return rect.intersects(CRect(x, y, width, height)); } @@ -1487,36 +1277,11 @@ bool CNxWidget::checkCollision(CNxWidget *widget) const // Get the clipped rect CRect rect; - widget->getRectClippedToHierarchy(rect); + widget->getRect(rect); return rect.intersects(m_rect); } /** - * Invalidate the visible region cache for all widgets below the supplied - * widget in this widget's child stack. This will cause those widgets to - * - * recalculate their visible regions next time they try to draw themselves. - * @param widget A pointer to a child widget. - */ - -void CNxWidget::invalidateLowerWidgetsVisibleRectCache(CNxWidget *widget) -{ - // Find the widget - - int widgetIndex = getWidgetIndex(widget); - - // Invalidate lower widgets - - for (int i = widgetIndex - 1; i > -1; i--) - { - if (m_children[i]->checkCollision(widget)) - { - m_children[i]->invalidateVisibleRectCache(); - } - } -} - -/** * Adds a widget to this widget's child stack. The widget is added to the * top of the stack. Note that the widget can only be added if it is not * already a child of another widget. @@ -1540,7 +1305,6 @@ void CNxWidget::addWidget(CNxWidget *widget) } widget->enableDrawing(); - invalidateVisibleRectCache(); widget->redraw(); } } @@ -1562,252 +1326,11 @@ void CNxWidget::insertWidget(CNxWidget *widget) m_children.insert(0, widget); widget->enableDrawing(); - invalidateVisibleRectCache(); widget->redraw(); } } /** - * Rebuild the list of this widget's visible regions - */ - -void CNxWidget::cacheVisibleRects(void) const -{ - m_rectCache->cache(); -} - -/** - * Mark this widget's visible region cache as invalid, and do the same - * to its child widgets. - */ - -void CNxWidget::invalidateVisibleRectCache(void) -{ - m_rectCache->invalidate(); - - // Invalidate child cache - - for (int i = 0; i < m_children.size(); i++) - { - m_children[i]->invalidateVisibleRectCache(); - } -} - -/** - * Erase a child widget by drawing the widgets behind it. - * - * @param widget The child widget to erase. - */ - -void CNxWidget::eraseWidget(CNxWidget *widget) -{ - // Locate the widget - - int widgetIndex = getWidgetIndex(widget); - - // Ensure rect cache is up to date - - widget->cacheVisibleRects(); - - // Order all lower widgets to redraw themselves based on the erased widget's - // visible rect cache - - for (int i = widgetIndex - 1; i > -1; i--) - { - m_children[i]->redrawDirty(widget->getForegroundRegions(), widget); - } - - // Order this widget to redraw itself based on any remaining rectangles - // in the erased widget's rect cache - - redrawDirty(widget->getForegroundRegions(), widget); - invalidateVisibleRectCache(); -} - -/** - * Redraw any visible regions of this widget that have become corrupted. - * - * @param invalidRects A list of corrupt regions. - * @param sender A pointer to the widget that corrupted the regions. - */ - -void CNxWidget::redrawDirty(TNxArray<CRect> *invalidRects, CNxWidget *sender) -{ - if (isDrawingEnabled()) - { - // Draw any children first - - redrawDirtyChildren(invalidRects, sender); - - // Create an array that will contain all of the rects from the - // original array that overlap this widget - - TNxArray<CRect> *overlappingRects = new TNxArray<CRect>(); - - // Remove any non-overlapping rectangles from dirty vector and add to - // overlapping vector - - m_rectCache->splitRectangles(invalidRects, overlappingRects, sender); - - // Create an array that will contain all of the rects that overlap this - // widget clipped to its parent - - TNxArray<CRect> *rectsToDraw = new TNxArray<CRect>(); - - // Split from overlappingRects into rectsToDraw, giving us an array - // of rects that overlap only the visible portions of this widget - - m_rectCache->splitRectangles(overlappingRects, rectsToDraw, sender); - - // Get the graphics port for drawing in this window - - CGraphicsPort *port = m_widgetControl->getGraphicsPort(); - - // Draw the dirty rects - - if (rectsToDraw->size() > 0) - { - for (int i = 0; i < rectsToDraw->size(); i++) - { - drawBorder(port); - drawContents(port); - } - } - - // Copy all of the overlapping rects we didn't draw back to the main - // array of rects that need to be drawn by another widget - - for (int i = 0; i < overlappingRects->size(); i++) - { - invalidRects->push_back(overlappingRects->at(i)); - } - - // Clean up - - delete overlappingRects; - delete rectsToDraw; - } -} - -/** - * Clips a rectangular region to the dimensions of this widget and its ancestors. - * - * @param rect The region that needs to be clipped. - */ - -void CNxWidget::clipRectToHierarchy(CRect &rect) const { - - const CNxWidget *parent = m_parent; - const CNxWidget *widget = this; - CRect thisRect; - - while (parent != NULL) - { - // Standard widgets can draw into client space - - parent->getClientRect(thisRect); - - // Adjust rect to screen space - - thisRect.offset(parent->getX(), parent->getY()); - rect.clipToIntersect(thisRect); - - // Send up to parent - - widget = parent; - parent = parent->getParent(); - } -} - - /** - * Swaps the depth of the supplied child widget. - * - * @param widget A pointer to the child widget that needs to swap depths. - * @return True if the swap was successful. - */ - -bool CNxWidget::swapWidgetDepth(CNxWidget *widget) -{ - // Can we swap? - - if (m_children.size() > 1) - { - int widgetSource = 0; - int widgetDest = 0; - - // Locate the widget in the vector - - widgetSource = getWidgetIndex(widget); - - // Attempt to raise up - - int i = getHigherVisibleWidget(widgetSource); - if (i > -1) - { - // Raise - - widgetDest = i; - } - else - { - // Lower to bottom of stack - - widgetDest = 0; - } - - // Erase the widget from the screen - - eraseWidget(widget); - - // Swap - - CNxWidget *tmp = m_children[widgetSource]; - m_children[widgetSource] = m_children[widgetDest]; - m_children[widgetDest] = tmp; - - // Invalidate the widgets below the top affected widget - - if (widgetSource < widgetDest) - { - // Source lower; invalidate from dest down - - m_children[widgetDest]->invalidateVisibleRectCache(); - invalidateLowerWidgetsVisibleRectCache(m_children[widgetDest]); - } - else - { - // Dest lower; invalidate from source down - - m_children[widgetSource]->invalidateVisibleRectCache(); - invalidateLowerWidgetsVisibleRectCache(m_children[widgetSource]); - } - - // Redraw the widget - - widget->redraw(); - return true; - } - - return false; -} - -/** - * Swap the depth of this widget. - * - * @return True if the swap was successful. - */ - -bool CNxWidget::swapDepth(void) -{ - if (m_parent != (CNxWidget *)NULL) - { - return m_parent->swapWidgetDepth(this); - } - - return false; -} - -/** * Remove this widget from the widget hierarchy. Returns * responsibility for deleting the widget back to the developer. * Does not unregister the widget from the VBL system. @@ -1909,26 +1432,6 @@ void CNxWidget::goModal(void) } /** - * Get the index of the specified child widget. - * - * @param widget The widget to get the index of. - * @return The index of the widget. -1 if the widget is not found. - */ - -const int CNxWidget::getWidgetIndex(const CNxWidget *widget) const -{ - for (int i = 0; i < m_children.size(); i++) - { - if (m_children[i] == widget) - { - return i; - } - } - - return -1; -} - -/** * Get the child widget at the specified index. * * @param index Index of the child to retrieve. @@ -1977,38 +1480,6 @@ void CNxWidget::useWidgetStyle(const CWidgetStyle *style) } /** - * Checks if the supplied coordinates collide with a portion of this widget - * that is not obscured by its siblings, but that may be obscured by - * its children. - * - * @param x X coordinate of the click. - * @param y Y coordinate of the click. - * @return True if a collision occurred; false if not. - */ - -bool CNxWidget::checkCollisionWithForegroundRects(nxgl_coord_t x, nxgl_coord_t y) const -{ - if (isHidden()) - { - return false; - } - - cacheVisibleRects(); - - CRect *rect; - for (int i = 0; i < m_rectCache->getForegroundRegions()->size(); ++i) - { - rect = &(m_rectCache->getForegroundRegions()->at(i)); - if (rect->contains(x, y)) - { - return true; - } - } - - return false; -} - -/** * Draw all visible regions of this widget's children. */ @@ -2080,72 +1551,6 @@ void CNxWidget::closeChild(CNxWidget *widget) } /** - * Redraws all regions of child widgets that fall within the invalidRects - * regions. - * - * @param invalidRects List of invalid regions that need to be redrawn. - * @param sender Pointer to the widget that initiated the redraw. - */ - -void CNxWidget::redrawDirtyChildren(TNxArray<CRect> *invalidRects, CNxWidget *sender) -{ - for (int i = m_children.size() - 1; i > -1 ; i--) - { - if (invalidRects->size() > 0) - { - if (m_children.at(i) != sender) - { - m_children[i]->redrawDirty(invalidRects, sender); - } - } - else - { - break; - } - } -} - -/** - * Get the index of the next visible widget higher up the z-order. - * - * @param startIndex The starting index. - * @return The index of the next highest visible widget. - */ - -const int CNxWidget::getHigherVisibleWidget(const int startIndex) const -{ - for (int i = startIndex; i < m_children.size(); i++) - { - if (!m_children[i]->isHidden()) - { - return i; - } - } - - return -1; -} - -/** - * Get the index of the next visible widget lower down the z-order. - * - * @param startIndex The starting index. - * @return The index of the next lowest visible widget. - */ - -const int CNxWidget::getLowerVisibleWidget(const int startIndex) const -{ - for (int i = startIndex; i > -1; i--) - { - if (!m_children[i]->isHidden()) - { - return i; - } - } - - return -1; -} - -/** * Notify this widget that it is being dragged, and set its drag point. * * @param x The x coordinate of the drag position relative to this widget. diff --git a/NxWidgets/libnxwidgets/src/crectcache.cxx b/NxWidgets/libnxwidgets/src/crectcache.cxx deleted file mode 100644 index 3f74ee75d..000000000 --- a/NxWidgets/libnxwidgets/src/crectcache.cxx +++ /dev/null @@ -1,521 +0,0 @@ -/**************************************************************************** - * NxWidgets/libnxwidgets/src/crectcache.cxx - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors - * me be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - **************************************************************************** - * - * Portions of this package derive from Woopsi (http://woopsi.org/) and - * portions are original efforts. It is difficult to determine at this - * point what parts are original efforts and which parts derive from Woopsi. - * However, in any event, the work of Antony Dzeryn will be acknowledged - * in most NxWidget files. Thanks Antony! - * - * Copyright (c) 2007-2011, Antony Dzeryn - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names "Woopsi", "Simian Zombie" nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <sys/types.h> -#include <stdint.h> -#include <stdbool.h> - -#include <nuttx/nx/nxglib.h> - -#include "crectcache.hxx" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * CNxFont Method Implementations - ****************************************************************************/ - -using namespace NXWidgets; - -/** - * Constructor. - * - * @param widget Widget that contains the rect cache. - */ - -CRectCache::CRectCache(const CNxWidget* widget) -{ - m_widget = widget; - m_foregroundInvalid = true; - m_backgroundInvalid = true; -} - -/** - * Rebuild the cache if it is invalid. - */ - -void CRectCache::cache(void) -{ - cacheBackgroundRegions(); -} - -/** - * Works out which rectangles in the invalidRects list overlap this - * widget, then cuts the rectangles into smaller pieces. The overlapping - * pieces are pushed into validRects, and the non-overlapping pieces are - * pushed back into the invalidRects vector. - * - * @param invalidRects A vector of regions that need to be tested - * for collisions against this widget; they represent regions that need - * to be redrawn. - * @param validRects A vector of regions that represents areas of the - * display that do not need to be redrawn. - * @param sender Pointer to the widget that initiated the split. - */ - -void CRectCache::splitRectangles(TNxArray<CRect>* invalidRects, - TNxArray<CRect>* validRects, - FAR const CNxWidget *sender) const -{ - // Check for collisions with any rectangles in the vector - - for (int i = 0; i < invalidRects->size(); i++) - { - // Get rectangle to check - - CRect checkRect = invalidRects->at(i); - nxgl_coord_t splitX[4]; - nxgl_coord_t splitY[4]; - unsigned int rectXCount = 0; - unsigned int rectYCount = 0; - unsigned int overlapXRect = 0; - unsigned int overlapYRect = 0; - - nxgl_coord_t width = checkRect.getWidth(); - nxgl_coord_t height = checkRect.getHeight(); - - if (m_widget->checkCollision(checkRect.getX(), checkRect.getY(), width, height)) - { - // Got a collision. We need to split this rectangle - // Get clipped dimensions of widget - - CRect widgetRect; - m_widget->getRectClippedToHierarchy(widgetRect); - - // Vertical split - // Start at left edge of rectangle - - splitX[0] = checkRect.getX(); - - // Check for second split - - if (checkRect.getX() < widgetRect.getX()) - { - // Widget is to the right of the invalid rectangle (or in the centre) - - if (splitX[rectXCount] != widgetRect.getX()) - { - rectXCount++; - splitX[rectXCount] = widgetRect.getX(); - - // The next rectangle is the overlap - - overlapXRect = rectXCount; - } - } - else - { - // Widget rectangle is on the left of the invalid rectangle - - if (splitX[rectXCount] != widgetRect.getX2() + 1) - { - // We've found the start of the overlapping rectangle! - - overlapXRect = rectXCount; - rectXCount++; - - // Split is either the end of the widget or the end of the - // invalid rect, whichever comes first - - if (widgetRect.getX2() <= checkRect.getX2()) - { - splitX[rectXCount] = widgetRect.getX2() + 1; - } - else - { - splitX[rectXCount] = checkRect.getX2() + 1; - } - } - else - { - // Found the start of the overlapping rectangle - - overlapXRect = rectXCount; - } - } - - // Check for third split - - if (widgetRect.getX2() + 1 <= checkRect.getX2() + 1) - { - // Widget ends before the invalid rectangle - - if (splitX[rectXCount] != widgetRect.getX2() + 1) - { - // Record end of overlap - - rectXCount++; - splitX[rectXCount] = widgetRect.getX2() + 1; - } - } - - // Store end of invalid rectangle - - if (splitX[rectXCount] <= checkRect.getX2()) - { - rectXCount++; - splitX[rectXCount] = checkRect.getX2() + 1; - } - - // Horizontal split - // Start at left edge of rectangle - - splitY[0] = checkRect.getY(); - - // Check for second split - - if (checkRect.getY() < widgetRect.getY()) - { - // Widget below the invalid rectangle (or in the centre) - - if (splitY[rectYCount] != widgetRect.getY()) - { - rectYCount++; - splitY[rectYCount] = widgetRect.getY(); - - // The next rectangle is the overlap - - overlapYRect = rectYCount; - } - } - else - { - // Widget rectangle above the invalid rectangle - - if (splitY[rectYCount] != widgetRect.getY2() + 1) - { - // We've found the start of the overlapping rectangle! - - overlapYRect = rectYCount; - rectYCount++; - - // Split is either the end of the widget or the end of the - // invalid rect, whichever comes first - - if (widgetRect.getY2() <= checkRect.getY2()) - { - splitY[rectYCount] = widgetRect.getY2() + 1; - } - else - { - splitY[rectYCount] = checkRect.getY2() + 1; - } - } - else - { - // Found the start of the overlapping rectangle - - overlapYRect = rectYCount; - } - } - - // Check for third split - - if (widgetRect.getY2() < checkRect.getY2()) - { - // Widget ends before the invalid rectangle - - if (splitY[rectYCount] != widgetRect.getY2() + 1) - { - // Record end of overlap - - rectYCount++; - splitY[rectYCount] = widgetRect.getY2() + 1; - } - } - - // Store end of invalid rectangle - - if (splitY[rectYCount] <= checkRect.getY2()) - { - rectYCount++; - splitY[rectYCount] = checkRect.getY() + 1; - } - - // Remove the original rectangle - - invalidRects->erase(i); - - // Force the loop to re-examine the new rectangle at this index - - i--; - - // Add the new rectangles (not the overlap; that's the one we need to draw) - - for (unsigned int xRects = 0; xRects < rectXCount; xRects++) - { - for (unsigned int yRects = 0; yRects < rectYCount; yRects++) - { - // Is this the overlap? - - if ((overlapXRect == xRects) && (overlapYRect == yRects)) - { - // Got the overlap, so set the output values - - CRect overlapRect; - overlapRect.setX(splitX[xRects]); - overlapRect.setY(splitY[yRects]); - overlapRect.setX2(splitX[xRects + 1] - 1); - overlapRect.setY2(splitY[yRects + 1] - 1); - - if (overlapRect.hasDimensions()) - { - validRects->push_back(overlapRect); - } - } - else - { - // Not an overlap; add to vector - - CRect newRect; - newRect.setX(splitX[xRects]); - newRect.setY(splitY[yRects]); - newRect.setX2(splitX[xRects + 1] - 1); - newRect.setY2(splitY[yRects + 1] - 1); - - // Insert the new rectangle at the start so we don't - - if (newRect.hasDimensions()) - { - invalidRects->push_back(newRect); - } - - // Increase iterator to compensate for insertion - - i++; - } - } - } - } - } -} - -/** - * Move any rectangles from the visibleRects list that overlap this widget - * into the invisibleRects list. Used during visible region calculations. - * - * @param visibleRects A vector of regions that are not overlapped. - * @param invisibleRects A vector of regions that are overlapped. - * @param widget The widget that requested the lists. - * @see splitRectangles() - */ - -void CRectCache::removeOverlappedRects(TNxArray<CRect> *visibleRects, - TNxArray<CRect> *invisibleRects, - FAR const CNxWidget* widget) const -{ - const CNxWidget* parent = m_widget; - int widgetIndex = -1; - - while ((widget != NULL) && (parent != NULL)) - { - // Locate widget in the list; we add one to the index to - // ensure that we deal with the next widget up in the z-order - - widgetIndex = parent->getWidgetIndex(widget) + 1; - - // Widget should never be the bottom item on the screen - - if (widgetIndex > 0) - { - // Remove any overlapped rectangles - - for (int i = widgetIndex; i < parent->getChildCount(); i++) - { - if (visibleRects->size() > 0) - { - parent->getChild(i)->getCRectCache()->splitRectangles(visibleRects, invisibleRects, widget); - } - else - { - break; - } - } - } - - if (visibleRects->size() > 0) - { - widget = parent; - - if (parent != NULL) - { - parent = parent->getParent(); - } - } - else - { - return; - } - } -} - -/** - * Cache the foreground regions. - */ - -void CRectCache::cacheForegroundRegions(void) -{ - if (m_foregroundInvalid) - { - // Use internal region cache to store the non-overlapped rectangles - // We will use this to clip the widget - - m_foregroundRegions.clear(); - - // Create pointer to a vector to store the overlapped rectangles - // We can discard this later as we don't need it - - TNxArray<CRect>* invisibleRects = new TNxArray<CRect>(); - - // Copy the clipped widget dimensions into a rect - - CRect rect; - m_widget->getRectClippedToHierarchy(rect); - - // Do we have a visible region left? - - if (rect.hasDimensions()) - { - // Add rect to list - - m_foregroundRegions.push_back(rect); - - // Request refresh - - if (m_widget->getParent() != NULL) - { - m_widget->getParent()->getCRectCache()->removeOverlappedRects(&m_foregroundRegions, invisibleRects, m_widget); - } - } - - // Tidy up - - delete invisibleRects; - m_foregroundInvalid = false; - } -} - -/** - * Cache the background regions. - */ - -void CRectCache::cacheBackgroundRegions(void) -{ - // Ensure that foreground is up to date - - cacheForegroundRegions(); - - if (m_backgroundInvalid) - { - // Cache visible regions not overlapped by children - - m_backgroundRegions.clear(); - - // Create pointer to a vector to store the overlapped rectangles - // We can discard this later as we don't need it - - TNxArray<CRect>* invisibleRects = new TNxArray<CRect>(); - - // Copy all foreground regions into the new vector - - for (int i = 0; i < m_foregroundRegions.size(); i++) - { - m_backgroundRegions.push_back(m_foregroundRegions[i]); - } - - // Remove all child rects from the visible vector - - for (int i = 0; i < m_widget->getChildCount(); i++) - { - if (m_backgroundRegions.size() > 0) - { - m_widget->getChild(i)->getCRectCache()->splitRectangles(&m_backgroundRegions, invisibleRects, m_widget); - } - else - { - break; - } - } - - // Tidy up - - delete invisibleRects; - m_backgroundInvalid = false; - } -} - - diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx index afd17e6e2..9c0d67be3 100644 --- a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx +++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx @@ -291,44 +291,6 @@ const int CWidgetControl::getWidgetIndex(const CNxWidget *widget) const } /** - * Redraws any dirty regions within the supplied region. - * - * @param rect The region to redraw - */ - -void CWidgetControl::eraseRect(CRect rect) -{ - // Create pointer to a vector to store the invalid rectangles - - TNxArray<CRect> *invalidRectangles = new TNxArray<CRect>(); - - if (invalidRectangles != (TNxArray<CRect> *)NULL) - { - // Add rectangle into the vector - - invalidRectangles->push_back(rect); - - // Refresh children - - for (int i = m_widgets.size() - 1; i > -1 ; i--) - { - if (invalidRectangles->size() > 0) - { - m_widgets[i]->redrawDirty(invalidRectangles, (CNxWidget *)NULL); - } - else - { - break; - } - } - - // Tidy up - - delete invalidRectangles; - } -} - -/** * Remove a controlled widget * * @param widget The widget to be removed @@ -477,7 +439,6 @@ void CWidgetControl::redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more { CRect rect; rect.setNxRect(nxRect); - eraseRect(rect); } /** diff --git a/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx index de8a31b4b..21d21add9 100644 --- a/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx +++ b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx @@ -280,40 +280,6 @@ void CWidgetEventHandlerList::raiseDropEvent(nxgl_coord_t x, nxgl_coord_t y) } /** - * Raise a move forward event to the event handler. - */ - -void CWidgetEventHandlerList::raiseMoveForwardEvent(void) -{ - if (isEnabled()) - { - CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE); - - for (int i = 0; i < m_widgetEventHandlers.size(); ++i) - { - m_widgetEventHandlers.at(i)->handleMoveForwardEvent(e); - } - } -} - -/** - * Raise a move backward event to the event handler. - */ - -void CWidgetEventHandlerList::raiseMoveBackwardEvent(void) -{ - if (isEnabled()) - { - CWidgetEventArgs e(m_widget, 0, 0, 0, 0, KEY_CODE_NONE); - - for (int i = 0; i < m_widgetEventHandlers.size(); ++i) - { - m_widgetEventHandlers.at(i)->handleMoveBackwardEvent(e); - } - } -} - -/** * Raise a key press event to the event handler. * * @param key The code of the key that caused the event. |