2008-04-20 00:16:27 +02:00
|
|
|
/*
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
UI-MANAGER.hpp - Global UI Manager
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
2017, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
*/
|
2011-02-06 21:23:34 +01:00
|
|
|
|
|
|
|
|
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
/** @file ui-manager.hpp
|
2017-01-27 20:42:42 +01:00
|
|
|
** Manager for application resources and similar global state.
|
|
|
|
|
** The central UiManager instance is owned by the GtkLumiera object and initialised in GTK-main.
|
|
|
|
|
** It offers services to provide Icons and other resources and to set and access a general UI theme.
|
2011-02-06 21:23:34 +01:00
|
|
|
**
|
2008-04-20 00:16:27 +02:00
|
|
|
** @see gtk-lumiera.hpp
|
2017-01-27 20:42:42 +01:00
|
|
|
** @see ui-bus.hpp
|
2008-04-20 00:16:27 +02:00
|
|
|
*/
|
|
|
|
|
|
2009-01-31 19:12:04 +01:00
|
|
|
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
#ifndef GUI_WORKSPACE_UI_MANAGER_H
|
|
|
|
|
#define GUI_WORKSPACE_UI_MANAGER_H
|
2008-04-20 00:16:27 +02:00
|
|
|
|
2011-02-06 21:23:34 +01:00
|
|
|
#include "gui/gtk-base.hpp"
|
2017-02-01 03:55:20 +01:00
|
|
|
#include "gui/workspace/actions.hpp"
|
|
|
|
|
#include "gui/workspace/window-list.hpp"
|
2011-02-06 21:23:34 +01:00
|
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
#include <cairomm/cairomm.h>
|
2011-02-07 00:54:16 +01:00
|
|
|
#include <string>
|
2014-04-03 22:42:48 +02:00
|
|
|
#include <memory>
|
2011-02-06 21:23:34 +01:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
|
2008-04-20 00:16:27 +02:00
|
|
|
namespace gui {
|
2011-02-07 00:54:16 +01:00
|
|
|
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
namespace model { class Project; } ////////////////////////////////////////////////////TICKET #1048 : rectify UI lifecycle
|
|
|
|
|
namespace controller { class Controller; } ////////////////////////////////////////////////////TICKET #1048 : rectify UI lifecycle
|
2017-01-26 21:51:19 +01:00
|
|
|
|
|
|
|
|
class UiBus;
|
|
|
|
|
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
namespace workspace {
|
|
|
|
|
|
2011-02-07 00:54:16 +01:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
using std::shared_ptr;
|
|
|
|
|
using std::string;
|
2009-01-31 19:12:04 +01:00
|
|
|
|
2011-02-06 21:23:34 +01:00
|
|
|
|
|
|
|
|
|
2009-01-31 17:31:15 +01:00
|
|
|
/**
|
2017-01-27 20:42:42 +01:00
|
|
|
* The centralised manager of all icons and resources within Lumiera's GUI.
|
2011-01-03 10:30:45 +01:00
|
|
|
*/
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
class UiManager
|
2017-01-26 21:51:19 +01:00
|
|
|
: public Gtk::UIManager
|
2017-01-26 20:51:43 +01:00
|
|
|
, boost::noncopyable
|
2015-05-29 04:44:58 +02:00
|
|
|
{
|
2017-01-26 20:51:43 +01:00
|
|
|
UiBus& uiBus_;
|
|
|
|
|
|
2017-02-01 03:55:20 +01:00
|
|
|
WindowList windowList_;
|
|
|
|
|
Actions actions_;
|
|
|
|
|
|
|
|
|
|
string iconSearchPath_;
|
|
|
|
|
string resourceSerachPath_;
|
2015-05-29 04:44:58 +02:00
|
|
|
|
2017-01-23 01:13:38 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/** The registered icon size for giant 48x48 px icons.
|
|
|
|
|
* @remarks This value is set to BuiltinIconSize::ICON_SIZE_INVALID
|
|
|
|
|
* until register_giant_icon_size is called.
|
|
|
|
|
*/
|
|
|
|
|
static Gtk::IconSize GiantIconSize;
|
|
|
|
|
|
|
|
|
|
/** The registered icon size for giant 16x16 px icons.
|
|
|
|
|
* @remarks This value is set to BuiltinIconSize::ICON_SIZE_INVALID
|
|
|
|
|
* until register_app_icon_sizes is called.
|
|
|
|
|
*/
|
|
|
|
|
static Gtk::IconSize MenuIconSize;
|
|
|
|
|
|
|
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
public:
|
2017-01-26 20:51:43 +01:00
|
|
|
/**
|
|
|
|
|
* There is one global UiManager instance,
|
|
|
|
|
* which is created by [the Application](\ref GtkLumiera)
|
|
|
|
|
* and allows access to the UI-Bus backbone. The UiManager itself
|
|
|
|
|
* is _not a ctrl::Controller,_ and thus not directly connected to the Bus.
|
|
|
|
|
* Rather, supports the top-level windows for creating a consistent interface.
|
|
|
|
|
*/
|
|
|
|
|
UiManager (UiBus& bus);
|
|
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
/**
|
2017-02-01 03:55:20 +01:00
|
|
|
* Set up the first top-level application window.
|
|
|
|
|
* This triggers the build-up of the user interface widgets.
|
2015-05-29 04:44:58 +02:00
|
|
|
*/
|
2017-02-01 03:55:20 +01:00
|
|
|
void createApplicationWindow();
|
2015-05-29 04:44:58 +02:00
|
|
|
|
2017-02-01 03:55:20 +01:00
|
|
|
/** @todo find a solution how to enable/disable menu entries according to focus
|
|
|
|
|
* /////////////////////////////////////////////////TICKET #1076 find out how to handle this properly
|
|
|
|
|
*/
|
|
|
|
|
void updateWindowFocusRelatedActions();
|
2015-05-29 04:44:58 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the theme to use for the Lumiera GUI.
|
|
|
|
|
* @param stylesheetName GTK CSS stylesheet to load from the resourceSearchPath_
|
|
|
|
|
* @throw error::Config if this stylesheet can't be resolved on the searchpath
|
|
|
|
|
* @see #init
|
|
|
|
|
* @see lumiera::Config
|
|
|
|
|
*/
|
|
|
|
|
void setTheme (string const& stylesheetName);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A utility function which reads a colour style from the GTK Style.
|
|
|
|
|
* @param widget The widget to load the style out of.
|
|
|
|
|
* @param property_name The name of the style property to load.
|
|
|
|
|
* @param red The fallback red intensity.
|
|
|
|
|
* @param green The fallback green intensity.
|
|
|
|
|
* @param blue The fallback blue intensity.
|
|
|
|
|
* @return The loaded colour.
|
|
|
|
|
*/
|
|
|
|
|
static Cairo::RefPtr<Cairo::SolidPattern>
|
|
|
|
|
readStyleColourProperty (Gtk::Widget &widget, const gchar *property_name,
|
|
|
|
|
guint16 red, guint16 green, guint16 blue);
|
|
|
|
|
|
2017-01-26 21:51:19 +01:00
|
|
|
void allowCloseWindow (bool yes);
|
2015-05-29 04:44:58 +02:00
|
|
|
|
|
|
|
|
private:
|
2017-02-01 03:55:20 +01:00
|
|
|
void initGlobalUI ();
|
2015-05-29 04:44:58 +02:00
|
|
|
|
|
|
|
|
void registerAppIconSizes();
|
|
|
|
|
void registerStockItems();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds an icon (in different sizes) to the icon factory.
|
|
|
|
|
* @param factory The factory to add the icon to.
|
|
|
|
|
* @param icon_name The file name of the icon to add.
|
|
|
|
|
* @param id The id name of the icon.
|
|
|
|
|
* @param label The user readable icon name for this icon.
|
|
|
|
|
* @return \c true if the icon was successfully loaded,
|
|
|
|
|
* returns \c false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
addStockIconSet (Glib::RefPtr<Gtk::IconFactory> const& factory
|
|
|
|
|
,cuString& icon_name
|
|
|
|
|
,cuString& id
|
|
|
|
|
,cuString& label);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads an icon, searching standard icon locations,
|
|
|
|
|
* and adds it to an icon set.
|
|
|
|
|
* @param icon_set The icon set to add the icon to.
|
|
|
|
|
* @param icon_name The file name of the icon to load.
|
|
|
|
|
* @param size The size of the icon to load.
|
|
|
|
|
* @param wildcard \c true if this icon is to be wildcarded.
|
|
|
|
|
* @return \c true if the icon was loaded successfully.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
addStockIcon (Glib::RefPtr<Gtk::IconSet> const& icon_set
|
|
|
|
|
,cuString& icon_name
|
|
|
|
|
,Gtk::IconSize size
|
|
|
|
|
,bool wildcard);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads an icon from a the icon theme
|
|
|
|
|
* @param icon_set The icon set to add the icon to.
|
|
|
|
|
* @param icon_name The name of the icon to load.
|
|
|
|
|
* @param size The size of the icon to load.
|
|
|
|
|
* @param wildcard \c true if this icon is to be wildcarded.
|
|
|
|
|
* @return \c true if the icon was loaded successfully.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
addThemeIconSource (Glib::RefPtr<Gtk::IconSet> const& icon_set
|
|
|
|
|
,cuString& icon_name
|
|
|
|
|
,Gtk::IconSize size
|
|
|
|
|
,bool wildcard);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads an icon from a non theme set.
|
|
|
|
|
* @param icon_set The icon set to add the icon to.
|
|
|
|
|
* @param base_dir The root icons directory to load from.
|
|
|
|
|
* @param icon_name The file name of the icon to load.
|
|
|
|
|
* @param size The size of the icon to load.
|
|
|
|
|
* @param wildcard \c true if this icon is to be wildcarded.
|
|
|
|
|
* @return \c true if the icon was loaded successfully.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
addNonThemeIconSource (Glib::RefPtr<Gtk::IconSet> const& icon_set
|
|
|
|
|
,cuString& base_dir
|
|
|
|
|
,cuString& icon_name
|
|
|
|
|
,Gtk::IconSize size
|
|
|
|
|
,bool wildcard);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads an icon from a specific path and adds it to an icon set.
|
|
|
|
|
* @param path The path to load from.
|
|
|
|
|
* @param icon_set The icon set to add the icon to.
|
|
|
|
|
* @param size The size of the icon to load.
|
|
|
|
|
* @param wildcard \c true if this icon is to be wildcarded.
|
|
|
|
|
* @return \c true if the icon was loaded successfully.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
addStockIconFromPath (string path
|
|
|
|
|
,Glib::RefPtr<Gtk::IconSet> const& icon_set
|
|
|
|
|
,Gtk::IconSize size
|
|
|
|
|
,bool wildcard);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
};
|
2008-10-10 11:56:07 +02:00
|
|
|
|
2009-01-31 19:12:04 +01:00
|
|
|
|
2008-11-18 23:06:31 +01:00
|
|
|
|
Rectify UI top-level -- introduce a global UiManager (#1067)
There seems to be a mismatch in the arrangement of the top-level entities
* we support multiple windows, yet from reading the code, you'd ge the impression we aren't really aware we have multiple top-level windows
* the `WindowManager` is the core UI manager, which feels like a mix-up in concerns
* the `WorkspaceWindow::createUI()` does the global UI initialisation. Again, we have multiple workspace windows.
* `GtkLumiera::main()` creates a `Model` and a `Controller` in local function scope, but stores the `WindowManager` in an object field.
* it seems, for that very reason, `GtlLumiera` needed to be a singleton, to allow by-name access to "the" `WindowManager`
* needless to say, this causes a host of problems when shutting down the UI.
The idea is to introduce a dedicated UiManager, to deal with the central
framework induced concerns solely, and to demote the WindowManager and the
WorkspaceWindows to care only for their local concerns
2017-01-23 00:40:17 +01:00
|
|
|
}}// namespace gui::workspace
|
|
|
|
|
#endif /*GUI_WORKSPACE_UI_MANAGER_H*/
|