AUI_OVERRIDE_STYLE#
Allows to define a style to the view right in place.
| Header: | #include <AUI/Util/kAUI.h> |
| CMake: | aui_link(my_target PUBLIC aui::core) |
Definition#
#define AUI_OVERRIDE_STYLE &ass::PropertyListRecursive
Detailed Description#
#include <AUI/ASS/ASS.h>
using namespace ass;
...
setContents(Centered {
_new<ALabel>("Red text!") AUI_OVERRIDE_STYLE { TextColor { AColor::RED } },
});
Also applicable to declarative-style views:
#include <AUI/ASS/ASS.h>
using namespace ass;
...
setContents(Centered {
Label { "Red text!" } AUI_OVERRIDE_STYLE { TextColor { AColor::RED } },
});
Examples#
examples/7guis/cells/src/main.cpp
7GUIs Cells — Spreadsheet processor (Excel).
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker — Flight Booker.
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer — Undo, redo, dialog control.
},
},
},
_new<CircleDrawArea>(aui::ptr::fake_shared(&mState)),
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } });
}
private:
State mState;
examples/7guis/timer/src/main.cpp
7GUIs Timer — Timer example.
examples/7guis/crud/src/main.cpp
7GUIs CRUD — Create/Read/Update/Delete example.
Horizontal::Expanding {
Vertical::Expanding {
Horizontal {
Label { "Filter prefix:" },
_new<ATextField>() AUI_OVERRIDE_STYLE { Expanding(1, 0) } && mFilterPrefix,
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
AScrollArea::Builder().withExpanding().withContents(
AUI_DECLARATIVE_FOR(i, *mUsers | FILTER_VIEW, AVerticalLayout) {
auto view = _new<ALabel>();
view & i->displayName;
examples/7guis/counter/src/main.cpp
7GUIs Counter — Simple counter.
examples/7guis/temperature_converter/src/main.cpp
7GUIs Temperature Converter — Fahrenheit to Celsius and vice versa.
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game — Minesweeper game implementation driven by ass.
},
_container<AStackedLayout>(
{ // also assign ".frame" ASS class in place
mGrid = _new<AViewContainer>() << ".frame" }),
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } });
beginGame(10, 10, 20);
}
void MinesweeperWindow::openCell(int x, int y, bool doGameLoseIfBomb) {
examples/app/fractal/src/FractalWindow.cpp
Fractal Example — Fractal viewer application demonstrating usage of custom shaders.
&ANumberPicker::valueChanged, this, [fractal](int v) { fractal->setIterations(v); }) AUI_LET {
it->setMax(1000);
it->setValue(350);
},
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } });
fractal->focus();
}
examples/app/game_of_life/src/main.cpp
Game of Life — Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
b.setText(isRunning ? "Pause" : "Run");
};
connect(it->clicked, [&] { mCells.isRunning = !mCells.isRunning; });
},
} AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
},
Centered {
_new<CellsView>(aui::ptr::fake_shared(&mCells)) AUI_OVERRIDE_STYLE {
Expanding(),
BackgroundSolid(AColor::BLACK),
examples/app/notes/src/main.cpp
Notes App — Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.
return Vertical {
Label {
.text = AUI_REACT(stringOneLinePreview(note->title)),
} AUI_OVERRIDE_STYLE { FontSize { 10_pt }, ATextOverflow::ELLIPSIS },
Label {
.text = AUI_REACT(stringOneLinePreview(note->content)),
} AUI_OVERRIDE_STYLE {
ATextOverflow::ELLIPSIS,
Opacity { 0.7f },
examples/ui/minimal_ui_assets_xmake/src/MainWindow.cpp
Minimal UI Template XMake with Assets — Minimal UI boilerplate template XMake with AUI Assets.
MainWindow::MainWindow(): AWindow("Project template app", 300_dp, 200_dp) {
setContents(
Centered{
Vertical{
Centered { Icon { ":img/logo.svg" } AUI_OVERRIDE_STYLE { FixedSize(64_dp) } },
Centered { Label { "Hello world from AUI!" } },
_new<AButton>("Visit GitHub repo").connect(&AView::clicked, this, [] {
APlatform::openUrl("https://github.com/aui-framework/aui");
}),
_new<AButton>("Visit docs").connect(&AView::clicked, this, [] {
examples/ui/contacts/src/main.cpp
AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
Vertical {
SpacerFixed(8_dp),
_new<ATextField>() && mSearchQuery,
SpacerFixed(8_dp),
AText::fromString(predefined::DISCLAIMER) AUI_OVERRIDE_STYLE { ATextAlign::CENTER },
SpacerFixed(8_dp),
experimental::Dynamic {
.content = AUI_REACT(mSearchQuery->empty() ? indexedList() : searchQueryList()),
},
Label { AUI_REACT("{} contact(s)"_format(mContactCount)) } AUI_LET {
examples/ui/opengl_simple/src/main.cpp
OpenGL Example — Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
auto window = _new<AWindow>("OpenGL Demo", 600_dp, 300_dp);
auto state = _new<State>();
window->setContents(
Stacked {
_new<MyRenderer>(state) AUI_OVERRIDE_STYLE { Expanding() },
Horizontal::Expanding {
Vertical {
Vertical {
Label { AUI_REACT(fmt::format("FPS: {:.1f}", *state->fps)) },
} AUI_OVERRIDE_STYLE {
examples/ui/views/src/ExampleWindow.cpp
Views Example — All-in-one views building example.
};
/// [label_coloring]
static _<AView> link(const AString& url) {
return Label { url } AUI_OVERRIDE_STYLE {
TextColor { AColor::BLUE },
BorderBottom { 1_px, AColor::BLUE },
ACursor::POINTER,
} AUI_LET { AObject::connect(it->clicked, AObject::GENERIC_OBSERVER, [url] { APlatform::openUrl(url); }); };
}
Examples#
examples/app/minesweeper/src/NewGameWindow.cpp
Minesweeper Game — Minesweeper game implementation driven by ass.
{
"Mines count:"_as,
mMines = _new<ANumberPicker>() AUI_LET { it->setMin(8); },
},
}) AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
mDifficultyLabel = _new<ALabel>(),
Horizontal {
_new<ASpacerExpanding>(),
_new<AButton>("Start game") AUI_LET {
it->setDefault();
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example — Fractal viewer application demonstrating usage of custom shaders.
_form({
{ "Re="_as, re },
{ "Im="_as, im },
{ "Scale="_as, scale },
}) AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
Horizontal {
SpacerExpanding {},
_new<AButton>("Jump").connect(
&AButton::clicked, this,
[&, fractalView, re, im, scale]() {
examples/ui/contacts/src/view/common.cpp
AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
_<AView> profilePhoto(const _<Contact>& contact) {
return Centered {
Label {
AUI_REACT(contact->displayName->empty() ? "?" : AString(1, contact->displayName->first()).uppercase())
} AUI_OVERRIDE_STYLE { Opacity(0.5f), FontSize { 32_dp } },
} AUI_OVERRIDE_STYLE {
FixedSize { 64_dp },
BorderRadius { 32_dp },
BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
};