Merge pull request #26166 from ksooo/improve-plugin-ctx-menus
[xbmc.git] / xbmc / pictures / GUIWindowSlideShow.h
blob5c6e82268a1371129f71b8654ae818feec01d86e
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "SlideShowPicture.h"
12 #include "guilib/GUIDialog.h"
13 #include "interfaces/IAnnouncer.h"
14 #include "interfaces/ISlideShowDelegate.h"
15 #include "threads/Event.h"
16 #include "threads/Thread.h"
18 #include <memory>
19 #include <set>
21 class CFileItemList;
22 class CVariant;
24 class CGUIWindowSlideShow;
26 class CBackgroundPicLoader : public CThread
28 public:
29 CBackgroundPicLoader();
30 ~CBackgroundPicLoader() override;
32 void Create(CGUIWindowSlideShow *pCallback);
33 void LoadPic(int iPic, int iSlideNumber, const std::string &strFileName, const int maxWidth, const int maxHeight);
34 bool IsLoading() { return m_isLoading; }
35 int SlideNumber() const { return m_iSlideNumber; }
36 int Pic() const { return m_iPic; }
38 private:
39 void Process() override;
40 int m_iPic = 0;
41 int m_iSlideNumber = 0;
42 std::string m_strFileName;
43 int m_maxWidth = 0;
44 int m_maxHeight = 0;
46 CEvent m_loadPic;
47 bool m_isLoading = false;
49 CGUIWindowSlideShow* m_pCallback = nullptr;
52 class CGUIWindowSlideShow : public CGUIDialog,
53 public ISlideShowDelegate,
54 public ANNOUNCEMENT::IAnnouncer
56 public:
57 CGUIWindowSlideShow(void);
58 ~CGUIWindowSlideShow() override;
60 // Implementation of ISlideShowDelegate
61 void Add(const CFileItem* picture) override;
62 bool IsPlaying() const override;
63 void Select(const std::string& picture) override;
64 void GetSlideShowContents(CFileItemList& list) override;
65 std::shared_ptr<const CFileItem> GetCurrentSlide() override;
66 void StartSlideShow() override;
67 void PlayPicture() override;
68 bool InSlideShow() const override;
69 int NumSlides() const override;
70 int CurrentSlide() const override;
71 bool IsPaused() const override { return m_bPause; }
72 bool IsShuffled() const override { return m_bShuffled; }
73 void Reset() override;
74 void RunSlideShow(const std::string& strPath,
75 bool bRecursive = false,
76 bool bRandom = false,
77 bool bNotRandom = false,
78 const std::string& beginSlidePath = "",
79 bool startSlideShow = true,
80 SortBy method = SortByLabel,
81 SortOrder order = SortOrderAscending,
82 SortAttribute sortAttributes = SortAttributeNone,
83 const std::string& strExtensions = "") override;
84 void AddFromPath(const std::string& strPath,
85 bool bRecursive,
86 SortBy method = SortByLabel,
87 SortOrder order = SortOrderAscending,
88 SortAttribute sortAttributes = SortAttributeNone,
89 const std::string& strExtensions = "") override;
90 void Shuffle() override;
91 int GetDirection() const override { return m_iDirection; }
93 // implementation of IAnnouncer
94 void Announce(ANNOUNCEMENT::AnnouncementFlag flag,
95 const std::string& sender,
96 const std::string& message,
97 const CVariant& data) override;
99 bool OnMessage(CGUIMessage& message) override;
100 EVENT_RESULT OnMouseEvent(const CPoint& point, const KODI::MOUSE::CMouseEvent& event) override;
101 bool OnAction(const CAction& action) override;
102 void Render() override;
103 void RenderEx() override;
104 void Process(unsigned int currentTime, CDirtyRegionList& regions) override;
105 void OnDeinitWindow(int nextWindowID) override;
107 void OnLoadPic(int iPic,
108 int iSlideNumber,
109 const std::string& strFileName,
110 std::unique_ptr<CTexture> pTexture,
111 bool bFullSize);
113 static void RunSlideShow(const std::vector<std::string>& paths, int start = 0);
115 private:
116 void ShowNext();
117 void ShowPrevious();
118 void SetDirection(int direction); // -1: rewind, 1: forward
120 typedef std::set<std::string> path_set; // set to track which paths we're adding
121 void AddItems(const std::string &strPath, path_set *recursivePaths,
122 SortBy method = SortByLabel,
123 SortOrder order = SortOrderAscending,
124 SortAttribute sortAttributes = SortAttributeNone);
125 bool PlayVideo();
126 CSlideShowPic::DISPLAY_EFFECT GetDisplayEffect(int iSlideNumber) const;
127 void RenderPause();
128 void RenderErrorMessage();
129 void Rotate(float fAngle, bool immediate = false);
130 void Zoom(int iZoom);
131 void ZoomRelative(float fZoom, bool immediate = false);
132 void Move(float fX, float fY);
133 void GetCheckedSize(float width, float height, int &maxWidth, int &maxHeight);
134 std::string GetPicturePath(CFileItem *item);
135 int GetNextSlide();
137 void AnnouncePlayerPlay(const CFileItemPtr& item);
138 void AnnouncePlayerPause(const CFileItemPtr& item);
139 void AnnouncePlayerStop(const CFileItemPtr& item);
140 void AnnouncePlaylistClear();
141 void AnnouncePlaylistAdd(const CFileItemPtr& item, int pos);
142 void AnnouncePropertyChanged(const std::string &strProperty, const CVariant &value);
144 int m_iCurrentSlide;
145 int m_iNextSlide;
146 int m_iDirection;
147 float m_fRotate;
148 float m_fInitialRotate;
149 int m_iZoomFactor;
150 float m_fZoom;
151 float m_fInitialZoom;
153 bool m_bShuffled;
154 bool m_bSlideShow;
155 bool m_bPause;
156 bool m_bPlayingVideo;
157 int m_iVideoSlide = -1;
158 bool m_bErrorMessage;
160 std::vector<CFileItemPtr> m_slides;
162 std::unique_ptr<CSlideShowPic> m_Image[2];
164 int m_iCurrentPic;
165 // background loader
166 std::unique_ptr<CBackgroundPicLoader> m_pBackgroundLoader;
167 int m_iLastFailedNextSlide;
168 bool m_bLoadNextPic;
169 RESOLUTION m_Resolution;
170 CPoint m_firstGesturePoint;