neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
gradient.hpp
Go to the documentation of this file.
1// gradient.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <neolib/core/uuid.hpp>
25
26namespace neogfx::game
27{
28 struct gradient
29 {
31 std::optional<aabb_2d> boundingBox;
32
34 {
35 static const neolib::uuid& id()
36 {
37 static const neolib::uuid sId = { 0x7056b018, 0x15a1, 0x4bb1, 0x8b32, { 0xa2, 0x2e, 0x2a, 0x9f, 0xb7, 0xe7 } };
38 return sId;
39 }
40 static const i_string& name()
41 {
42 static const string sName = "Gradient";
43 return sName;
44 }
45 static uint32_t field_count()
46 {
47 return 2;
48 }
49 static component_data_field_type field_type(uint32_t aFieldIndex)
50 {
51 switch (aFieldIndex)
52 {
53 case 0:
54 return component_data_field_type::Id;
55 case 1:
56 return component_data_field_type::Aabb2d | component_data_field_type::Optional;
57 default:
58 throw invalid_field_index();
59 }
60 }
61 static neolib::uuid field_type_id(uint32_t aFieldIndex)
62 {
63 switch (aFieldIndex)
64 {
65 case 0:
66 case 1:
67 return neolib::uuid{};
68 default:
69 throw invalid_field_index();
70 }
71 }
72 static const i_string& field_name(uint32_t aFieldIndex)
73 {
74 static const string sFieldNames[] =
75 {
76 "Id",
77 "Bounding Box"
78 };
79 return sFieldNames[aFieldIndex];
80 }
81 };
82 };
83
84 inline bool batchable(const gradient& lhs, const gradient& rhs)
85 {
86 return lhs.id.cookie() == rhs.id.cookie() &&
87 lhs.boundingBox == rhs.boundingBox; // todo: allow batching with different bounding boxes
88 }
89}
bool batchable(const filter &lhs, const filter &rhs)
Definition filter.hpp:88
basic_cookie_ref_ptr< cookie > cookie_ref_ptr
Definition jar.hpp:732
static const i_string & field_name(uint32_t aFieldIndex)
Definition gradient.hpp:72
static uint32_t field_count()
Definition gradient.hpp:45
static const neolib::uuid & id()
Definition gradient.hpp:35
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition gradient.hpp:49
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition gradient.hpp:61
static const i_string & name()
Definition gradient.hpp:40
std::optional< aabb_2d > boundingBox
Definition gradient.hpp:31
neolib::cookie_ref_ptr id
Definition gradient.hpp:30