Merge pull request #4775 from jmarshallnz/empty_episode_playcount
[vuplus_xbmc] / xbmc / dialogs / GUIDialogBusy.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "guilib/GUIDialog.h"
24
25 class IRunnable;
26 class CEvent;
27
28 class CGUIDialogBusy: public CGUIDialog
29 {
30 public:
31   CGUIDialogBusy(void);
32   virtual ~CGUIDialogBusy(void);
33   virtual bool OnBack(int actionID);
34   virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
35   virtual void Render();
36   /*! \brief set the current progress of the busy operation
37    \param progress a percentage of progress
38    */
39   void SetProgress(float progress);
40
41   bool IsCanceled() { return m_bCanceled; }
42
43   /*! \brief Wait for a runnable to execute off-thread.
44    Creates a thread to run the given runnable, and while waiting
45    it displays the busy dialog.
46    \param runnable the IRunnable to run.
47    \return true if the runnable completes, false if the user cancels early.
48    */
49   static bool Wait(IRunnable *runnable);
50
51   /*! \brief Wait on an event while displaying the busy dialog.
52    Throws up the busy dialog after the given time.
53    \param even the CEvent to wait on.
54    \param displaytime the time in ms to wait prior to showing the busy dialog (defaults to 100ms)
55    \param allowCancel whether the user can cancel the wait, defaults to true.
56    \return true if the event completed, false if cancelled.
57    */
58   static bool WaitOnEvent(CEvent &event, unsigned int timeout = 100, bool allowCancel = true);
59 protected:
60   virtual void Show_Internal(); // modeless'ish
61   bool m_bCanceled;
62   bool m_bLastVisible;
63   float m_progress; ///< current progress
64 };