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
42
class
API_AUI_VIEWS
ADrawableView
:
public
AView
{
43
public
:
48
explicit
ADrawableView
(
const
AUrl
& url);
49
54
explicit
ADrawableView
(
_<IDrawable>
drawable);
55
ADrawableView
();
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
68
private
:
69
_<IDrawable>
mDrawable;
70
};
71
72
template
<>
73
struct
ADataBindingDefault
<
ADrawableView
,
_
<
IDrawable
>> {
74
public
:
75
static
void
setup
(
const
_<ADrawableView>
& view) {
76
}
77
78
static
auto
getSetter() {
return
&ADrawableView::setDrawable; }
79
};
80
81
namespace
declarative {
82
using
Icon =
aui::ui_building::view<ADrawableView>
;
83
}
ADrawableView
Simple view to draw an IDrawable.
Definition:
ADrawableView.h:42
AUrl
Uniform Resource Locator implementation.
Definition:
AUrl.h:31
AView
Base class of all UI objects.
Definition:
AView.h:77
AView::redraw
void redraw()
Request window manager to redraw this AView.
Definition:
AView.cpp:68
AView::render
virtual void render(ARenderContext ctx)
Draws this AView. Noone should call this function except rendering routine.
Definition:
AView.cpp:142
IDrawable
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
ADataBindingDefault
Definition:
ADataBinding.h:24
ADataBindingDefault::setup
static void setup(const _< View > &view)
Definition:
ADataBinding.h:30
ARenderContext
Render context passed to AView::render.
Definition:
ARenderContext.h:43
aui::ui_building::view
Definition:
Declarative.h:91