Skip to content

_#

@brief An std::weak_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/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/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.h

Fractal Example - Fractal viewer application demonstrating usage of custom shaders.

#include "FractalView.h"

class JumpToCoordsWindow : public AWindow {
public:
    explicit JumpToCoordsWindow(_<FractalView> fractalView, AWindow* parent);
};

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.

    AProperty<bool> isRunning = false;
    emits<> frameComplete;

private:
    _<ATimer> mTimer = _new<ATimer>(100ms);
    AFuture<> mFrame;
    glm::ivec2 mSize {};
    AVector<CellState> mStorage;
    AVector<CellState> mNextPopulation;

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/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/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_WITH_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/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_WITH_STYLE { FixedSize { {}, 1_px }, BackgroundSolid { AColor::GRAY } };
}

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/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/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

static constexpr auto MAX_RADIUS = 128.f;

class CircleDrawArea : public AView {
public:
    CircleDrawArea(_<State> state) : mState(std::move(state)) {
        setCustomStyle({
          Expanding(),
          BackgroundSolid(AColor::WHITE),
          Border(1_px, AColor::GRAY),
          AOverflow::HIDDEN_FROM_THIS,

Public Methods#

_ { #:: ::() }#


_::_(T* v)

Trap constructor

In order to make shared pointer from the raw one, please explicitly specify how do you want manage memory by using either aui::ptr::manage or aui::ptr::fake. ## Examples ??? note "examples/app/game_of_life/src/main.cpp" [Game of Life](game-of-life.md) - Game of Life implementation that uses advanced large dynamic data rendering techniques such as [ITexture](itexture.md), [AImage](aimage.md) to be GPU friendly. The computation is performed in [AThreadPool](athreadpool.md).

    AProperty<bool> isRunning = false;
    emits<> frameComplete;

private:
    _<ATimer> mTimer = _new<ATimer>(100ms);
    AFuture<> mFrame;
    glm::ivec2 mSize {};
    AVector<CellState> mStorage;
    AVector<CellState> mNextPopulation;
??? note "examples/7guis/circle_drawer/src/main.cpp" [7GUIs Circle Drawer](7guis-circle-drawer.md) - Undo, redo, dialog control.
static constexpr auto MAX_RADIUS = 128.f;

class CircleDrawArea : public AView {
public:
    CircleDrawArea(_<State> state) : mState(std::move(state)) {
        setCustomStyle({
          Expanding(),
          BackgroundSolid(AColor::WHITE),
          Border(1_px, AColor::GRAY),
          AOverflow::HIDDEN_FROM_THIS,
??? note "examples/ui/infinite_lazy_list/src/main.cpp" [Infinite Lazy List](infinite-lazy-list.md) - 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;
### value { #_::value _::value() }
---
std::add_lvalue_reference_t<T> _::value()
Dereferences the stored pointer.
On a debug build, throws an assertion failure if the stored pointer is `nullptr`, otherwise behaviour is undefined. ## Examples ??? note "examples/ui/infinite_lazy_list/src/main.cpp" [Infinite Lazy List](infinite-lazy-list.md) - 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;
??? note "examples/7guis/flight_booker/src/main.cpp" [7GUIs Flight Booker](7guis-flight-booker.md) - Flight Booker.
                  return sys_days(ymd);
              },
            }),
            it->text());
        it & state.parsed > [](AView& textField, const AOptional<system_clock::time_point>& value) {
            textField.setAssName(".red", !value.hasValue());
        };
    };
}
??? note "examples/7guis/cells/tests/FormulaTests.cpp" [7GUIs Cells](7guis-cells.md) - Spreadsheet processor (Excel).
TEST_F(Cells_Formula, ChangePropagation) {
    mSpreadsheet[{1, 0}].expression = "=A0+1";

    mSpreadsheet[{0, 0}].expression = "228";
    EXPECT_EQ(std::get<double>(mSpreadsheet[{1, 0}].value.value()), 229);

    mSpreadsheet[{0, 0}].expression = "0";
    EXPECT_EQ(std::get<double>(mSpreadsheet[{1, 0}].value.value()), 1);
}
??? note "examples/7guis/temperature_converter/src/main.cpp" [7GUIs Temperature Converter](7guis-temperature-converter.md) - Fahrenheit to Celsius and vice versa.
    TemperatureConverterWindow() : AWindow("AUI - 7GUIs - TempConv", 300_dp, 50_dp) {
        setContents(Centered {
          Horizontal {
            myPicker() AUI_LET {
                biConnect(it->value(), mCelsius);
                it->focus();
            },
            Label { "°C" },
            Label { "=" } AUI_WITH_STYLE { Margin { {}, 16_dp } },
            myPicker() AUI_LET { biConnect(it->value(), mFahrenheit); },
### weak { #_::weak _::weak() }
---
_weak<T> _::weak()
Returns
weak reference
## Examples ??? note "examples/ui/infinite_lazy_list/src/main.cpp" [Infinite Lazy List](infinite-lazy-list.md) - 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;