![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS#include <agar/core.h> #include <agar/gui.h> DESCRIPTIONThe graphical appearance of Agar widgets (including typography, colors, paddings, spacings and decorations) is determined by the stylesheet of their parent AG_Window(3). An Selector conditions allow widgets to be styled based on their current geometry ("width", "height") or the zoom level of their windows ("zoom"). Attributes defined by a stylesheet can be overridden on a per widget instance basis with the AG_SetStyle(3) family of functions. Agar stylesheets allow C-style comments. TYPOGRAPHYStyle attributes are case-insensitive. The following are available:
The font-family attribute selects the type
face. Agar will look up system fonts (via fontconfig), Core Fonts as well as
user-installed fonts (under
AG_Config(3)
The font-size attribute sets the font size either in points ("10pts", "10.5pts") for vector fonts, pixels ("12px") for bitmap fonts, or in percentage of the parent widget font's size ("80%"). Generally, the font sizes of GUI elements should be given in "%" so that the zoom function may work as expected (the AG_ZoomIn(3) and AG_ZoomOut(3) functions work by simply increasing or decreasing the target window's "font-size"). The font-weight attribute sets the weight of the font:
The font-style attribute selects the style of the font:
The font-stretch attribute selects the width variant:
COLORSColor-defining style attributes include:
Colors allow an optional state selector (e.g., "color#focused"). If no selector is given then the given color is assigned to all states.
Color values can be specified using any one of the representations below. See AG_ColorFromString(3) for details.
RGBA and HSV components may be expressed in "%" (in relation to the same color entry in the parent widget's palette). Color keywords are matched case-insensitively. PADDING AND SPACINGPaddings, margins and inner spacings are specified in pixels:
The padding attribute sets the inner padding amount in pixels. If given as a single "<Number>", the same amount is applied to all sides. Negative values are allowed, and may be used to condense content. The margin attribute sets the outer margin amount in pixels. If given as a single "<Number>", the same amount is applied to all sides. The margin amounts must be positive. The spacing attribute sets the horizontal and vertical spacings between inner elements of a widget. If given as a single "<Number>", the same amount is used for both horizontal and vertical spacings. Negative values are allowed, and may be used to condense content. Margin is handled generically by container widgts. Padding and inner spacings are implemented in a widget-specific way. Different widget classes will handle padding and spacing differently. C INTERFACEvoid
The
The
The
EXAMPLESAgar's default stylesheet is compiled from gui/style.css. It is a good starting point for writing new stylesheets. The following stylesheet fragment selects a condensed font, tweaks the color scheme and sets padding values for the AG_Button(3) class: AG_Button { font-family: league-gothic; font-stretch: condensed; font-size: 120%; color: AntiqueWhite; text-color: #000; color#disabled: rgb(200,200,200); text-color#disabled: rgb(125,125,125); high-color#hover: red; low-color#hover: darkred; padding: 5 4 5 4; /* TRBL */ } The following example uses an E > F (children of class) selector to set the color of all buttons embedded in the AG_Numerical(3) widget: AG_Numerical > AG_Button { color: blue; } The following example uses an E > "F" (children named) selector to set the color of specific button instances embedded in the AG_Numerical(3) widget: AG_Numerical > "increm" { color: red; } AG_Numerical > "decrem" { color: green; } The following example switches to a condensed font when the width of the widget is below a given threshold: AG_HSVPal { font-family: league-gothic; font-size: 140%; } AG_HSVPal (width < 90) { font-family: league-gothic-condensed; font-size: 120%; } By default, a widget instance inherits its style attributes from its parent. The syntax allows certain attributes, such as "font-size" and "color" to be specified in relation to the parent. For example: font-size: 50%; # Half of parent font size color: hsv(100%,50%,100%); # Half of parent saturation color: hsv(100%,100%,75%); # 3/4 of parent value SEE ALSOHISTORYA very basic
|