AUI Framework
master
Cross-platform module-based framework for developing C++20 desktop applications
|
CSS-like styling system. More...
CSS-like styling system.
AUI uses CSS-like stylesheet domain specific language, ASS (stands for Aui Style Sheets). Like CSS, ASS is a list of rules. A rule consists of a selector and a list of properties. Selector is a basic matcher that determines whether apply a rule to the specific view or not. Selector is the first statement in a rule and further statements are style properties. Property controls the specific aspect of view's style (i.e. FontSize { 18_pt }
equals "call setFontSize(18_pt) for every matched view").
CSS | AUI ASS | Meaning |
---|---|---|
AButton {
background: red;
color: white;
}
| {
t<AButton>(),
BackgroundColor { AColor::RED },
TextColor { AColor::WHITE },
},
| Set all buttons' background to red and text color to white |
ATextField::hover {
border: 1px solid #00f;
}
| {
t<ATextField>::hover(),
Border { 1_dp, 0x0000ff_rgb },
},
| Set all text fields' border to #00f (blue) on hover |
Global stylesheet is applied to the whole program.
Somewhere in your entry point, you may write:
Container stylesheet is applied only to children (both direct and indirect) of the container.
The code below draws "Hello" label with red background and centered alignment, and "World" label with blue background, using with_style:
In case with_style is not applicable, you may use setCustomStyle instead.
As said earlier, first statement in a rule is selector. Here's some examples.
Works faster than selecting indirect child
Sub selector is kind of a selector that depends on view's state (i.e, pressed or focused). Sub selectors, as well as other selectors don't replace previous rules entirely. Instead, they extend existing rules. However, same properties are replaced.
Hovered view is a view below mouse cursor.
Active view is a pressed view.
Focused view is a view that was clicked and currently receiving keyboard input.
Disabled view is a view with AView::setEnabled(false) thus not able to change it's state.
See below for declarations and selectors.
Classes | |
struct | ass::Backdrop |
Represents backdrop filter effect which applied to the pixels behind the view (i.e., blur, grayscale, etc.) More... | |
struct | ass::BackgroundCropping |
Controls background texture cropping by exact UV coordinates. Useful for texture atlases. More... | |
struct | ass::BackgroundEffect |
Represents custom-rendered background effect. More... | |
struct | ass::BackgroundGradient |
Represents gradient background. More... | |
struct | ass::BackgroundImage |
Represents textured (image) background. More... | |
struct | ass::BackgroundSolid |
Represents solid (single color) background. More... | |
struct | ass::Border |
Represents border. More... | |
struct | ass::BorderBottom |
Represents bottom border. More... | |
struct | ass::BorderLeft |
Represents left border. More... | |
struct | ass::BorderRadius |
Controls border radius. More... | |
struct | ass::BorderRight |
Represents right border. More... | |
struct | ass::BorderTop |
Represents top border. More... | |
struct | ass::BoxShadow |
Represents box shadow. More... | |
struct | ass::BoxShadowInner |
Represents box shadow. More... | |
struct | ass::Expanding |
Controls the expanding of AView. More... | |
struct | ass::FixedSize |
Controls the fixed size of AView. More... | |
struct | ass::Font |
Controls the font of AView. More... | |
struct | ass::FontFamily |
Controls the font family of AView. More... | |
struct | ass::FontSize |
Controls the font size of AView. More... | |
struct | ass::LayoutSpacing |
Controls the gap between elements of the container. Basically acts like a margin, but the gaps appear between views only, not around them. More... | |
struct | ass::LineHeight |
Controls line height multiplier of the font of the AView. More... | |
struct | ass::Margin |
Controls view's margins. More... | |
struct | ass::MaxSize |
Controls the max size of AView. More... | |
struct | ass::MinSize |
Controls the min size of AView. More... | |
struct | ass::Opacity |
Controls the opacity of AView. More... | |
struct | ass::Padding |
Controls the padding of AView. More... | |
struct | ass::ScrollbarAppearance |
Controls how do scrollbars and content appear in AScrollArea. This rule is applicable to AScrollArea only. More... | |
struct | ass::TextBorder |
Controls the text border of AView. More... | |
struct | ass::TextColor |
Controls the text color of AView. More... | |
struct | ass::TextShadow |
Controls the text shadow of AView. More... | |
struct | ass::TransformOffset |
Controls the rendering offset transform of AView. More... | |
struct | ass::TransformRotate |
Controls the rendering offset transform of AView. More... | |
struct | ass::TransformScale |
Controls the rendering scale transform of AView. More... | |
class | ACursor |
Represents cursor type. More... | |
Enumerations | |
enum class | ass::Sizing { Sizing::NONE , Sizing::FIT , Sizing::CENTER , Sizing::TILE , Sizing::FIT_PADDING , Sizing::COVER , Sizing::CONTAIN , Sizing::CONTAIN_PADDING , Sizing::SPLIT_2X2 , Sizing::CROPPED } |
Determines sizing rules of a background texture (BackgroundImage). More... | |
enum class | AScreenOrientation { UNDEFINED = 0 , PORTRAIT = 1 , LANDSCAPE = 2 } |
Controls screen orientation. | |
enum class | ATextAlign { LEFT , CENTER , RIGHT , JUSTIFY } |
Controls the text alignment inside AView. | |
enum class | VerticalAlign { DEFAULT , MIDDLE } |
Controls the text vertical alignment of AView. | |
|
strong |
Determines sizing rules of a background texture (BackgroundImage).
Enumerator | |
---|---|
NONE | Image is kept in it's original size. |
FIT | Resize image to view's area without keeping aspect ratio. |
CENTER | Center the image. |
TILE | Tile texture. Use with Repeat::X_y. |
FIT_PADDING | Resize image to view's content area without keeping aspect ratio. |
COVER | Resize image to view's area keeping aspect ratio and cutting of excess parts. Matches CSS background-size: cover. |
CONTAIN | Resize image to view's area keeping aspect ratio and keeping space not covered by the image. Matches CSS background-size: contain. |
CONTAIN_PADDING | Resize image to view's content area keeping aspect ratio and keeping space not covered by the image. Partially matches CSS background-size: contain. |
SPLIT_2X2 | Texture divided by 4 parts of the same size, keeping their original size. Useful for textured buttons and inputs in games. When the view is larger than the texture, the free space is covered by stretching the central row (for vertical) and the central column (for horizontal). |
CROPPED | Texture is cropped by BackgroundCropping rule. |