[ui] Add two view manipulation functions

One moves and resizes the view in one operation as a bit of an
optimization as moving and resizing both update any child views, and
this does only one update.

The other sets the gravity and updates any child views as their
absolute positions would change as well as the updated view's absolute
position.
This commit is contained in:
Bill Currie 2021-07-10 17:57:59 +09:00
parent 4b1eb0d760
commit a75c027b7f
2 changed files with 38 additions and 0 deletions

View File

@ -215,6 +215,28 @@ void view_resize (view_t *view, int xl, int yl);
*/ */
void view_move (view_t *view, int xp, int yp); void view_move (view_t *view, int xp, int yp);
/** Chage the location and size of a view in a single operation.
The absolute X and Y coorinates of the view are updated as necessary to
keep the coordinates of the view's origin correct relative to the view's
geometry.
\param view The view to move.
\param xp The new X coordinate of the view relative to its gravity.
\param yp The new Y coordinate of the view relative to its gravity.
\param xl The new width of the view.
\param yl The new height of the view.
*/
void view_setgeometry (view_t *view, int xp, int yp, int xl, int yl);
/** Change the gravity of a view, adjusting its position appropriately
\param view The view which will have its gravity set..
\param grav The gravity of the view. determines the view's origin and
its positioning within the view's parent.
*/
void view_setgravity (view_t *view, grav_t grav);
///@} ///@}
#endif//__QF_ui_view_h #endif//__QF_ui_view_h

View File

@ -221,3 +221,19 @@ view_move (view_t *view, int xp, int yp)
view->ypos = yp; view->ypos = yp;
setgeometry (view); setgeometry (view);
} }
VISIBLE void
view_setgeometry (view_t *view, int xp, int yp, int xl, int yl)
{
view->xpos = xp;
view->ypos = yp;
_resize (view, xl, yl);
setgeometry (view);
}
VISIBLE void
view_setgravity (view_t *view, grav_t grav)
{
view->gravity = grav;
setgeometry (view);
}