xbmc
GUIMultiImage.h
Go to the documentation of this file.
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 "GUIImage.h"
17 #include "threads/CriticalSection.h"
18 #include "utils/Job.h"
19 #include "utils/Stopwatch.h"
20 
21 #include <vector>
22 
27 class CGUIMultiImage : public CGUIControl, public IJobCallback
28 {
29 public:
30  CGUIMultiImage(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& texture, unsigned int timePerImage, unsigned int fadeTime, bool randomized, bool loop, unsigned int timeToPauseAtEnd);
31  CGUIMultiImage(const CGUIMultiImage &from);
32  ~CGUIMultiImage(void) override;
33  CGUIMultiImage* Clone() const override { return new CGUIMultiImage(*this); }
34 
35  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
36  void Render() override;
37  void UpdateVisibility(const CGUIListItem *item = NULL) override;
38  void UpdateInfo(const CGUIListItem *item = NULL) override;
39  bool OnAction(const CAction &action) override;
40  bool OnMessage(CGUIMessage &message) override;
41  void AllocResources() override;
42  void FreeResources(bool immediately = false) override;
43  void DynamicResourceAlloc(bool bOnOff) override;
44  bool IsDynamicallyAllocated() override { return m_bDynamicResourceAlloc; }
45  void SetInvalid() override;
46  bool CanFocus() const override;
47  std::string GetDescription() const override;
48 
49  void SetInfo(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &info);
50  void SetAspectRatio(const CAspectRatio &ratio);
51 
52 protected:
53  void LoadDirectory();
54  void OnDirectoryLoaded();
55  void CancelLoading();
56 
57  enum DIRECTORY_STATUS { UNLOADED = 0, LOADING, LOADED, READY };
58  void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
59 
60  class CMultiImageJob : public CJob
61  {
62  public:
63  explicit CMultiImageJob(const std::string &path);
64  bool DoWork() override;
65  const char* GetType() const override { return "multiimage"; }
66 
67  std::vector<std::string> m_files;
68  std::string m_path;
69  };
70 
72  std::string m_currentPath;
73  unsigned int m_currentImage;
74  CStopWatch m_imageTimer;
75  unsigned int m_timePerImage;
76  unsigned int m_timeToPauseAtEnd;
77  bool m_randomized;
78  bool m_loop;
79 
80  bool m_bDynamicResourceAlloc;
81  std::vector<std::string> m_files;
82 
83  CGUIImage m_image;
84 
85  CCriticalSection m_section;
86  DIRECTORY_STATUS m_directoryStatus;
87  unsigned int m_jobID;
88 };
89 
Definition: Stopwatch.h:14
Definition: GUIMultiImage.h:60
Definition: GUIListItem.h:30
Base class for jobs that are executed asynchronously.
Definition: Job.h:109
Definition: GUIInfoLabel.h:31
Base class for controls.
Definition: GUIControl.h:75
const char * GetType() const override
Function that returns the type of job.
Definition: GUIMultiImage.h:65
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
bool DoWork() override
Main workhorse function of CJob instances.
Definition: GUIMultiImage.cpp:295
Definition: GUITexture.h:28
Definition: GUITexture.h:51
Definition: GUIMultiImage.h:27
void OnJobComplete(unsigned int jobID, bool success, CJob *job) override
The callback used when a job completes.
Definition: GUIMultiImage.cpp:268
Definition: GUIMessage.h:365
Definition: GUIImage.h:27
Callback interface for asynchronous jobs.
Definition: Job.h:31