neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
surface_manager.hpp
Go to the documentation of this file.
1// surface_manager.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>
26#include <neogfx/hid/nest.hpp>
27
28namespace neogfx
29{
31 {
32 public:
33 define_declared_event(DpiChanged, dpi_changed, i_surface&)
34 public:
35 struct already_rendering_surfaces : std::logic_error { already_rendering_surfaces() : std::logic_error("neogfx::surface_manager::already_rendering_surfaces") {} };
36 private:
37 struct surface_sorter
38 {
39 bool operator()(i_surface* left, i_surface* right) const
40 {
41 if (left->is_owner_of(*right))
42 return true;
43 else if (right->is_owner_of(*left))
44 return false;
45 else
46 return left->z_order() > right->z_order();
47 }
48 };
49 typedef std::vector<i_surface*> surface_list;
51 public:
52 surface_manager(i_basic_services& aBasicServices, i_rendering_engine& aRenderingEngine);
53 public:
54 bool initialising_surface() const override;
55 void add_surface(i_surface& aSurface) override;
56 void remove_surface(i_surface& aSurface) override;
57 std::size_t surface_count() const override;
58 i_surface& surface(std::size_t aIndex) override;
59 bool any_strong_surfaces() const override;
60 std::size_t strong_surface_count() const override;
61 bool process_events(bool& aLastWindowClosed) override;
62 void layout_surfaces() override;
63 void invalidate_surfaces() override;
64 void render_surfaces() override;
65 void display_error_message(std::string const& aTitle, std::string const& aMessage) const override;
66 void display_error_message(const i_native_window& aParent, std::string const& aTitle, std::string const& aMessage) const override;
67 uint32_t display_count() const override;
68 i_display& display(uint32_t aDisplayIndex = 0) const override;
69 i_display& display(const i_surface& aSurface) const override;
70 rect desktop_rect(uint32_t aDisplayIndex = 0) const override;
71 rect desktop_rect(const i_surface& aSurface) const override;
72 public:
73 const i_surface& surface_at_position(const i_surface& aProgenitor, const point& aPosition, bool aForMouseEvent = false) const override;
74 i_surface& surface_at_position(const i_surface& aProgenitor, const point& aPosition, bool aForMouseEvent = false) override;
75 public:
76 i_nest& nest_for(i_widget& aNestWidget, nest_type aNestType) const override;
77 virtual i_nest& find_nest(i_native_window const& aNestedWindow) const override;
78 void destroy_nest(i_nest& aNest) override;
79 i_nest& active_nest() const override;
80 void activate_nest(i_nest& aNest) override;
81 void deactivate_nest(i_nest& aNest) override;
82 public:
83 bool is_surface_attached(void* aNativeSurfaceHandle) const override;
84 i_surface& attached_surface(void* aNativeSurfaceHandle) override;
85 private:
86 i_basic_services& iBasicServices;
87 i_rendering_engine& iRenderingEngine;
88 surface_list iSurfaces;
89 bool iRenderingSurfaces;
90 sink iSink;
91 mutable std::vector<std::unique_ptr<i_nest>> iNests;
92 std::vector<i_nest*> iActiveNest;
93 };
94}
virtual bool is_owner_of(const i_surface &aChildSurface) const =0
virtual double z_order() const =0
void deactivate_nest(i_nest &aNest) override
void render_surfaces() override
i_display & display(const i_surface &aSurface) const override
i_display & display(uint32_t aDisplayIndex=0) const override
bool any_strong_surfaces() const override
rect desktop_rect(const i_surface &aSurface) const override
void display_error_message(std::string const &aTitle, std::string const &aMessage) const override
void destroy_nest(i_nest &aNest) override
i_surface & attached_surface(void *aNativeSurfaceHandle) override
i_surface & surface(std::size_t aIndex) override
void invalidate_surfaces() override
bool process_events(bool &aLastWindowClosed) override
std::size_t surface_count() const override
i_nest & active_nest() const override
uint32_t display_count() const override
void activate_nest(i_nest &aNest) override
std::size_t strong_surface_count() const override
void display_error_message(const i_native_window &aParent, std::string const &aTitle, std::string const &aMessage) const override
i_surface & surface_at_position(const i_surface &aProgenitor, const point &aPosition, bool aForMouseEvent=false) override
void layout_surfaces() override
rect desktop_rect(uint32_t aDisplayIndex=0) const override
surface_manager(i_basic_services &aBasicServices, i_rendering_engine &aRenderingEngine)
const i_surface & surface_at_position(const i_surface &aProgenitor, const point &aPosition, bool aForMouseEvent=false) const override
void add_surface(i_surface &aSurface) override
bool is_surface_attached(void *aNativeSurfaceHandle) const override
void remove_surface(i_surface &aSurface) override
virtual i_nest & find_nest(i_native_window const &aNestedWindow) const override
bool initialising_surface() const override
i_nest & nest_for(i_widget &aNestWidget, nest_type aNestType) const override
nest_type
Definition i_nest.hpp:30
#define define_declared_event(name, declName,...)
Definition event.hpp:195