void nxbe_closewindow(struct nxbe_window_s *wnd) { FAR struct nxbe_state_s *be; #ifdef CONFIG_DEBUG if (!wnd) { return; } #endif be = wnd->be; /* The background window should never be closed */ DEBUGASSERT(wnd != &be->bkgd); /* Is there a window above the one being closed? */ if (wnd->above) { /* 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->below->above = wnd->above; /* Redraw the windows that were below us (and may now be exposed) */ nxbe_redrawbelow(be, wnd->below, &wnd->bounds); /* Then discard the window structure. Here we assume that the user-space * allocator was used. */ kumm_free(wnd); }
void nxbe_lower(FAR struct nxbe_window_s *wnd) { FAR struct nxbe_state_s *be = wnd->be; FAR struct nxbe_window_s *below; /* If the window is already at the bottom, then there is nothing to do */ if (!wnd->below || wnd->below == &be->bkgd) { return; } /* Remove the window from its current position in the list */ wnd->below->above = wnd->above; /* Was it at the top of the display? */ if (wnd->above) { /* No... it was in the middle somewhere */ wnd->above->below = wnd->below; } else { /* Yes.. set the new top window */ be->topwnd = wnd->below; be->topwnd->above = NULL; } /* Remember the window that was just below us */ below = wnd->below; /* Then put the lowered window at the bottom (just above the background window) */ wnd->below = &be->bkgd; wnd->above = be->bkgd.above; be->bkgd.above = wnd; /* Redraw the windows that were below us (but now are above) */ nxbe_redrawbelow(be, below, &wnd->bounds); }
void nxbe_setsize(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_size_s *size) { struct nxgl_rect_s bounds; #ifdef CONFIG_DEBUG if (!wnd) { return; } #endif /* Save the before size of the window's bounding box */ nxgl_rectcopy(&bounds, &wnd->bounds); /* Add the window origin to the supplied size get the new window bounding box */ wnd->bounds.pt2.x = wnd->bounds.pt1.x + size->w - 1; wnd->bounds.pt2.y = wnd->bounds.pt1.y + size->h - 1; /* Clip the new bounding box so that lies within the background screen */ nxgl_rectintersect(&wnd->bounds, &wnd->bounds, &wnd->be->bkgd.bounds); /* We need to update the larger of the two rectangles. That will be the * union of the before and after sizes. */ nxgl_rectunion(&bounds, &bounds, &wnd->bounds); /* Report the new size/position */ nxfe_reportposition(wnd); /* Then redraw this window AND all windows below it. Having resized the * window, we may have exposed previoulsy obscured portions of windows * below this one. */ nxbe_redrawbelow(wnd->be, wnd, &bounds); }
void nxbe_setposition(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_point_s *pos) { struct nxgl_rect_s before; struct nxgl_rect_s rect; #ifdef CONFIG_DEBUG if (!wnd) { return; } #endif /* Back out the old window origin position from the bounding box */ nxgl_rectoffset(&rect, &wnd->bounds, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); /* Add the new window origin into the bounding box */ nxgl_rectcopy(&before, &wnd->bounds); nxgl_rectoffset(&wnd->bounds, &rect, pos->x, pos->y); /* Get the union of the 'before' bounding box and the 'after' bounding * this union is the region of the display that must be updated. */ nxgl_rectunion(&rect, &before, &wnd->bounds); nxgl_rectintersect(&rect, &rect, &wnd->be->bkgd.bounds); /* Report the new size/position */ nxfe_reportposition(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(wnd->be, wnd, &rect); }