]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/art_manager.hpp
skins2: rework image control (scale while preserving aspect ratio)
[vlc] / modules / gui / skins2 / src / art_manager.hpp
1 /*****************************************************************************
2  * art_manager.hpp
3  *****************************************************************************
4  * Copyright (C) 2010 the VideoLAN team
5  * $Id$
6  *
7  * Author: Erwan Tulou      <erwan10@vidoelan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef ART_MANAGER_HPP
25 #define ART_MANAGER_HPP
26
27 #include "file_bitmap.hpp"
28 #include <string>
29 #include <list>
30
31
32 /// Class for art bitmaps
33 class ArtBitmap: public FileBitmap
34 {
35 public:
36
37     string getUriName() { return m_uriName; }
38
39     /// Constructor/destructor
40     ArtBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
41                string uriName ) :
42         FileBitmap( pIntf, pImageHandler, uriName, -1 ),
43         m_uriName( uriName ) {}
44     virtual ~ArtBitmap() {}
45
46 private:
47     /// uriName
48     string m_uriName;
49 };
50
51
52 /// Singleton object for handling art
53 class ArtManager: public SkinObject
54 {
55 public:
56     /// Get the instance of ArtManager
57     /// Returns NULL if the initialization of the object failed
58     static ArtManager *instance( intf_thread_t *pIntf );
59
60     /// Delete the instance of ArtManager
61     static void destroy( intf_thread_t *pIntf );
62
63     /// Retrieve for the art file from uri name
64     ArtBitmap* getArtBitmap( string uriName );
65
66 protected:
67     // Protected because it is a singleton
68     ArtManager( intf_thread_t *pIntf );
69     virtual ~ArtManager();
70
71 private:
72     /// Image handler (used to load art files)
73     image_handler_t *m_pImageHandler;
74
75     // keep a cache of art already open
76     list<ArtBitmap*> m_listBitmap;
77 };
78
79 #endif