neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
view_container.ipp
Go to the documentation of this file.
1// view_container.ipp
2/*
3neogfx C++ App/Game Engine
4Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
25
26namespace neogfx::mvc
27{
28 inline view_stack::view_stack(i_layout& aLayout, i_view_container& aParent) :
29 drag_drop_target<framed_scrollable_widget>{ aLayout, frame_style::NoFrame }, iLayout{ *this }, iParent{ aParent }
30 {
31 set_padding(neogfx::padding{});
33 }
34
35 inline focus_policy view_stack::focus_policy() const
36 {
37 if (base_type::has_focus_policy())
38 return base_type::focus_policy();
40 }
41
42 template <typename Base>
44 base_type{ aParent }, iStyle(aStyle), iLayout0{ *this }, iLayout1{ iLayout0 }, iViewStack{ base_type::page_layout(), *this }
45 {
46 base_type::set_padding(neogfx::padding{});
47 iLayout0.set_padding(neogfx::padding{});
48 }
49
50 template <typename Base>
51 inline view_container<Base>::view_container(i_layout& aLayout, view_container_style aStyle) :
52 base_type{ aLayout }, iStyle(aStyle), iLayout0{ *this }, iLayout1{ iLayout0 }, iViewStack{ base_type::page_layout(), *this }
53 {
54 base_type::set_padding(neogfx::padding{});
55 iLayout0.set_padding(neogfx::padding{});
56 }
57
58 template <typename Base>
60 {
61 return true;
62 }
63
64 template <typename Base>
66 {
67 return *this;
68 }
69
70 template <typename Base>
72 {
73 return *this;
74 }
75
76 template <typename Base>
78 {
79 return *this;
80 }
81
82 template <typename Base>
84 {
85 return *this;
86 }
87
88 template <typename Base>
90 {
91 return iViewStack;
92 }
93
94 template <typename Base>
96 {
97 return iViewStack;
98 }
99
100 template <typename Base>
102 {
103 return view_stack().layout();
104 }
105
106 template <typename Base>
108 {
109 return iStyle;
110 }
111
112 template <typename Base>
114 {
115 if (iStyle != aNewStyle)
116 {
117 iStyle = aNewStyle;
118 /* todo: update everything */
119 }
120 }
121
122 template <typename Base>
124 {
125 iControllers.push_back(std::shared_ptr<i_controller>(std::shared_ptr<i_controller>(), &aController));
126 aController.view_added([this](i_view& aView) { ViewAdded.trigger(aView); });
127 aController.view_removed([this](i_view& aView) { ViewRemoved.trigger(aView); });
128 }
129
130 template <typename Base>
131 inline void view_container<Base>::add_controller(std::shared_ptr<i_controller> aController)
132 {
133 iControllers.push_back(aController);
134 aController->view_added([this](i_view& aView) { ViewAdded.trigger(aView); });
135 aController->view_removed([this](i_view& aView) { ViewRemoved.trigger(aView); });
136 }
137
138 template <typename Base>
140 {
141 for (auto c = iControllers.begin(); c != iControllers.end(); ++c)
142 {
143 if (&**c == &aController)
144 {
145 iControllers.erase(c);
146 return;
147 }
148 }
149 throw controller_not_found();
150 }
151
152 template <typename Base>
154 {
155 return true;
156 }
157}
void set_padding(optional_padding const &aPadding, bool aUpdateLayout=true) override
const i_tab_container & tab_container() const override
bool is_widget() const override
void change_style(view_container_style aNewStyle) override
view_container_style style() const override
void remove_controller(i_controller &aController) override
const i_widget & as_widget() const override
bool is_managing_layout() const override
const mvc::view_stack & view_stack() const override
void add_controller(i_controller &aController) override
i_layout & page_layout() override
const i_layout & layout() const override
Definition widget.ipp:611
scrollable_widget< framed_widget< widget<> > > framed_scrollable_widget