diff --git a/src/gui/gtk-base.hpp b/src/gui/gtk-base.hpp new file mode 100644 index 000000000..12c0d5638 --- /dev/null +++ b/src/gui/gtk-base.hpp @@ -0,0 +1,104 @@ +/* + GTK-BASE.hpp - GTK includes and basic definitions + + Copyright (C) Lumiera.org + 2011, Hermann Vosseler + 2008, Joel Holdsworth + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + 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. + + 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. + +*/ + + +/** @file gtk-base.hpp + ** A set of basic GTK includes. + ** There are some tricky point to consider when including the + ** basic GTKmm headers. Especially, GTK tries to shadow the ERROR macro + ** from Microsoft Windows. Unfortunately this breaks the ERROR macro from NoBug; + ** thus we need to include NoBug \em after GTK + ** + ** Besides, this header defines the basic NLS. Most parts of the GUI rely either + ** directly on this header, or through the inclusion of gtk-lumiera.hpp + ** + ** @see GtkLumiera + */ + + +#ifndef GUI_GTK_BASE_H +#define GUI_GTK_BASE_H + +//--------------------tricky special Include sequence +#include +#include +#include +//--------------------tricky special Include sequence + +#include "lib/error.hpp" +#include "lib/util.hpp" +#include "lib/lumitime.hpp" + + +#ifdef ENABLE_NLS +# include +# define _(String) gettext (String) +# define gettext_noop(String) String +# define N_(String) gettext_noop (String) +#else +# define _(String) (String) +# define N_(String) String +# define textdomain(Domain) +# define bindtextdomain(Package, Directory) +#endif + + + + +/* ======= Namespace Definitions ======= */ + +/** Lumiera GTK GUI implementation root. */ +namespace gui { + + /** Dialog box classes. */ + namespace dialogs {} + + /** The Lumiera GTK-GUI uses a thin proxy layer data model + * on top of the actual "high-level-model", which lives in the + * Proc-Layer below. GUI operations interact with these proxy model + * entities, which in turn forward the calls to the actual objects + * in the Proc-Layer, through the Command system (which enables UNDO). + * + * @todo: as of 1/2011 this connection between the GUI proxy model and + * the Proc-Layer model needs to be set up. Currently, the GUI model + * entities are just created standalone and thus dysfunctional. + */ + namespace model {} + + /** The namespace of all video output implementations. */ + namespace output {} + + /** Docking panel classes. */ + namespace panels {} + + /** Lumiera custom widgets. */ + namespace widgets {} + + /** The workspace window and it's helper classes. */ + namespace workspace {} + + /** GUI helpers, utility functions and classes. */ + namespace util {} + +}// namespace gui +#endif diff --git a/src/gui/gtk-lumiera.cpp b/src/gui/gtk-lumiera.cpp index 3ec81680f..a67d419d1 100644 --- a/src/gui/gtk-lumiera.cpp +++ b/src/gui/gtk-lumiera.cpp @@ -1,5 +1,5 @@ /* - gtk-lumiera.cpp - The entry point for the GTK GUI application + GtkLumiera - The Lumiera GUI Application Object Copyright (C) Lumiera.org 2008, Joel Holdsworth @@ -20,24 +20,14 @@ * *****************************************************/ -#include -#include -#ifdef ENABLE_NLS -# include -#endif +#include "gui/gtk-lumiera.hpp" +#include "gui/window-manager.hpp" +#include "gui/workspace/workspace-window.hpp" +#include "gui/controller/controller.hpp" +#include "gui/model/project.hpp" +#include "lib/singleton.hpp" -#include "gtk-lumiera.hpp" -#include "window-manager.hpp" -#include "workspace/workspace-window.hpp" -#include "model/project.hpp" -#include "controller/controller.hpp" - -extern "C" { -#include "common/interface.h" -} - -NOBUG_CPP_DEFINE_FLAG(gui); using namespace Gtk; using namespace Glib; @@ -47,36 +37,47 @@ using namespace gui::model; using namespace gui::controller; using namespace std; -GtkLumiera the_application; - - - - namespace gui { +namespace { + /** storage for the Main Application object */ + lib::Singleton theApplicationInstance; +} + + + + +GtkLumiera& +GtkLumiera::application() +{ + return theApplicationInstance(); +} + + + void -GtkLumiera::main(int argc, char *argv[]) +GtkLumiera::main (int argc, char *argv[]) { Glib::thread_init(); Main kit(argc, argv); - Glib::set_application_name(get_app_title()); + Glib::set_application_name (get_app_title()); Project project; Controller controller(project); - windowManager.init(); - windowManager.set_theme("lumiera_ui.rc"); - windowManager.new_window(project, controller); + windowManagerInstance_.init(); + windowManagerInstance_.set_theme ("lumiera_ui.rc"); + windowManagerInstance_.new_window (project, controller); kit.run(); } WindowManager& -GtkLumiera::get_window_manager() +GtkLumiera::windowManager() { - return windowManager; + return windowManagerInstance_; } Glib::ustring @@ -125,10 +126,5 @@ GtkLumiera::get_app_authors() return list; } -GtkLumiera& -application() -{ - return the_application; -} } // namespace gui diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp index de7c509bf..226e1acf3 100644 --- a/src/gui/gtk-lumiera.hpp +++ b/src/gui/gtk-lumiera.hpp @@ -1,5 +1,5 @@ /* - gtk-lumiera.hpp - Application wide global definitions + GTK-LUMIERA.hpp - The Lumiera GUI Application Object Copyright (C) Lumiera.org 2008, Joel Holdsworth @@ -25,137 +25,58 @@ ** @see gtk-lumiera.cpp */ -#ifndef GTK_LUMIERA_HPP -#define GTK_LUMIERA_HPP +#ifndef GUI_GTK_LUMIERA_H +#define GUI_GTK_LUMIERA_H -#include -#include -#include // need to include this after gtkmm.h, because types.h from GTK tries to shaddow the ERROR macro from windows, which kills NoBug's ERROR macro + +#include "gui/gtk-base.hpp" +#include "gui/window-manager.hpp" + +#include #include -#include -#include -#include -#include -#include -#include -#include "lib/util.hpp" -#include "lib/lumitime.hpp" -#include "window-manager.hpp" -extern "C" { -#include -} - -//NOBUG_DECLARE_FLAG(gui); - -#ifdef ENABLE_NLS -# include -# define _(String) gettext (String) -# define gettext_noop(String) String -# define N_(String) gettext_noop (String) -#else -# define _(String) (String) -# define N_(String) String -# define textdomain(Domain) -# define bindtextdomain(Package, Directory) -#endif - -/** - * Lumiera GTK GUI implementation root. - */ namespace gui { - -/* ===== The Application Class ===== */ + + +/* ====== The Application Class ====== */ /** * The main application class. */ -class GtkLumiera : private boost::noncopyable -{ -public: - void main(int argc, char *argv[]); - - WindowManager& get_window_manager(); - - static Glib::ustring get_home_data_path(); - - /** - * Returns the name of the application - */ - static const Glib::ustring get_app_title(); - - /** - * Returns the version number of the application - */ - static const Glib::ustring get_app_version(); - - /** - * Returns the copyright of the application - */ - static const Glib::ustring get_app_copyright(); - - /** - * Returns the website of the application - */ - static const Glib::ustring get_app_website(); - - /** - * Returns tn alphabetical list of the application's authors - */ - static const std::vector get_app_authors(); - -protected: - /** - * The application window manager object - */ - WindowManager windowManager; -}; - -/** - * Returns a reference to the global application object - */ -GtkLumiera& application(); - -/* ===== Namespace Definitions ===== */ - -/** - * The namespace of all dialog box classes. - */ -namespace dialogs {} - -/** - * The namespace of data model classes. - */ -namespace model {} - -/** - * The namespace of all video output implementations. - */ -namespace output {} - -/** - * The namespace of all docking panel classes. - */ -namespace panels {} - -/** - * The namespace of all Lumiera custom widgets. - */ -namespace widgets {} - -/** - * The namespace of the workspace window, and it's helper classes. - */ -namespace workspace {} - -/** - * The namespace of utility functions and classes. - */ -namespace util {} - -} // namespace gui - -#endif // GTK_LUMIERA_HPP - +class GtkLumiera + : boost::noncopyable + { + /** Central application window manager instance */ + WindowManager windowManagerInstance_; + + + public: + /** access the the global application object */ + static GtkLumiera& application(); + + + + void main(int argc, char *argv[]); + + WindowManager& windowManager(); + + static Glib::ustring get_home_data_path(); + + + /** the name of the application */ + static const Glib::ustring get_app_title(); + + static const Glib::ustring get_app_version(); + + static const Glib::ustring get_app_copyright(); + + static const Glib::ustring get_app_website(); + + /** alphabetical list of the application's authors */ + static const std::vector get_app_authors(); + + }; +}// namespace gui +#endif diff --git a/src/gui/guistart.cpp b/src/gui/guistart.cpp index d5f072058..b5b5ee6e9 100644 --- a/src/gui/guistart.cpp +++ b/src/gui/guistart.cpp @@ -110,7 +110,8 @@ namespace gui { int argc =0; char *argv[] = {}; // dummy command line for GTK - gui::application().main(argc, argv); // execute the GTK Event Loop + // execute the GTK Event Loop____________ + GtkLumiera::application().main(argc, argv); if (!lumiera_error_peek()) return; // all went well, normal shutdown diff --git a/src/gui/model/parent-track.hpp b/src/gui/model/parent-track.hpp index 9112c86f7..78451972e 100644 --- a/src/gui/model/parent-track.hpp +++ b/src/gui/model/parent-track.hpp @@ -25,11 +25,15 @@ ** are also track parents. This class wraps proc layer data */ +#ifndef PARENT_TRACK_HPP +#define PARENT_TRACK_HPP + #include "track.hpp" #include "lib/observable-list.hpp" -#ifndef PARENT_TRACK_HPP -#define PARENT_TRACK_HPP +#include +#include + namespace gui { namespace model { diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index aef78f9e3..198368fae 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -19,10 +19,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + /** @file timeline-panel.hpp ** This file contains the definition of the timeline panel */ + #ifndef TIMELINE_PANEL_HPP #define TIMELINE_PANEL_HPP @@ -30,8 +33,12 @@ #include "gui/widgets/timecode-widget.hpp" #include "gui/widgets/timeline-widget.hpp" +#include +#include + using namespace gui::widgets; + namespace gui { namespace model { diff --git a/src/gui/widgets/timeline/timeline-body.hpp b/src/gui/widgets/timeline/timeline-body.hpp index 6a4bb0b28..72dc374b2 100644 --- a/src/gui/widgets/timeline/timeline-body.hpp +++ b/src/gui/widgets/timeline/timeline-body.hpp @@ -29,6 +29,8 @@ #include "gui/gtk-lumiera.hpp" #include "timeline-tool.hpp" +#include + namespace gui { namespace model { diff --git a/src/gui/widgets/timeline/timeline-layout-helper.hpp b/src/gui/widgets/timeline/timeline-layout-helper.hpp index dbd588a34..bc0f1c39d 100644 --- a/src/gui/widgets/timeline/timeline-layout-helper.hpp +++ b/src/gui/widgets/timeline/timeline-layout-helper.hpp @@ -30,6 +30,8 @@ #include "gui/gtk-lumiera.hpp" #include "lib/tree.hpp" +#include + namespace gui { namespace model { diff --git a/src/gui/widgets/timeline/timeline-track.hpp b/src/gui/widgets/timeline/timeline-track.hpp index 21c5be6da..a45bf5ab4 100644 --- a/src/gui/widgets/timeline/timeline-track.hpp +++ b/src/gui/widgets/timeline/timeline-track.hpp @@ -19,21 +19,28 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + /** @file widgets/timeline/timeline-track.hpp ** This file contains the definition of timeline track object */ + +#ifndef TIMELINE_TRACK_HPP +#define TIMELINE_TRACK_HPP + + #include "gui/gtk-lumiera.hpp" #include "gui/model/track.hpp" #include "gui/widgets/menu-button.hpp" #include "gui/widgets/mini-button.hpp" #include "gui/widgets/button-bar.hpp" -#include "timeline-clip.hpp" -#include "timeline-header-container.hpp" -#include "timeline-header-widget.hpp" +#include "gui/widgets/timeline/timeline-clip.hpp" +#include "gui/widgets/timeline/timeline-header-container.hpp" +#include "gui/widgets/timeline/timeline-header-widget.hpp" + +#include -#ifndef TIMELINE_TRACK_HPP -#define TIMELINE_TRACK_HPP namespace gui { namespace widgets { diff --git a/src/gui/window-manager.cpp b/src/gui/window-manager.cpp index 44c550215..461c9c01c 100644 --- a/src/gui/window-manager.cpp +++ b/src/gui/window-manager.cpp @@ -1,5 +1,5 @@ /* - window-manager.cpp - Defines the global UI Manager class + WindowManager - Global UI Manager class Copyright (C) Lumiera.org 2008, Joel Holdsworth @@ -20,9 +20,10 @@ * *****************************************************/ -#include "window-manager.hpp" -#include "include/logging.h" -#include "workspace/workspace-window.hpp" + +#include "gui/window-manager.hpp" +#include "gui/gtk-lumiera.hpp" +#include "gui/workspace/workspace-window.hpp" using namespace Gtk; using namespace Glib; diff --git a/src/gui/window-manager.hpp b/src/gui/window-manager.hpp index 4f23ac6e6..090babdc2 100644 --- a/src/gui/window-manager.hpp +++ b/src/gui/window-manager.hpp @@ -1,5 +1,5 @@ /* - window-manager.hpp - Defines the global UI Manager class + WINDOW-MANAGER.hpp - Global UI Manager class Copyright (C) Lumiera.org 2008, Joel Holdsworth @@ -19,20 +19,31 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + /** @file window-manager.hpp - ** This file contains the defintion of global UI Manager class. - ** @see window-manager.cpp + ** Manager for all application windows and resources. + ** This file defines the global UI Manager class. The central WindowManager + ** instance is owned by the GtkLumiera object and initialised in GTK-main. + ** The WindowManager has the ability to create new windows integrated with + ** the application framework, to provide Icons and other resources and + ** to set and access a general UI theme. + ** ** @see gtk-lumiera.hpp */ -#include - -#include "gtk-lumiera.hpp" -//#include "workspace/workspace-window.hpp" #ifndef WINDOW_MANAGER_HPP #define WINDOW_MANAGER_HPP +#include "gui/gtk-base.hpp" + +#include +#include +#include + + + namespace gui { namespace model { @@ -50,11 +61,13 @@ namespace workspace { /** * The centralised manager of all lumiera-gui's windows. */ -class WindowManager : private boost::noncopyable +class WindowManager + : boost::noncopyable { public: /** - * Initializes the window manager object + * Initialise the window manager on application start. + * Register the icon configuration and sizes. */ void init(); @@ -104,17 +117,16 @@ private: * otherwise. */ void update_close_window_in_menus(); - - /** - * Registers the custom icon sizes. - */ - static void register_app_icon_sizes(); + + + /** Registers the custom icon sizes. */ + void register_app_icon_sizes(); /** * Registers application stock items: icons and * labels associated with IDs */ - static void register_stock_items(); + void register_stock_items(); /** * Adds an icon (in different sizes) to the icon factory. @@ -125,7 +137,7 @@ private: * @return Returns true if the icon was successfully loaded, returns * false otherwise. */ - static bool add_stock_icon_set( + bool add_stock_icon_set( const Glib::RefPtr& factory, const Glib::ustring& icon_name, const Glib::ustring& id, @@ -141,7 +153,7 @@ private: * wildcarded. * @return Returns true if the icon was loaded successfully. */ - static bool add_stock_icon(Gtk::IconSet &icon_set, + bool add_stock_icon(Gtk::IconSet &icon_set, const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard); /** @@ -153,7 +165,7 @@ private: * wildcarded. * @return Returns true if the icon was loaded successfully. */ - static bool add_theme_icon_source(Gtk::IconSet &icon_set, + bool add_theme_icon_source(Gtk::IconSet &icon_set, const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard); /** @@ -166,7 +178,7 @@ private: * wildcarded. * @return Returns true if the icon was loaded successfully. */ - static bool add_non_theme_icon_source(Gtk::IconSet &icon_set, + bool add_non_theme_icon_source(Gtk::IconSet &icon_set, const Glib::ustring& base_dir, const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard); @@ -179,7 +191,7 @@ private: * wildcarded. * @return Returns true if the icon was loaded successfully. */ - static bool add_stock_icon_from_path(Glib::ustring path, + bool add_stock_icon_from_path(Glib::ustring path, Gtk::IconSet &icon_set, Gtk::IconSize size, bool wildcard); private: @@ -203,6 +215,7 @@ public: static Gtk::IconSize MenuIconSize; }; -} // namespace gui -#endif // WINDOW_MANAGER_HPP + +}// namespace gui +#endif diff --git a/src/gui/workspace/actions.cpp b/src/gui/workspace/actions.cpp index 4260b40ad..d448c41a4 100644 --- a/src/gui/workspace/actions.cpp +++ b/src/gui/workspace/actions.cpp @@ -334,7 +334,7 @@ Actions::on_menu_track_add() void Actions::on_menu_window_new_window() { - application().get_window_manager().new_window( + GtkLumiera::application().windowManager().new_window( workspaceWindow.get_project(), workspaceWindow.get_controller()); }