AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
BackgroundCropping.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 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 3.12.2020.
   14//
   15
   16#pragma once
   17
   18#include "AUI/Render/IRenderer.h"
   19#include "IProperty.h"
   20
   21namespace ass {
   22
   27    struct BackgroundCropping {
   28        unset_wrap<glm::vec2> offset;
   29        unset_wrap<glm::vec2> size;
   30
   31        BackgroundCropping() noexcept = default;
   32        BackgroundCropping(const BackgroundCropping&) noexcept = default;
   33        BackgroundCropping(const glm::vec2& offset, const unset_wrap<glm::vec2>& size) noexcept:
   34            offset(offset), size(size) {}
   35
   36        static const BackgroundCropping H4_1;
   37        static const BackgroundCropping H4_2;
   38        static const BackgroundCropping H4_3;
   39        static const BackgroundCropping H4_4;
   40    };
   41
   42    namespace prop {
   43        template<>
   44        struct API_AUI_VIEWS Property<BackgroundCropping>: IPropertyBase {
   45        private:
   46            BackgroundCropping mInfo;
   47
   48        public:
   49            Property(const BackgroundCropping& info) : mInfo(info) {
   50
   51            }
   52
   53            void applyFor(AView* view) override;
   54
   55            [[nodiscard]]
   56            const auto& value() const noexcept {
   57                return mInfo;
   58            }
   59        };
   60
   61    }
   62}
   63
   64inline const ass::BackgroundCropping ass::BackgroundCropping::H4_1 = { glm::vec2{0.f / 4.f, 0.f}, glm::vec2{1.f / 4.f, 1.f} };
   65inline const ass::BackgroundCropping ass::BackgroundCropping::H4_2 = { glm::vec2{1.f / 4.f, 0.f}, glm::vec2{1.f / 4.f, 1.f} };
   66inline const ass::BackgroundCropping ass::BackgroundCropping::H4_3 = { glm::vec2{2.f / 4.f, 0.f}, glm::vec2{1.f / 4.f, 1.f} };
   67inline const ass::BackgroundCropping ass::BackgroundCropping::H4_4 = { glm::vec2{3.f / 4.f, 0.f}, glm::vec2{1.f / 4.f, 1.f} };
Base class of all UI objects.
Definition AView.h:78
Controls background texture cropping by exact UV coordinates. Useful for texture atlases.
Definition BackgroundCropping.h:27
Base class for all properties.
Definition IPropertyBase.h:50
Definition unset.h:28