Merge pull request #26273 from 78andyp/blurayfixes2
[xbmc.git] / xbmc / addons / gui / skin / SkinTimer.h
blob9c07fe2cae74918faa871136a2af8209c29cddaa
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 "guilib/GUIAction.h"
12 #include "interfaces/info/InfoExpression.h"
13 #include "utils/Stopwatch.h"
15 #include <memory>
16 #include <string>
18 /*! \brief Skin timers are skin objects that dependent on time and can be fully controlled from skins either using boolean
19 * conditions or builtin functions. This class represents the Skin Timer object.
20 * \sa Skin_Timers
22 class CSkinTimer : public CStopWatch
24 public:
25 /*! \brief Skin timer constructor
26 * \param name - the name of the timer
27 * \param startCondition - the boolean info expression to start the timer (may be null)
28 * \param resetCondition - the boolean info expression to reset the timer (may be null)
29 * \param stopCondition - the boolean info expression to stop the timer (may be null)
30 * \param startActions - the builtin functions to execute on timer start (actions may be empty)
31 * \param stopActions - the builtin functions to execute on timer stop (actions may be empty)
32 * \param resetOnStart - if the timer should be reset when started (i.e. start from zero if true or resumed if false)
34 CSkinTimer(const std::string& name,
35 const INFO::InfoPtr& startCondition,
36 const INFO::InfoPtr& resetCondition,
37 const INFO::InfoPtr& stopCondition,
38 const CGUIAction& startActions,
39 const CGUIAction& stopActions,
40 bool resetOnStart);
42 /*! \brief Default skin timer destructor */
43 virtual ~CSkinTimer() = default;
45 /*! \brief Start the skin timer */
46 void Start();
48 /*! \brief Resets the skin timer so that the elapsed time of the timer is 0 */
49 void Reset();
51 /*! \brief stops the skin timer */
52 void Stop();
54 /*! \brief Getter for the timer name
55 * \return the timer name
57 const std::string& GetName() const;
59 /*! \brief Getter for the timer start boolean condition/expression
60 * \return the start boolean condition/expression (may be null)
62 INFO::InfoPtr GetStartCondition() const;
64 /*! \brief Getter for the timer reset boolean condition/expression
65 * \return the reset boolean condition/expression (may be null)
67 INFO::InfoPtr GetResetCondition() const;
69 /*! \brief Getter for the timer start boolean condition/expression
70 * \return the start boolean condition/expression (may be null)
72 INFO::InfoPtr GetStopCondition() const;
74 /*! \brief Checks if a given timer is configured to reset every time it starts
75 * \return true if the timer is configured to reset on start, false otherwise
77 bool ResetsOnStart() const;
79 /*! \brief Gets the start actions of this skin timer
80 * \return the actions configured to start when the timer is started
82 const CGUIAction& GetStartActions() const;
84 /*! \brief Gets the stop actions of this skin timer
85 * \return the actions configured to start when the timer is stopped
87 const CGUIAction& GetStopActions() const;
89 /*! \brief Evaluates the timer start boolean info expression returning the respective result.
90 * \details Called from the skin timer manager to check if the timer should be started
91 * \return true if the condition is true, false otherwise
93 bool VerifyStartCondition() const;
95 /*! \brief Evaluates the timer reset boolean info expression returning the respective result.
96 * \details Called from the skin timer manager to check if the timer should be reset to 0
97 * \return true if the condition is true, false otherwise
99 bool VerifyResetCondition() const;
101 /*! \brief Evaluates the timer stop boolean info expression returning the respective result.
102 * \details Called from the skin timer manager to check if the timer should be stopped
103 * \return true if the condition is true, false otherwise
105 bool VerifyStopCondition() const;
107 private:
108 /*! \brief Called when this timer is started */
109 void OnStart();
111 /*! \brief Called when this timer is stopped */
112 void OnStop();
114 /*! The name of the skin timer */
115 std::string m_name;
116 /*! The info boolean expression that automatically starts the timer if evaluated true */
117 INFO::InfoPtr m_startCondition;
118 /*! The info boolean expression that automatically resets the timer if evaluated true */
119 INFO::InfoPtr m_resetCondition;
120 /*! The info boolean expression that automatically stops the timer if evaluated true */
121 INFO::InfoPtr m_stopCondition;
122 /*! The builtin functions to be executed when the timer is started */
123 CGUIAction m_startActions;
124 /*! The builtin functions to be executed when the timer is stopped */
125 CGUIAction m_stopActions;
126 /*! if the timer should be reset on start (or just resumed) */
127 bool m_resetOnStart{false};