xbmc
GUIImage.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
16 #include "GUIControl.h"
17 #include "GUITexture.h"
19 
20 #include <vector>
21 
27 class CGUIImage : public CGUIControl
28 {
29 public:
31  {
32  public:
33  CFadingTexture(const CGUITexture* texture, unsigned int fadeTime)
34  {
35  // create a copy of our texture, and allocate resources
36  m_texture.reset(texture->Clone());
37  m_texture->AllocResources();
38  m_fadeTime = fadeTime;
39  m_fading = false;
40  };
42  {
43  m_texture->FreeResources();
44  };
45 
46  std::unique_ptr<CGUITexture> m_texture;
47  unsigned int m_fadeTime;
48  bool m_fading;
49 
50  private:
51  CFadingTexture(const CFadingTexture&) = delete;
52  CFadingTexture& operator=(const CFadingTexture&) = delete;
53  };
54 
55  CGUIImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture);
56  CGUIImage(const CGUIImage &left);
57  ~CGUIImage(void) override;
58  CGUIImage* Clone() const override { return new CGUIImage(*this); }
59 
60  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
61  void Render() override;
62  void UpdateVisibility(const CGUIListItem *item = NULL) override;
63  bool OnAction(const CAction &action) override ;
64  bool OnMessage(CGUIMessage& message) override;
65  void AllocResources() override;
66  void FreeResources(bool immediately = false) override;
67  void DynamicResourceAlloc(bool bOnOff) override;
68  bool IsDynamicallyAllocated() override { return m_bDynamicResourceAlloc; }
69  void SetInvalid() override;
70  bool CanFocus() const override;
71  void UpdateInfo(const CGUIListItem *item = NULL) override;
72 
73  virtual void SetInfo(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &info);
74  virtual void SetFileName(const std::string& strFileName, bool setConstant = false, const bool useCache = true);
75  virtual void SetAspectRatio(const CAspectRatio &aspect);
76  void SetWidth(float width) override;
77  void SetHeight(float height) override;
78  void SetPosition(float posX, float posY) override;
79  std::string GetDescription() const override;
80  void SetCrossFade(unsigned int time);
81 
82  const std::string& GetFileName() const;
83  float GetTextureWidth() const;
84  float GetTextureHeight() const;
85 
86  CRect CalcRenderRegion() const override;
87 
88 #ifdef _DEBUG
89  void DumpTextureUse() override;
90 #endif
91 protected:
92  virtual void AllocateOnDemand();
93  virtual void FreeTextures(bool immediately = false);
94  void FreeResourcesButNotAnims();
95  unsigned char GetFadeLevel(unsigned int time) const;
96  bool ProcessFading(CFadingTexture *texture, unsigned int frameTime, unsigned int currentTime);
97 
98  bool m_bDynamicResourceAlloc;
99 
100  // border + conditional info
101  CTextureInfo m_image;
103 
104  std::unique_ptr<CGUITexture> m_texture;
105  std::vector<CFadingTexture *> m_fadingTextures;
106  std::string m_currentTexture;
107  std::string m_currentFallback;
108 
109  unsigned int m_crossFadeTime;
110  unsigned int m_currentFadeTime;
111  unsigned int m_lastRenderTime;
112 };
113 
Definition: GUIListItem.h:30
Definition: GUIInfoLabel.h:31
Base class for controls.
Definition: GUIControl.h:75
std::unique_ptr< CGUITexture > m_texture
texture to fade out
Definition: GUIImage.h:44
CRect CalcRenderRegion() const override
calculate the render region in parentcontrol coordinates of this control Called during process to upd...
Definition: GUIImage.cpp:291
bool m_fading
whether we&#39;re fading out
Definition: GUIImage.h:48
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
unsigned int m_fadeTime
time to fade out (ms)
Definition: GUIImage.h:47
Definition: GUITexture.h:28
Definition: GUITexture.h:51
Definition: GUITexture.h:73
Definition: GUIMessage.h:365
Definition: GUIImage.h:27
Definition: GUIImage.h:30