_#
An std::shared_ptr with AUI extensions.
| Header: | #include <AUI/Common/SharedPtrTypes.h> |
| CMake: | aui_link(my_target PUBLIC aui::core) |
Detailed Description#
Note
Of course, it is not good tone to define a class with _ type but it significantly increases coding speed. Instead of writing every time std::shared_ptr you should write only the _ symbol.
Examples#
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.
examples/app/minesweeper/src/MinesweeperWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
bool mBombsPlanted = false;
int mBombs;
int mOpenedCells;
_<AViewContainer> mGrid;
AVector<FieldCell> mField;
void openCell(int x, int y, bool doGameLoseIfBomb);
int countBombsAround(int x, int y);
bool isValidCell(int x, int y) { return x >= 0 && x < mFieldColumns && y >= 0 && y < mFieldRows; }
examples/app/minesweeper/src/NewGameWindow.h
Minesweeper Game - Minesweeper game implementation driven by ass.
NewGameWindow(MinesweeperWindow* minesweeper);
private:
MinesweeperWindow* mMinesweeper;
_<ANumberPicker> mWidth;
_<ANumberPicker> mHeight;
_<ANumberPicker> mMines;
_<ALabel> mDifficultyLabel;
void updateMinesMax();
examples/app/fractal/src/JumpToCoordsWindow.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
examples/app/fractal/src/FractalView.h
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
class FractalView : public AView {
private:
gl::Program mShader;
_<gl::Texture2D> mTexture;
glm::mat4 mTransform;
float mAspectRatio;
void handleMatrixUpdated();
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
#include <AUI/Platform/AMessageBox.h>
using namespace declarative;
JumpToCoordsWindow::JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent)
: AWindow("Jump to coords", 854_dp, 500_dp, parent, WindowStyle::NO_RESIZE) {
auto re = _new<ATextField>();
auto im = _new<ATextField>();
auto scale = _new<ATextField>();
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/ui/contacts/src/view/ContactDetailsView.h
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
#include <AUI/View/AViewContainer.h>
class ContactDetailsView : public AViewContainerBase {
public:
ContactDetailsView(_<Contact> contact);
signals:
emits<> deleteAction;
private:
examples/ui/contacts/src/view/common.h
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
#include <AUI/View/AView.h>
namespace common_views {
_<AView> divider();
}
examples/ui/contacts/src/view/common.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
using namespace ass;
using namespace declarative;
_<AView> common_views::divider() {
return _new<AView>() AUI_OVERRIDE_STYLE { FixedSize { {}, 1_px }, BackgroundSolid { AColor::GRAY } };
}
examples/ui/backdrop/src/main.cpp
Backdrop - Backdrop effects demo.
using namespace declarative;
using namespace ass;
static auto headerWithContents(_<AView> content) {
auto result = Stacked {
AScrollArea::Builder().withContents(content).build() AUI_OVERRIDE_STYLE {
Expanding(),
Padding { 80_dp, 0, 0 },
} AUI_LET { it->setExtraStylesheet(
examples/ui/views/src/ExampleWindow.h
Views Example - All-in-one views building example.
bool onDragEnter(const ADragNDrop::EnterEvent& event) override;
private:
ADeque<_<AWindow>> mWindows;
AAsyncHolder mAsync;
_<IAudioPlayer> mWavAudio;
_<IAudioPlayer> mOggAudio;
};
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
Public Methods#
constructor { #:: ::() }#
Constructs a shared_ptr which shares ownership of the object managed by v.
Constructs a shared_ptr which shares ownership of the object managed by v. If v manages no object, *this
manages no object either.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
Move-constructs a shared_ptr from v.
After the construction, *this contains a copy of the previous state of v, v is empty and its stored pointer
is null.
In comparison to copy-constructing, the move-constructor is cheaper, as it does not require an atomic operation.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
Constructs a shared_ptr which shares ownership of the object managed by v.
Constructs a shared_ptr which shares ownership of the object managed by v. If v manages no object, *this
manages no object either.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
Move-constructs a shared_ptr from v.
After the construction, *this contains a copy of the previous state of v, v is empty and its stored pointer
is null.
In comparison to copy-constructing, the move-constructor is cheaper, as it does not require an atomic operation.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
Constructs a shared_ptr which shares ownership of the object managed by v.
Throws std::bad_weak_ptr if expired.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;
_::_(const _weak<T>& v)
Constructs a shared_ptr which shares ownership of the object managed by v.
Throws std::bad_weak_ptr if expired.
Examples:
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.
examples/ui/opengl_simple/src/main.cpp
OpenGL Example - Demonstrates how to integrate custom OpenGL rendering with AUI Framework.
};
class MyRenderer : public AView {
public:
MyRenderer(_<State> state) : mState(std::move(state)) {
// Simple passthrough ES 2.0 shaders
const char* vsSrc =
"attribute vec2 aPos;\n"
"void main(){\n"
" gl_Position = vec4(aPos, 0.0, 1.0);\n"
examples/7guis/flight_booker/src/main.cpp
7GUIs Flight Booker - Flight Booker.
struct std::common_type<ass::BackgroundSolid, std::nullptr_t> {
using type = _<ass::prop::IPropertyBase>;
};
auto dateTextField(_<DateTextFieldState> state) {
return _new<ATextField>() AUI_LET {
AObject::connect(
state->parsed, it, [&it = *it, &state = *state](const AOptional<system_clock::time_point>& value) {
if (!value) {
return;
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
examples/ui/infinite_lazy_list/src/main.cpp
Infinite Lazy List - Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.
};
});
return Vertical {
AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
Centered {
_new<ASpinnerV2>() AUI_LET {
AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
// when a spinner appears, we indicate that we need more items.
state->needMore = true;