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 "threads/Event.h"
14 #include "threads/Thread.h"
15 #include "utils/SortUtils.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
;
41 std::string m_strFileName
;
48 CGUIWindowSlideShow
*m_pCallback
;
51 class CGUIWindowSlideShow
: public CGUIDialog
54 CGUIWindowSlideShow(void);
55 ~CGUIWindowSlideShow() override
= default;
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
®ions
) override
;
63 void OnDeinitWindow(int nextWindowID
) override
;
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
,
87 const std::string
& strFileName
,
88 std::unique_ptr
<CTexture
> pTexture
,
90 int NumSlides() const;
91 int CurrentSlide() const;
93 bool IsPaused() const { return m_bPause
; }
94 bool IsShuffled() const { return m_bShuffled
; }
95 int GetDirection() const { return m_iDirection
; }
97 static void RunSlideShow(const std::vector
<std::string
>& paths
, int start
= 0);
102 void SetDirection(int direction
); // -1: rewind, 1: forward
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
);
110 CSlideShowPic::DISPLAY_EFFECT
GetDisplayEffect(int iSlideNumber
) const;
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
);
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
);
132 float m_fInitialRotate
;
135 float m_fInitialZoom
;
140 bool m_bPlayingVideo
;
141 int m_iVideoSlide
= -1;
142 bool m_bErrorMessage
;
144 std::vector
<CFileItemPtr
> m_slides
;
146 CSlideShowPic m_Image
[2];
150 std::unique_ptr
<CBackgroundPicLoader
> m_pBackgroundLoader
;
151 int m_iLastFailedNextSlide
;
153 RESOLUTION m_Resolution
;
154 CPoint m_firstGesturePoint
;