summaryrefslogtreecommitdiffstats
path: root/xbmc/guilib/GUIDialog.h
blob: 7300c1fa1b6289cd300103abeff7e63fd79016c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

/*!
\file GUIDialog.h
\brief
*/

#include "GUIWindow.h"
#include "WindowIDs.h"

#ifdef TARGET_WINDOWS_STORE
#pragma pack(push, 8)
#endif
enum class DialogModalityType
{
  MODELESS,
  MODAL
};
#ifdef TARGET_WINDOWS_STORE
#pragma pack(pop)
#endif

/*!
 \ingroup winmsg
 \brief
 */
class CGUIDialog :
      public CGUIWindow
{
public:
  CGUIDialog(int id, const std::string &xmlFile, DialogModalityType modalityType = DialogModalityType::MODAL);
  ~CGUIDialog(void) override;

  bool OnAction(const CAction &action) override;
  bool OnMessage(CGUIMessage& message) override;
  void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
  void Render() override;

  void Open(const std::string &param = "");
  void Open(bool bProcessRenderLoop, const std::string& param = "");

  bool OnBack(int actionID) override;

  bool IsDialogRunning() const override { return m_active; }
  bool IsDialog() const override { return true; }
  bool IsModalDialog() const override { return m_modalityType == DialogModalityType::MODAL; }
  virtual DialogModalityType GetModalityType() const { return m_modalityType; }

  void SetAutoClose(unsigned int timeoutMs);
  void ResetAutoClose(void);
  void CancelAutoClose(void);
  bool IsAutoClosed(void) const { return m_bAutoClosed; }
  void SetSound(bool OnOff) { m_enableSound = OnOff; }
  bool IsSoundEnabled() const override { return m_enableSound; }

protected:
  bool Load(TiXmlElement *pRootElement) override;
  void SetDefaults() override;
  void OnWindowLoaded() override;
  using CGUIWindow::UpdateVisibility;
  virtual void UpdateVisibility();

  virtual void Open_Internal(bool bProcessRenderLoop, const std::string &param = "");
  void OnDeinitWindow(int nextWindowID) override;

  void ProcessRenderLoop(bool renderOnly = false);

  bool m_wasRunning; ///< \brief true if we were running during the last DoProcess()
  bool m_autoClosing;
  bool m_enableSound;
  unsigned int m_showStartTime;
  unsigned int m_showDuration;
  bool m_bAutoClosed;
  DialogModalityType m_modalityType;
};