AG_Fixed
—
agar pixel-precision container
#include <agar/core.h>
#include <agar/gui.h>
The AG_Fixed
container widgets positions its children at
specific locations given in pixels. It is useful for positioning cosmetic
components applications such as games, running at fixed resolutions.
AG_Fixed *
AG_FixedNew
(AG_Widget
*parent, Uint flags);
The AG_FixedNew
() function allocates,
initializes, and attaches a new AG_Fixed
widget. The
flags may include:
- AG_FIXED_FILLBG
- Fill the widget background with
FIXED_BG_COLOR
.
- AG_FIXED_BOX
- Draw a decorative 3D-style box in the background.
- AG_FIXED_FRAME
- Draw a decorative frame in the background.
- AG_FIXED_NO_UPDATE
- Disable automatic invocation of
AG_WidgetUpdate(3)
whenever widgets are repositioned. As an optimisation when large number of
widgets are to be positioned, this option can be used and
AG_WidgetUpdate(3)
manually invoked only once all widgets are in place.
- AG_FIXED_HFILL
- Expand horizontally in parent (equivalent to invoking
AG_ExpandHoriz(3)).
- AG_FIXED_VFILL
- Expand vertically in parent (equivalent to invoking
AG_ExpandVert(3)).
- AG_FIXED_EXPAND
- Shorthand for
AG_FIXED_HFILL|AG_FIXED_VFILL
.
void
AG_FixedPut
(AG_Fixed
*fixed, void *child,
int x,
int y);
void
AG_FixedDel
(AG_Fixed
*fixed, void
*child);
void
AG_FixedSize
(AG_Fixed
*fixed, void
*child, int width,
int height);
void
AG_FixedMove
(AG_Fixed
*fixed, void
*child, int new_x,
int new_y);
The AG_FixedPut
() function attaches the
widget child and positions it at the given
coordinates. AG_FixedDel
() detaches the given
widget.
Alternatively, you can avoid AG_FixedPut
()
and AG_FixedDel
() altogether and instead use
AG_ObjectAttach(3)
and
AG_ObjectDetach(3)
followed by calls to AG_FixedSize
() and
AG_FixedMove
().
Functions AG_FixedSize
() and
AG_FixedMove
() set the size and location of a given
widget in pixels.
The AG_Fixed
widget does not generate any event.
See tests/fixedres.c in the Agar source distribution.
The AG_Fixed
widget first appeared in Agar 1.0.