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
110
111
112
113
114
115
116
117
118
119
|
/*!
\file guiImage.h
\brief
*/
#ifndef GUILIB_GUIIMAGECONTROL_H
#define GUILIB_GUIIMAGECONTROL_H
#pragma once
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GUIControl.h"
#include "GUITexture.h"
/*!
\ingroup controls
\brief
*/
class CGUIImage : public CGUIControl
{
public:
class CFadingTexture
{
public:
CFadingTexture(const CGUITexture &texture, unsigned int fadeTime)
{
// create a copy of our texture, and allocate resources
m_texture = new CGUITexture(texture);
m_texture->AllocResources();
m_fadeTime = fadeTime;
m_fading = false;
};
~CFadingTexture()
{
m_texture->FreeResources();
delete m_texture;
};
CGUITexture *m_texture; ///< texture to fade out
unsigned int m_fadeTime; ///< time to fade out (ms)
bool m_fading; ///< whether we're fading out
};
CGUIImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture);
CGUIImage(const CGUIImage &left);
virtual ~CGUIImage(void);
virtual CGUIImage *Clone() const { return new CGUIImage(*this); };
virtual void Render();
virtual void UpdateVisibility(const CGUIListItem *item = NULL);
virtual bool OnAction(const CAction &action) ;
virtual bool OnMessage(CGUIMessage& message);
virtual void AllocResources();
virtual void FreeResources(bool immediately = false);
virtual void DynamicResourceAlloc(bool bOnOff);
virtual bool IsDynamicallyAllocated() { return m_bDynamicResourceAlloc; };
virtual void SetInvalid();
virtual bool CanFocus() const;
virtual void UpdateInfo(const CGUIListItem *item = NULL);
virtual void SetInfo(const CGUIInfoLabel &info);
virtual void SetFileName(const CStdString& strFileName, bool setConstant = false);
virtual void SetAspectRatio(const CAspectRatio &aspect);
virtual void SetWidth(float width);
virtual void SetHeight(float height);
virtual void SetPosition(float posX, float posY);
virtual CStdString GetDescription() const;
void SetCrossFade(unsigned int time);
const CStdString& GetFileName() const;
float GetTextureWidth() const;
float GetTextureHeight() const;
#ifdef _DEBUG
virtual void DumpTextureUse();
#endif
protected:
virtual void AllocateOnDemand();
virtual void FreeTextures(bool immediately = false);
void FreeResourcesButNotAnims();
unsigned char GetFadeLevel(unsigned int time) const;
bool RenderFading(CFadingTexture *texture, unsigned int frameTime);
bool m_bDynamicResourceAlloc;
// border + conditional info
CTextureInfo m_image;
CGUIInfoLabel m_info;
CGUITexture m_texture;
std::vector<CFadingTexture *> m_fadingTextures;
CStdString m_currentTexture;
unsigned int m_crossFadeTime;
unsigned int m_currentFadeTime;
unsigned int m_lastRenderTime;
};
#endif
|