summaryrefslogtreecommitdiff
path: root/imagecache.h
blob: cbecffe720b907da0332b70a9a5af0a193ffe568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef __NOPACITY_IMAGECACHE_H
#define __NOPACITY_IMAGECACHE_H

#define X_DISPLAY_MISSING

#include <vdr/osd.h>
#include <vdr/skins.h>
#include <Magick++.h>
#include <vector>
#include "imagemagickwrapper.h"

using namespace Magick;

enum eCacheType {
    ctMenuIcon = 0,
    ctSkinIcon,
    ctLogo,
    ctLogoMenuItem,
    ctLogoTimer,
    ctSkinElement,
};

enum eSkinElementType {
    seNone = -1,
    seDefault = 0,
    seDefaultHigh,
    seMain,
    seMainHigh,
    seMainTop,
    seSchedules,
    seSchedulesHigh,
    seSchedulesTop,
    seChannels,
    seChannelsHigh,
    seChannelsTop,
    seRecordings,
    seRecordingsHigh,
    seRecordingsTop,
    seTimers,
    seTimersHigh,
    seTimersTop,
    seSetup,
    seSetupHigh,
    seSetupTop,
    seTracks,
    seTracksHigh,
    seTracksTop,
    seButtonRed,
    seButtonGreen,
    seButtonYellow,
    seButtonBlue,
    seMenuHeader,
    seMenuHeaderTop,
    seChannelBackground,
    seChannelTop,
    seChannelLogoBack,
    seReplayBackground,
    seReplayTop,
    seMessageStatus,
    seMessageInfo,
    seMessageWarning,
    seMessageError,
    seVolumeBackground,
    seScrollbar,
};

struct sImgProperties {
    int width;
    int height;
    bool preserveAspect;
};

class cImageCache : public cImageMagickWrapper {
public:
    cImageCache();
    ~cImageCache();
    bool ThemeChanged(void);
    cImage *GetMenuIcon(std::string name);
    cImage *GetSkinIcon(std::string name, int width=0, int height=0, bool preserveAspect = true);
    cImage *GetSkinElement(eSkinElementType type);
    cImage *GetLogo(eCacheType type, const cChannel *channel);
    cImage GetBackground(tColor back, tColor blend, int width, int height, bool flip = false);
    std::string GetCacheSize(eCacheType type);
private:
    cImage *tempStaticLogo;
    std::string osdTheme;
    std::map<std::string, cImage*> menuIconCache;
    std::map<std::string, cImage*> skinIconCache;
    std::map<eSkinElementType, cImage*> skinElementCache;
    std::map<std::string, cImage*> logoCache;
    std::map<std::string, cImage*> logoMenuItemCache;
    std::map<std::string, cImage*> logoTimerCache;
    std::vector<std::pair<std::string, cPoint> > GetMenuIcons(void);
    std::vector<std::pair<std::string, sImgProperties> > GetSkinIcons(void);
    void CreateCache(void);
    bool LoadIcon(eCacheType type, std::string name);
    void InsertIntoIconCache(eCacheType type, std::string name, int width, int height, bool preserveAspect = true);
    bool LoadLogo(const cChannel *channel);
    void InsertIntoLogoCache(eCacheType type, std::string channelID);
    cPoint LogoSize(eCacheType type);
    void CreateSkinElementsBlended(void);
    void CreateSkinElementsGraphics(void);
    void InsertIntoSkinElementCache(eSkinElementType type, int width=0, int height=0);
    void Clear(void);
};

extern cImageCache *imgCache;

#endif //__NOPACITY_IMAGECACHE_H