Data Structures | |
struct | view_s |
Typedefs | |
typedef struct view_s | view_t |
The view object. More... | |
Enumerations | |
enum | grav_t { grav_center, grav_north, grav_northeast, grav_east, grav_southeast, grav_south, grav_southwest, grav_west, grav_northwest } |
Control the positioning of a view within its parent. More... | |
Functions | |
void | view_add (view_t *par, view_t *view) |
Add a view to a parent view at the end of the parents view list. More... | |
void | view_delete (view_t *view) |
Delete a view and all its child views. More... | |
void | view_draw (view_t *view) |
Draw the child views of a view. More... | |
void | view_insert (view_t *par, view_t *view, int pos) |
Insert a view into a parent view at the specified location. More... | |
void | view_move (view_t *view, int xp, int yp) |
Chage the location of a view. More... | |
view_t * | view_new (int xp, int yp, int xl, int yl, grav_t grav) |
Create a new view. More... | |
void | view_remove (view_t *par, view_t *view) |
Remove a view from its parent. More... | |
void | view_resize (view_t *view, int xl, int yl) |
Change the size of a view. More... | |
enum grav_t |
Control the positioning of a view within its parent.
The directions are the standard compass rose (north, east, south, west in clockwise order) with north at the top.
The origin of the view is taken to be the point corresponding point on the edge of the view (eg, southeast is bottom right), or the view's center for center gravity. When the relative coordinates of the view are (0,0), the view's origin is placed on the parent view's gravity point using the view's gravity (not the parent view's gravity). That is, the parent view's gravity has no effect on the view's position within the parent view.
The gravity also affects the direction the view moves as the relative coordinates of the view change.
No checking is done to ensure the view stays within the parent, or that the view is smaller than the parent. This is by design. It is up to the drawing callbacks to do any necessary clipping.
Add a view to a parent view at the end of the parents view list.
The absolute X and Y coordianates of the inserted view and its child views are updated based on the view's gravity.
The added view will be drawn last (and thus on top of earlier views).
par | The parent view to which the view is to be added. |
view | The view to add. |
void view_delete | ( | view_t * | view | ) |
Delete a view and all its child views.
If the view has a parent, the view will be removed from its parent.
view | The view to delete. |
void view_draw | ( | view_t * | view | ) |
Draw the child views of a view.
If a child view is not visible (view_t::visible is 0), the child will be skipped.
view | The view of which to draw the children. |
Insert a view into a parent view at the specified location.
If pos
is negative, it is taken to be relative to the end of the parent's list of views (view_insert (par, view, -1) is equivalent to view_add (par, view)). pos
is clipped to be within the correct range.
The absolute X and Y coordianates of the inserted view and its child views are updated based on the view's gravity.
The position of the view within the parent view's child view list determines the draw order (and thus Z order) of the view, with position 0 being drawn first.
par | The parent view into which the view is to be inserted. |
view | The view to insert. |
pos | The position at which to insert the view into the parent. |
Chage the location of a view.
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.
view | The view to move. |
xp | The new X coordinate of the view relative to its gravity. |
yp | The new Y coordinate of the view relative to its gravity. |
Create a new view.
view_t::draw is set to view_draw() and the view is made visible. All coordinates are set appropriately for the new view being a root view. All other fields not set by the parameters are 0.
xp | The X coordinate of the view's origin. |
yp | The Y coordinate of the view's origin. |
xl | The width of the view. |
yl | The height of the view. |
grav | The gravity of the view. determines the view's origin and its positioning within the view's parent. |
Remove a view from its parent.
par | The parent view from which the view is to be removed. |
view | The view to remove. |
Change the size of a view.
The view's children are also resized based on their view_t::resize_x and view_t::resize_y flags.
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.
view | The view to resize. |
xl | The new width of the view. |
yl | The new height of the view. |