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.
11 #include "SlideShowPicture.h"
12 #include "guilib/GUIDialog.h"
13 #include "interfaces/ISlideShowDelegate.h"
14 #include "threads/Event.h"
15 #include "threads/Thread.h"
23 class CGUIWindowSlideShow
;
25 class CBackgroundPicLoader
: public CThread
28 CBackgroundPicLoader();
29 ~CBackgroundPicLoader() override
;
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
; }
38 void Process() override
;
40 int m_iSlideNumber
= 0;
41 std::string m_strFileName
;
46 bool m_isLoading
= false;
48 CGUIWindowSlideShow
* m_pCallback
= nullptr;
51 class CGUIWindowSlideShow
: public CGUIDialog
, public ISlideShowDelegate
54 CGUIWindowSlideShow(void);
55 ~CGUIWindowSlideShow() override
;
57 // Implementation of ISlideShowDelegate
58 void Add(const CFileItem
* picture
) override
;
59 bool IsPlaying() const override
;
60 void Select(const std::string
& picture
) override
;
61 void GetSlideShowContents(CFileItemList
& list
) override
;
62 std::shared_ptr
<const CFileItem
> GetCurrentSlide() override
;
63 void StartSlideShow() override
;
64 void PlayPicture() override
;
65 bool InSlideShow() const override
;
66 int NumSlides() const override
;
67 int CurrentSlide() const override
;
68 bool IsPaused() const override
{ return m_bPause
; }
69 bool IsShuffled() const override
{ return m_bShuffled
; }
70 void Reset() override
;
71 void RunSlideShow(const std::string
& strPath
,
72 bool bRecursive
= false,
74 bool bNotRandom
= false,
75 const std::string
& beginSlidePath
= "",
76 bool startSlideShow
= true,
77 SortBy method
= SortByLabel
,
78 SortOrder order
= SortOrderAscending
,
79 SortAttribute sortAttributes
= SortAttributeNone
,
80 const std::string
& strExtensions
= "") override
;
81 void AddFromPath(const std::string
& strPath
,
83 SortBy method
= SortByLabel
,
84 SortOrder order
= SortOrderAscending
,
85 SortAttribute sortAttributes
= SortAttributeNone
,
86 const std::string
& strExtensions
= "") override
;
87 void Shuffle() override
;
88 int GetDirection() const override
{ return m_iDirection
; }
90 bool OnMessage(CGUIMessage
& message
) override
;
91 EVENT_RESULT
OnMouseEvent(const CPoint
& point
, const KODI::MOUSE::CMouseEvent
& event
) override
;
92 bool OnAction(const CAction
& action
) override
;
93 void Render() override
;
94 void RenderEx() override
;
95 void Process(unsigned int currentTime
, CDirtyRegionList
& regions
) override
;
96 void OnDeinitWindow(int nextWindowID
) override
;
98 void OnLoadPic(int iPic
,
100 const std::string
& strFileName
,
101 std::unique_ptr
<CTexture
> pTexture
,
104 static void RunSlideShow(const std::vector
<std::string
>& paths
, int start
= 0);
109 void SetDirection(int direction
); // -1: rewind, 1: forward
111 typedef std::set
<std::string
> path_set
; // set to track which paths we're adding
112 void AddItems(const std::string
&strPath
, path_set
*recursivePaths
,
113 SortBy method
= SortByLabel
,
114 SortOrder order
= SortOrderAscending
,
115 SortAttribute sortAttributes
= SortAttributeNone
);
117 CSlideShowPic::DISPLAY_EFFECT
GetDisplayEffect(int iSlideNumber
) const;
119 void RenderErrorMessage();
120 void Rotate(float fAngle
, bool immediate
= false);
121 void Zoom(int iZoom
);
122 void ZoomRelative(float fZoom
, bool immediate
= false);
123 void Move(float fX
, float fY
);
124 void GetCheckedSize(float width
, float height
, int &maxWidth
, int &maxHeight
);
125 std::string
GetPicturePath(CFileItem
*item
);
128 void AnnouncePlayerPlay(const CFileItemPtr
& item
);
129 void AnnouncePlayerPause(const CFileItemPtr
& item
);
130 void AnnouncePlayerStop(const CFileItemPtr
& item
);
131 void AnnouncePlaylistClear();
132 void AnnouncePlaylistAdd(const CFileItemPtr
& item
, int pos
);
133 void AnnouncePropertyChanged(const std::string
&strProperty
, const CVariant
&value
);
139 float m_fInitialRotate
;
142 float m_fInitialZoom
;
147 bool m_bPlayingVideo
;
148 int m_iVideoSlide
= -1;
149 bool m_bErrorMessage
;
151 std::vector
<CFileItemPtr
> m_slides
;
153 std::unique_ptr
<CSlideShowPic
> m_Image
[2];
157 std::unique_ptr
<CBackgroundPicLoader
> m_pBackgroundLoader
;
158 int m_iLastFailedNextSlide
;
160 RESOLUTION m_Resolution
;
161 CPoint m_firstGesturePoint
;