neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_graphics_context.hpp
Go to the documentation of this file.
1// i_graphics_context.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 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 <memory>
24#ifdef _WIN32
25#pragma warning( push )
26#pragma warning( disable: 4459 ) // declaration of 'name' hides global declaration
27#endif
28#include <boost/multi_array.hpp>
29#ifdef _WIN32
30#pragma warning( pop )
31#endif
32#include <optional>
36#include <neogfx/gfx/path.hpp>
37#include <neogfx/gfx/pen.hpp>
41#include <neogfx/game/mesh.hpp>
43
44namespace neogfx
45{
46 class i_surface;
47 class i_texture;
48 class i_widget;
49 class i_render_target;
50
51 class i_graphics_context;
52
53 typedef int32_t layer_t;
54 layer_t constexpr LayerWidget = 0x00000000u;
55 layer_t constexpr LayerNestedWindow = 0x10000000u;
56
58 {
60 std::unique_ptr<i_graphics_context> buffer1;
61 std::unique_ptr<i_graphics_context> buffer2;
62 };
63
64 ping_pong_buffers create_ping_pong_buffers(const i_rendering_context& aContext, const size& aExtents, texture_sampling aSampling = texture_sampling::Multisample, const optional_color& aClearColor = color{ vec4{0.0, 0.0, 0.0, 0.0} });
65
66 struct tab_stop
67 {
69
72
73 std::partial_ordering operator<=>(tab_stop const&) const noexcept = default;
74 };
75
77 {
78 public:
79 virtual tab_stop const& default_stop() const = 0;
80 virtual neolib::i_vector<tab_stop> const& stops() const = 0;
81 };
82
83 class tab_stops : public i_tab_stops
84 {
85 public:
86 tab_stops(tab_stop const& aDefaultStop) :
87 iDefaultStop{ aDefaultStop }
88 {
89 }
90 template <typename TabStopIter>
91 tab_stops(tab_stop const& aDefaultStop, TabStopIter aStopsBegin, TabStopIter aStopsEnd) :
92 iDefaultStop{ aDefaultStop },
93 iStops{ aStopsBegin, aStopsEnd }
94 {
95 }
96 tab_stops(i_tab_stops const& aOther) :
97 tab_stops(aOther.default_stop(), aOther.stops().begin(), aOther.stops().end())
98 {
99 }
100 public:
101 bool operator==(tab_stops const& aOther) const noexcept
102 {
103 return std::forward_as_tuple(iDefaultStop, iStops) == std::forward_as_tuple(aOther.iDefaultStop, aOther.iStops);
104 }
105 std::partial_ordering operator<=>(tab_stops const& aOther) const noexcept
106 {
107 return std::forward_as_tuple(iDefaultStop, iStops) <=> std::forward_as_tuple(aOther.iDefaultStop, aOther.iStops);
108 }
109 public:
110 tab_stop const& default_stop() const override
111 {
112 return iDefaultStop;
113 }
114 neolib::i_vector<tab_stop> const& stops() const override
115 {
116 return iStops;
117 }
118 private:
119 tab_stop iDefaultStop;
121 };
122
124 {
125 // types
126 public:
127 enum class type
128 {
129 Attached,
131 };
132 // exceptions
133 public:
134 struct unattached : std::logic_error { unattached() : std::logic_error("neogfx::i_graphics_context::unattached") {} };
135 struct no_tab_stops : std::logic_error { no_tab_stops() : std::logic_error("neogfx::i_graphics_context::no_tab_stops") {} };
136 struct password_not_set : std::logic_error { password_not_set() : std::logic_error("neogfx::i_graphics_context::password_not_set") {} };
137 // construction
138 public:
139 virtual ~i_graphics_context() = default;
140 // units
141 public:
142 virtual delta to_device_units(const delta& aValue) const = 0;
143 virtual size to_device_units(const size& aValue) const = 0;
144 virtual point to_device_units(const point& aValue) const = 0;
145 virtual vec2 to_device_units(const vec2& aValue) const = 0;
146 virtual rect to_device_units(const rect& aValue) const = 0;
147 virtual path to_device_units(const path& aValue) const = 0;
148 virtual delta from_device_units(const delta& aValue) const = 0;
149 virtual size from_device_units(const size& aValue) const = 0;
150 virtual point from_device_units(const point& aValue) const = 0;
151 virtual rect from_device_units(const rect& aValue) const = 0;
152 virtual path from_device_units(const path& aValue) const = 0;
153 // state
154 public:
155 virtual void flush() const = 0;
156 // layers
157 public:
158 virtual layer_t layer() const = 0;
159 virtual void set_layer(layer_t aLayer) = 0;
160 // coordinate system
161 public:
165 virtual void set_logical_coordinates(const neogfx::logical_coordinates& aCoordinates) const = 0;
166 // viewport
167 public:
168 virtual void set_extents(const size& aExtents) const = 0;
169 virtual void set_origin(const point& aOrigin) const = 0;
170 virtual point origin() const = 0;
171 virtual void set_default_viewport() const = 0;
172 virtual void set_viewport(const rect& aViewportRect) const = 0;
173 // clipping
174 public:
175 virtual void scissor_on(const rect& aRect) const = 0;
176 virtual void scissor_off() const = 0;
177 // anti-aliasing
178 public:
180 virtual void set_smoothing_mode(neogfx::smoothing_mode aSmoothingMode) const = 0;
181 virtual bool snap_to_pixel() const = 0;
182 virtual void set_snap_to_pixel(bool aSnap) const = 0;
183 // blending
184 public:
185 virtual double opacity() const = 0;
186 virtual void set_opacity(double aOpacity) const = 0;
188 virtual void set_blending_mode(neogfx::blending_mode aBlendingMode) const = 0;
189 // drawing mode
190 public:
191 virtual void push_logical_operation(logical_operation aLogicalOperation) const = 0;
192 virtual void pop_logical_operation() const = 0;
193 virtual void line_stipple_on(scalar aFactor, uint16_t aPattern, scalar aPosition = 0.0) const = 0;
194 virtual void line_stipple_off() const = 0;
195 virtual bool is_subpixel_rendering_on() const = 0;
196 virtual void subpixel_rendering_on() const = 0;
197 virtual void subpixel_rendering_off() const = 0;
198 // canvas
199 public:
200 virtual void clear(const color& aColor, const std::optional<scalar>& aZpos = std::optional<scalar>{}) const = 0;
201 virtual void clear_depth_buffer() const = 0;
202 virtual void clear_stencil_buffer() const = 0;
203 virtual void blit(const rect& aDestinationRect, const i_graphics_context& aSource, const rect& aSourceRect) const = 0;
204 virtual void blur(const rect& aDestinationRect, const i_graphics_context& aSource, const rect& aSourceRect, dimension aRadius, blurring_algorithm aAlgorithm = blurring_algorithm::Gaussian, scalar aParameter1 = 5, scalar aParameter2 = 1.0) const = 0;
205 // gradient
206 public:
207 virtual void clear_gradient() = 0;
208 virtual void set_gradient(const gradient& aGradient, const rect& aBoundingBox) = 0;
209 // shape
210 public:
211 virtual void set_pixel(const point& aPoint, const color& aColor) const = 0;
212 virtual void draw_pixel(const point& aPoint, const color& aColor) const = 0;
213 virtual void draw_line(const point& aFrom, const point& aTo, const pen& aPen) const = 0;
214 virtual void draw_triangle(const point& aP0, const point& aP1, const point& aP2, const pen& aPen, const brush& aFill = brush{}) const = 0;
215 virtual void draw_rect(const rect& aRect, const pen& aPen, const brush& aFill = brush{}) const = 0;
216 virtual void draw_rounded_rect(const rect& aRect, const vec4& aRadius, const pen& aPen, const brush& aFill = brush{}) const = 0;
217 virtual void draw_checker_rect(const rect& aRect, const size& aSquareSize, const pen& aPen, const brush& aFill1, const brush& aFill2) const = 0;
218 virtual void draw_circle(const point& aCenter, dimension aRadius, const pen& aPen, const brush& aFill = brush{}) const = 0;
219 virtual void draw_ellipse(const point& aCenter, dimension aRadiusA, dimension aRadiusB, const pen& aPen, const brush& aFill = brush{}) const = 0;
220 virtual void draw_pie(const point& aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const pen& aPen, const brush& aFill = brush{}) const = 0;
221 virtual void draw_arc(const point& aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const pen& aPen, const brush& aFill = brush{}) const = 0;
222 virtual void draw_cubic_bezier(const point& aP0, const point& aP1, const point& aP2, const point& aP3, const pen& aPen) const = 0;
223 virtual void draw_path(const path& aPath, const pen& aPen, const brush& aFill = brush{}) const = 0;
224 virtual void draw_shape(const game::mesh& aShape, const vec3& aPosition, const pen& aPen, const brush& aFill = brush{}) const = 0;
225 virtual void draw_entities(game::i_ecs& aEcs, int32_t aLayer = 0) const = 0;
226 virtual void draw_focus_rect(const rect& aRect) const = 0;
227 // text
228 public:
229 virtual font const& default_font() const = 0;
230 virtual void set_default_font(const font& aDefaultFont) const = 0;
231 virtual bool has_tab_stops() const = 0;
232 virtual i_tab_stops const& tab_stops() const = 0;
233 virtual void set_tab_stops(i_tab_stops const& aTabStops) = 0;
234 virtual void clear_tab_stops() = 0;
235 virtual size text_extent(std::string const& aText) const = 0;
236 virtual size text_extent(std::string const& aText, const font& aFont) const = 0;
237 virtual size text_extent(std::string const& aText, std::function<font(std::string::size_type)> aFontSelector) const = 0;
238 virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd) const = 0;
239 virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font& aFont) const = 0;
240 virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function<font(std::string::size_type)> aFontSelector) const = 0;
241 virtual size multiline_text_extent(std::string const& aText) const = 0;
242 virtual size multiline_text_extent(std::string const& aText, const font& aFont) const = 0;
243 virtual size multiline_text_extent(std::string const& aText, std::function<font(std::string::size_type)> aFontSelector) const = 0;
244 virtual size multiline_text_extent(std::string const& aText, dimension aMaxWidth) const = 0;
245 virtual size multiline_text_extent(std::string const& aText, const font& aFont, dimension aMaxWidth) const = 0;
246 virtual size multiline_text_extent(std::string const& aText, std::function<font(std::string::size_type)> aFontSelector, dimension aMaxWidth) const = 0;
247 virtual size glyph_text_extent(const glyph_text& aText) const = 0;
248 virtual size glyph_text_extent(const glyph_text& aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd) const = 0;
249 virtual size multiline_glyph_text_extent(const glyph_text& aText, dimension aMaxWidth) const = 0;
250 virtual glyph_text to_glyph_text(std::string const& aText) const = 0;
251 virtual glyph_text to_glyph_text(std::string const& aText, std::function<font(std::string::size_type)> aFontSelector) const = 0;
252 virtual glyph_text to_glyph_text(std::string const& aText, const font& aFont) const = 0;
253 virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd) const = 0;
254 virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font& aFont) const = 0;
255 virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function<font(std::string::size_type)> aFontSelector) const = 0;
256 virtual glyph_text to_glyph_text(const std::u32string& aText) const = 0;
257 virtual glyph_text to_glyph_text(const std::u32string& aText, const font& aFont) const = 0;
258 virtual glyph_text to_glyph_text(const std::u32string& aText, std::function<font(std::u32string::size_type)> aFontSelector) const = 0;
259 virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd) const = 0;
260 virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, const font& aFont) const = 0;
261 virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, std::function<font(std::u32string::size_type)> aFontSelector) const = 0;
262 virtual multiline_glyph_text to_multiline_glyph_text(std::string const& aText, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
263 virtual multiline_glyph_text to_multiline_glyph_text(std::string const& aText, const font& aFont, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
264 virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
265 virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font& aFont, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
266 virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function<font(std::string::size_type)> aFontSelector, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
267 virtual multiline_glyph_text to_multiline_glyph_text(const std::u32string& aText, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
268 virtual multiline_glyph_text to_multiline_glyph_text(const std::u32string& aText, const font& aFont, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
269 virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
270 virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, const font& aFont, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
271 virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, std::function<font(std::u32string::size_type)> aFontSelector, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
272 virtual multiline_glyph_text to_multiline_glyph_text(const glyph_text& aText, dimension aMaxWidth, alignment aAlignment = alignment::Left) const = 0;
273 virtual bool is_text_left_to_right(std::string const& aText) const = 0;
274 virtual bool is_text_left_to_right(std::string const& aText, const font& aFont) const = 0;
275 virtual bool is_text_right_to_left(std::string const& aText) const = 0;
276 virtual bool is_text_right_to_left(std::string const& aText, const font& aFont) const = 0;
277 virtual void draw_text(const point& aPoint, std::string const& aText, const text_format& aTextFormat) const = 0;
278 virtual void draw_text(const point& aPoint, std::string const& aText, const font& aFont, const text_format& aTextFormat) const = 0;
279 virtual void draw_text(const point& aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const text_format& aTextFormat) const = 0;
280 virtual void draw_text(const point& aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font& aFont, const text_format& aTextFormat) const = 0;
281 virtual void draw_text(const vec3& aPoint, std::string const& aText, const text_format& aTextFormat) const = 0;
282 virtual void draw_text(const vec3& aPoint, std::string const& aText, const font& aFont, const text_format& aTextFormat) const = 0;
283 virtual void draw_text(const vec3& aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const text_format& aTextFormat) const = 0;
284 virtual void draw_text(const vec3& aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font& aFont, const text_format& aTextFormat) const = 0;
285 virtual void draw_multiline_text(const point& aPoint, std::string const& aText, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
286 virtual void draw_multiline_text(const point& aPoint, std::string const& aText, const font& aFont, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
287 virtual void draw_multiline_text(const point& aPoint, std::string const& aText, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
288 virtual void draw_multiline_text(const point& aPoint, std::string const& aText, const font& aFont, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
289 virtual void draw_multiline_text(const vec3& aPoint, std::string const& aText, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
290 virtual void draw_multiline_text(const vec3& aPoint, std::string const& aText, const font& aFont, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
291 virtual void draw_multiline_text(const vec3& aPoint, std::string const& aText, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
292 virtual void draw_multiline_text(const vec3& aPoint, std::string const& aText, const font& aFont, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
293 virtual void draw_glyph_text(const point& aPoint, const glyph_text& aText, const text_format& aTextFormat) const = 0;
294 virtual void draw_glyph_text(const point& aPoint, const glyph_text& aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd, const text_format& aTextFormat) const = 0;
295 virtual void draw_glyph_text(const vec3& aPoint, const glyph_text& aText, const text_format& aTextFormat) const = 0;
296 virtual void draw_glyph_text(const vec3& aPoint, const glyph_text& aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd, const text_format& aTextFormat) const = 0;
297 virtual void draw_multiline_glyph_text(const point& aPoint, const glyph_text& aText, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
298 virtual void draw_multiline_glyph_text(const vec3& aPoint, const glyph_text& aText, dimension aMaxWidth, const text_format& aTextFormat, alignment aAlignment = alignment::Left) const = 0;
299 virtual void draw_multiline_glyph_text(const point& aPoint, const multiline_glyph_text& aText, const text_format& aTextFormat) const = 0;
300 virtual void draw_multiline_glyph_text(const vec3& aPoint, const multiline_glyph_text& aText, const text_format& aTextFormat) const = 0;
301 virtual void draw_glyph(const point& aPoint, const glyph_text& aText, const glyph_char& aGlyphChar, const text_format& aTextFormat) const = 0;
302 virtual void draw_glyph(const vec3& aPoint, const glyph_text& aText, const glyph_char& aGlyphChar, const text_format& aTextFormat) const = 0;
303 virtual void draw_glyphs(const point& aPoint, const glyph_text& aText, const text_format_spans& aSpans) const = 0;
304 virtual void draw_glyphs(const vec3& aPoint, const glyph_text& aText, const text_format_spans& aSpans) const = 0;
305 virtual char mnemonic() const = 0;
306 virtual bool mnemonic_set() const = 0;
307 virtual void set_mnemonic(bool aShowMnemonics, char aMnemonicPrefix = '&') const = 0;
308 virtual void unset_mnemonic() const = 0;
309 virtual bool mnemonics_shown() const = 0;
310 virtual bool password() const = 0;
311 virtual std::string const& password_mask() const = 0;
312 virtual void set_password(bool aPassword, std::string const& aMask = "\xE2\x97\x8F") = 0;
313 // texture
314 public:
315 virtual void draw_texture(const point& aPoint, const i_texture& aTexture, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
316 virtual void draw_texture(const rect& aRect, const i_texture& aTexture, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
317 virtual void draw_texture(const point& aPoint, const i_texture& aTexture, const rect& aTextureRect, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
318 virtual void draw_texture(const rect& aRect, const i_texture& aTexture, const rect& aTextureRect, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
319 virtual void draw_texture(const game::mesh& aMesh, const i_texture& aTexture, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
320 virtual void draw_texture(const game::mesh& aMesh, const i_texture& aTexture, const rect& aTextureRect, const color_or_gradient& aColor = {}, shader_effect aShaderEffect = shader_effect::None) const = 0;
321 // 3D
322 public:
323 // todo: set_transformation et al
324 virtual void draw_mesh(const game::mesh& aMesh, const game::material& aMaterial, const optional_mat44& aTransformation = optional_mat44{}, const std::optional<game::filter>& aFilter = {}) const = 0;
325 // helpers
326 public:
327 void draw_rounded_rect(const rect& aRect, dimension aRadius, const pen& aPen, const brush& aFill = brush{}) const
328 {
329 draw_rounded_rect(aRect, vec4{ aRadius, aRadius, aRadius, aRadius }, aPen, aFill);
330 }
331 void fill_triangle(const point& aP0, const point& aP1, const point& aP2, const brush& aFill) const
332 {
333 draw_triangle(aP0, aP1, aP2, pen{}, aFill);
334 }
335 void fill_rect(const rect& aRect, const brush& aFill) const
336 {
337 draw_rect(aRect, pen{}, aFill);
338 }
339 void fill_rounded_rect(const rect& aRect, const vec4& aRadius, const brush& aFill) const
340 {
341 draw_rounded_rect(aRect, aRadius, pen{}, aFill);
342 }
343 void fill_checker_rect(const rect& aRect, const size& aSquareSize, const brush& aFill1, const brush& aFill2) const
344 {
345 draw_checker_rect(aRect, aSquareSize, pen{}, aFill1, aFill2);
346 }
347 void fill_circle(const point& aCenter, dimension aRadius, const brush& aFill) const
348 {
349 draw_circle(aCenter, aRadius, pen{}, aFill);
350 }
351 void fill_ellipse(const point& aCenter, dimension aRadiusA, dimension aRadiusB, const brush& aFill) const
352 {
353 draw_ellipse(aCenter, aRadiusA, aRadiusB, pen{}, aFill);
354 }
355 void fill_pie(const point& aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const brush& aFill) const
356 {
357 draw_pie(aCenter, aRadius, aStartAngle, aEndAngle, pen{}, aFill);
358 }
359 void fill_arc(const point& aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const brush& aFill) const
360 {
361 draw_arc(aCenter, aRadius, aStartAngle, aEndAngle, pen{}, aFill);
362 }
363 void fill_path(const path& aPath, const brush& aFill) const
364 {
365 draw_path(aPath, pen{}, aFill);
366 }
367 void fill_shape(const game::mesh& aShape, const vec3& aPosition, const brush& aFill) const
368 {
369 draw_shape(aShape, aPosition, pen{}, aFill);
370 }
371 void fill_rounded_rect(const rect& aRect, dimension aRadius, const brush& aFill) const
372 {
373 fill_rounded_rect(aRect, vec4{ aRadius, aRadius, aRadius, aRadius }, aFill);
374 }
375 };
376
377 template <typename Iter>
378 inline void draw_glyph_text(i_graphics_context const& aGc, const vec3& aPoint, const glyph_text& aGlyphText, Iter aGlyphTextBegin, Iter aGlyphTextEnd, const text_format& aTextFormat)
379 {
380 vec3 pos = aPoint;
381 for (auto iterGlyph = aGlyphTextBegin; iterGlyph != aGlyphTextEnd; ++iterGlyph)
382 {
383 aGc.draw_glyph(pos, aGlyphText, *iterGlyph, aTextFormat);
384 pos.x += advance(*iterGlyph).cx;
385 }
386 }
387
389 {
390 public:
391 scoped_mnemonics(i_graphics_context const& aGc, bool aShowMnemonics, char aMnemonicPrefix = '&') :
392 iGc(aGc)
393 {
394 iGc.set_mnemonic(aShowMnemonics, aMnemonicPrefix);
395 }
397 {
398 iGc.unset_mnemonic();
399 }
400 private:
401 const i_graphics_context& iGc;
402 };
403
405 {
406 public:
407 scoped_coordinate_system(i_graphics_context const& aGc, const point& aOrigin, const size& aExtents, logical_coordinate_system aCoordinateSystem) :
408 iGc(aGc), iPreviousOrigin{ aGc.origin() }, iPreviousCoordinateSystem(aGc.logical_coordinate_system()), iPreviousCoordinates(aGc.logical_coordinates())
409 {
410 iGc.set_logical_coordinate_system(aCoordinateSystem);
411 apply_origin(aOrigin, aExtents);
412 }
413 scoped_coordinate_system(i_graphics_context const& aGc, const point& aOrigin, const size& aExtents, logical_coordinate_system aCoordinateSystem, const neogfx::logical_coordinates& aCoordinates) :
414 iGc(aGc), iPreviousOrigin{ aGc.origin() }, iPreviousCoordinateSystem(aGc.logical_coordinate_system()), iPreviousCoordinates(aGc.logical_coordinates())
415 {
416 iGc.set_logical_coordinate_system(aCoordinateSystem);
417 iGc.set_logical_coordinates(aCoordinates);
418 apply_origin(aOrigin, aExtents);
419 }
421 iGc(aGc), iPreviousOrigin{ aGc.origin() }, iPreviousCoordinateSystem(aGc.logical_coordinate_system()), iPreviousCoordinates(aGc.logical_coordinates())
422 {
425 iGc.set_origin(aSource.origin());
426 }
428 iGc(aGc), iPreviousOrigin{ aGc.origin() }, iPreviousCoordinateSystem(aGc.logical_coordinate_system()), iPreviousCoordinates(aGc.logical_coordinates())
429 {
432 iGc.set_origin({});
433 }
435 {
436 if (iGc.logical_coordinate_system() != iPreviousCoordinateSystem)
437 iGc.set_logical_coordinate_system(iPreviousCoordinateSystem);
438 if (iGc.logical_coordinates() != iPreviousCoordinates)
439 iGc.set_logical_coordinates(iPreviousCoordinates);
440 if (iGc.origin() != iPreviousOrigin)
441 iGc.set_origin(iPreviousOrigin);
442 }
443 private:
444 void apply_origin(const point& aOrigin, const size& aExtents)
445 {
447 iGc.set_origin(aOrigin);
449 iGc.set_origin(point{ aOrigin.x, iGc.render_target().extents().cy - (aOrigin.y + aExtents.cy) });
450 }
451 private:
452 const i_graphics_context& iGc;
453 point iPreviousOrigin;
454 logical_coordinate_system iPreviousCoordinateSystem;
455 neogfx::logical_coordinates iPreviousCoordinates;
456 };
457
459 {
460 public:
461 scoped_snap_to_pixel(i_graphics_context const& aGc, bool aSnapToPixel = true) :
462 iGc{ aGc }, iPreviousSnapped{ aGc.snap_to_pixel() }
463 {
464 iGc.set_snap_to_pixel(aSnapToPixel);
465 }
467 {
468 iGc.set_snap_to_pixel(iPreviousSnapped);
469 }
470 private:
471 const i_graphics_context& iGc;
472 bool iPreviousSnapped;
473 };
474
476 {
477 public:
478 scoped_opacity(i_graphics_context const& aGc, double aOpacity) :
479 iGc{ aGc }, iPreviousOpacity { aGc.opacity() }
480 {
481 iGc.set_opacity(iGc.opacity() * aOpacity);
482 }
484 {
485 iGc.set_opacity(iPreviousOpacity);
486 }
487 private:
488 const i_graphics_context& iGc;
489 double iPreviousOpacity;
490 };
491
493 {
494 public:
496 iGc{ aGc }, iPreviousBlendingMode{ aGc.blending_mode() }
497 {
498 iGc.set_blending_mode(aBlendigMode);
499 }
501 {
502 iGc.set_blending_mode(iPreviousBlendingMode);
503 }
504 private:
505 const i_graphics_context& iGc;
506 neogfx::blending_mode iPreviousBlendingMode;
507 };
508
510 {
511 public:
512 scoped_scissor(i_graphics_context const& aGc, const rect& aScissorRect) :
513 iGc{ aGc }
514 {
515 iGc.scissor_on(aScissorRect);
516 }
518 {
519 iGc.scissor_off();
520 }
521 private:
522 const i_graphics_context& iGc;
523 };
524
525 inline void draw_alpha_background(i_graphics_context& aGc, const rect& aRect, dimension aAlphaPatternSize = 4.0_dip)
526 {
527 scoped_scissor scissor(aGc, aRect);
528 aGc.fill_checker_rect(aRect, size{ aAlphaPatternSize }, color{ 160, 160, 160 }, color{ 255, 255, 255 });
529 }
530
539
540 template <typename Filter>
542 {
543 public:
545 iGc{ aGc },
546 iFilter{ aFilter },
547 iBufferRect{ point{}, aFilter.region.extents() + size{ aFilter.radius * 2.0 } },
548 iBuffers{ std::move(create_ping_pong_buffers(aGc, iBufferRect.extents())) },
549 iRenderTarget{ front_buffer() }
550 {
551 front_buffer().set_origin(-aFilter.region.top_left() + point{ aFilter.radius, aFilter.radius });
552 }
554 {
556 {
557 iRenderTarget.emplace(back_buffer());
558 if constexpr (std::is_same_v<Filter, blur_filter>)
559 back_buffer().blur(iBufferRect, front_buffer(), iBufferRect, iFilter.radius, iFilter.algorithm, iFilter.parameter1, iFilter.parameter2);
560 }
561 iRenderTarget = {};
563 rect const drawRect{ iFilter.region.top_left() - point{ iFilter.radius, iFilter.radius }, iBufferRect.extents() };
564 iGc.draw_texture(drawRect, back_buffer().render_target().target_texture(), iBufferRect);
565 }
566 public:
568 {
569 return *iBuffers.buffer1;
570 }
572 {
573 return *iBuffers.buffer2;
574 }
575 private:
577 Filter iFilter;
578 rect iBufferRect;
579 ping_pong_buffers iBuffers;
580 std::optional<scoped_render_target> iRenderTarget;
581 };
582
583 template <typename ValueType = double, uint32_t W = 5>
584 inline std::array<std::array<ValueType, W>, W> static_gaussian_filter(ValueType aSigma = 1.0)
585 {
586 const int32_t mean = static_cast<int32_t>(W / 2);
587 std::array<std::array<ValueType, W>, W> kernel = {};
588 if (aSigma != 0)
589 {
590 ValueType sum = 0.0;
591 for (int32_t x = -mean; x <= mean; ++x)
592 {
593 for (int32_t y = -mean; y <= mean; ++y)
594 {
595 kernel[x + mean][y + mean] =
596 static_cast<ValueType>((1.0 / (2.0 * boost::math::constants::pi<ValueType>() * aSigma * aSigma)) * std::exp(-((x * x + y * y) / (2.0 * aSigma * aSigma))));
597 sum += kernel[x + mean][y + mean];
598 }
599 }
600 for (uint32_t x = 0; x < W; ++x)
601 for (uint32_t y = 0; y < W; ++y)
602 kernel[x][y] /= sum;
603 }
604 else
605 kernel[mean][mean] = static_cast<ValueType>(1.0);
606 return kernel;
607 }
608
609 template <typename ValueType = double>
610 inline boost::multi_array<ValueType, 2> dynamic_gaussian_filter(uint32_t aKernelSize = 5, ValueType aSigma = 1.0)
611 {
612 const int32_t mean = static_cast<int32_t>(aKernelSize / 2);
613 boost::multi_array<ValueType, 2> kernel(boost::extents[aKernelSize][aKernelSize]);
614 if (aSigma != 0)
615 {
616 ValueType sum = 0.0;
617 for (int32_t x = -mean; x <= mean; ++x)
618 {
619 for (int32_t y = -mean; y <= mean; ++y)
620 {
621 kernel[x + mean][y + mean] =
622 static_cast<ValueType>((1.0 / (2.0 * boost::math::constants::pi<ValueType>() * aSigma * aSigma)) * std::exp(-((x * x + y * y) / (2.0 * aSigma * aSigma))));
623 sum += kernel[x + mean][y + mean];
624 }
625 }
626 for (uint32_t x = 0; x < aKernelSize; ++x)
627 for (uint32_t y = 0; y < aKernelSize; ++y)
628 kernel[x][y] /= sum;
629 }
630 else
631 kernel[mean][mean] = static_cast<ValueType>(1.0);
632 return kernel;
633 }
634
636 {
637 public:
638 scoped_tab_stops(i_graphics_context& aGc, std::optional<tab_stops> const& aTabStops) :
639 iGc{ aGc }
640 {
641 if (iGc.has_tab_stops())
642 iPrevious.emplace(iGc.tab_stops());
643 if (aTabStops.has_value())
644 iGc.set_tab_stops(aTabStops.value());
645 else
646 iGc.clear_tab_stops();
647 }
649 {
650 if (iPrevious.has_value())
651 iGc.set_tab_stops(iPrevious.value());
652 else
653 iGc.clear_tab_stops();
654 }
655 private:
657 std::optional<tab_stops> iPrevious;
658 };
659}
coordinate_type x
coordinate_type y
const size_type & extents() const
dimension_type cy
i_glyph_text::const_iterator const_iterator
virtual void draw_texture(const point &aPoint, const i_texture &aTexture, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual void draw_multiline_glyph_text(const vec3 &aPoint, const multiline_glyph_text &aText, const text_format &aTextFormat) const =0
virtual bool is_text_right_to_left(std::string const &aText, const font &aFont) const =0
virtual size multiline_glyph_text_extent(const glyph_text &aText, dimension aMaxWidth) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, std::function< font(std::u32string::size_type)> aFontSelector, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual void clear_stencil_buffer() const =0
virtual point from_device_units(const point &aValue) const =0
virtual std::string const & password_mask() const =0
virtual void set_default_viewport() const =0
virtual point to_device_units(const point &aValue) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, const font &aFont, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual ~i_graphics_context()=default
virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, const font &aFont) const =0
virtual size multiline_text_extent(std::string const &aText, std::function< font(std::string::size_type)> aFontSelector) const =0
void fill_rounded_rect(const rect &aRect, const vec4 &aRadius, const brush &aFill) const
virtual glyph_text to_glyph_text(const std::u32string &aText, const font &aFont) const =0
virtual void draw_multiline_text(const vec3 &aPoint, std::string const &aText, const font &aFont, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::string const &aText, const font &aFont, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual size text_extent(std::string const &aText) const =0
virtual void set_layer(layer_t aLayer)=0
virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd) const =0
virtual void draw_rounded_rect(const rect &aRect, const vec4 &aRadius, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_glyph(const vec3 &aPoint, const glyph_text &aText, const glyph_char &aGlyphChar, const text_format &aTextFormat) const =0
virtual void line_stipple_off() const =0
virtual point origin() const =0
virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd) const =0
virtual void draw_texture(const point &aPoint, const i_texture &aTexture, const rect &aTextureRect, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual void push_logical_operation(logical_operation aLogicalOperation) const =0
virtual void draw_glyph_text(const point &aPoint, const glyph_text &aText, const text_format &aTextFormat) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual void draw_focus_rect(const rect &aRect) const =0
virtual void draw_multiline_text(const vec3 &aPoint, std::string const &aText, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function< font(std::string::size_type)> aFontSelector, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual void draw_text(const vec3 &aPoint, std::string const &aText, const text_format &aTextFormat) const =0
virtual delta from_device_units(const delta &aValue) const =0
virtual size multiline_text_extent(std::string const &aText, const font &aFont) const =0
virtual void flush() const =0
virtual void draw_arc(const point &aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const pen &aPen, const brush &aFill=brush{}) const =0
virtual bool mnemonic_set() const =0
virtual void draw_pie(const point &aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_multiline_glyph_text(const vec3 &aPoint, const glyph_text &aText, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
void fill_arc(const point &aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const brush &aFill) const
virtual void draw_text(const vec3 &aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font &aFont, const text_format &aTextFormat) const =0
virtual void clear(const color &aColor, const std::optional< scalar > &aZpos=std::optional< scalar >{}) const =0
virtual void draw_pixel(const point &aPoint, const color &aColor) const =0
virtual void draw_cubic_bezier(const point &aP0, const point &aP1, const point &aP2, const point &aP3, const pen &aPen) const =0
virtual vec2 to_device_units(const vec2 &aValue) const =0
virtual size multiline_text_extent(std::string const &aText) const =0
virtual neogfx::blending_mode blending_mode() const =0
virtual glyph_text to_glyph_text(const std::u32string &aText, std::function< font(std::u32string::size_type)> aFontSelector) const =0
virtual void draw_multiline_text(const point &aPoint, std::string const &aText, const font &aFont, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
void fill_triangle(const point &aP0, const point &aP1, const point &aP2, const brush &aFill) const
virtual void set_logical_coordinate_system(neogfx::logical_coordinate_system aSystem) const =0
virtual neogfx::smoothing_mode smoothing_mode() const =0
virtual void pop_logical_operation() const =0
virtual void draw_text(const point &aPoint, std::string const &aText, const text_format &aTextFormat) const =0
virtual i_tab_stops const & tab_stops() const =0
virtual glyph_text to_glyph_text(std::string const &aText) const =0
virtual void draw_glyph_text(const vec3 &aPoint, const glyph_text &aText, const text_format &aTextFormat) const =0
virtual void draw_multiline_glyph_text(const point &aPoint, const glyph_text &aText, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual void line_stipple_on(scalar aFactor, uint16_t aPattern, scalar aPosition=0.0) const =0
virtual void set_mnemonic(bool aShowMnemonics, char aMnemonicPrefix='&') const =0
virtual void unset_mnemonic() const =0
virtual bool password() const =0
void fill_rect(const rect &aRect, const brush &aFill) const
virtual void draw_text(const vec3 &aPoint, std::string const &aText, const font &aFont, const text_format &aTextFormat) const =0
virtual void draw_multiline_glyph_text(const point &aPoint, const multiline_glyph_text &aText, const text_format &aTextFormat) const =0
virtual void scissor_on(const rect &aRect) const =0
virtual void scissor_off() const =0
virtual void draw_text(const vec3 &aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const text_format &aTextFormat) const =0
void fill_circle(const point &aCenter, dimension aRadius, const brush &aFill) const
virtual double opacity() const =0
virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function< font(std::string::size_type)> aFontSelector) const =0
virtual void subpixel_rendering_off() const =0
void draw_rounded_rect(const rect &aRect, dimension aRadius, const pen &aPen, const brush &aFill=brush{}) const
void fill_checker_rect(const rect &aRect, const size &aSquareSize, const brush &aFill1, const brush &aFill2) const
virtual void set_logical_coordinates(const neogfx::logical_coordinates &aCoordinates) const =0
virtual void draw_glyph_text(const vec3 &aPoint, const glyph_text &aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd, const text_format &aTextFormat) const =0
virtual void draw_multiline_text(const vec3 &aPoint, std::string const &aText, const font &aFont, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual void set_smoothing_mode(neogfx::smoothing_mode aSmoothingMode) const =0
virtual layer_t layer() const =0
virtual bool snap_to_pixel() const =0
virtual glyph_text to_glyph_text(std::string const &aText, std::function< font(std::string::size_type)> aFontSelector) const =0
virtual void draw_glyphs(const vec3 &aPoint, const glyph_text &aText, const text_format_spans &aSpans) const =0
virtual bool is_subpixel_rendering_on() const =0
virtual void blit(const rect &aDestinationRect, const i_graphics_context &aSource, const rect &aSourceRect) const =0
void fill_path(const path &aPath, const brush &aFill) const
virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, std::function< font(std::string::size_type)> aFontSelector) const =0
virtual void draw_multiline_text(const point &aPoint, std::string const &aText, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual void blur(const rect &aDestinationRect, const i_graphics_context &aSource, const rect &aSourceRect, dimension aRadius, blurring_algorithm aAlgorithm=blurring_algorithm::Gaussian, scalar aParameter1=5, scalar aParameter2=1.0) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::string const &aText, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
void fill_rounded_rect(const rect &aRect, dimension aRadius, const brush &aFill) const
virtual void set_snap_to_pixel(bool aSnap) const =0
void fill_ellipse(const point &aCenter, dimension aRadiusA, dimension aRadiusB, const brush &aFill) const
virtual void draw_text(const point &aPoint, std::string const &aText, const font &aFont, const text_format &aTextFormat) const =0
virtual void draw_multiline_text(const vec3 &aPoint, std::string const &aText, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual void draw_line(const point &aFrom, const point &aTo, const pen &aPen) const =0
virtual glyph_text to_glyph_text(const std::u32string &aText) const =0
virtual void clear_gradient()=0
virtual size multiline_text_extent(std::string const &aText, const font &aFont, dimension aMaxWidth) const =0
virtual glyph_text to_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font &aFont) const =0
void fill_shape(const game::mesh &aShape, const vec3 &aPosition, const brush &aFill) const
virtual void draw_text(const point &aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const text_format &aTextFormat) const =0
virtual void draw_circle(const point &aCenter, dimension aRadius, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_texture(const game::mesh &aMesh, const i_texture &aTexture, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual size glyph_text_extent(const glyph_text &aText) const =0
virtual bool is_text_left_to_right(std::string const &aText, const font &aFont) const =0
virtual bool has_tab_stops() const =0
virtual neogfx::logical_coordinate_system logical_coordinate_system() const =0
virtual void draw_multiline_text(const point &aPoint, std::string const &aText, dimension aMaxWidth, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual rect from_device_units(const rect &aValue) const =0
virtual void set_origin(const point &aOrigin) const =0
virtual bool is_text_left_to_right(std::string const &aText) const =0
virtual path to_device_units(const path &aValue) const =0
virtual font const & default_font() const =0
virtual void draw_glyph_text(const point &aPoint, const glyph_text &aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd, const text_format &aTextFormat) const =0
virtual bool is_text_right_to_left(std::string const &aText) const =0
virtual void set_opacity(double aOpacity) const =0
void fill_pie(const point &aCenter, dimension aRadius, angle aStartAngle, angle aEndAngle, const brush &aFill) const
virtual neogfx::logical_coordinates logical_coordinates() const =0
virtual void set_password(bool aPassword, std::string const &aMask="\xE2\x97\x8F")=0
virtual multiline_glyph_text to_multiline_glyph_text(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font &aFont, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd) const =0
virtual glyph_text to_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, std::function< font(std::u32string::size_type)> aFontSelector) const =0
virtual void draw_multiline_text(const point &aPoint, std::string const &aText, const font &aFont, const text_format &aTextFormat, alignment aAlignment=alignment::Left) const =0
virtual void set_blending_mode(neogfx::blending_mode aBlendingMode) const =0
virtual void draw_shape(const game::mesh &aShape, const vec3 &aPosition, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void set_pixel(const point &aPoint, const color &aColor) const =0
virtual multiline_glyph_text to_multiline_glyph_text(const glyph_text &aText, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual void set_extents(const size &aExtents) const =0
virtual void subpixel_rendering_on() const =0
virtual size to_device_units(const size &aValue) const =0
virtual void draw_entities(game::i_ecs &aEcs, int32_t aLayer=0) const =0
virtual size text_extent(std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font &aFont) const =0
virtual multiline_glyph_text to_multiline_glyph_text(std::u32string::const_iterator aTextBegin, std::u32string::const_iterator aTextEnd, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual void draw_ellipse(const point &aCenter, dimension aRadiusA, dimension aRadiusB, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_texture(const game::mesh &aMesh, const i_texture &aTexture, const rect &aTextureRect, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual path from_device_units(const path &aValue) const =0
virtual size from_device_units(const size &aValue) const =0
virtual void draw_texture(const rect &aRect, const i_texture &aTexture, const rect &aTextureRect, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual glyph_text to_glyph_text(std::string const &aText, const font &aFont) const =0
virtual void set_viewport(const rect &aViewportRect) const =0
virtual rect to_device_units(const rect &aValue) const =0
virtual size multiline_text_extent(std::string const &aText, std::function< font(std::string::size_type)> aFontSelector, dimension aMaxWidth) const =0
virtual multiline_glyph_text to_multiline_glyph_text(const std::u32string &aText, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual size text_extent(std::string const &aText, std::function< font(std::string::size_type)> aFontSelector) const =0
virtual size text_extent(std::string const &aText, const font &aFont) const =0
virtual multiline_glyph_text to_multiline_glyph_text(const std::u32string &aText, const font &aFont, dimension aMaxWidth, alignment aAlignment=alignment::Left) const =0
virtual char mnemonic() const =0
virtual void draw_path(const path &aPath, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_glyphs(const point &aPoint, const glyph_text &aText, const text_format_spans &aSpans) const =0
virtual void clear_tab_stops()=0
virtual void draw_triangle(const point &aP0, const point &aP1, const point &aP2, const pen &aPen, const brush &aFill=brush{}) const =0
virtual delta to_device_units(const delta &aValue) const =0
virtual void draw_rect(const rect &aRect, const pen &aPen, const brush &aFill=brush{}) const =0
virtual void draw_checker_rect(const rect &aRect, const size &aSquareSize, const pen &aPen, const brush &aFill1, const brush &aFill2) const =0
virtual void draw_text(const point &aPoint, std::string::const_iterator aTextBegin, std::string::const_iterator aTextEnd, const font &aFont, const text_format &aTextFormat) const =0
virtual void set_gradient(const gradient &aGradient, const rect &aBoundingBox)=0
virtual size glyph_text_extent(const glyph_text &aText, glyph_text::const_iterator aTextBegin, glyph_text::const_iterator aTextEnd) const =0
virtual size multiline_text_extent(std::string const &aText, dimension aMaxWidth) const =0
virtual void draw_mesh(const game::mesh &aMesh, const game::material &aMaterial, const optional_mat44 &aTransformation=optional_mat44{}, const std::optional< game::filter > &aFilter={}) const =0
virtual void clear_depth_buffer() const =0
virtual bool mnemonics_shown() const =0
virtual void set_tab_stops(i_tab_stops const &aTabStops)=0
virtual void draw_glyph(const point &aPoint, const glyph_text &aText, const glyph_char &aGlyphChar, const text_format &aTextFormat) const =0
virtual void draw_texture(const rect &aRect, const i_texture &aTexture, const color_or_gradient &aColor={}, shader_effect aShaderEffect=shader_effect::None) const =0
virtual void set_default_font(const font &aDefaultFont) const =0
virtual const i_texture & target_texture() const =0
virtual const i_render_target & render_target() const =0
virtual neogfx::logical_coordinate_system logical_coordinate_system() const =0
virtual neogfx::logical_coordinates logical_coordinates() const =0
virtual tab_stop const & default_stop() const =0
virtual neolib::i_vector< tab_stop > const & stops() const =0
scoped_blending_mode(i_graphics_context const &aGc, neogfx::blending_mode aBlendigMode)
scoped_coordinate_system(i_graphics_context const &aGc, i_rendering_context const &aSource)
scoped_coordinate_system(i_graphics_context const &aGc, const point &aOrigin, const size &aExtents, logical_coordinate_system aCoordinateSystem)
scoped_coordinate_system(i_graphics_context const &aGc, const point &aOrigin, const size &aExtents, logical_coordinate_system aCoordinateSystem, const neogfx::logical_coordinates &aCoordinates)
scoped_coordinate_system(i_graphics_context const &aGc, i_graphics_context const &aSource)
i_graphics_context const & front_buffer() const
scoped_filter(i_graphics_context &aGc, Filter const &aFilter)
i_graphics_context const & back_buffer() const
scoped_mnemonics(i_graphics_context const &aGc, bool aShowMnemonics, char aMnemonicPrefix='&')
scoped_opacity(i_graphics_context const &aGc, double aOpacity)
scoped_scissor(i_graphics_context const &aGc, const rect &aScissorRect)
scoped_snap_to_pixel(i_graphics_context const &aGc, bool aSnapToPixel=true)
scoped_tab_stops(i_graphics_context &aGc, std::optional< tab_stops > const &aTabStops)
std::partial_ordering operator<=>(tab_stops const &aOther) const noexcept
tab_stops(tab_stop const &aDefaultStop)
bool operator==(tab_stops const &aOther) const noexcept
neolib::i_vector< tab_stop > const & stops() const override
tab_stops(i_tab_stops const &aOther)
tab_stops(tab_stop const &aDefaultStop, TabStopIter aStopsBegin, TabStopIter aStopsEnd)
tab_stop const & default_stop() const override
ping_pong_buffers create_ping_pong_buffers(const i_rendering_context &aContext, const size &aExtents, texture_sampling aSampling=texture_sampling::Multisample, const optional_color &aClearColor=color{ vec4{0.0, 0.0, 0.0, 0.0} })
std::array< std::array< ValueType, W >, W > static_gaussian_filter(ValueType aSigma=1.0)
blurring_algorithm
logical_coordinate_system
layer_t constexpr LayerWidget
void draw_alpha_background(i_graphics_context &aGc, const rect &aRect, dimension aAlphaPatternSize=4.0_dip)
default_geometry_value_type dimension
void draw_glyph_text(i_graphics_context const &aGc, const vec3 &aPoint, const glyph_text &aGlyphText, Iter aGlyphTextBegin, Iter aGlyphTextEnd, const text_format &aTextFormat)
layer_t constexpr LayerNestedWindow
logical_operation
basic_point< coordinate > point
boost::multi_array< ValueType, 2 > dynamic_gaussian_filter(uint32_t aKernelSize=5, ValueType aSigma=1.0)
texture_sampling
Definition i_texture.hpp:42
double scalar
Definition numerical.hpp:63
Definition plf_hive.h:79
blurring_algorithm algorithm
std::unique_ptr< i_graphics_context > buffer1
std::unique_ptr< i_graphics_context > buffer2
std::partial_ordering operator<=>(tab_stop const &) const noexcept=default