window_manager.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27*/
28
29#pragma once
30
31#include <memory>
32#include "../../Core/Math/point.h"
33#include "../../UI/TopLevel/top_level_window.h"
34#include "window_controller.h"
35
36namespace clan
37{
38 class View;
39 class WindowManagerImpl;
40
43 {
44 public:
47
49 void set_exit_on_last_close(bool enable = true);
50
52 void present_main(const std::shared_ptr<WindowController> &controller, DisplayWindowDescription* desc = nullptr, WindowShowType show_type = WindowShowType::show);
53
54 template<typename T, typename... Types>
55 std::shared_ptr<T> present_main(Types &&... args)
56 {
57 auto controller = std::make_shared<T>(std::forward<Types>(args)...);
58 present_main(controller);
59 return controller;
60 }
61
63 void present_modal(View *owner, const std::shared_ptr<WindowController> &controller, DisplayWindowDescription* desc = nullptr);
64
65 template<typename T, typename... Types>
66 std::shared_ptr<T> present_modal(View *owner, Types &&... args)
67 {
68 auto controller = std::make_shared<T>(std::forward<Types>(args)...);
69 present_modal(owner, controller);
70 return controller;
71 }
72
74 void present_popup(View *owner, const Pointf &pos, const std::shared_ptr<WindowController> &controller, DisplayWindowDescription* desc = nullptr);
75
76 template<typename T, typename... Types>
77 std::shared_ptr<T> present_popup(View *owner, const Pointf &pos, Types &&... args)
78 {
79 auto controller = std::make_shared<T>(std::forward<Types>(args)...);
80 present_popup(owner, controller);
81 return controller;
82 }
83
85 void flip(int interval = -1);
86
87 private:
88 WindowManager(const WindowManager &) = delete;
89 WindowManager &operator=(const WindowManager &) = delete;
90
91 std::unique_ptr<WindowManagerImpl> impl;
92 friend class WindowController;
93 };
94}
Display window description class.
Definition display_window_description.h:50
2D (x,y) point structure - Float
Definition point.h:72
View for an area of the user interface.
Definition view.h:66
std::shared_ptr< T > present_modal(View *owner, Types &&... args)
Definition window_manager.h:66
void present_popup(View *owner, const Pointf &pos, const std::shared_ptr< WindowController > &controller, DisplayWindowDescription *desc=nullptr)
Shows a popup window.
void set_exit_on_last_close(bool enable=true)
Notifices RunLoop to exit when last presented window is dismissed.
friend class WindowController
Definition window_manager.h:92
std::shared_ptr< T > present_popup(View *owner, const Pointf &pos, Types &&... args)
Definition window_manager.h:77
std::shared_ptr< T > present_main(Types &&... args)
Definition window_manager.h:55
void present_modal(View *owner, const std::shared_ptr< WindowController > &controller, DisplayWindowDescription *desc=nullptr)
Shows a modal dialog.
void present_main(const std::shared_ptr< WindowController > &controller, DisplayWindowDescription *desc=nullptr, WindowShowType show_type=WindowShowType::show)
Shows a main window.
void flip(int interval=-1)
Translates a call to all top-level windows.
Definition clanapp.h:36
WindowShowType
Definition top_level_window.h:38
@ show
Definition top_level_window.h:40