summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
committermanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
commit4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch)
tree9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
parentf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff)
downloadkodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.gz
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.bz2
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h247
1 files changed, 247 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
new file mode 100644
index 0000000..e9c5a9d
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
@@ -0,0 +1,247 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress }
37 /// **Progress dialog shown for background work**
38 ///
39 /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>"
40 /// given class are basically used to create Kodi's extended progress.
41 ///
42 ///
43 /// --------------------------------------------------------------------------
44 ///
45 /// **Example:**
46 /// ~~~~~~~~~~~~~{.cpp}
47 /// #include <kodi/gui/dialogs/ExtendedProgress.h>
48 ///
49 /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress");
50 /// ext_progress->SetText("Test progress");
51 /// for (unsigned int i = 0; i < 50; i += 10)
52 /// {
53 /// ext_progress->SetProgress(i, 100);
54 /// sleep(1);
55 /// }
56 ///
57 /// ext_progress->SetTitle("Test Extended progress - Second round");
58 /// ext_progress->SetText("Test progress - Step 2");
59 ///
60 /// for (unsigned int i = 50; i < 100; i += 10)
61 /// {
62 /// ext_progress->SetProgress(i, 100);
63 /// sleep(1);
64 /// }
65 /// delete ext_progress;
66 /// ~~~~~~~~~~~~~
67 ///
68 class CExtendedProgress
69 {
70 public:
71 //==========================================================================
72 ///
73 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
74 /// Construct a new dialog
75 ///
76 /// @param[in] title Title string
77 ///
78 CExtendedProgress(const std::string& title = "")
79 {
80 using namespace ::kodi::addon;
81 m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str());
82 if (!m_DialogHandle)
83 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!");
84 }
85 //--------------------------------------------------------------------------
86
87 //==========================================================================
88 ///
89 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
90 /// Destructor
91 ///
92 ~CExtendedProgress()
93 {
94 using namespace ::kodi::addon;
95 if (m_DialogHandle)
96 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
97 }
98 //--------------------------------------------------------------------------
99
100 //==========================================================================
101 ///
102 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
103 /// @brief Get the used title
104 ///
105 /// @return Title string
106 ///
107 std::string Title() const
108 {
109 using namespace ::kodi::addon;
110 std::string text;
111 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
112 if (strMsg != nullptr)
113 {
114 if (std::strlen(strMsg))
115 text = strMsg;
116 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg);
117 }
118 return text;
119 }
120 //--------------------------------------------------------------------------
121
122 //==========================================================================
123 ///
124 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
125 /// @brief To set the title of dialog
126 ///
127 /// @param[in] title Title string
128 ///
129 void SetTitle(const std::string& title)
130 {
131 using namespace ::kodi::addon;
132 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str());
133 }
134 //--------------------------------------------------------------------------
135
136 //==========================================================================
137 ///
138 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
139 /// @brief Get the used text information string
140 ///
141 /// @return Text string
142 ///
143 std::string Text() const
144 {
145 using namespace ::kodi::addon;
146 std::string text;
147 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
148 if (strMsg != nullptr)
149 {
150 if (std::strlen(strMsg))
151 text = strMsg;
152 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg);
153 }
154 return text;
155 }
156 //--------------------------------------------------------------------------
157
158 //==========================================================================
159 ///
160 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
161 /// @brief To set the used text information string
162 ///
163 /// @param[in] text information text to set
164 ///
165 void SetText(const std::string& text)
166 {
167 using namespace ::kodi::addon;
168 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str());
169 }
170 //--------------------------------------------------------------------------
171
172 //==========================================================================
173 ///
174 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
175 /// @brief To ask dialog is finished
176 ///
177 /// @return True if on end
178 ///
179 bool IsFinished() const
180 {
181 using namespace ::kodi::addon;
182 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
183 }
184 //--------------------------------------------------------------------------
185
186 //==========================================================================
187 ///
188 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
189 /// @brief Mark progress finished
190 ///
191 void MarkFinished()
192 {
193 using namespace ::kodi::addon;
194 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
195 }
196 //--------------------------------------------------------------------------
197
198 //==========================================================================
199 ///
200 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
201 /// @brief Get the current progress position as percent
202 ///
203 /// @return Position
204 ///
205 float Percentage() const
206 {
207 using namespace ::kodi::addon;
208 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
209 }
210 //--------------------------------------------------------------------------
211
212 //==========================================================================
213 ///
214 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
215 /// @brief To set the current progress position as percent
216 ///
217 /// @param[in] percentage Position to use from 0.0 to 100.0
218 ///
219 void SetPercentage(float percentage)
220 {
221 using namespace ::kodi::addon;
222 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
223 }
224 //--------------------------------------------------------------------------
225
226 //==========================================================================
227 ///
228 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
229 /// @brief To set progress position with predefined places
230 ///
231 /// @param[in] currentItem Place position to use
232 /// @param[in] itemCount Amount of used places
233 ///
234 void SetProgress(int currentItem, int itemCount)
235 {
236 using namespace ::kodi::addon;
237 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount);
238 }
239 //--------------------------------------------------------------------------
240
241 private:
242 void* m_DialogHandle;
243 };
244
245} /* namespace dialogs */
246} /* namespace gui */
247} /* namespace kodi */