]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/skin_common.hpp
skins2: implement a ArtManager singleton
[vlc] / modules / gui / skins2 / src / skin_common.hpp
1 /*****************************************************************************
2  * skin_common.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #ifndef SKIN_COMMON_HPP
30 #define SKIN_COMMON_HPP
31
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_charset.h>
35 #include <vlc_fs.h>
36
37 #include <string>
38 using namespace std;
39
40 class AsyncQueue;
41 class Logger;
42 class Dialogs;
43 class Interpreter;
44 class OSFactory;
45 class OSLoop;
46 class VarManager;
47 class VlcProc;
48 class VoutManager;
49 class ArtManager;
50 class Theme;
51 class ThemeRepository;
52
53 #ifndef M_PI
54 #   define M_PI 3.14159265358979323846
55 #endif
56
57 #ifdef _MSC_VER
58 // turn off 'warning C4355: 'this' : used in base member initializer list'
59 #pragma warning ( disable:4355 )
60 // turn off 'identifier was truncated to '255' characters in the debug info'
61 #pragma warning ( disable:4786 )
62 #endif
63
64
65 /// Wrapper around FromLocale, to avoid the need to call LocaleFree()
66 static inline string sFromLocale( const string &rLocale )
67 {
68     char *s = FromLocale( rLocale.c_str() );
69     string res = s;
70     LocaleFree( s );
71     return res;
72 }
73
74 #ifdef WIN32
75 /// Wrapper around FromWide, to avoid the need to call free()
76 static inline string sFromWide( const wstring &rWide )
77 {
78     char *s = FromWide( rWide.c_str() );
79     string res = s;
80     free( s );
81     return res;
82 }
83 #endif
84
85 /// Wrapper around ToLocale, to avoid the need to call LocaleFree()
86 static inline string sToLocale( const string &rUTF8 )
87 {
88     char *s = ToLocale( rUTF8.c_str() );
89     string res = s;
90     LocaleFree( s );
91     return res;
92 }
93
94
95 //---------------------------------------------------------------------------
96 // intf_sys_t: description and status of skin interface
97 //---------------------------------------------------------------------------
98 struct intf_sys_t
99 {
100     /// The input thread
101     input_thread_t *p_input;
102
103     /// The playlist thread
104     playlist_t *p_playlist;
105
106     /// Message bank subscription
107     msg_subscription_t *p_sub;
108
109     // "Singleton" objects: MUST be initialized to NULL !
110     /// Logger
111     Logger *p_logger;
112     /// Asynchronous command queue
113     AsyncQueue *p_queue;
114     /// Dialog provider
115     Dialogs *p_dialogs;
116     /// Script interpreter
117     Interpreter *p_interpreter;
118     /// Factory for OS specific classes
119     OSFactory *p_osFactory;
120     /// Main OS specific message loop
121     OSLoop *p_osLoop;
122     /// Variable manager
123     VarManager *p_varManager;
124     /// VLC state handler
125     VlcProc *p_vlcProc;
126     /// Vout manager
127     VoutManager *p_voutManager;
128     /// Art manager
129     ArtManager *p_artManager;
130     /// Theme repository
131     ThemeRepository *p_repository;
132
133     /// Current theme
134     Theme *p_theme;
135
136     /// synchronisation at start of interface
137     vlc_thread_t thread;
138     vlc_mutex_t  init_lock;
139     vlc_cond_t   init_wait;
140     bool         b_ready;
141
142     /// handle (vout windows)
143     void*        handle;
144     vlc_mutex_t  vout_lock;
145     vlc_cond_t   vout_wait;
146     bool         b_vout_ready;
147 };
148
149
150 /// Base class for all skin classes
151 class SkinObject
152 {
153 public:
154     SkinObject( intf_thread_t *pIntf ): m_pIntf( pIntf ) { }
155     virtual ~SkinObject() { }
156
157     /// Getter (public because it is used in C callbacks in the win32
158     /// interface)
159     intf_thread_t *getIntf() const { return m_pIntf; }
160
161 private:
162     intf_thread_t *m_pIntf;
163 };
164
165
166 #endif