xbmc
GUIWindowSlideShow.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 
11 #include "SlideShowPicture.h"
12 #include "guilib/GUIDialog.h"
13 #include "threads/Event.h"
14 #include "threads/Thread.h"
15 #include "utils/SortUtils.h"
16 
17 #include <memory>
18 #include <set>
19 
20 class CFileItemList;
21 class CVariant;
22 
24 
26 {
27 public:
29  ~CBackgroundPicLoader() override;
30 
31  void Create(CGUIWindowSlideShow *pCallback);
32  void LoadPic(int iPic, int iSlideNumber, const std::string &strFileName, const int maxWidth, const int maxHeight);
33  bool IsLoading() { return m_isLoading; }
34  int SlideNumber() const { return m_iSlideNumber; }
35  int Pic() const { return m_iPic; }
36 
37 private:
38  void Process() override;
39  int m_iPic;
40  int m_iSlideNumber;
41  std::string m_strFileName;
42  int m_maxWidth;
43  int m_maxHeight;
44 
45  CEvent m_loadPic;
46  bool m_isLoading;
47 
48  CGUIWindowSlideShow *m_pCallback;
49 };
50 
52 {
53 public:
54  CGUIWindowSlideShow(void);
55  ~CGUIWindowSlideShow() override = default;
56 
57  bool OnMessage(CGUIMessage& message) override;
58  EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event) override;
59  bool OnAction(const CAction &action) override;
60  void Render() override;
61  void RenderEx() override;
62  void Process(unsigned int currentTime, CDirtyRegionList &regions) override;
63  void OnDeinitWindow(int nextWindowID) override;
64 
65  void Reset();
66  void Add(const CFileItem *picture);
67  bool IsPlaying() const;
68  void Select(const std::string& strPicture);
69  void GetSlideShowContents(CFileItemList &list);
70  std::shared_ptr<const CFileItem> GetCurrentSlide();
71  void RunSlideShow(const std::string &strPath, bool bRecursive = false,
72  bool bRandom = false, bool bNotRandom = false,
73  const std::string &beginSlidePath="", bool startSlideShow = true,
74  SortBy method = SortByLabel,
75  SortOrder order = SortOrderAscending,
76  SortAttribute sortAttributes = SortAttributeNone,
77  const std::string &strExtensions="");
78  void AddFromPath(const std::string &strPath, bool bRecursive,
79  SortBy method = SortByLabel,
80  SortOrder order = SortOrderAscending,
81  SortAttribute sortAttributes = SortAttributeNone,
82  const std::string &strExtensions="");
83  void StartSlideShow();
84  bool InSlideShow() const;
85  void OnLoadPic(int iPic,
86  int iSlideNumber,
87  const std::string& strFileName,
88  std::unique_ptr<CTexture> pTexture,
89  bool bFullSize);
90  int NumSlides() const;
91  int CurrentSlide() const;
92  void Shuffle();
93  bool IsPaused() const { return m_bPause; }
94  bool IsShuffled() const { return m_bShuffled; }
95  int GetDirection() const { return m_iDirection; }
96 
97  static void RunSlideShow(const std::vector<std::string>& paths, int start = 0);
98 
99 private:
100  void ShowNext();
101  void ShowPrevious();
102  void SetDirection(int direction); // -1: rewind, 1: forward
103 
104  typedef std::set<std::string> path_set; // set to track which paths we're adding
105  void AddItems(const std::string &strPath, path_set *recursivePaths,
106  SortBy method = SortByLabel,
107  SortOrder order = SortOrderAscending,
108  SortAttribute sortAttributes = SortAttributeNone);
109  bool PlayVideo();
110  CSlideShowPic::DISPLAY_EFFECT GetDisplayEffect(int iSlideNumber) const;
111  void RenderPause();
112  void RenderErrorMessage();
113  void Rotate(float fAngle, bool immediate = false);
114  void Zoom(int iZoom);
115  void ZoomRelative(float fZoom, bool immediate = false);
116  void Move(float fX, float fY);
117  void GetCheckedSize(float width, float height, int &maxWidth, int &maxHeight);
118  std::string GetPicturePath(CFileItem *item);
119  int GetNextSlide();
120 
121  void AnnouncePlayerPlay(const CFileItemPtr& item);
122  void AnnouncePlayerPause(const CFileItemPtr& item);
123  void AnnouncePlayerStop(const CFileItemPtr& item);
124  void AnnouncePlaylistClear();
125  void AnnouncePlaylistAdd(const CFileItemPtr& item, int pos);
126  void AnnouncePropertyChanged(const std::string &strProperty, const CVariant &value);
127 
128  int m_iCurrentSlide;
129  int m_iNextSlide;
130  int m_iDirection;
131  float m_fRotate;
132  float m_fInitialRotate;
133  int m_iZoomFactor;
134  float m_fZoom;
135  float m_fInitialZoom;
136 
137  bool m_bShuffled;
138  bool m_bSlideShow;
139  bool m_bPause;
140  bool m_bPlayingVideo;
141  int m_iVideoSlide = -1;
142  bool m_bErrorMessage;
143 
144  std::vector<CFileItemPtr> m_slides;
145 
146  CSlideShowPic m_Image[2];
147 
148  int m_iCurrentPic;
149  // background loader
150  std::unique_ptr<CBackgroundPicLoader> m_pBackgroundLoader;
151  int m_iLastFailedNextSlide;
152  bool m_bLoadNextPic;
153  RESOLUTION m_Resolution;
154  CPoint m_firstGesturePoint;
155 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: SlideShowPicture.h:25
Definition: Thread.h:44
Represents a list of files.
Definition: FileItem.h:713
Definition: GUIWindowSlideShow.h:51
EVENT_RESULT
Results of OnMouseEvent() Any value not equal to EVENT_RESULT_UNHANDLED indicates that the event was ...
Definition: GUIControl.h:60
Definition: Variant.h:29
Definition: GUIWindowSlideShow.h:25
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
Definition: GUIDialog.h:35
Definition: LibInputPointer.h:13
Definition: GUIMessage.h:365
SortBy
Definition: SortUtils.h:49
Represents a file on a share.
Definition: FileItem.h:102
Simple class for mouse events.
Definition: Key.h:114
1 : Sort by Name (String: Label)
Definition: SortUtils.h:54