AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
ADrawableView.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12//
13// Created by alex2 on 23.10.2020.
14//
15
16#pragma once
17
18#include <AUI/Image/IDrawable.h>
19#include <AUI/Util/Declarative.h>
20#include "AView.h"
21
42class API_AUI_VIEWS ADrawableView: public AView {
43public:
48 explicit ADrawableView(const AUrl& url);
49
54 explicit ADrawableView(_<IDrawable> drawable);
56 void render(ARenderContext context) override;
57
58 void setDrawable(const _<IDrawable>& drawable) {
59 mDrawable = drawable;
60 redraw();
61 }
62
63 [[nodiscard]]
64 const _<IDrawable>& getDrawable() const noexcept {
65 return mDrawable;
66 }
67
68private:
69 _<IDrawable> mDrawable;
70};
71
72template<>
74public:
75 static void setup(const _<ADrawableView>& view) {
76 }
77
78 static auto getSetter() { return &ADrawableView::setDrawable; }
79};
80
81namespace declarative {
83}
Simple view to draw an IDrawable.
Definition: ADrawableView.h:42
Uniform Resource Locator implementation.
Definition: AUrl.h:31
Base class of all UI objects.
Definition: AView.h:77
void redraw()
Request window manager to redraw this AView.
Definition: AView.cpp:68
virtual void render(ARenderContext ctx)
Draws this AView. Noone should call this function except rendering routine.
Definition: AView.cpp:142
An abstract image that determines itself how it is displayed. Essentially an abstraction from vector ...
Definition: IDrawable.h:28
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Definition: ADataBinding.h:24
static void setup(const _< View > &view)
Definition: ADataBinding.h:30
Render context passed to AView::render.
Definition: ARenderContext.h:43
Definition: Declarative.h:91