Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
window-locator.cpp
Go to the documentation of this file.
1/*
2 WindowLocator - manage all top level windows
3
4 Copyright (C)
5 2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
26#include "lib/util.hpp"
27
28#include <memory>
29#include <list>
30
31using util::isnil;
32using std::list;
33
34
35namespace stage {
36namespace ctrl {
37
38 using workspace::WorkspaceWindow;
39
40
41
42 PanelLocator::PanelLocator (WindowList& all_top_level_wndows)
43 : windowList_{all_top_level_wndows}
44 { }
45
46
47
49 : globalCtx_{globals}
50 , windowList_{}
51 , panelLoc_{windowList_}
52 , elementAccess_{*this, panelLoc_}
53 { }
54
56
57
58
59 void
61 {
63 REQUIRE(window);
64
65 window->signal_delete_event().connect(sigc::mem_fun(
67
68 windowList_.push_back(window);
69
70 window->show();
71
73 }
74
75
81 void
86
87
97 {
98 REQUIRE (not isnil (windowList_));
99
100 for (auto pwin : windowList_)
101 if (pwin->is_active())
102 return *pwin;
103
104 // use the first window in list when none is active
105 return *windowList_.front();
106 }
107
108
115 {
116 REQUIRE (not isnil (windowList_));
117
118 for (auto pwin : windowList_)
119 if (pwin->has_focus())
120 return *pwin;
121
122 // use the first window in list when none has focus
123 return *windowList_.front();
124 }
125
126
127 bool
129 {
130 REQUIRE(event);
131 REQUIRE(event->window);
132
133 list<PWindow>::iterator iterator{windowList_.begin()};
134
135 while (iterator != windowList_.end())
136 {
137 PWindow workspace_window(*iterator);
138 REQUIRE(workspace_window);
139
140 Glib::RefPtr<Gdk::Window> window = workspace_window->get_window();
141 REQUIRE(window);
142 if (window->gobj() == event->window)
143 {
144 // This window has been closed
145 iterator = windowList_.erase(iterator);
146 }
147 else
148 iterator++;
149 }
150
151 if (windowList_.empty())
152 // All windows have been closed - we should exit
154
156
157 // Unless this is false, the window won't close
158 return false;
159 }
160
161
162 void
167
168
177 {
178 REQUIRE (not isnil(windowList_));
179
180 for (auto window : windowList_)
181 if (window->getPanelManager().hasPanel (typeID))
182 return window->getPanelManager().showPanel (typeID);
183
184 // no instance of the desired panel type exists yet...
185 for (auto window : windowList_)
186 if (window->is_active())
187 return window->getPanelManager().showPanel (typeID);
188
189 // use the first window in list when none is active
190 return windowList_.front()->getPanelManager().showPanel (typeID);
191 }
192
193
194
195
196
197}}// namespace stage::ctrl
A global circle of top-level UI management facilities.
panel::Panel & preliminary_impl_PanelLookup(int typeID)
void allowCloseWindow(bool yes)
void terminateUI()
Cause the main event loop to terminate, so the application as a whole unwinds.
workspace::WorkspaceWindow & findFocusWindow()
similar to findActiveWindow(), for the 'has_focus' property
std::shared_ptr< workspace::WorkspaceWindow > PWindow
void updateCloseWindowInMenus()
On creating and closing of any window, handle enabling or disabling of the Window/Close Window menu o...
void closeWindow()
close (and thus destroy) the current active window.
workspace::WorkspaceWindow & findActiveWindow()
find and retrieve a WorkspaceWindow (top-level window) marked as 'active' by GTK.
bool on_window_closed(GdkEventAny *event)
Event handler for when a window has been closed.
The base class for all dockable panels.
Definition panel.hpp:42
The main Lumiera workspace window.
A service to discover and access raw UI elements in a cross cutting way.
Dependency context to hold all the global UI top-level entities.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
bool isnil(lib::time::Duration const &dur)
Access and query front-end to locate, access and place docking panels.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Manager for all top level application windows.
This file contains the definition of the main workspace window parent, which is the toplevel parent o...