[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / guilib / VisibleEffect.h
bloba5b19e294a97d2baee7c72110e8480798347264d
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 enum ANIMATION_PROCESS { ANIM_PROCESS_NONE = 0, ANIM_PROCESS_NORMAL, ANIM_PROCESS_REVERSE };
12 enum ANIMATION_STATE { ANIM_STATE_NONE = 0, ANIM_STATE_DELAYED, ANIM_STATE_IN_PROCESS, ANIM_STATE_APPLIED };
14 // forward definitions
16 class TiXmlElement;
17 class Tweener;
18 class CGUIListItem;
20 #include "interfaces/info/InfoBool.h"
21 #include "utils/ColorUtils.h"
22 #include "utils/Geometry.h" // for CPoint, CRect
23 #include "utils/TransformMatrix.h" // needed for the TransformMatrix member
25 #include <memory>
26 #include <string>
27 #include <vector>
29 enum ANIMATION_TYPE
31 ANIM_TYPE_UNFOCUS = -3,
32 ANIM_TYPE_HIDDEN,
33 ANIM_TYPE_WINDOW_CLOSE,
34 ANIM_TYPE_NONE,
35 ANIM_TYPE_WINDOW_OPEN,
36 ANIM_TYPE_VISIBLE,
37 ANIM_TYPE_FOCUS,
38 ANIM_TYPE_CONDITIONAL // for animations triggered by a condition change
41 class CAnimEffect
43 public:
44 enum EFFECT_TYPE
46 EFFECT_TYPE_NONE = 0,
47 EFFECT_TYPE_FADE,
48 EFFECT_TYPE_FADE_DIFFUSE,
49 EFFECT_TYPE_SLIDE,
50 EFFECT_TYPE_ROTATE_X,
51 EFFECT_TYPE_ROTATE_Y,
52 EFFECT_TYPE_ROTATE_Z,
53 EFFECT_TYPE_ZOOM
56 CAnimEffect(const TiXmlElement *node, EFFECT_TYPE effect);
57 CAnimEffect(unsigned int delay, unsigned int length, EFFECT_TYPE effect);
58 CAnimEffect(const CAnimEffect &src);
60 virtual ~CAnimEffect();
61 CAnimEffect& operator=(const CAnimEffect &src);
63 void Calculate(unsigned int time, const CPoint &center);
64 void ApplyState(ANIMATION_STATE state, const CPoint &center);
66 unsigned int GetDelay() const { return m_delay; }
67 unsigned int GetLength() const { return m_delay + m_length; }
68 const TransformMatrix& GetTransform() const { return m_matrix; }
69 EFFECT_TYPE GetType() const { return m_effect; }
71 static std::shared_ptr<Tweener> GetTweener(const TiXmlElement *pAnimationNode);
72 protected:
73 TransformMatrix m_matrix;
74 EFFECT_TYPE m_effect;
76 private:
77 virtual void ApplyEffect(float offset, const CPoint &center)=0;
79 // timing variables
80 unsigned int m_length;
81 unsigned int m_delay;
83 std::shared_ptr<Tweener> m_pTweener;
86 class CFadeEffect : public CAnimEffect
88 public:
89 CFadeEffect(const TiXmlElement* node, bool reverseDefaults, EFFECT_TYPE effect);
90 CFadeEffect(float start, float end, unsigned int delay, unsigned int length);
91 CFadeEffect(KODI::UTILS::COLOR::Color start,
92 KODI::UTILS::COLOR::Color end,
93 unsigned int delay,
94 unsigned int length);
95 ~CFadeEffect() override = default;
96 private:
97 void ApplyEffect(float offset, const CPoint &center) override;
99 float m_startAlpha;
100 float m_endAlpha;
101 KODI::UTILS::COLOR::ColorFloats m_startColor;
102 KODI::UTILS::COLOR::ColorFloats m_endColor;
105 class CSlideEffect : public CAnimEffect
107 public:
108 explicit CSlideEffect(const TiXmlElement *node);
109 ~CSlideEffect() override = default;
110 private:
111 void ApplyEffect(float offset, const CPoint &center) override;
113 float m_startX;
114 float m_startY;
115 float m_endX;
116 float m_endY;
119 class CRotateEffect : public CAnimEffect
121 public:
122 CRotateEffect(const TiXmlElement *node, EFFECT_TYPE effect);
123 ~CRotateEffect() override = default;
124 private:
125 void ApplyEffect(float offset, const CPoint &center) override;
127 float m_startAngle;
128 float m_endAngle;
130 bool m_autoCenter;
131 CPoint m_center;
134 class CZoomEffect : public CAnimEffect
136 public:
137 CZoomEffect(const TiXmlElement *node, const CRect &rect);
138 ~CZoomEffect() override = default;
139 private:
140 void ApplyEffect(float offset, const CPoint &center) override;
142 float m_startX;
143 float m_startY;
144 float m_endX;
145 float m_endY;
147 bool m_autoCenter;
148 CPoint m_center;
151 class CAnimation
153 public:
154 CAnimation();
155 CAnimation(const CAnimation &src);
157 virtual ~CAnimation();
159 CAnimation& operator=(const CAnimation &src);
161 static CAnimation CreateFader(float start, float end, unsigned int delay, unsigned int length, ANIMATION_TYPE type = ANIM_TYPE_NONE);
163 void Create(const TiXmlElement *node, const CRect &rect, int context);
165 void Animate(unsigned int time, bool startAnim);
166 void ResetAnimation();
167 void ApplyAnimation();
168 inline void RenderAnimation(TransformMatrix &matrix)
170 RenderAnimation(matrix, CPoint());
172 void RenderAnimation(TransformMatrix &matrix, const CPoint &center);
173 void QueueAnimation(ANIMATION_PROCESS process);
175 inline bool IsReversible() const { return m_reversible; }
176 inline ANIMATION_TYPE GetType() const { return m_type; }
177 inline ANIMATION_STATE GetState() const { return m_currentState; }
178 inline ANIMATION_PROCESS GetProcess() const { return m_currentProcess; }
179 inline ANIMATION_PROCESS GetQueuedProcess() const { return m_queuedProcess; }
181 bool CheckCondition();
182 void UpdateCondition(const CGUIListItem *item = NULL);
183 void SetInitialCondition();
185 private:
186 void Calculate(const CPoint &point);
187 void AddEffect(const std::string &type, const TiXmlElement *node, const CRect &rect);
189 enum ANIM_REPEAT { ANIM_REPEAT_NONE = 0, ANIM_REPEAT_PULSE, ANIM_REPEAT_LOOP };
191 // type of animation
192 ANIMATION_TYPE m_type;
193 bool m_reversible;
194 INFO::InfoPtr m_condition;
196 // conditional anims can repeat
197 ANIM_REPEAT m_repeatAnim;
198 bool m_lastCondition;
200 // state of animation
201 ANIMATION_PROCESS m_queuedProcess;
202 ANIMATION_PROCESS m_currentProcess;
203 ANIMATION_STATE m_currentState;
205 // timing of animation
206 unsigned int m_start;
207 unsigned int m_length;
208 unsigned int m_delay;
209 unsigned int m_amount;
211 std::vector<CAnimEffect *> m_effects;
215 * Class used to handle scrolling, allow using tweeners.
216 * Usage:
217 * start scrolling using ScrollTo() method / stop scrolling using Stop() method
218 * update scroll value each frame with current time using Update() method
219 * get/set scroll value using GetValue()/SetValue()
221 class CScroller
223 public:
224 CScroller(unsigned int duration = 200, std::shared_ptr<Tweener> tweener = std::shared_ptr<Tweener>());
225 CScroller(const CScroller& right);
226 CScroller& operator=(const CScroller &src);
227 ~CScroller();
230 * Set target value scroller will be scrolling to
231 * @param endPos target
233 void ScrollTo(float endPos);
236 * Immediately stop scrolling
238 void Stop() { m_delta = 0; }
240 * Update the scroller to where it would be at the given time point, calculating a new Value.
241 * @param time time point
242 * @return True if we are scrolling at given time point
244 bool Update(unsigned int time);
247 * Value of scroll
249 float GetValue() const { return m_scrollValue; }
250 void SetValue(float scrollValue) { m_scrollValue = scrollValue; }
252 bool IsScrolling() const { return m_delta != 0; }
253 bool IsScrollingUp() const { return m_delta < 0; }
254 bool IsScrollingDown() const { return m_delta > 0; }
256 unsigned int GetDuration() const { return m_duration; }
258 private:
259 float Tween(float progress);
261 float m_scrollValue;
262 float m_delta; //!< Brief distance that we have to travel during scroll
263 float m_startPosition; //!< Brief starting position of scroll
264 bool m_hasResumePoint; //!< Brief check if we should tween from middle of the tween
265 unsigned int m_startTime; //!< Brief starting time of scroll
267 unsigned int m_duration; //!< Brief duration of scroll
268 std::shared_ptr<Tweener> m_pTweener;