diff --git a/graphics/nxbe/Make.defs b/graphics/nxbe/Make.defs index 561fec8e1d7..fb3efd413b2 100644 --- a/graphics/nxbe/Make.defs +++ b/graphics/nxbe/Make.defs @@ -37,8 +37,8 @@ CSRCS += nxbe_bitmap.c nxbe_configure.c nxbe_colormap.c nxbe_clipper.c CSRCS += nxbe_closewindow.c nxbe_redraw.c nxbe_redrawbelow.c CSRCS += nxbe_setposition.c nxbe_move.c nxbe_getrectangle.c CSRCS += nxbe_fill.c nxbe_filltrapezoid.c nxbe_setpixel.c -CSRCS += nxbe_lower.c nxbe_raise.c nxbe_modal.c -CSRCS += nxbe_setsize.c nxbe_visible.c +CSRCS += nxbe_lower.c nxbe_raise.c nxbe_modal.c nxbe_isvisible.c +CSRCS += nxbe_setsize.c nxbe_setvisibility.c ifeq ($(CONFIG_NX_RAMBACKED),y) CSRCS += nxbe_flush.c diff --git a/graphics/nxbe/nxbe.h b/graphics/nxbe/nxbe.h index f2be127c6ed..29c0ac683f5 100644 --- a/graphics/nxbe/nxbe.h +++ b/graphics/nxbe/nxbe.h @@ -500,6 +500,25 @@ void nxbe_lower(FAR struct nxbe_window_s *wnd); void nxbe_modal(FAR struct nxbe_window_s *wnd, bool enable); +/**************************************************************************** + * Name: nxbe_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * wnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxbe_setvisibility(FAR struct nxbe_window_s *wnd, bool hide); + /**************************************************************************** * Name: nxbe_setpixel * @@ -737,7 +756,7 @@ void nxbe_redrawbelow(FAR struct nxbe_state_s *be, FAR const struct nxgl_rect_s *rect); /**************************************************************************** - * Name: nxbe_visible + * Name: nxbe_isvisible * * Description: * Return true if the point, pt, in window wnd is visible. pt is in @@ -745,8 +764,8 @@ void nxbe_redrawbelow(FAR struct nxbe_state_s *be, * ****************************************************************************/ -bool nxbe_visible(FAR struct nxbe_window_s *wnd, - FAR const struct nxgl_point_s *pos); +bool nxbe_isvisible(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos); /**************************************************************************** * Name: nxbe_clipper diff --git a/graphics/nxbe/nxbe_bitmap.c b/graphics/nxbe/nxbe_bitmap.c index 2bb8bb3d7c0..b93899e5f71 100644 --- a/graphics/nxbe/nxbe_bitmap.c +++ b/graphics/nxbe/nxbe_bitmap.c @@ -221,6 +221,13 @@ void nxbe_bitmap_dev(FAR struct nxbe_window_s *wnd, DEBUGASSERT(wnd != NULL && dest != NULL && src != NULL && origin != NULL); DEBUGASSERT(wnd->be != NULL && wnd->be->plane != NULL); + /* Don't update hidden windows */ + + if (NXBE_ISHIDDEN(wnd)) + { + return; + } + /* Verify that the destination rectangle begins "below" and to the "right" * of the origin */ @@ -324,15 +331,20 @@ void nxbe_bitmap(FAR struct nxbe_window_s *wnd, } #endif - /* Rend the bitmap directly to the graphics device in any case */ + /* Don't update hidden windows */ - nxbe_bitmap_dev(wnd, dest, src, origin, stride); + if (!NXBE_ISHIDDEN(wnd)) + { + /* Rend the bitmap directly to the graphics device */ + + nxbe_bitmap_dev(wnd, dest, src, origin, stride); #ifdef CONFIG_NX_SWCURSOR - /* Update cursor backup memory and redraw the cursor in the modified window - * region. - */ + /* Update cursor backup memory and redraw the cursor in the modified window + * region. + */ - nxbe_cursor_backupdraw_all(wnd, dest); + nxbe_cursor_backupdraw_all(wnd, dest); #endif + } } diff --git a/graphics/nxbe/nxbe_closewindow.c b/graphics/nxbe/nxbe_closewindow.c index c5d577e5b9f..4648b958a5b 100644 --- a/graphics/nxbe/nxbe_closewindow.c +++ b/graphics/nxbe/nxbe_closewindow.c @@ -97,36 +97,41 @@ void nxbe_closewindow(FAR struct nxbe_window_s *wnd) NXBE_STATE_CLRMODAL(be); } - /* Is there a window above the one being closed? */ + /* A hidden window does not exist in the hiearchy */ - if (wnd->above != NULL) + if (!NXBE_ISHIDDEN(wnd)) { - /* Yes, now the window below that one is the window below - * the one being closed. + /* Is there a window above the one being closed? */ + + if (wnd->above != NULL) + { + /* Yes, now the window below that one is the window below + * the one being closed. + */ + + wnd->above->below = wnd->below; + } + else + { + /* No, then the top window is the one below this (which + * can never be NULL because the background window is + * always at the true bottom of the list + */ + + be->topwnd = wnd->below; + } + + /* There is always a window below the one being closed (because + * the background is never closed. Now, the window above that + * is the window above the one that is being closed. */ - wnd->above->below = wnd->below; + wnd->below->above = wnd->above; + + /* Redraw the windows that were below us (and may now be exposed) */ + + nxbe_redrawbelow(be, wnd->below, &wnd->bounds); } - else - { - /* No, then the top window is the one below this (which - * can never be NULL because the background window is - * always at the true bottom of the list - */ - - be->topwnd = wnd->below; - } - - /* There is always a window below the one being closed (because - * the background is never closed. Now, the window above that - * is the window above the one that is being closed. - */ - - wnd->below->above = wnd->above; - - /* Redraw the windows that were below us (and may now be exposed) */ - - nxbe_redrawbelow(be, wnd->below, &wnd->bounds); #ifdef CONFIG_NX_RAMBACKED /* Free any allocated, per-window framebuffer */ diff --git a/graphics/nxbe/nxbe_fill.c b/graphics/nxbe/nxbe_fill.c index c8d8826a9ba..5cd7566c535 100644 --- a/graphics/nxbe/nxbe_fill.c +++ b/graphics/nxbe/nxbe_fill.c @@ -237,8 +237,13 @@ void nxbe_fill(FAR struct nxbe_window_s *wnd, } #endif - /* Rend the bitmap directly to the graphics device in any case */ + /* Don't update hidden windows */ - nxbe_fill_dev(wnd, &remaining, color); + if (!NXBE_ISHIDDEN(wnd)) + { + /* Rend the bitmap directly to the graphics device */ + + nxbe_fill_dev(wnd, &remaining, color); + } } } diff --git a/graphics/nxbe/nxbe_filltrapezoid.c b/graphics/nxbe/nxbe_filltrapezoid.c index 8cca149d4d4..44c68f60b70 100644 --- a/graphics/nxbe/nxbe_filltrapezoid.c +++ b/graphics/nxbe/nxbe_filltrapezoid.c @@ -340,6 +340,9 @@ void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd, } else #endif + /* Don't update hidden windows */ + + if (!NXBE_ISHIDDEN(wnd)) { /* Update only the graphics device memory. */ diff --git a/graphics/nxbe/nxbe_flush.c b/graphics/nxbe/nxbe_flush.c index e1036756fd6..e19c6bed94c 100644 --- a/graphics/nxbe/nxbe_flush.c +++ b/graphics/nxbe/nxbe_flush.c @@ -90,17 +90,22 @@ void nxbe_flush(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_point_s *origin, unsigned int stride) { - /* Copy the modified per-window frambuffer into device memory. */ + /* Don't update hidden windows */ - nxbe_bitmap_dev(wnd, dest, src, origin, stride); + if (!NXBE_ISHIDDEN(wnd)) + { + /* Copy the modified per-window frambuffer into device memory. */ + + nxbe_bitmap_dev(wnd, dest, src, origin, stride); #ifdef CONFIG_NX_SWCURSOR - /* Update cursor backup memory and redraw the cursor in the modified - * window region. - */ + /* Update cursor backup memory and redraw the cursor in the modified + * window region. + */ - nxbe_cursor_backupdraw_all(wnd, dest); + nxbe_cursor_backupdraw_all(wnd, dest); #endif + } } #endif /* CONFIG_NX_RAMBACKED */ diff --git a/graphics/nxbe/nxbe_getrectangle.c b/graphics/nxbe/nxbe_getrectangle.c index e913a03aaf0..c0cb02058cf 100644 --- a/graphics/nxbe/nxbe_getrectangle.c +++ b/graphics/nxbe/nxbe_getrectangle.c @@ -201,6 +201,9 @@ void nxbe_getrectangle(FAR struct nxbe_window_s *wnd, } else #endif + /* If the window is hidden, then there is no available data source */ + + if (!NXBE_ISHIDDEN(wnd)) { #ifdef CONFIG_NX_SWCURSOR /* Is the software cursor visible? */ diff --git a/graphics/nxbe/nxbe_visible.c b/graphics/nxbe/nxbe_isvisible.c similarity index 87% rename from graphics/nxbe/nxbe_visible.c rename to graphics/nxbe/nxbe_isvisible.c index 0f0c1327c3d..5b8ea229849 100644 --- a/graphics/nxbe/nxbe_visible.c +++ b/graphics/nxbe/nxbe_isvisible.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxbe/nxbe_visible.c + * graphics/nxbe/nxbe_isvisible.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ * Private Types ****************************************************************************/ -struct nxbe_visible_s +struct nxbe_setvisibility_s { struct nxbe_clipops_s cops; bool visible; @@ -70,7 +70,7 @@ static void nxbe_clipvisible(FAR struct nxbe_clipops_s *cops, FAR struct nxbe_plane_s *plane, FAR const struct nxgl_rect_s *rect) { - FAR struct nxbe_visible_s *info = (FAR struct nxbe_visible_s *)cops; + FAR struct nxbe_setvisibility_s *info = (FAR struct nxbe_setvisibility_s *)cops; info->visible = true; } @@ -79,7 +79,7 @@ static void nxbe_clipvisible(FAR struct nxbe_clipops_s *cops, ****************************************************************************/ /**************************************************************************** - * Name: nxbe_visible + * Name: nxbe_isvisible * * Description: * Return true if the point, pt, in window wnd is visible. pt is in @@ -87,10 +87,17 @@ static void nxbe_clipvisible(FAR struct nxbe_clipops_s *cops, * ****************************************************************************/ -bool nxbe_visible(FAR struct nxbe_window_s *wnd, - FAR const struct nxgl_point_s *pos) +bool nxbe_isvisible(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos) { - struct nxbe_visible_s info; + struct nxbe_setvisibility_s info; + + /* Hidden windows are never visible */ + + if (NXBE_ISHIDDEN(wnd)) + { + return false; + } /* Check if the absolute position lies within the window */ @@ -99,7 +106,7 @@ bool nxbe_visible(FAR struct nxbe_window_s *wnd, return false; } - /* If this is the top window, then the psition is visible */ + /* If this is the top window, then the position is visible */ if (!wnd->above) { @@ -120,3 +127,4 @@ bool nxbe_visible(FAR struct nxbe_window_s *wnd, return info.visible; } + diff --git a/graphics/nxbe/nxbe_lower.c b/graphics/nxbe/nxbe_lower.c index 77bbbba4612..06a3e3b5830 100644 --- a/graphics/nxbe/nxbe_lower.c +++ b/graphics/nxbe/nxbe_lower.c @@ -64,9 +64,12 @@ void nxbe_lower(FAR struct nxbe_window_s *wnd) /* If the window is already at the bottom, then there is nothing to do. * Refuse to lower the background window; Refuse to lower a modal window. + * It is impossible to lower a hidden window because it does not exist + * in the hiearchy. */ - if (wnd->below == NULL || wnd->below == &be->bkgd || NXBE_ISMODAL(wnd)) + if (wnd->below == NULL || wnd->below == &be->bkgd || + NXBE_ISMODAL(wnd) || NXBE_ISHIDDEN(wnd)) { return; } diff --git a/graphics/nxbe/nxbe_move.c b/graphics/nxbe/nxbe_move.c index 84951a2cacf..532b34bd5ba 100644 --- a/graphics/nxbe/nxbe_move.c +++ b/graphics/nxbe/nxbe_move.c @@ -465,6 +465,9 @@ void nxbe_move(FAR struct nxbe_window_s *wnd, } else #endif + /* Don't update hidden windows */ + + if (!NXBE_ISHIDDEN(wnd)) { /* Update only the graphics device memory. */ diff --git a/graphics/nxbe/nxbe_raise.c b/graphics/nxbe/nxbe_raise.c index f9792e0460d..c4ec11a56c3 100644 --- a/graphics/nxbe/nxbe_raise.c +++ b/graphics/nxbe/nxbe_raise.c @@ -78,10 +78,10 @@ void nxbe_raise(FAR struct nxbe_window_s *wnd) /* If this window is already at the top of the display, then do nothing * (this covers modal window which must always be at the top). Don't - * raise the background window. + * raise the background window and don't raise hidden windows. */ - if (wnd->above == NULL || wnd->below == NULL) + if (wnd->above == NULL || wnd->below == NULL || NXBE_ISHIDDEN(wnd)) { return; } @@ -118,6 +118,13 @@ void nxbe_raise(FAR struct nxbe_window_s *wnd) wnd->below = be->topwnd->below; be->topwnd->below = wnd; + + /* Then redraw this window AND all windows below it. Having moved the + * window, we may have exposed previoulsy obscured portions of windows + * below this one. + */ + + nxbe_redrawbelow(be, wnd, &wnd->bounds); } else { @@ -128,11 +135,11 @@ void nxbe_raise(FAR struct nxbe_window_s *wnd) be->topwnd->above = wnd; be->topwnd = wnd; + + /* This window is now at the top of the display, we know, therefore, + * that it is not obscured by another window + */ + + nxmu_redrawreq(wnd, &wnd->bounds); } - - /* This window is now at the top of the display, we know, therefore, that - * it is not obscured by another window - */ - - nxmu_redrawreq(wnd, &wnd->bounds); } diff --git a/graphics/nxbe/nxbe_setpixel.c b/graphics/nxbe/nxbe_setpixel.c index cb8ddd1ad41..97562b93bcf 100644 --- a/graphics/nxbe/nxbe_setpixel.c +++ b/graphics/nxbe/nxbe_setpixel.c @@ -86,10 +86,6 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops, #endif } -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * Name: nxbe_setpixel * @@ -106,22 +102,20 @@ static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops, * ****************************************************************************/ -void nxbe_setpixel(FAR struct nxbe_window_s *wnd, - FAR const struct nxgl_point_s *pos, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +static void nxbe_setpixel_dev(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { struct nxbe_setpixel_s info; struct nxgl_rect_s rect; int i; - DEBUGASSERT(wnd != NULL && pos != NULL); - /* Offset the position by the window origin */ nxgl_vectoradd(&rect.pt1, pos, &wnd->bounds.pt1); /* Make sure that the point is within the limits of the window - * and of the background screen + * and of the background screen. */ if (!nxgl_rectinside(&wnd->bounds, &rect.pt1) || @@ -165,3 +159,55 @@ void nxbe_setpixel(FAR struct nxbe_window_s *wnd, #endif } } + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxbe_setpixel + * + * Description: + * Fill the specified rectangle in the window with the specified color + * + * Input Parameters: + * wnd - The window structure reference + * rect - The location to be filled + * col - The color to use in the fill + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxbe_setpixel(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + DEBUGASSERT(wnd != NULL && pos != NULL); + +#ifdef CONFIG_NX_RAMBACKED + /* If this window supports a pre-window frame buffer then shadow the full, + * unclipped bitmap in that framebuffer. + * REVISIT: The logic to set a pixel in the per-window frame buffer is missing + */ + + DEBUGASSERT(!NXBE_ISRAMBACKED(wnd)); +#endif + + /* Don't update hidden windows */ + + if (!NXBE_ISHIDDEN(wnd)) + { + nxbe_setpixel_dev(wnd, pos, color); + +#ifdef CONFIG_NX_SWCURSOR + /* Was the software cursor visible? + * REVISIT: Missing logic for the case where the update clobbers a + * single pixel in the cursor image + */ + + DEBUGASSERT(!wnd->be->cursor.visible); +#endif + } +} diff --git a/graphics/nxbe/nxbe_setvisibility.c b/graphics/nxbe/nxbe_setvisibility.c new file mode 100644 index 00000000000..055350b4a62 --- /dev/null +++ b/graphics/nxbe/nxbe_setvisibility.c @@ -0,0 +1,202 @@ +/**************************************************************************** + * graphics/nxbe/nxbe_setvisibility.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 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 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "nxbe.h" +#include "nxmu.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxbe_show_window + * + * Description: + * Make a hidden window visible. + * + * Input Parameters: + * wnd - The window to be shown + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxbe_show_window(FAR struct nxbe_window_s *wnd) +{ + FAR struct nxbe_state_s *be = wnd->be; + + /* Restore the window to the top of the hierarchy. Exception: If the top + * window is a modal window, then only raise it to second highest. + */ + + if (NXBE_STATE_ISMODAL(be) && be->topwnd->below != NULL) + { + /* We are in a modal state. The topwnd is not the background and it + * has focus. + */ + + wnd->above = be->topwnd; + wnd->below = be->topwnd->below; + + be->topwnd->below = wnd; + } + else + { + /* Otherwise re-insert the window at the top on the display. */ + + wnd->above = NULL; + wnd->below = be->topwnd; + + be->topwnd->above = wnd; + be->topwnd = wnd; + + /* This window is now at the top of the display, we know, therefore, + * that it is not obscured by another window. Just redraw it. + */ + + nxmu_redrawreq(wnd, &wnd->bounds); + } + + /* Mark the window no longer hidden */ + + NXBE_CLRHIDDEN(wnd); +} + +/**************************************************************************** + * Name: nxbe_hide_window + * + * Description: + * Hide a visible window. + * + * Input Parameters: + * wnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxbe_hide_window(FAR struct nxbe_window_s *wnd) +{ + FAR struct nxbe_state_s *be = wnd->be; + + /* The background window should never be hidden */ + + DEBUGASSERT(wnd != &be->bkgd); + + /* Remove this window from the hiearachy */ + + /* Is there a window above the one being hidden? */ + + if (wnd->above != NULL) + { + /* Yes, now the window below that one is the window below + * the one being hidden. + */ + + wnd->above->below = wnd->below; + } + else + { + /* No, then the top window is the one below this (which + * can never be NULL because the background window is + * always at the true bottom of the list + */ + + be->topwnd = wnd->below; + } + + /* There is always a window below the one being closed (because + * the background is never closed. Now, the window above that + * is the window above the one that is being closed. + */ + + wnd->below->above = wnd->above; + + /* Redraw the windows that were below us (and may now be exposed) */ + + nxbe_redrawbelow(be, wnd->below, &wnd->bounds); + + /* And mark the window as hidden */ + + NXBE_SETHIDDEN(wnd); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxbe_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * wnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nxbe_setvisibility(FAR struct nxbe_window_s *wnd, bool hide) +{ + /* Are we showing the window? Or hiding it? */ + + if (hide && !NXBE_ISHIDDEN(wnd)) + { + nxbe_hide_window(wnd); + } + else if (!hide && NXBE_ISHIDDEN(wnd)) + { + nxbe_show_window(wnd); + } +} diff --git a/graphics/nxmu/nxmu_mouse.c b/graphics/nxmu/nxmu_mouse.c index 83b074c3669..641fec7bcbe 100644 --- a/graphics/nxmu/nxmu_mouse.c +++ b/graphics/nxmu/nxmu_mouse.c @@ -138,7 +138,7 @@ int nxmu_mousereport(struct nxbe_window_s *wnd) { /* Yes.. Is the mouse position visible in this window? */ - if (nxbe_visible(wnd, &g_mpos)) + if (nxbe_isvisible(wnd, &g_mpos)) { /* Yes... Convert the mouse position to window relative * coordinates and send it to the client diff --git a/graphics/nxmu/nxmu_redrawreq.c b/graphics/nxmu/nxmu_redrawreq.c index 48032bcb205..fb6c15ac1f3 100644 --- a/graphics/nxmu/nxmu_redrawreq.c +++ b/graphics/nxmu/nxmu_redrawreq.c @@ -67,67 +67,73 @@ void nxmu_redrawreq(FAR struct nxbe_window_s *wnd, * update the device content from that framebuffer. */ - if (NXBE_ISRAMBACKED(wnd)) + if (NXBE_ISRAMBACKED(wnd) && !NXBE_ISHIDDEN(wnd)) { - FAR const void *src[CONFIG_NX_NPLANES]; - struct nxgl_rect_s wndrect; - struct nxgl_point_s origin; - unsigned int bpp; + /* But don't update hidden windows */ - /* Put the rectangle back relative to the window */ - - nxgl_rectoffset(&wndrect, rect, - -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); - - /* Get the source of address of the rectangle in the framebuffer. */ - - bpp = wnd->be->plane[0].pinfo.bpp; - src[0] = (FAR const void *) - ((FAR uint8_t *)wnd->fbmem + - wndrect.pt1.y * wnd->stride + - ((bpp * wndrect.pt1.x) >> 3)); - - /* For resolutions less than 8-bits, the starting pixel will be - * contained in the byte pointed to by src[0]but may not be properly - * aligned for the transfer. We fix this by modifying the origin. - */ - - origin.x = wndrect.pt1.x; - origin.y = wndrect.pt1.y; - - switch (bpp) + if (!NXBE_ISHIDDEN(wnd)) { -#ifndef CONFIG_NX_DISABLE_1BPP - case 1: /* 1 bit per pixel */ + FAR const void *src[CONFIG_NX_NPLANES]; + struct nxgl_rect_s wndrect; + struct nxgl_point_s origin; + unsigned int bpp; + + /* Put the rectangle back relative to the window */ + + nxgl_rectoffset(&wndrect, rect, + -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); + + /* Get the source of address of the rectangle in the framebuffer. */ + + bpp = wnd->be->plane[0].pinfo.bpp; + src[0] = (FAR const void *) + ((FAR uint8_t *)wnd->fbmem + + wndrect.pt1.y * wnd->stride + + ((bpp * wndrect.pt1.x) >> 3)); + + /* For resolutions less than 8-bits, the starting pixel will be + * contained in the byte pointed to by src[0]but may not be + * properly aligned for the transfer. We fix this by modifying + * the origin. + */ + + origin.x = wndrect.pt1.x; + origin.y = wndrect.pt1.y; + + switch (bpp) { - origin.x &= ~7; - } - break; +#ifndef CONFIG_NX_DISABLE_1BPP + case 1: /* 1 bit per pixel */ + { + origin.x &= ~7; + } + break; #endif #ifndef CONFIG_NX_DISABLE_2BPP - case 2: /* 2 bits per pixel */ - { - origin.x &= ~3; - } - break; + case 2: /* 2 bits per pixel */ + { + origin.x &= ~3; + } + break; #endif #ifndef CONFIG_NX_DISABLE_4BPP - case 4: /* 4 bits per pixel */ - { - origin.x &= ~1; - } - break; + case 4: /* 4 bits per pixel */ + { + origin.x &= ~1; + } + break; #endif - default: - break; + default: + break; + } + + /* And render the bitmap into device graphics memory */ + + nxbe_flush(wnd, &wndrect, src, &origin, wnd->stride); } - - /* And render the bitmap into device graphics memory */ - - nxbe_flush(wnd, &wndrect, src, &origin, wnd->stride); } else #endif diff --git a/graphics/nxmu/nxmu_server.c b/graphics/nxmu/nxmu_server.c index b0b999bbbf5..00f7b87b4ba 100644 --- a/graphics/nxmu/nxmu_server.c +++ b/graphics/nxmu/nxmu_server.c @@ -455,6 +455,14 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) } break; + case NX_SVRMSG_SETVISIBILITY: /* Show or hide a window */ + { + FAR struct nxsvrmsg_setvisibility_s *vismsg = + (FAR struct nxsvrmsg_setvisibility_s *)buffer; + nxbe_setvisibility(vismsg->wnd, vismsg->hide); + } + break; + case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */ { FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer; diff --git a/include/nuttx/nx/nx.h b/include/nuttx/nx/nx.h index fa56e4dd55a..cf37b03dfcd 100644 --- a/include/nuttx/nx/nx.h +++ b/include/nuttx/nx/nx.h @@ -85,6 +85,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* Handles ******************************************************************/ /* The interface to the NX server is managed using a opaque handle: */ @@ -678,6 +679,25 @@ int nx_lower(NXWINDOW hwnd); int nx_modal(NXWINDOW hwnd, bool modal); +/**************************************************************************** + * Name: nx_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * hwnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_setvisibility(NXWINDOW hwnd, bool hide); + /**************************************************************************** * Name: nx_setpixel * diff --git a/include/nuttx/nx/nxbe.h b/include/nuttx/nx/nxbe.h index 4d3ae3e7ece..91829bcf80f 100644 --- a/include/nuttx/nx/nxbe.h +++ b/include/nuttx/nx/nxbe.h @@ -52,6 +52,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ #ifndef CONFIG_NX_NPLANES @@ -70,6 +71,7 @@ * NXBE_WINDOW_FRAMED - Framed (NxTK) Window * NXBE_WINDOW_RAMBACKED - Window is backed by a framebuffer * NXBE_WINDOW_MODAL - Window is in a focused, modal state + * NXBE_WINDOW_HIDDEN - Window is hidden */ #define NXBE_WINDOW_BLOCKED (1 << 0) /* Bit 0: The window is blocked and will @@ -77,6 +79,7 @@ #define NXBE_WINDOW_FRAMED (1 << 1) /* Bit 1: Framed (NxTK) Window */ #define NXBE_WINDOW_RAMBACKED (1 << 2) /* Bit 2: Window is backed by a framebuffer */ #define NXBE_WINDOW_MODAL (1 << 3) /* Bit 3: Window is in a focused, modal state */ +#define NXBE_WINDOW_HIDDEN (1 << 4) /* Bit 4: Window is hidden */ /* Valid user flags for different window types */ @@ -120,6 +123,13 @@ #define NXBE_CLRMODAL(wnd) \ do { (wnd)->flags &= ~NXBE_WINDOW_MODAL; } while (0) +#define NXBE_ISHIDDEN(wnd) \ + (((wnd)->flags & NXBE_WINDOW_HIDDEN) != 0) +#define NXBE_SETHIDDEN(wnd) \ + do { (wnd)->flags |= NXBE_WINDOW_HIDDEN; } while (0) +#define NXBE_CLRHIDDEN(wnd) \ + do { (wnd)->flags &= ~NXBE_WINDOW_HIDDEN; } while (0) + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/include/nuttx/nx/nxmu.h b/include/nuttx/nx/nxmu.h index a0091dcc3da..9f6d5f34597 100644 --- a/include/nuttx/nx/nxmu.h +++ b/include/nuttx/nx/nxmu.h @@ -152,6 +152,7 @@ enum nxmsg_e NX_SVRMSG_RAISE, /* Move the window to the top */ NX_SVRMSG_LOWER, /* Move the window to the bottom */ NX_SVRMSG_MODAL, /* Select/de-slect window modal state */ + NX_SVRMSG_SETVISIBILITY, /* Show or hide a window */ NX_SVRMSG_SETPIXEL, /* Set a single pixel in the window with a color */ NX_SVRMSG_FILL, /* Fill a rectangle in the window with a color */ NX_SVRMSG_GETRECTANGLE, /* Get a rectangular region in the window */ @@ -397,6 +398,17 @@ struct nxsvrmsg_modal_s bool modal; /* True: enter modal state; False: leave modal state */ }; +/* This message either (1) hides a visible window, or (2) makes a hidden + * window visible. + */ + +struct nxsvrmsg_setvisibility_s +{ + uint32_t msgid; /* NX_SVRMSG_SETVISIBILITY */ + FAR struct nxbe_window_s *wnd; /* The window to be modified */ + bool hide; /* True: Hide window; False: show window */ +}; + /* Set a single pixel in the window with a color */ struct nxsvrmsg_setpixel_s diff --git a/include/nuttx/nx/nxtk.h b/include/nuttx/nx/nxtk.h index 0ec3918b148..d82084fdead 100644 --- a/include/nuttx/nx/nxtk.h +++ b/include/nuttx/nx/nxtk.h @@ -347,6 +347,25 @@ int nxtk_lower(NXTKWINDOW hfwnd); int nxtk_modal(NXTKWINDOW hfwnd, bool modal); +/**************************************************************************** + * Name: nxtk_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * hfwnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_setvisibility(NXTKWINDOW hfwnd, bool hide); + /**************************************************************************** * Name: nxtk_fillwindow * diff --git a/libs/libnx/nxmu/Make.defs b/libs/libnx/nxmu/Make.defs index 0d07587e70a..681bb1f7244 100644 --- a/libs/libnx/nxmu/Make.defs +++ b/libs/libnx/nxmu/Make.defs @@ -49,7 +49,7 @@ CSRCS += nxmu_sendwindow.c nx_closewindow.c nx_constructwindow.c CSRCS += nx_bitmap.c nx_fill.c nx_filltrapezoid.c nx_getposition.c CSRCS += nx_getrectangle.c nx_lower.c nx_modal.c nx_move.c nx_openwindow.c CSRCS += nx_raise.c nx_redrawreq.c nx_setpixel.c nx_setposition.c -CSRCS += nx_setsize.c +CSRCS += nx_setsize.c nx_setvisibility.c ifeq ($(CONFIG_NX_HWCURSOR),y) CSRCS += nx_cursor.c diff --git a/libs/libnx/nxmu/nx_modal.c b/libs/libnx/nxmu/nx_modal.c index 54f7954b66c..6822108a3d8 100644 --- a/libs/libnx/nxmu/nx_modal.c +++ b/libs/libnx/nxmu/nx_modal.c @@ -69,7 +69,7 @@ int nx_modal(NXWINDOW hwnd, bool modal) { FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_modal_s outmsg; + struct nxsvrmsg_modal_s outmsg; /* Send the MODAL message */ diff --git a/libs/libnx/nxmu/nx_setvisibility.c b/libs/libnx/nxmu/nx_setvisibility.c new file mode 100644 index 00000000000..211a38be893 --- /dev/null +++ b/libs/libnx/nxmu/nx_setvisibility.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * libs/libnx/nxmu/nx_setvisibility.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 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 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * hwnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_setvisibility(NXWINDOW hwnd, bool hide) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_setvisibility_s outmsg; + + /* Send the MODAL message */ + + outmsg.msgid = NX_SVRMSG_SETVISIBILITY; + outmsg.wnd = wnd; + outmsg.hide = hide; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setvisibility_s)); +} diff --git a/libs/libnx/nxtk/Make.defs b/libs/libnx/nxtk/Make.defs index ad31ce382d4..9990f180e55 100644 --- a/libs/libnx/nxtk/Make.defs +++ b/libs/libnx/nxtk/Make.defs @@ -40,7 +40,7 @@ ifeq ($(CONFIG_NX),y) CSRCS += nxtk_setsubwindows.c nxtk_events.c nxtk_block.c nxtk_synch.c CSRCS += nxtk_subwindowclip.c nxtk_containerclip.c nxtk_subwindowmove.c CSRCS += nxtk_drawframe.c -CSRCS += nxtk_raise.c nxtk_lower.c nxtk_modal.c +CSRCS += nxtk_raise.c nxtk_lower.c nxtk_modal.c nxtk_setvisibility.c CSRCS += nxtk_setposition.c nxtk_getposition.c nxtk_setsize.c CSRCS += nxtk_openwindow.c nxtk_closewindow.c nxtk_fillwindow.c diff --git a/libs/libnx/nxtk/nxtk_setvisibility.c b/libs/libnx/nxtk/nxtk_setvisibility.c new file mode 100644 index 00000000000..912ebaea082 --- /dev/null +++ b/libs/libnx/nxtk/nxtk_setvisibility.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * libs/libnx/nxtk/nxtk_setvisibility.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 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 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_setvisibility + * + * Description: + * Select if the window is visible or hidden. A hidden window is still + * present will will update normally, but will be on the visiable on the + * display until it is unhidden. + * + * Input Parameters: + * hfwnd - The window to be modified + * hide - True: Window will be hidden; false: Window will be visible + * + * Returned Value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_setvisibility(NXTKWINDOW hfwnd, bool hide) +{ + return nx_setvisibility((NXWINDOW)hfwnd, hide); +}