AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
BackgroundGradient.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 29.12.2020.
14//
15
16#pragma once
17
18#include <AUI/Util/ALayoutDirection.h>
19#include "IProperty.h"
20
21namespace ass {
28
29 BackgroundGradient(std::nullptr_t) noexcept {};
30 BackgroundGradient(ALinearGradientBrush brush) noexcept: gradient(std::move(brush)) {}
31
32 BackgroundGradient(AColor begin, AColor end, AAngleRadians angle) noexcept: gradient(ALinearGradientBrush{
33 .colors = {
34 {0.f, begin},
35 {1.f, end},
36 },
37 .rotation = angle
38 }) {}
39 BackgroundGradient(AColor begin, AColor end, ALayoutDirection direction) noexcept: BackgroundGradient(begin, end, direction == ALayoutDirection::VERTICAL ? 180_deg : 90_deg) {}
40 };
41
42 namespace prop {
43 template<>
44 struct API_AUI_VIEWS Property<BackgroundGradient>: IPropertyBase {
45 private:
47
48 public:
49 Property(const BackgroundGradient& info) : mInfo(info) {
50
51 }
52
53 void renderFor(AView* view, const ARenderContext& ctx) override;
54
55 PropertySlot getPropertySlot() const override;
56
57 [[nodiscard]]
58 const auto& value() const noexcept {
59 return mInfo;
60 }
61
62 };
63
64 }
65}
Strong type used to store angle in radians.
Definition: AAngleRadians.h:42
Represents a 4-component floating point color.
Definition: AColor.h:27
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition: AOptional.h:32
Base class of all UI objects.
Definition: AView.h:77
Definition: ABrush.h:48
Render context passed to AView::render.
Definition: ARenderContext.h:43
Represents gradient background.
Definition: BackgroundGradient.h:26
Base class for all properties.
Definition: IPropertyBase.h:49
Definition: IProperty.h:19