AButton#
Button with text, which can be pushed to make some action.
Header: | #include <AUI/View/AButton.h> |
CMake: | aui_link(my_target PUBLIC aui::views) |
Detailed Description#
Button is a fundamental view which can be pushed to make some action.

Button is styled with background, box shadow, and a border that highlights on hover. When pushed, the shadow disappears, making an illusion of pressing.
Button can be made default. In such case, it is colored to user's accent color, making it stand out. Also, when the
user presses Enter
, the button is pushed automatically.
Button usually contains text only, but in practice any view can be put in it.
|
Examples#
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
{ "Scale="_as, scale },
}),
Horizontal {
SpacerExpanding {},
_new<AButton>("Jump").connect(
&AButton::clicked, this,
[&, fractalView, re, im, scale]() {
try {
auto dRe = std::stod((*re->text()).toStdString());
auto dIm = -std::stod((*re->text()).toStdString());
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.
GameOfLifeWindow() : AWindow("Game of Life") {
setContents(Vertical {
Centered {
Horizontal {
_new<AButton>("Randomize") AUI_LET {
connect(it->clicked, AUI_SLOT(mCells)::randomize);
},
_new<AButton>() AUI_LET {
it & mCells.isRunning > [](AButton& b, bool isRunning) {
b.setText(isRunning ? "Pause" : "Run");
examples/app/minesweeper/src/Style.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
examples/ui/minimal_ui_xmake/src/MainWindow.cpp
Minimal UI Template XMake - Minimal UI boilerplate template XMake.
setContents(
Centered{
Vertical{
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, [] {
APlatform::openUrl("https://aui-framework.github.io/");
}),
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
examples/7guis/timer/src/main.cpp
7GUIs Timer - Timer example.
});
it->setCustomStyle({ Expanding {} });
},
},
_new<AButton>("Reset Timer") AUI_WITH_STYLE {
Expanding { 1, 0 },
} AUI_LET { connect(it->clicked, me::reset); },
},
});
examples/app/fractal/src/FractalWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
},
},
},
Vertical {
_new<AButton>("Identity").connect(&AButton::clicked, AUI_SLOT(fractal)::reset),
_new<AButton>("Jump to coords...")
.connect(&AButton::clicked, this, [&, fractal]() { _new<JumpToCoordsWindow>(fractal, this)->show(); }),
_new<ALabel>("Iterations:"),
_new<ANumberPicker>().connect(
&ANumberPicker::valueChanged, this, [fractal](int v) { fractal->setIterations(v); }) AUI_LET {
examples/app/minesweeper/src/NewGameWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
}),
mDifficultyLabel = _new<ALabel>(),
Horizontal {
_new<ASpacerExpanding>(),
_new<AButton>("Start game") AUI_LET {
it->setDefault();
connect(it->clicked, me::begin);
},
_new<AButton>("Cancel").connect(&AButton::clicked, me::close),
},
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game - Minesweeper game implementation driven by ass.
MinesweeperWindow::MinesweeperWindow() : AWindow("Minesweeper", 100_dp, 100_dp) {
setContents(Vertical {
Horizontal {
Centered::Expanding {
_new<AButton>("New game...").connect(&AButton::clicked, me::newGame),
},
},
_container<AStackedLayout>(
{ // also assign ".frame" ASS class in place
mGrid = _new<AViewContainer>() << ".frame" }) });