neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_gradient_manager.hpp
Go to the documentation of this file.
1// i_gradient_manager.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 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/jar.hpp>
25
26namespace neogfx
27{
29 {
30 friend class gradient_object;
31 // exceptions
32 public:
33 struct gradient_not_found : std::logic_error { gradient_not_found() : std::logic_error("neogfx::i_gradient_manager::gradient_not_found") {} };
34 // types
35 public:
37 // operations
38 public:
39 virtual void clear_gradients() = 0;
40 virtual i_gradient_sampler const& sampler(i_gradient const& aGradient) = 0;
41 virtual i_gradient_filter const& filter(i_gradient const& aGradient) = 0;
42 // helpers
43 public:
45 {
47 do_find_gradient(aId, result);
48 return result;
49 }
51 {
53 do_create_gradient(result);
54 return result;
55 }
57 {
59 do_create_gradient(aOther, result);
60 return result;
61 }
63 {
65 do_create_gradient(aCssDeclaration, result);
66 return result;
67 }
69 {
71 do_create_gradient(aColor, result);
72 return result;
73 }
75 {
77 do_create_gradient(aColor, aDirection, result);
78 return result;
79 }
81 {
83 do_create_gradient(aColor1, aColor2, aDirection, result);
84 return result;
85 }
86 neolib::ref_ptr<i_gradient> create_gradient(i_gradient::color_stop_list const& aColorStops, gradient_direction aDirection = gradient_direction::Vertical)
87 {
89 do_create_gradient(aColorStops, aDirection, result);
90 return result;
91 }
92 neolib::ref_ptr<i_gradient> create_gradient(i_gradient::color_stop_list const& aColorStops, i_gradient::alpha_stop_list const& aAlphaStops, gradient_direction aDirection = gradient_direction::Vertical)
93 {
95 do_create_gradient(aColorStops, aAlphaStops, aDirection, result);
96 return result;
97 }
98 neolib::ref_ptr<i_gradient> create_gradient(i_gradient const& aOther, i_gradient::color_stop_list const& aColorStops)
99 {
101 do_create_gradient(aOther, aColorStops, result);
102 return result;
103 }
104 neolib::ref_ptr<i_gradient> create_gradient(i_gradient const& aOther, i_gradient::color_stop_list const& aColorStops, i_gradient::alpha_stop_list const& aAlphaStops)
105 {
107 do_create_gradient(aOther, aColorStops, aAlphaStops, result);
108 return result;
109 }
111 {
113 do_create_gradient(aColors, aDirection, result);
114 return result;
115 }
116 neolib::ref_ptr<i_gradient> create_gradient(std::initializer_list<sRGB_color> const& aColors, gradient_direction aDirection = gradient_direction::Vertical)
117 {
118 return create_gradient(neolib::vector<sRGB_color>{aColors}, aDirection);
119 }
120 // implementation
121 private:
122 virtual void do_find_gradient(gradient_id aId, neolib::i_ref_ptr<i_gradient>& aResult) const = 0;
123 virtual void do_create_gradient(neolib::i_ref_ptr<i_gradient>& aResult) = 0;
124 virtual void do_create_gradient(i_gradient const& aOther, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
125 virtual void do_create_gradient(i_string const& aCssDeclaration, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
126 virtual void do_create_gradient(sRGB_color const& aColor, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
127 virtual void do_create_gradient(sRGB_color const& aColor, gradient_direction aDirection, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
128 virtual void do_create_gradient(sRGB_color const& aColor1, sRGB_color const& aColor2, gradient_direction aDirection, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
129 virtual void do_create_gradient(i_gradient::color_stop_list const& aColorStops, gradient_direction aDirection, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
130 virtual void do_create_gradient(i_gradient::color_stop_list const& aColorStops, i_gradient::alpha_stop_list const& aAlphaStops, gradient_direction aDirection, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
131 virtual void do_create_gradient(i_gradient const& aOther, i_gradient::color_stop_list const& aColorStops, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
132 virtual void do_create_gradient(i_gradient const& aOther, i_gradient::color_stop_list const& aColorStops, i_gradient::alpha_stop_list const& aAlphaStops, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
133 virtual void do_create_gradient(neolib::i_vector<sRGB_color::abstract_type> const& aColors, gradient_direction aDirection, neolib::i_ref_ptr<i_gradient>& aResult) = 0;
134 public:
135 static uuid const& iid() { static uuid const sIid{ 0x15d5c3b1, 0x195e, 0x4e90, 0x9b65, { 0x46, 0x70, 0x7e, 0xb9, 0x6e, 0xd5 } }; return sIid; }
136 };
137}
virtual i_gradient_sampler const & sampler(i_gradient const &aGradient)=0
neolib::ref_ptr< i_gradient > create_gradient()
neolib::ref_ptr< i_gradient > create_gradient(i_gradient const &aOther)
neolib::ref_ptr< i_gradient > create_gradient(sRGB_color const &aColor1, sRGB_color const &aColor2, gradient_direction aDirection=gradient_direction::Vertical)
neolib::ref_ptr< i_gradient > create_gradient(std::initializer_list< sRGB_color > const &aColors, gradient_direction aDirection=gradient_direction::Vertical)
virtual void clear_gradients()=0
virtual i_gradient_filter const & filter(i_gradient const &aGradient)=0
neolib::ref_ptr< i_gradient > create_gradient(i_gradient::color_stop_list const &aColorStops, gradient_direction aDirection=gradient_direction::Vertical)
neolib::ref_ptr< i_gradient > find_gradient(gradient_id aId) const
neolib::ref_ptr< i_gradient > create_gradient(neolib::i_vector< sRGB_color::abstract_type > const &aColors, gradient_direction aDirection=gradient_direction::Vertical)
neolib::ref_ptr< i_gradient > create_gradient(i_string const &aCssDeclaration)
neolib::ref_ptr< i_gradient > create_gradient(i_gradient const &aOther, i_gradient::color_stop_list const &aColorStops)
neolib::ref_ptr< i_gradient > create_gradient(i_gradient::color_stop_list const &aColorStops, i_gradient::alpha_stop_list const &aAlphaStops, gradient_direction aDirection=gradient_direction::Vertical)
neolib::ref_ptr< i_gradient > create_gradient(sRGB_color const &aColor)
neolib::ref_ptr< i_gradient > create_gradient(i_gradient const &aOther, i_gradient::color_stop_list const &aColorStops, i_gradient::alpha_stop_list const &aAlphaStops)
neolib::ref_ptr< i_gradient > create_gradient(sRGB_color const &aColor, gradient_direction aDirection)
game::id_t gradient_id
gradient_direction