2008-12-02 20:08:19 +01:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libnx/nxtk/nxtk_subwindowmove.c
|
2008-12-02 20:08:19 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2008-12-02 20:08:19 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-12-02 20:08:19 +01:00
|
|
|
*
|
2021-02-23 19:55:00 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-12-02 20:08:19 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2011-07-24 22:49:01 +02:00
|
|
|
#include <nuttx/nx/nx.h>
|
|
|
|
#include <nuttx/nx/nxtk.h>
|
2008-12-02 20:08:19 +01:00
|
|
|
|
2015-12-30 00:31:17 +01:00
|
|
|
#include "nxtk.h"
|
2008-12-02 20:08:19 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxtk_subwindowmove
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform common clipping operations in preparatons for calling nx_move()
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* fwnd - The framed window within which the move is to be done.
|
2021-02-23 20:23:56 +01:00
|
|
|
* This must have been previously created by
|
|
|
|
* nxtk_openwindow().
|
2008-12-02 20:08:19 +01:00
|
|
|
* destrect - The loccation to receive the clipped rectangle relative
|
|
|
|
* to containing window
|
|
|
|
* destoffset - The location to received the clipped offset.
|
|
|
|
* srcrect - Describes the rectangular region relative to the client
|
|
|
|
* sub-window to move relative to the sub-window
|
|
|
|
* srcoffset - The offset to move the region
|
|
|
|
* bounds - The subwindow bounds in absolute screen coordinates.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2008-12-02 20:08:19 +01:00
|
|
|
* OK on success; ERROR on failure with errno set appropriately
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd,
|
|
|
|
FAR struct nxgl_rect_s *destrect,
|
|
|
|
FAR struct nxgl_point_s *destoffset,
|
|
|
|
FAR const struct nxgl_rect_s *srcrect,
|
|
|
|
FAR const struct nxgl_point_s *srcoffset,
|
|
|
|
FAR const struct nxgl_rect_s *bounds)
|
|
|
|
{
|
|
|
|
struct nxgl_rect_s abssrc;
|
|
|
|
|
|
|
|
/* Temporarily, position the src rectangle in absolute screen coordinates */
|
|
|
|
|
|
|
|
nxgl_rectoffset(&abssrc, srcrect, bounds->pt1.x, bounds->pt1.y);
|
|
|
|
|
|
|
|
/* Clip the src rectangle to lie within the client window region */
|
|
|
|
|
|
|
|
nxgl_rectintersect(&abssrc, &abssrc, &fwnd->fwrect);
|
|
|
|
|
2021-02-23 20:23:56 +01:00
|
|
|
/* Clip the source rectangle so that destination area is within the
|
|
|
|
* window.
|
|
|
|
*/
|
2008-12-02 20:08:19 +01:00
|
|
|
|
|
|
|
destoffset->x = srcoffset->x;
|
|
|
|
if (destoffset->x < 0)
|
|
|
|
{
|
|
|
|
if (abssrc.pt1.x + destoffset->x < bounds->pt1.x)
|
|
|
|
{
|
2012-12-07 17:00:56 +01:00
|
|
|
abssrc.pt1.x = bounds->pt1.x - destoffset->x;
|
2008-12-02 20:08:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (abssrc.pt2.x + destoffset->x > bounds->pt2.x)
|
|
|
|
{
|
2012-12-07 17:00:56 +01:00
|
|
|
abssrc.pt2.x = bounds->pt2.x - destoffset->x;
|
2008-12-02 20:08:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
destoffset->y = srcoffset->y;
|
|
|
|
if (destoffset->y < 0)
|
|
|
|
{
|
|
|
|
if (abssrc.pt1.y + destoffset->y < bounds->pt1.y)
|
|
|
|
{
|
2012-12-07 17:00:56 +01:00
|
|
|
abssrc.pt1.y = bounds->pt1.y - destoffset->y;
|
2008-12-02 20:08:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (abssrc.pt2.y + destoffset->y > bounds->pt2.y)
|
|
|
|
{
|
2012-12-07 17:00:56 +01:00
|
|
|
abssrc.pt2.y = bounds->pt2.y - destoffset->y;
|
2008-12-02 20:08:19 +01:00
|
|
|
}
|
|
|
|
|
2013-12-28 18:33:21 +01:00
|
|
|
/* Then move the rectangle so that is relative to the containing window,
|
|
|
|
* not the client subwindow
|
2008-12-02 20:08:19 +01:00
|
|
|
*/
|
|
|
|
|
2013-12-28 18:33:21 +01:00
|
|
|
nxgl_rectoffset(destrect, &abssrc, -fwnd->wnd.bounds.pt1.x,
|
|
|
|
-fwnd->wnd.bounds.pt1.y);
|
2008-12-02 20:08:19 +01:00
|
|
|
}
|