xbmc
GUIDialogExtendedProgressBar.h
1 /*
2  * Copyright (C) 2012-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "guilib/GUIDialog.h"
12 
13 #include <string>
14 #include <vector>
15 
17 {
18 public:
19  explicit CGUIDialogProgressBarHandle(const std::string& strTitle) : m_strTitle(strTitle) {}
20  virtual ~CGUIDialogProgressBarHandle(void) = default;
21 
22  const std::string &Title(void) { return m_strTitle; }
23  void SetTitle(const std::string &strTitle);
24 
25  std::string Text(void) const;
26  void SetText(const std::string &strText);
27 
28  bool IsFinished(void) const { return m_bFinished; }
29  void MarkFinished(void) { m_bFinished = true; }
30 
31  float Percentage(void) const { return m_fPercentage;}
32  void SetPercentage(float fPercentage) { m_fPercentage = fPercentage; }
33  void SetProgress(int currentItem, int itemCount);
34 
35 private:
36  mutable CCriticalSection m_critSection;
37  float m_fPercentage = 0;
38  std::string m_strTitle;
39  std::string m_strText;
40  bool m_bFinished = false;
41 };
42 
44 {
45 public:
47  ~CGUIDialogExtendedProgressBar(void) override = default;
48  bool OnMessage(CGUIMessage& message) override;
49  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
50 
51  CGUIDialogProgressBarHandle *GetHandle(const std::string &strTitle);
52 
53 protected:
54  void UpdateState(unsigned int currentTime);
55 
56  CCriticalSection m_critSection;
57  unsigned int m_iCurrentItem;
58  unsigned int m_iLastSwitchTime;
59  std::vector<CGUIDialogProgressBarHandle *> m_handles;
60 };
Definition: GUIDialogExtendedProgressBar.h:43
Definition: GUIDialog.h:35
Definition: GUIMessage.h:365
Definition: GUIDialogExtendedProgressBar.h:16