Skip to content

ADrawableView#

Simple view to draw images.

Header:#include <AUI/View/ADrawableView.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

ADrawableView brings you more control over the drawable. This is useful for drawables with extended interface (i.e., AAnimatedImage).

The sizing and positioning acts like ass::BackgroundImage. Moreover, these rules are taken from ass::BackgroundImage applied to ADrawableView:

auto drawable = IDrawable::fromUrl(":animation.webp");
_new<ADrawableView>(drawable) AUI_WITH_STYLE {
  BackgroundImage({}, {}, {}, Sizing::COVER), // <- drawable is sized and positioned as with COVER.
};

When applying ass::BackgroundImage, do not pass url to it, it's redundant for ADrawableView and would cause a debug error.

API surface#

struct declarative::Icon

Empty structure.

Examples#

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" } with_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/backdrop/src/main.cpp

Backdrop - Backdrop effects demo.

    window->setContents(headerWithContents(
        Centered {
          Vertical::Expanding {
            Centered {
              Icon { ":logo.svg" } AUI_WITH_STYLE { FixedSize { 128_dp } },
            } AUI_WITH_STYLE { FixedSize { 500_dp, {} } },
            AText::fromString(
                "    — Eh bien, mon prince. Gênes et Lucques ne sont plus que des apanages, des "
                "поместья, de la famille Buonaparte. Non, je vous préviens que si vous ne me dites pas "
                "que nous avons la guerre, si vous vous permettez encore de pallier toutes les infamies, "

examples/ui/contacts/src/view/ContactDetailsView.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

        return;
    }

    // discard
    if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
        return;
    }
    mContact = mOriginalContact;
    mEditorMode = false;
}

Public Methods#

constructor#


explicit ADrawableView::ADrawableView(const AUrl& url)

Create an instance with the URL of a image resource.

Arguments
url
URL to the image resource.

explicit ADrawableView::ADrawableView(_<IDrawable> drawable)

Create an instance from the given drawable.

Arguments
drawable
The IDrawable to be rendered.

drawable#


auto ADrawableView::drawable()

Drawable property.