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/IAnnouncer.h"
14 #include "interfaces/ISlideShowDelegate.h"
15 #include "threads/Event.h"
16 #include "threads/Thread.h"
24 class CGUIWindowSlideShow
;
26 class CBackgroundPicLoader
: public CThread
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
; }
39 void Process() override
;
41 int m_iSlideNumber
= 0;
42 std::string m_strFileName
;
47 bool m_isLoading
= false;
49 CGUIWindowSlideShow
* m_pCallback
= nullptr;
52 class CGUIWindowSlideShow
: public CGUIDialog
,
53 public ISlideShowDelegate
,
54 public ANNOUNCEMENT::IAnnouncer
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,
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
,
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
,
109 const std::string
& strFileName
,
110 std::unique_ptr
<CTexture
> pTexture
,
113 static void RunSlideShow(const std::vector
<std::string
>& paths
, int start
= 0);
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
);
126 CSlideShowPic::DISPLAY_EFFECT
GetDisplayEffect(int iSlideNumber
) const;
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
);
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
);
148 float m_fInitialRotate
;
151 float m_fInitialZoom
;
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];
166 std::unique_ptr
<CBackgroundPicLoader
> m_pBackgroundLoader
;
167 int m_iLastFailedNextSlide
;
169 RESOLUTION m_Resolution
;
170 CPoint m_firstGesturePoint
;