]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/skin_common.hpp
skins2: implement a ArtManager singleton
[vlc] / modules / gui / skins2 / src / skin_common.hpp
index ae4ced2306293bed0a0c6c941679cc07c0d5b4c0..64b1dfd6255c1795cb43ec688d0d5c4f6d3c9125 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * skin_common.hpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
+ * Copyright (C) 2003 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * 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
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #ifndef SKIN_COMMON_HPP
 #define SKIN_COMMON_HPP
 
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_common.h>
+#include <vlc_interface.h>
+#include <vlc_charset.h>
+#include <vlc_fs.h>
 
 #include <string>
 using namespace std;
@@ -39,6 +45,8 @@ class OSFactory;
 class OSLoop;
 class VarManager;
 class VlcProc;
+class VoutManager;
+class ArtManager;
 class Theme;
 class ThemeRepository;
 
@@ -46,17 +54,42 @@ class ThemeRepository;
 #   define M_PI 3.14159265358979323846
 #endif
 
-// Useful macros
-#define SKINS_DELETE( p ) \
-   if( p ) \
-   { \
-       delete p; \
-   } \
-   else \
-   { \
-       msg_Err( getIntf(), "delete NULL pointer in %s at line %d", \
-                __FILE__, __LINE__ ); \
-   }
+#ifdef _MSC_VER
+// turn off 'warning C4355: 'this' : used in base member initializer list'
+#pragma warning ( disable:4355 )
+// turn off 'identifier was truncated to '255' characters in the debug info'
+#pragma warning ( disable:4786 )
+#endif
+
+
+/// Wrapper around FromLocale, to avoid the need to call LocaleFree()
+static inline string sFromLocale( const string &rLocale )
+{
+    char *s = FromLocale( rLocale.c_str() );
+    string res = s;
+    LocaleFree( s );
+    return res;
+}
+
+#ifdef WIN32
+/// Wrapper around FromWide, to avoid the need to call free()
+static inline string sFromWide( const wstring &rWide )
+{
+    char *s = FromWide( rWide.c_str() );
+    string res = s;
+    free( s );
+    return res;
+}
+#endif
+
+/// Wrapper around ToLocale, to avoid the need to call LocaleFree()
+static inline string sToLocale( const string &rUTF8 )
+{
+    char *s = ToLocale( rUTF8.c_str() );
+    string res = s;
+    LocaleFree( s );
+    return res;
+}
 
 
 //---------------------------------------------------------------------------
@@ -90,49 +123,43 @@ struct intf_sys_t
     VarManager *p_varManager;
     /// VLC state handler
     VlcProc *p_vlcProc;
+    /// Vout manager
+    VoutManager *p_voutManager;
+    /// Art manager
+    ArtManager *p_artManager;
     /// Theme repository
     ThemeRepository *p_repository;
 
     /// Current theme
     Theme *p_theme;
+
+    /// synchronisation at start of interface
+    vlc_thread_t thread;
+    vlc_mutex_t  init_lock;
+    vlc_cond_t   init_wait;
+    bool         b_ready;
+
+    /// handle (vout windows)
+    void*        handle;
+    vlc_mutex_t  vout_lock;
+    vlc_cond_t   vout_wait;
+    bool         b_vout_ready;
 };
 
 
 /// Base class for all skin classes
 class SkinObject
 {
-    public:
-        SkinObject( intf_thread_t *pIntf ): m_pIntf( pIntf ) {}
-        virtual ~SkinObject() {}
-
-        /// Getter (public because it is used in C callbacks in the win32
-        /// interface)
-        intf_thread_t *getIntf() const { return m_pIntf; }
-
-        /// Class for callbacks
-        class Callback {
-            public:
-                /// Type for callback methods
-                typedef void (*CallbackFunc_t)( SkinObject* );
-
-                /// Create a callback with the given object and function
-                Callback( SkinObject *pObj, CallbackFunc_t pFunc ):
-                    m_pObj( pObj ), m_pFunc( pFunc ) {}
-                ~Callback() {}
-
-                /// Getters
-                SkinObject *getObj() const { return m_pObj; }
-                CallbackFunc_t getFunc() const { return m_pFunc; }
-
-            private:
-                /// Pointer on the callback object
-                SkinObject *const m_pObj;
-                /// Pointer on the callback method
-                CallbackFunc_t m_pFunc;
-        };
-
-    private:
-        intf_thread_t *m_pIntf;
+public:
+    SkinObject( intf_thread_t *pIntf ): m_pIntf( pIntf ) { }
+    virtual ~SkinObject() { }
+
+    /// Getter (public because it is used in C callbacks in the win32
+    /// interface)
+    intf_thread_t *getIntf() const { return m_pIntf; }
+
+private:
+    intf_thread_t *m_pIntf;
 };