window_manager.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore 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 "window_controller.h"
34 
35 namespace uicore
36 {
37  class View;
38  class WindowManagerImpl;
39 
42  {
43  public:
45  static void set_exit_on_last_close(bool enable = true);
46 
48  static void present_main(const std::shared_ptr<WindowController> &controller);
49 
50  template<typename T, typename... Types>
51  static std::shared_ptr<T> present_main(Types &&... args)
52  {
53  auto controller = std::make_shared<T>(std::forward<Types>(args)...);
54  present_main(controller);
55  return controller;
56  }
57 
59  static void present_modal(View *owner, const std::shared_ptr<WindowController> &controller);
60 
61  template<typename T, typename... Types>
62  static std::shared_ptr<T> present_modal(View *owner, Types &&... args)
63  {
64  auto controller = std::make_shared<T>(std::forward<Types>(args)...);
65  present_modal(owner, controller);
66  return controller;
67  }
68 
70  static void present_popup(View *owner, const Pointf &pos, const std::shared_ptr<WindowController> &controller);
71 
72  template<typename T, typename... Types>
73  static std::shared_ptr<T> present_popup(View *owner, const Pointf &pos, Types &&... args)
74  {
75  auto controller = std::make_shared<T>(std::forward<Types>(args)...);
76  present_popup(owner, pos, controller);
77  return controller;
78  }
79 
80  private:
81  WindowManager() = delete;
82  WindowManager(const WindowManager &) = delete;
83  WindowManager &operator=(const WindowManager &) = delete;
84 
85  std::unique_ptr<WindowManagerImpl> impl;
86  friend class WindowController;
87  };
88 }
static void present_main(const std::shared_ptr< WindowController > &controller)
Shows a main window.
static std::shared_ptr< T > present_popup(View *owner, const Pointf &pos, Types &&...args)
Definition: window_manager.h:73
Base class for controllers managing windows.
Definition: window_controller.h:40
2D (x,y) point structure - Float
Definition: point.h:68
static void present_modal(View *owner, const std::shared_ptr< WindowController > &controller)
Shows a modal dialog.
Manages one or more windows.
Definition: window_manager.h:41
static void present_popup(View *owner, const Pointf &pos, const std::shared_ptr< WindowController > &controller)
Shows a popup window.
static std::shared_ptr< T > present_main(Types &&...args)
Definition: window_manager.h:51
static std::shared_ptr< T > present_modal(View *owner, Types &&...args)
Definition: window_manager.h:62
View for an area of the user interface.
Definition: view.h:68
static void set_exit_on_last_close(bool enable=true)
Notifices RunLoop to exit when last presented window is dismissed.
Definition: Application/application.h:35