diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui')
34 files changed, 0 insertions, 8049 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt deleted file mode 100644 index 834ec00..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | set(HEADERS General.h | ||
| 2 | ListItem.h | ||
| 3 | Window.h | ||
| 4 | definitions.h | ||
| 5 | renderHelper.h) | ||
| 6 | |||
| 7 | if(NOT ENABLE_STATIC_LIBS) | ||
| 8 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui) | ||
| 9 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h deleted file mode 100644 index b5a6393..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h +++ /dev/null | |||
| @@ -1,175 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../AddonBase.h" | ||
| 12 | #include "definitions.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | |||
| 19 | //============================================================================ | ||
| 20 | /// | ||
| 21 | // \defgroup cpp_kodi_gui ::general | ||
| 22 | /// \addtogroup cpp_kodi_gui | ||
| 23 | /// @{ | ||
| 24 | /// @brief **Allow use of binary classes and function to use on add-on's** | ||
| 25 | /// | ||
| 26 | /// Permits the use of the required functions of the add-on to Kodi. This class | ||
| 27 | /// also contains some functions to the control. | ||
| 28 | /// | ||
| 29 | /// These are pure functions them no other initialization need. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included | ||
| 32 | /// to enjoy it. | ||
| 33 | /// | ||
| 34 | |||
| 35 | //========================================================================== | ||
| 36 | /// | ||
| 37 | /// \ingroup cpp_kodi_gui | ||
| 38 | /// @brief Performs a graphical lock of rendering engine | ||
| 39 | /// | ||
| 40 | inline void ATTRIBUTE_HIDDEN Lock() | ||
| 41 | { | ||
| 42 | using namespace ::kodi::addon; | ||
| 43 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | ||
| 44 | } | ||
| 45 | |||
| 46 | //-------------------------------------------------------------------------- | ||
| 47 | |||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui | ||
| 51 | /// @brief Performs a graphical unlock of previous locked rendering engine | ||
| 52 | /// | ||
| 53 | inline void ATTRIBUTE_HIDDEN Unlock() | ||
| 54 | { | ||
| 55 | using namespace ::kodi::addon; | ||
| 56 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui | ||
| 63 | /// @brief Return the the current screen height with pixel | ||
| 64 | /// | ||
| 65 | inline int ATTRIBUTE_HIDDEN GetScreenHeight() | ||
| 66 | { | ||
| 67 | using namespace ::kodi::addon; | ||
| 68 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 69 | } | ||
| 70 | //-------------------------------------------------------------------------- | ||
| 71 | |||
| 72 | //========================================================================== | ||
| 73 | /// | ||
| 74 | /// \ingroup cpp_kodi_gui | ||
| 75 | /// @brief Return the the current screen width with pixel | ||
| 76 | /// | ||
| 77 | inline int ATTRIBUTE_HIDDEN GetScreenWidth() | ||
| 78 | { | ||
| 79 | using namespace ::kodi::addon; | ||
| 80 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 81 | } | ||
| 82 | //-------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //========================================================================== | ||
| 85 | /// | ||
| 86 | /// \ingroup cpp_kodi_gui | ||
| 87 | /// @brief Return the the current screen rendering resolution | ||
| 88 | /// | ||
| 89 | inline int ATTRIBUTE_HIDDEN GetVideoResolution() | ||
| 90 | { | ||
| 91 | using namespace ::kodi::addon; | ||
| 92 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | |||
| 96 | //========================================================================== | ||
| 97 | /// | ||
| 98 | /// \ingroup cpp_kodi_gui | ||
| 99 | /// @brief Returns the id for the current 'active' dialog as an integer. | ||
| 100 | /// | ||
| 101 | /// @return The currently active dialog Id | ||
| 102 | /// | ||
| 103 | /// | ||
| 104 | ///------------------------------------------------------------------------- | ||
| 105 | /// | ||
| 106 | /// **Example:** | ||
| 107 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 108 | /// .. | ||
| 109 | /// int wid = kodi::gui::GetCurrentWindowDialogId(); | ||
| 110 | /// .. | ||
| 111 | /// ~~~~~~~~~~~~~ | ||
| 112 | /// | ||
| 113 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId() | ||
| 114 | { | ||
| 115 | using namespace ::kodi::addon; | ||
| 116 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui | ||
| 123 | /// @brief Returns the id for the current 'active' window as an integer. | ||
| 124 | /// | ||
| 125 | /// @return The currently active window Id | ||
| 126 | /// | ||
| 127 | /// | ||
| 128 | ///------------------------------------------------------------------------- | ||
| 129 | /// | ||
| 130 | /// **Example:** | ||
| 131 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 132 | /// .. | ||
| 133 | /// int wid = kodi::gui::GetCurrentWindowId(); | ||
| 134 | /// .. | ||
| 135 | /// ~~~~~~~~~~~~~ | ||
| 136 | /// | ||
| 137 | inline int ATTRIBUTE_HIDDEN GetCurrentWindowId() | ||
| 138 | { | ||
| 139 | using namespace ::kodi::addon; | ||
| 140 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 141 | } | ||
| 142 | //-------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //========================================================================== | ||
| 145 | /// | ||
| 146 | /// \ingroup cpp_kodi_gui | ||
| 147 | /// \brief To get hardware specific device context interface | ||
| 148 | /// | ||
| 149 | /// \return The currently active device context | ||
| 150 | /// | ||
| 151 | /// \warning This function is only be supported under Windows, on all other | ||
| 152 | /// OS it return `nullptr`! | ||
| 153 | /// | ||
| 154 | /// \note Returned Windows class pointer is `ID3D11DeviceContext1`. | ||
| 155 | /// | ||
| 156 | /// | ||
| 157 | ///------------------------------------------------------------------------- | ||
| 158 | /// | ||
| 159 | /// **Example:** | ||
| 160 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 161 | /// #include <d3d11_1.h> | ||
| 162 | /// .. | ||
| 163 | /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::gui::GetHWContext()); | ||
| 164 | /// .. | ||
| 165 | /// ~~~~~~~~~~~~~ | ||
| 166 | /// | ||
| 167 | inline void* GetHWContext() | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_hw_context(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | } /* namespace gui */ | ||
| 175 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h deleted file mode 100644 index 1af4863..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h +++ /dev/null | |||
| @@ -1,366 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../AddonBase.h" | ||
| 12 | #include "definitions.h" | ||
| 13 | |||
| 14 | #include <memory> | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | |||
| 21 | class CWindow; | ||
| 22 | |||
| 23 | class ATTRIBUTE_HIDDEN CAddonGUIControlBase | ||
| 24 | { | ||
| 25 | public: | ||
| 26 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 27 | |||
| 28 | protected: | ||
| 29 | explicit CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 30 | : m_controlHandle(nullptr), | ||
| 31 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 32 | m_Window(window) {} | ||
| 33 | |||
| 34 | virtual ~CAddonGUIControlBase() = default; | ||
| 35 | |||
| 36 | friend class CWindow; | ||
| 37 | |||
| 38 | GUIHANDLE m_controlHandle; | ||
| 39 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 40 | CAddonGUIControlBase* m_Window; | ||
| 41 | |||
| 42 | private: | ||
| 43 | CAddonGUIControlBase() = delete; | ||
| 44 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 45 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 46 | }; | ||
| 47 | |||
| 48 | class CListItem; | ||
| 49 | typedef std::shared_ptr<CListItem> ListItemPtr; | ||
| 50 | |||
| 51 | //============================================================================ | ||
| 52 | /// | ||
| 53 | /// \defgroup cpp_kodi_gui_CListItem List Item | ||
| 54 | /// \ingroup cpp_kodi_gui | ||
| 55 | /// @brief \cpp_class{ kodi::gui::CListItem } | ||
| 56 | /// **Selectable window list item** | ||
| 57 | /// | ||
| 58 | /// The list item control is used for creating item lists in Kodi | ||
| 59 | /// | ||
| 60 | /// The with \ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 61 | /// class is used to create a item entry for a list on window and to support it's | ||
| 62 | /// control. | ||
| 63 | /// | ||
| 64 | |||
| 65 | //============================================================================ | ||
| 66 | /// | ||
| 67 | /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators | ||
| 68 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 69 | /// @brief **Library definition values** | ||
| 70 | /// | ||
| 71 | |||
| 72 | class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase | ||
| 73 | { | ||
| 74 | public: | ||
| 75 | //========================================================================== | ||
| 76 | /// | ||
| 77 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 78 | /// @brief Class constructor with parameters | ||
| 79 | /// | ||
| 80 | /// @param[in] label Item label | ||
| 81 | /// @param[in] label2 Second Item label (if needed) | ||
| 82 | /// @param[in] iconImage Item icon image (if needed) | ||
| 83 | /// @param[in] path Path to where item is defined | ||
| 84 | /// | ||
| 85 | CListItem( | ||
| 86 | const std::string& label = "", | ||
| 87 | const std::string& label2 = "", | ||
| 88 | const std::string& iconImage = "", | ||
| 89 | const std::string& path = "") | ||
| 90 | : CAddonGUIControlBase(nullptr) | ||
| 91 | { | ||
| 92 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 93 | label2.c_str(), iconImage.c_str(), | ||
| 94 | path.c_str()); | ||
| 95 | } | ||
| 96 | |||
| 97 | /* | ||
| 98 | * Constructor used for parts given by list items from addon window | ||
| 99 | * | ||
| 100 | * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 101 | * Not needed for addon development itself | ||
| 102 | */ | ||
| 103 | explicit CListItem(GUIHANDLE listItemHandle) | ||
| 104 | : CAddonGUIControlBase(nullptr) | ||
| 105 | { | ||
| 106 | m_controlHandle = listItemHandle; | ||
| 107 | } | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 112 | /// @brief Class destructor | ||
| 113 | /// | ||
| 114 | ~CListItem() override | ||
| 115 | { | ||
| 116 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 123 | /// @brief Returns the listitem label. | ||
| 124 | /// | ||
| 125 | /// @return Label of item | ||
| 126 | /// | ||
| 127 | std::string GetLabel() | ||
| 128 | { | ||
| 129 | std::string label; | ||
| 130 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 131 | if (ret != nullptr) | ||
| 132 | { | ||
| 133 | if (std::strlen(ret)) | ||
| 134 | label = ret; | ||
| 135 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 136 | } | ||
| 137 | return label; | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 144 | /// @brief Sets the listitem label. | ||
| 145 | /// | ||
| 146 | /// @param[in] label string or unicode - text string. | ||
| 147 | /// | ||
| 148 | void SetLabel(const std::string& label) | ||
| 149 | { | ||
| 150 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 151 | } | ||
| 152 | //-------------------------------------------------------------------------- | ||
| 153 | |||
| 154 | //========================================================================== | ||
| 155 | /// | ||
| 156 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 157 | /// @brief Returns the second listitem label. | ||
| 158 | /// | ||
| 159 | /// @return Second label of item | ||
| 160 | /// | ||
| 161 | std::string GetLabel2() | ||
| 162 | { | ||
| 163 | std::string label; | ||
| 164 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 165 | if (ret != nullptr) | ||
| 166 | { | ||
| 167 | if (std::strlen(ret)) | ||
| 168 | label = ret; | ||
| 169 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 170 | } | ||
| 171 | return label; | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //========================================================================== | ||
| 176 | /// | ||
| 177 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 178 | /// @brief Sets the listitem's label2. | ||
| 179 | /// | ||
| 180 | /// @param[in] label string or unicode - text string. | ||
| 181 | /// | ||
| 182 | void SetLabel2(const std::string& label) | ||
| 183 | { | ||
| 184 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 191 | /// @brief Sets the listitem's art | ||
| 192 | /// | ||
| 193 | /// @param[in] type Type of Art to set | ||
| 194 | /// - Some default art values (any string possible): | ||
| 195 | /// | value (type) | Type | | ||
| 196 | /// |:-------------:|:--------------------------------------------------| | ||
| 197 | /// | thumb | string - image filename | ||
| 198 | /// | poster | string - image filename | ||
| 199 | /// | banner | string - image filename | ||
| 200 | /// | fanart | string - image filename | ||
| 201 | /// | clearart | string - image filename | ||
| 202 | /// | clearlogo | string - image filename | ||
| 203 | /// | landscape | string - image filename | ||
| 204 | /// | icon | string - image filename | ||
| 205 | /// @return The url to use for Art | ||
| 206 | /// | ||
| 207 | std::string GetArt(const std::string& type) | ||
| 208 | { | ||
| 209 | std::string strReturn; | ||
| 210 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); | ||
| 211 | if (ret != nullptr) | ||
| 212 | { | ||
| 213 | if (std::strlen(ret)) | ||
| 214 | strReturn = ret; | ||
| 215 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 216 | } | ||
| 217 | return strReturn; | ||
| 218 | } | ||
| 219 | //-------------------------------------------------------------------------- | ||
| 220 | |||
| 221 | //========================================================================== | ||
| 222 | /// | ||
| 223 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 224 | /// @brief Sets the listitem's art | ||
| 225 | /// | ||
| 226 | /// @param[in] type Type of Art to set | ||
| 227 | /// @param[in] url The url to use for Art | ||
| 228 | /// - Some default art values (any string possible): | ||
| 229 | /// | value (type) | Type | | ||
| 230 | /// |:-------------:|:--------------------------------------------------| | ||
| 231 | /// | thumb | string - image filename | ||
| 232 | /// | poster | string - image filename | ||
| 233 | /// | banner | string - image filename | ||
| 234 | /// | fanart | string - image filename | ||
| 235 | /// | clearart | string - image filename | ||
| 236 | /// | clearlogo | string - image filename | ||
| 237 | /// | landscape | string - image filename | ||
| 238 | /// | icon | string - image filename | ||
| 239 | /// | ||
| 240 | void SetArt(const std::string& type, const std::string& url) | ||
| 241 | { | ||
| 242 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); | ||
| 243 | } | ||
| 244 | //-------------------------------------------------------------------------- | ||
| 245 | |||
| 246 | //========================================================================== | ||
| 247 | /// | ||
| 248 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 249 | /// @brief Returns the path / filename of this listitem. | ||
| 250 | /// | ||
| 251 | /// @return Path string | ||
| 252 | /// | ||
| 253 | std::string GetPath() | ||
| 254 | { | ||
| 255 | std::string strReturn; | ||
| 256 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 257 | if (ret != nullptr) | ||
| 258 | { | ||
| 259 | if (std::strlen(ret)) | ||
| 260 | strReturn = ret; | ||
| 261 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 262 | } | ||
| 263 | return strReturn; | ||
| 264 | } | ||
| 265 | //-------------------------------------------------------------------------- | ||
| 266 | |||
| 267 | //========================================================================== | ||
| 268 | /// | ||
| 269 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 270 | /// @brief Sets the listitem's path. | ||
| 271 | /// | ||
| 272 | /// @param[in] path string or unicode - path, activated when | ||
| 273 | /// item is clicked. | ||
| 274 | /// | ||
| 275 | /// @note You can use the above as keywords for arguments. | ||
| 276 | /// | ||
| 277 | void SetPath(const std::string& path) | ||
| 278 | { | ||
| 279 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 280 | } | ||
| 281 | //-------------------------------------------------------------------------- | ||
| 282 | |||
| 283 | //========================================================================== | ||
| 284 | /// | ||
| 285 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 286 | /// @brief Sets a listitem property, similar to an infolabel. | ||
| 287 | /// | ||
| 288 | /// @param[in] key string - property name. | ||
| 289 | /// @param[in] value string or unicode - value of property. | ||
| 290 | /// | ||
| 291 | /// @note Key is NOT case sensitive. | ||
| 292 | /// You can use the above as keywords for arguments and skip certain\n | ||
| 293 | /// optional arguments.\n | ||
| 294 | /// Once you use a keyword, all following arguments require the | ||
| 295 | /// keyword. | ||
| 296 | /// | ||
| 297 | /// Some of these are treated internally by Kodi, such as the | ||
| 298 | /// <b>'StartOffset'</b> property, which is the offset in seconds at which to | ||
| 299 | /// start playback of an item. Others may be used in the skin to add | ||
| 300 | /// extra information, such as <b>'WatchedCount'</b> for tvshow items | ||
| 301 | /// | ||
| 302 | void SetProperty(const std::string& key, const std::string& value) | ||
| 303 | { | ||
| 304 | m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 305 | } | ||
| 306 | //-------------------------------------------------------------------------- | ||
| 307 | |||
| 308 | //========================================================================== | ||
| 309 | /// | ||
| 310 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 311 | /// @brief Returns a listitem property as a string, similar to an infolabel. | ||
| 312 | /// | ||
| 313 | /// @param[in] key string - property name. | ||
| 314 | /// @return string - List item property | ||
| 315 | /// | ||
| 316 | /// @note Key is NOT case sensitive.\n | ||
| 317 | /// You can use the above as keywords for arguments and skip certain | ||
| 318 | /// optional arguments.\n | ||
| 319 | /// Once you use a keyword, all following arguments require the | ||
| 320 | /// keyword. | ||
| 321 | /// | ||
| 322 | std::string GetProperty(const std::string& key) | ||
| 323 | { | ||
| 324 | std::string label; | ||
| 325 | char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 326 | if (ret != nullptr) | ||
| 327 | { | ||
| 328 | if (std::strlen(ret)) | ||
| 329 | label = ret; | ||
| 330 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 331 | } | ||
| 332 | return label; | ||
| 333 | } | ||
| 334 | //-------------------------------------------------------------------------- | ||
| 335 | |||
| 336 | //========================================================================== | ||
| 337 | /// | ||
| 338 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 339 | /// @brief To control selection of item in list (also multiple selection, | ||
| 340 | /// in list on serveral items possible). | ||
| 341 | /// | ||
| 342 | /// @param[in] selected if true becomes set as selected | ||
| 343 | /// | ||
| 344 | void Select(bool selected) | ||
| 345 | { | ||
| 346 | m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected); | ||
| 347 | } | ||
| 348 | //-------------------------------------------------------------------------- | ||
| 349 | |||
| 350 | //========================================================================== | ||
| 351 | /// | ||
| 352 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 353 | /// @brief Returns the listitem's selected status. | ||
| 354 | /// | ||
| 355 | /// @return true if selected, otherwise false | ||
| 356 | /// | ||
| 357 | bool IsSelected() | ||
| 358 | { | ||
| 359 | return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle); | ||
| 360 | } | ||
| 361 | //-------------------------------------------------------------------------- | ||
| 362 | |||
| 363 | }; | ||
| 364 | |||
| 365 | } /* namespace gui */ | ||
| 366 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h deleted file mode 100644 index 5011374..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h +++ /dev/null | |||
| @@ -1,909 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../AddonBase.h" | ||
| 12 | #include "ListItem.h" | ||
| 13 | |||
| 14 | #ifdef BUILD_KODI_ADDON | ||
| 15 | #include "../ActionIDs.h" | ||
| 16 | #else | ||
| 17 | #include "input/actions/ActionIDs.h" | ||
| 18 | #endif | ||
| 19 | |||
| 20 | namespace kodi | ||
| 21 | { | ||
| 22 | namespace gui | ||
| 23 | { | ||
| 24 | |||
| 25 | class CListItem; | ||
| 26 | |||
| 27 | //============================================================================ | ||
| 28 | /// | ||
| 29 | /// \defgroup cpp_kodi_gui_CWindow Window | ||
| 30 | /// \ingroup cpp_kodi_gui | ||
| 31 | /// @brief \cpp_class{ kodi::gui::CWindow } | ||
| 32 | /// **Main window control class** | ||
| 33 | /// | ||
| 34 | /// The with \ref Window.h "#include <kodi/gui/Window.h>" | ||
| 35 | /// included file brings support to create a window or dialog on Kodi. | ||
| 36 | /// | ||
| 37 | /// -------------------------------------------------------------------------- | ||
| 38 | /// | ||
| 39 | /// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b> | ||
| 40 | /// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and | ||
| 41 | /// used to identify for changes there and on callbacks. | ||
| 42 | /// | ||
| 43 | /// ~~~~~~~~~~~~~{.xml} | ||
| 44 | /// <control type="label" id="31"> | ||
| 45 | /// <description>Title Label</description> | ||
| 46 | /// ... | ||
| 47 | /// </control> | ||
| 48 | /// <control type="progress" id="32"> | ||
| 49 | /// <description>progress control</description> | ||
| 50 | /// ... | ||
| 51 | /// </control> | ||
| 52 | /// ~~~~~~~~~~~~~ | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | |||
| 56 | //============================================================================ | ||
| 57 | /// | ||
| 58 | /// \defgroup cpp_kodi_gui_CWindow_Defs Definitions, structures and enumerators | ||
| 59 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 60 | /// @brief <b>Library definition values</b> | ||
| 61 | /// | ||
| 62 | |||
| 63 | class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase | ||
| 64 | { | ||
| 65 | public: | ||
| 66 | //========================================================================== | ||
| 67 | /// | ||
| 68 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 69 | /// @brief Class constructor with needed values for window / dialog. | ||
| 70 | /// | ||
| 71 | /// Creates a new Window class. | ||
| 72 | /// | ||
| 73 | /// @param[in] xmlFilename XML file for the skin | ||
| 74 | /// @param[in] defaultSkin default skin to use if needed not available | ||
| 75 | /// @param[in] asDialog Use window as dialog if set | ||
| 76 | /// @param[in] isMedia [opt] bool - if False, create a regular window. | ||
| 77 | /// if True, create a mediawindow. | ||
| 78 | /// (default=false) | ||
| 79 | /// @note only usable for windows not for dialogs. | ||
| 80 | /// | ||
| 81 | /// | ||
| 82 | CWindow(const std::string& xmlFilename, const std::string& defaultSkin, bool asDialog, bool isMedia = false) | ||
| 83 | : CAddonGUIControlBase(nullptr) | ||
| 84 | { | ||
| 85 | m_controlHandle = m_interface->kodi_gui->window->create(m_interface->kodiBase, xmlFilename.c_str(), | ||
| 86 | defaultSkin.c_str(), asDialog, isMedia); | ||
| 87 | if (!m_controlHandle) | ||
| 88 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); | ||
| 89 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 90 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 91 | CBGetContextButtons, CBOnContextButton); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup CWindow | ||
| 98 | /// @brief Class destructor | ||
| 99 | /// | ||
| 100 | /// | ||
| 101 | /// | ||
| 102 | ~CWindow() override | ||
| 103 | { | ||
| 104 | if (m_controlHandle) | ||
| 105 | m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 106 | } | ||
| 107 | //-------------------------------------------------------------------------- | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 112 | /// @brief Show this window. | ||
| 113 | /// | ||
| 114 | /// Shows this window by activating it, calling close() after it wil activate the | ||
| 115 | /// current window again. | ||
| 116 | /// | ||
| 117 | /// @note If your Add-On ends this window will be closed to. To show it forever, | ||
| 118 | /// make a loop at the end of your Add-On or use doModal() instead. | ||
| 119 | /// | ||
| 120 | /// @warning If used must be the class be global present until Kodi becomes | ||
| 121 | /// closed. The creation can be done after before "Show" becomes called, but | ||
| 122 | /// not delete class after them. | ||
| 123 | /// | ||
| 124 | /// @return Return true if call and show is successed, | ||
| 125 | /// if false was something failed to get needed | ||
| 126 | /// skin parts. | ||
| 127 | /// | ||
| 128 | bool Show() | ||
| 129 | { | ||
| 130 | return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 137 | /// @brief Closes this window. | ||
| 138 | /// | ||
| 139 | /// Closes this window by activating the old window. | ||
| 140 | /// @note The window is not deleted with this method. | ||
| 141 | /// | ||
| 142 | void Close() | ||
| 143 | { | ||
| 144 | m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); | ||
| 145 | } | ||
| 146 | //-------------------------------------------------------------------------- | ||
| 147 | |||
| 148 | //========================================================================== | ||
| 149 | /// | ||
| 150 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 151 | /// @brief Display this window until close() is called. | ||
| 152 | /// | ||
| 153 | void DoModal() | ||
| 154 | { | ||
| 155 | m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); | ||
| 156 | } | ||
| 157 | //-------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //========================================================================== | ||
| 160 | /// | ||
| 161 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 162 | /// @brief Gives the control with the supplied focus. | ||
| 163 | /// | ||
| 164 | /// @param[in] iControlId On skin defined id of control | ||
| 165 | /// @return Return true if call and focus is successed, | ||
| 166 | /// if false was something failed to get needed | ||
| 167 | /// skin parts. | ||
| 168 | /// | ||
| 169 | /// | ||
| 170 | bool SetFocusId(int iControlId) | ||
| 171 | { | ||
| 172 | return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle, iControlId); | ||
| 173 | } | ||
| 174 | //-------------------------------------------------------------------------- | ||
| 175 | |||
| 176 | //========================================================================== | ||
| 177 | /// | ||
| 178 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 179 | /// @brief Returns the id of the control which is focused. | ||
| 180 | /// | ||
| 181 | /// @return Focused control id | ||
| 182 | /// | ||
| 183 | /// | ||
| 184 | int GetFocusId() | ||
| 185 | { | ||
| 186 | return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle); | ||
| 187 | } | ||
| 188 | //-------------------------------------------------------------------------- | ||
| 189 | |||
| 190 | //========================================================================== | ||
| 191 | /// | ||
| 192 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 193 | /// @brief To set the used label on given control id | ||
| 194 | /// | ||
| 195 | /// @param[in] controlId Control id where label need to set | ||
| 196 | /// @param[in] label Label to use | ||
| 197 | /// | ||
| 198 | /// | ||
| 199 | void SetControlLabel(int controlId, const std::string& label) | ||
| 200 | { | ||
| 201 | m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle, controlId, label.c_str()); | ||
| 202 | } | ||
| 203 | //-------------------------------------------------------------------------- | ||
| 204 | |||
| 205 | //========================================================================== | ||
| 206 | /// | ||
| 207 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 208 | /// @brief To set the visibility on given control id | ||
| 209 | /// | ||
| 210 | /// @param[in] controlId Control id where visibility is changed | ||
| 211 | /// @param[in] visible Boolean value with `true` for visible, `false` for hidden | ||
| 212 | /// | ||
| 213 | /// | ||
| 214 | void SetControlVisible(int controlId, bool visible) | ||
| 215 | { | ||
| 216 | m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle, controlId, visible); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 223 | /// @brief To set the selection on given control id | ||
| 224 | /// | ||
| 225 | /// @param[in] controlId Control id where selection is changed | ||
| 226 | /// @param[in] selected Boolean value with `true` for selected, `false` for not | ||
| 227 | /// | ||
| 228 | /// | ||
| 229 | void SetControlSelected(int controlId, bool selected) | ||
| 230 | { | ||
| 231 | m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle, controlId, selected); | ||
| 232 | } | ||
| 233 | //-------------------------------------------------------------------------- | ||
| 234 | |||
| 235 | //========================================================================== | ||
| 236 | /// | ||
| 237 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 238 | /// @brief Sets a window property, similar to an infolabel. | ||
| 239 | /// | ||
| 240 | /// @param[in] key string - property name. | ||
| 241 | /// @param[in] value string or unicode - value of property. | ||
| 242 | /// | ||
| 243 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 244 | /// equivalent to clearProperty(key).\n | ||
| 245 | /// You can use the above as keywords for arguments and skip certain | ||
| 246 | /// optional arguments.\n | ||
| 247 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 248 | /// | ||
| 249 | void SetProperty(const std::string& key, const std::string& value) | ||
| 250 | { | ||
| 251 | m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 252 | } | ||
| 253 | //-------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //========================================================================== | ||
| 256 | /// | ||
| 257 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 258 | /// @brief Returns a window property as a string, similar to an infolabel. | ||
| 259 | /// | ||
| 260 | /// @param[in] key string - property name. | ||
| 261 | /// @return The property as strin (if present) | ||
| 262 | /// | ||
| 263 | /// @note Key is NOT case sensitive. Setting value to an empty string is | ||
| 264 | /// equivalent to clearProperty(key).\n | ||
| 265 | /// You can use the above as keywords for arguments and skip certain | ||
| 266 | /// optional arguments.\n | ||
| 267 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 268 | /// | ||
| 269 | /// | ||
| 270 | std::string GetProperty(const std::string& key) const | ||
| 271 | { | ||
| 272 | std::string label; | ||
| 273 | char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 274 | if (ret != nullptr) | ||
| 275 | { | ||
| 276 | if (std::strlen(ret)) | ||
| 277 | label = ret; | ||
| 278 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 279 | } | ||
| 280 | return label; | ||
| 281 | } | ||
| 282 | //-------------------------------------------------------------------------- | ||
| 283 | |||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 287 | /// @brief Sets a window property with integer value | ||
| 288 | /// | ||
| 289 | /// @param[in] key string - property name. | ||
| 290 | /// @param[in] value integer value to set | ||
| 291 | /// | ||
| 292 | /// | ||
| 293 | void SetPropertyInt(const std::string& key, int value) | ||
| 294 | { | ||
| 295 | m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 296 | } | ||
| 297 | //-------------------------------------------------------------------------- | ||
| 298 | |||
| 299 | //========================================================================== | ||
| 300 | /// | ||
| 301 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 302 | /// @brief Returns a window property with integer value | ||
| 303 | /// | ||
| 304 | /// @param[in] key string - property name. | ||
| 305 | /// @return integer value of property | ||
| 306 | /// | ||
| 307 | int GetPropertyInt(const std::string& key) const | ||
| 308 | { | ||
| 309 | return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 310 | } | ||
| 311 | //-------------------------------------------------------------------------- | ||
| 312 | |||
| 313 | //========================================================================== | ||
| 314 | /// | ||
| 315 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 316 | /// @brief Sets a window property with boolean value | ||
| 317 | /// | ||
| 318 | /// @param[in] key string - property name. | ||
| 319 | /// @param[in] value boolean value to set | ||
| 320 | /// | ||
| 321 | /// | ||
| 322 | void SetPropertyBool(const std::string& key, bool value) | ||
| 323 | { | ||
| 324 | m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 325 | } | ||
| 326 | //-------------------------------------------------------------------------- | ||
| 327 | |||
| 328 | //========================================================================== | ||
| 329 | /// | ||
| 330 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 331 | /// @brief Returns a window property with boolean value | ||
| 332 | /// | ||
| 333 | /// @param[in] key string - property name. | ||
| 334 | /// @return boolean value of property | ||
| 335 | /// | ||
| 336 | bool GetPropertyBool(const std::string& key) const | ||
| 337 | { | ||
| 338 | return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 339 | } | ||
| 340 | //-------------------------------------------------------------------------- | ||
| 341 | |||
| 342 | //========================================================================== | ||
| 343 | /// | ||
| 344 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 345 | /// @brief Sets a window property with double value | ||
| 346 | /// | ||
| 347 | /// @param[in] key string - property name. | ||
| 348 | /// @param[in] value double value to set | ||
| 349 | /// | ||
| 350 | /// | ||
| 351 | void SetPropertyDouble(const std::string& key, double value) | ||
| 352 | { | ||
| 353 | m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle, key.c_str(), value); | ||
| 354 | } | ||
| 355 | //-------------------------------------------------------------------------- | ||
| 356 | |||
| 357 | //========================================================================== | ||
| 358 | /// | ||
| 359 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 360 | /// @brief Returns a window property with double value | ||
| 361 | /// | ||
| 362 | /// @param[in] key string - property name. | ||
| 363 | /// @return double value of property | ||
| 364 | /// | ||
| 365 | /// | ||
| 366 | double GetPropertyDouble(const std::string& key) const | ||
| 367 | { | ||
| 368 | return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 369 | } | ||
| 370 | //-------------------------------------------------------------------------- | ||
| 371 | |||
| 372 | //========================================================================== | ||
| 373 | /// | ||
| 374 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 375 | /// @brief Remove all present properties from window | ||
| 376 | /// | ||
| 377 | /// | ||
| 378 | /// | ||
| 379 | void ClearProperties() | ||
| 380 | { | ||
| 381 | m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle); | ||
| 382 | } | ||
| 383 | //-------------------------------------------------------------------------- | ||
| 384 | |||
| 385 | //========================================================================== | ||
| 386 | /// | ||
| 387 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 388 | /// @brief Clears the specific window property. | ||
| 389 | /// | ||
| 390 | /// @param[in] key string - property name. | ||
| 391 | /// | ||
| 392 | /// @note Key is NOT case sensitive. Equivalent to SetProperty(key, "") | ||
| 393 | /// You can use the above as keywords for arguments and skip certain | ||
| 394 | /// optional arguments. | ||
| 395 | /// Once you use a keyword, all following arguments require the | ||
| 396 | /// keyword. | ||
| 397 | /// | ||
| 398 | /// | ||
| 399 | ///----------------------------------------------------------------------- | ||
| 400 | /// | ||
| 401 | /// **Example:** | ||
| 402 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 403 | /// .. | ||
| 404 | /// ClearProperty('Category') | ||
| 405 | /// .. | ||
| 406 | /// ~~~~~~~~~~~~~ | ||
| 407 | /// | ||
| 408 | void ClearProperty(const std::string& key) | ||
| 409 | { | ||
| 410 | m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle, key.c_str()); | ||
| 411 | } | ||
| 412 | //-------------------------------------------------------------------------- | ||
| 413 | |||
| 414 | //@{ | ||
| 415 | //========================================================================== | ||
| 416 | /// | ||
| 417 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 418 | /// @brief Function delete all entries in integrated list. | ||
| 419 | /// | ||
| 420 | /// | ||
| 421 | /// | ||
| 422 | void ClearList() | ||
| 423 | { | ||
| 424 | m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); | ||
| 425 | } | ||
| 426 | //-------------------------------------------------------------------------- | ||
| 427 | |||
| 428 | //========================================================================== | ||
| 429 | /// | ||
| 430 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 431 | /// @brief To add a list item in the on window integrated list. | ||
| 432 | /// | ||
| 433 | /// @param[in] item List item to add | ||
| 434 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 435 | /// | ||
| 436 | /// | ||
| 437 | void AddListItem(ListItemPtr item, int itemPosition = -1) | ||
| 438 | { | ||
| 439 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); | ||
| 440 | } | ||
| 441 | //-------------------------------------------------------------------------- | ||
| 442 | |||
| 443 | //========================================================================== | ||
| 444 | /// | ||
| 445 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 446 | /// @brief To add a list item based upon string in the on window integrated list. | ||
| 447 | /// | ||
| 448 | /// @param[in] item List item to add | ||
| 449 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 450 | /// | ||
| 451 | /// | ||
| 452 | void AddListItem(const std::string item, int itemPosition = -1) | ||
| 453 | { | ||
| 454 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition); | ||
| 455 | } | ||
| 456 | //-------------------------------------------------------------------------- | ||
| 457 | |||
| 458 | //========================================================================== | ||
| 459 | /// | ||
| 460 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 461 | /// @brief Remove list item on position. | ||
| 462 | /// | ||
| 463 | /// @param[in] itemPosition List position to remove | ||
| 464 | /// | ||
| 465 | /// | ||
| 466 | void RemoveListItem(int itemPosition) | ||
| 467 | { | ||
| 468 | m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase, m_controlHandle, itemPosition); | ||
| 469 | } | ||
| 470 | //-------------------------------------------------------------------------- | ||
| 471 | |||
| 472 | //========================================================================== | ||
| 473 | /// | ||
| 474 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 475 | /// @brief Remove item with given control class from list. | ||
| 476 | /// | ||
| 477 | /// @param[in] item List item control class to remove | ||
| 478 | /// | ||
| 479 | /// | ||
| 480 | void RemoveListItem(ListItemPtr item) | ||
| 481 | { | ||
| 482 | m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle); | ||
| 483 | } | ||
| 484 | //-------------------------------------------------------------------------- | ||
| 485 | |||
| 486 | //========================================================================== | ||
| 487 | /// | ||
| 488 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 489 | /// @brief To get list item control class on wanted position. | ||
| 490 | /// | ||
| 491 | /// @param[in] listPos Position from where control is needed | ||
| 492 | /// @return The list item control class or null if not found | ||
| 493 | /// | ||
| 494 | /// @warning Function returns a new generated **CListItem** class! | ||
| 495 | /// | ||
| 496 | ListItemPtr GetListItem(int listPos) | ||
| 497 | { | ||
| 498 | GUIHANDLE handle = m_interface->kodi_gui->window->get_list_item(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 499 | if (!handle) | ||
| 500 | return ListItemPtr(); | ||
| 501 | |||
| 502 | return std::make_shared<kodi::gui::CListItem>(handle); | ||
| 503 | } | ||
| 504 | //-------------------------------------------------------------------------- | ||
| 505 | |||
| 506 | //========================================================================== | ||
| 507 | /// | ||
| 508 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 509 | /// @brief To set position of selected part in list. | ||
| 510 | /// | ||
| 511 | /// @param[in] listPos Position to use | ||
| 512 | /// | ||
| 513 | /// | ||
| 514 | void SetCurrentListPosition(int listPos) | ||
| 515 | { | ||
| 516 | m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 517 | } | ||
| 518 | //-------------------------------------------------------------------------- | ||
| 519 | |||
| 520 | //========================================================================== | ||
| 521 | /// | ||
| 522 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 523 | /// @brief To get current selected position in list | ||
| 524 | /// | ||
| 525 | /// @return Current list position | ||
| 526 | /// | ||
| 527 | /// | ||
| 528 | int GetCurrentListPosition() | ||
| 529 | { | ||
| 530 | return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase, m_controlHandle); | ||
| 531 | } | ||
| 532 | //-------------------------------------------------------------------------- | ||
| 533 | |||
| 534 | //========================================================================== | ||
| 535 | /// | ||
| 536 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 537 | /// @brief To get the amount of entries in the list. | ||
| 538 | /// | ||
| 539 | /// @return Size of in window integrated control class | ||
| 540 | /// | ||
| 541 | /// | ||
| 542 | int GetListSize() | ||
| 543 | { | ||
| 544 | return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle); | ||
| 545 | } | ||
| 546 | //-------------------------------------------------------------------------- | ||
| 547 | |||
| 548 | //========================================================================== | ||
| 549 | /// | ||
| 550 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 551 | /// @brief Sets a container property, similar to an infolabel. | ||
| 552 | /// | ||
| 553 | /// @param[in] key string - property name. | ||
| 554 | /// @param[in] value string or unicode - value of property. | ||
| 555 | /// | ||
| 556 | /// @note Key is NOT case sensitive.\n | ||
| 557 | /// You can use the above as keywords for arguments and skip certain | ||
| 558 | /// optional arguments.\n | ||
| 559 | /// Once you use a keyword, all following arguments require the keyword. | ||
| 560 | /// | ||
| 561 | /// | ||
| 562 | void SetContainerProperty(const std::string& key, const std::string& value) | ||
| 563 | { | ||
| 564 | m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); | ||
| 565 | } | ||
| 566 | //-------------------------------------------------------------------------- | ||
| 567 | |||
| 568 | //========================================================================== | ||
| 569 | /// | ||
| 570 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 571 | /// @brief Sets the content type of the container. | ||
| 572 | /// | ||
| 573 | /// @param[in] value string or unicode - content value. | ||
| 574 | /// | ||
| 575 | /// __Available content types__ | ||
| 576 | /// | Name | Media | | ||
| 577 | /// |:-----------:|:-----------------------------------------| | ||
| 578 | /// | actors | Videos | ||
| 579 | /// | addons | Addons, Music, Pictures, Programs, Videos | ||
| 580 | /// | albums | Music, Videos | ||
| 581 | /// | artists | Music, Videos | ||
| 582 | /// | countries | Music, Videos | ||
| 583 | /// | directors | Videos | ||
| 584 | /// | files | Music, Videos | ||
| 585 | /// | games | Games | ||
| 586 | /// | genres | Music, Videos | ||
| 587 | /// | images | Pictures | ||
| 588 | /// | mixed | Music, Videos | ||
| 589 | /// | movies | Videos | ||
| 590 | /// | Musicvideos | Music, Videos | ||
| 591 | /// | playlists | Music, Videos | ||
| 592 | /// | seasons | Videos | ||
| 593 | /// | sets | Videos | ||
| 594 | /// | songs | Music | ||
| 595 | /// | studios | Music, Videos | ||
| 596 | /// | tags | Music, Videos | ||
| 597 | /// | tvshows | Videos | ||
| 598 | /// | videos | Videos | ||
| 599 | /// | years | Music, Videos | ||
| 600 | /// | ||
| 601 | /// | ||
| 602 | void SetContainerContent(const std::string& value) | ||
| 603 | { | ||
| 604 | m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle, value.c_str()); | ||
| 605 | } | ||
| 606 | //-------------------------------------------------------------------------- | ||
| 607 | |||
| 608 | //========================================================================== | ||
| 609 | /// | ||
| 610 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 611 | /// @brief Get the id of the currently visible container. | ||
| 612 | /// | ||
| 613 | /// @return currently visible container id | ||
| 614 | /// | ||
| 615 | /// | ||
| 616 | int GetCurrentContainerId() | ||
| 617 | { | ||
| 618 | return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase, m_controlHandle); | ||
| 619 | } | ||
| 620 | //-------------------------------------------------------------------------- | ||
| 621 | //@} | ||
| 622 | |||
| 623 | //========================================================================== | ||
| 624 | /// | ||
| 625 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 626 | /// @brief To inform Kodi that it need to render region new. | ||
| 627 | /// | ||
| 628 | /// | ||
| 629 | void MarkDirtyRegion() | ||
| 630 | { | ||
| 631 | return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle); | ||
| 632 | } | ||
| 633 | //-------------------------------------------------------------------------- | ||
| 634 | |||
| 635 | //========================================================================== | ||
| 636 | // | ||
| 637 | /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on | ||
| 638 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 639 | //@{ | ||
| 640 | /// @brief <b>GUI window callback functions.</b> | ||
| 641 | /// | ||
| 642 | /// Functions to handle control callbacks from Kodi | ||
| 643 | /// | ||
| 644 | /// ------------------------------------------------------------------------ | ||
| 645 | /// | ||
| 646 | /// @link cpp_kodi_gui_CWindow Go back to normal functions from CWindow@endlink | ||
| 647 | // | ||
| 648 | |||
| 649 | //========================================================================== | ||
| 650 | /// | ||
| 651 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 652 | /// @brief OnInit method. | ||
| 653 | /// | ||
| 654 | /// @return Return true if initialize was done successful | ||
| 655 | /// | ||
| 656 | /// | ||
| 657 | virtual bool OnInit() { return false; } | ||
| 658 | //-------------------------------------------------------------------------- | ||
| 659 | |||
| 660 | //========================================================================== | ||
| 661 | /// | ||
| 662 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 663 | /// @brief OnFocus method. | ||
| 664 | /// | ||
| 665 | /// @param[in] controlId GUI control identifier | ||
| 666 | /// @return Return true if focus condition was handled there or false to handle them by Kodi itself | ||
| 667 | /// | ||
| 668 | /// | ||
| 669 | virtual bool OnFocus(int controlId) { return false; } | ||
| 670 | //-------------------------------------------------------------------------- | ||
| 671 | |||
| 672 | //========================================================================== | ||
| 673 | /// | ||
| 674 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 675 | /// @brief OnClick method. | ||
| 676 | /// | ||
| 677 | /// @param[in] controlId GUI control identifier | ||
| 678 | /// @return Return true if click was handled there | ||
| 679 | /// or false to handle them by Kodi itself | ||
| 680 | /// | ||
| 681 | /// | ||
| 682 | virtual bool OnClick(int controlId) { return false; } | ||
| 683 | //-------------------------------------------------------------------------- | ||
| 684 | |||
| 685 | //========================================================================== | ||
| 686 | /// | ||
| 687 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 688 | /// @brief OnAction method. | ||
| 689 | /// | ||
| 690 | /// @param[in] actionId The action id to perform, see | ||
| 691 | /// \ref kodi_key_action_ids to get list of | ||
| 692 | /// them | ||
| 693 | /// @return Return true if action was handled there | ||
| 694 | /// or false to handle them by Kodi itself | ||
| 695 | /// | ||
| 696 | /// | ||
| 697 | /// This method will receive all actions that the main program will send | ||
| 698 | /// to this window. | ||
| 699 | /// | ||
| 700 | /// @note | ||
| 701 | /// - By default, only the \c PREVIOUS_MENU and \c NAV_BACK actions are handled. | ||
| 702 | /// - Overwrite this method to let your code handle all actions. | ||
| 703 | /// - Don't forget to capture \c ACTION_PREVIOUS_MENU or \c ACTION_NAV_BACK, else the user can't close this window. | ||
| 704 | /// | ||
| 705 | /// | ||
| 706 | ///-------------------------------------------------------------------------- | ||
| 707 | /// | ||
| 708 | /// **Example:** | ||
| 709 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 710 | /// .. | ||
| 711 | /// /* Window used with parent / child way */ | ||
| 712 | /// bool cYOUR_CLASS::OnAction(int actionId) | ||
| 713 | /// { | ||
| 714 | /// switch (action) | ||
| 715 | /// { | ||
| 716 | /// case ACTION_PREVIOUS_MENU: | ||
| 717 | /// case ACTION_NAV_BACK: | ||
| 718 | /// printf("action recieved: previous"); | ||
| 719 | /// Close(); | ||
| 720 | /// return true; | ||
| 721 | /// case ACTION_SHOW_INFO: | ||
| 722 | /// printf("action recieved: show info"); | ||
| 723 | /// break; | ||
| 724 | /// case ACTION_STOP: | ||
| 725 | /// printf("action recieved: stop"); | ||
| 726 | /// break; | ||
| 727 | /// case ACTION_PAUSE: | ||
| 728 | /// printf("action recieved: pause"); | ||
| 729 | /// break; | ||
| 730 | /// default: | ||
| 731 | /// break; | ||
| 732 | /// } | ||
| 733 | /// return false; | ||
| 734 | /// } | ||
| 735 | /// .. | ||
| 736 | /// ~~~~~~~~~~~~~ | ||
| 737 | /// | ||
| 738 | virtual bool OnAction(int actionId, uint32_t buttoncode, wchar_t unicode) | ||
| 739 | { | ||
| 740 | switch (actionId) | ||
| 741 | { | ||
| 742 | case ACTION_PREVIOUS_MENU: | ||
| 743 | case ACTION_NAV_BACK: | ||
| 744 | Close(); | ||
| 745 | return true; | ||
| 746 | default: | ||
| 747 | break; | ||
| 748 | } | ||
| 749 | return false; | ||
| 750 | } | ||
| 751 | //-------------------------------------------------------------------------- | ||
| 752 | |||
| 753 | //========================================================================== | ||
| 754 | /// | ||
| 755 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 756 | /// @brief Get context menu buttons for list entry | ||
| 757 | /// | ||
| 758 | /// @param[in] itemNumber selected list item entry | ||
| 759 | /// @param[in] buttons list where context menus becomes added with his | ||
| 760 | /// identifier and name. | ||
| 761 | /// | ||
| 762 | virtual void GetContextButtons(int itemNumber, std::vector< std::pair<unsigned int, std::string> > &buttons) | ||
| 763 | { | ||
| 764 | } | ||
| 765 | //-------------------------------------------------------------------------- | ||
| 766 | |||
| 767 | //========================================================================== | ||
| 768 | /// | ||
| 769 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 770 | /// @brief Called after selection in context menu | ||
| 771 | /// | ||
| 772 | /// @param[in] itemNumber selected list item entry | ||
| 773 | /// @param[in] button the pressed button id | ||
| 774 | /// @return true if handled, otherwise false | ||
| 775 | /// | ||
| 776 | virtual bool OnContextButton(int itemNumber, unsigned int button) | ||
| 777 | { | ||
| 778 | return false; | ||
| 779 | } | ||
| 780 | //-------------------------------------------------------------------------- | ||
| 781 | |||
| 782 | //========================================================================== | ||
| 783 | /// | ||
| 784 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 785 | /// @brief **Set independent callbacks** | ||
| 786 | /// | ||
| 787 | /// If the class is used independent (with "new CWindow") and | ||
| 788 | /// not as parent (with "cCLASS_own : CWindow") from own must be the | ||
| 789 | /// callback from Kodi to add-on overdriven with own functions! | ||
| 790 | /// | ||
| 791 | /// @param[in] cbhdl The pointer to own handle data | ||
| 792 | /// structure / class | ||
| 793 | /// @param[in] CBOnInit Own defined window init function | ||
| 794 | /// @param[in] CBOnFocus Own defined focus function | ||
| 795 | /// @param[in] CBOnClick Own defined click function | ||
| 796 | /// @param[in] CBOnAction Own defined action function | ||
| 797 | /// @param[in] CBGetContextButtons [opt] To get context menu entries for | ||
| 798 | /// lists function | ||
| 799 | /// @param[in] CBOnContextButton [opt] Used context menu entry function | ||
| 800 | /// | ||
| 801 | /// | ||
| 802 | ///-------------------------------------------------------------------------- | ||
| 803 | /// | ||
| 804 | /// **Example:** | ||
| 805 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 806 | /// ... | ||
| 807 | /// | ||
| 808 | /// bool OnInit(GUIHANDLE cbhdl) | ||
| 809 | /// { | ||
| 810 | /// ... | ||
| 811 | /// return true; | ||
| 812 | /// } | ||
| 813 | /// | ||
| 814 | /// bool OnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 815 | /// { | ||
| 816 | /// ... | ||
| 817 | /// return true; | ||
| 818 | /// } | ||
| 819 | /// | ||
| 820 | /// bool OnClick(GUIHANDLE cbhdl, int controlId) | ||
| 821 | /// { | ||
| 822 | /// ... | ||
| 823 | /// return true; | ||
| 824 | /// } | ||
| 825 | /// | ||
| 826 | /// bool OnAction(GUIHANDLE cbhdl, int actionId) | ||
| 827 | /// { | ||
| 828 | /// ... | ||
| 829 | /// return true; | ||
| 830 | /// } | ||
| 831 | /// | ||
| 832 | /// ... | ||
| 833 | /// /* Somewhere where you create the window */ | ||
| 834 | /// CWindow myWindow = new CWindow; | ||
| 835 | /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); | ||
| 836 | /// ... | ||
| 837 | /// ~~~~~~~~~~~~~ | ||
| 838 | /// | ||
| 839 | void SetIndependentCallbacks( | ||
| 840 | GUIHANDLE cbhdl, | ||
| 841 | bool (*CBOnInit) (GUIHANDLE cbhdl), | ||
| 842 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), | ||
| 843 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), | ||
| 844 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode), | ||
| 845 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, | ||
| 846 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) | ||
| 847 | { | ||
| 848 | if (!cbhdl || | ||
| 849 | !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) | ||
| 850 | { | ||
| 851 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); | ||
| 852 | return; | ||
| 853 | } | ||
| 854 | |||
| 855 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 856 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 857 | CBGetContextButtons, CBOnContextButton); | ||
| 858 | } | ||
| 859 | //-------------------------------------------------------------------------- | ||
| 860 | //@} | ||
| 861 | |||
| 862 | private: | ||
| 863 | static bool CBOnInit(GUIHANDLE cbhdl) | ||
| 864 | { | ||
| 865 | return static_cast<CWindow*>(cbhdl)->OnInit(); | ||
| 866 | } | ||
| 867 | |||
| 868 | static bool CBOnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 869 | { | ||
| 870 | return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); | ||
| 871 | } | ||
| 872 | |||
| 873 | static bool CBOnClick(GUIHANDLE cbhdl, int controlId) | ||
| 874 | { | ||
| 875 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | ||
| 876 | } | ||
| 877 | |||
| 878 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode) | ||
| 879 | { | ||
| 880 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId, buttoncode, unicode); | ||
| 881 | } | ||
| 882 | |||
| 883 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) | ||
| 884 | { | ||
| 885 | std::vector< std::pair<unsigned int, std::string> > buttonList; | ||
| 886 | static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList); | ||
| 887 | if (!buttonList.empty()) | ||
| 888 | { | ||
| 889 | unsigned int presentSize = static_cast<unsigned int>(buttonList.size()); | ||
| 890 | if (presentSize > *size) | ||
| 891 | kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", *size); | ||
| 892 | else | ||
| 893 | *size = presentSize; | ||
| 894 | for (unsigned int i = 0; i < *size; ++i) | ||
| 895 | { | ||
| 896 | buttons[i].id = buttonList[i].first; | ||
| 897 | strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); | ||
| 898 | } | ||
| 899 | } | ||
| 900 | } | ||
| 901 | |||
| 902 | static bool CBOnContextButton(GUIHANDLE cbhdl, int itemNumber, unsigned int button) | ||
| 903 | { | ||
| 904 | return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button); | ||
| 905 | } | ||
| 906 | }; | ||
| 907 | |||
| 908 | } /* namespace gui */ | ||
| 909 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h deleted file mode 100644 index 081ab06..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h +++ /dev/null | |||
| @@ -1,171 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CButton Control Button | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CButton } | ||
| 26 | /// **Standard push button control for window** | ||
| 27 | /// | ||
| 28 | /// The button control is used for creating push buttons in Kodi. You can | ||
| 29 | /// choose the position, size, and look of the button, as well as choosing | ||
| 30 | /// what action(s) should be performed when pushed. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Button.h "#include <kodi/gui/controls/Button.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref skin_Button_control "button control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_button( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CButton() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 78 | visible); | ||
| 79 | } | ||
| 80 | //-------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | //========================================================================== | ||
| 83 | /// | ||
| 84 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 85 | /// @brief Set's the control's enabled/disabled state | ||
| 86 | /// | ||
| 87 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 88 | /// | ||
| 89 | void SetEnabled(bool enabled) | ||
| 90 | { | ||
| 91 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 92 | enabled); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | |||
| 96 | //========================================================================== | ||
| 97 | /// | ||
| 98 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 99 | /// @brief To set the text string on button | ||
| 100 | /// | ||
| 101 | /// @param[in] label Text to show | ||
| 102 | /// | ||
| 103 | void SetLabel(const std::string& label) | ||
| 104 | { | ||
| 105 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 106 | label.c_str()); | ||
| 107 | } | ||
| 108 | //-------------------------------------------------------------------------- | ||
| 109 | |||
| 110 | //========================================================================== | ||
| 111 | /// | ||
| 112 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 113 | /// @brief Get the used text from button | ||
| 114 | /// | ||
| 115 | /// @return Text shown | ||
| 116 | /// | ||
| 117 | std::string GetLabel() const | ||
| 118 | { | ||
| 119 | std::string label; | ||
| 120 | char* ret = | ||
| 121 | m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 122 | if (ret != nullptr) | ||
| 123 | { | ||
| 124 | if (std::strlen(ret)) | ||
| 125 | label = ret; | ||
| 126 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 127 | } | ||
| 128 | return label; | ||
| 129 | } | ||
| 130 | //-------------------------------------------------------------------------- | ||
| 131 | |||
| 132 | //========================================================================== | ||
| 133 | /// | ||
| 134 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 135 | /// @brief If two labels are used for button becomes it set with them | ||
| 136 | /// | ||
| 137 | /// @param[in] label Text for second label | ||
| 138 | /// | ||
| 139 | void SetLabel2(const std::string& label) | ||
| 140 | { | ||
| 141 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, | ||
| 142 | label.c_str()); | ||
| 143 | } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// @ingroup cpp_kodi_gui_control_CButton | ||
| 149 | /// @brief Get the second label if present | ||
| 150 | /// | ||
| 151 | /// @return Second label | ||
| 152 | /// | ||
| 153 | std::string GetLabel2() const | ||
| 154 | { | ||
| 155 | std::string label; | ||
| 156 | char* ret = | ||
| 157 | m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 158 | if (ret != nullptr) | ||
| 159 | { | ||
| 160 | if (std::strlen(ret)) | ||
| 161 | label = ret; | ||
| 162 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 163 | } | ||
| 164 | return label; | ||
| 165 | } | ||
| 166 | //-------------------------------------------------------------------------- | ||
| 167 | }; | ||
| 168 | |||
| 169 | } /* namespace controls */ | ||
| 170 | } /* namespace gui */ | ||
| 171 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/CMakeLists.txt deleted file mode 100644 index c7cc1dd..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/CMakeLists.txt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | set(HEADERS Button.h | ||
| 2 | Edit.h | ||
| 3 | FadeLabel.h | ||
| 4 | Image.h | ||
| 5 | Label.h | ||
| 6 | Progress.h | ||
| 7 | RadioButton.h | ||
| 8 | Rendering.h | ||
| 9 | SettingsSlider.h | ||
| 10 | Slider.h | ||
| 11 | Spin.h | ||
| 12 | TextBox.h) | ||
| 13 | |||
| 14 | if(NOT ENABLE_STATIC_LIBS) | ||
| 15 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_controls) | ||
| 16 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h deleted file mode 100644 index 99c01de..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h +++ /dev/null | |||
| @@ -1,275 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CEdit Control Edit | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CEdit } | ||
| 26 | /// **Editable window text control used as an input control for the osd keyboard | ||
| 27 | /// and other input fields** | ||
| 28 | /// | ||
| 29 | /// The edit control allows a user to input text in Kodi. You can choose the | ||
| 30 | /// font, size, colour, location and header of the text to be displayed. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Edit.h "#include <kodi/gui/controls/Edit.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref skin_Edit_control | ||
| 36 | /// "edit control". | ||
| 37 | /// | ||
| 38 | /// @note The call of the control is only possible from the corresponding | ||
| 39 | /// window as its class and identification number is required. | ||
| 40 | /// | ||
| 41 | |||
| 42 | //============================================================================ | ||
| 43 | // see gui/definition.h for use of group "cpp_kodi_gui_controls_CEdit_Defs" | ||
| 44 | /// | ||
| 45 | /// \defgroup cpp_kodi_gui_controls_CEdit_Defs Definitions, structures and enumerators | ||
| 46 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 47 | /// @brief **Library definition values** | ||
| 48 | /// | ||
| 49 | |||
| 50 | } /* namespace controls */ | ||
| 51 | } /* namespace gui */ | ||
| 52 | } /* namespace kodi */ | ||
| 53 | |||
| 54 | //============================================================================ | ||
| 55 | /// | ||
| 56 | /// \ingroup cpp_kodi_gui_controls_CEdit_Defs | ||
| 57 | /// @{ | ||
| 58 | /// @anchor AddonGUIInputType | ||
| 59 | /// @brief Text input types used on kodi::gui::controls::CEdit | ||
| 60 | enum AddonGUIInputType | ||
| 61 | { | ||
| 62 | /// Text inside edit control only readable | ||
| 63 | ADDON_INPUT_TYPE_READONLY = -1, | ||
| 64 | /// Normal text entries | ||
| 65 | ADDON_INPUT_TYPE_TEXT = 0, | ||
| 66 | /// To use on edit control only numeric numbers | ||
| 67 | ADDON_INPUT_TYPE_NUMBER, | ||
| 68 | /// To insert seconds | ||
| 69 | ADDON_INPUT_TYPE_SECONDS, | ||
| 70 | /// To insert time | ||
| 71 | ADDON_INPUT_TYPE_TIME, | ||
| 72 | /// To insert a date | ||
| 73 | ADDON_INPUT_TYPE_DATE, | ||
| 74 | /// Used for write in IP addresses | ||
| 75 | ADDON_INPUT_TYPE_IPADDRESS, | ||
| 76 | /// Text field used as password entry field with not visible text | ||
| 77 | ADDON_INPUT_TYPE_PASSWORD, | ||
| 78 | /// Text field used as password entry field with not visible text but | ||
| 79 | /// returned as MD5 value | ||
| 80 | ADDON_INPUT_TYPE_PASSWORD_MD5, | ||
| 81 | /// Use text field for search purpose | ||
| 82 | ADDON_INPUT_TYPE_SEARCH, | ||
| 83 | /// Text field as filter | ||
| 84 | ADDON_INPUT_TYPE_FILTER, | ||
| 85 | /// | ||
| 86 | ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW | ||
| 87 | }; | ||
| 88 | /// @} | ||
| 89 | //---------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | namespace kodi | ||
| 92 | { | ||
| 93 | namespace gui | ||
| 94 | { | ||
| 95 | namespace controls | ||
| 96 | { | ||
| 97 | |||
| 98 | class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase | ||
| 99 | { | ||
| 100 | public: | ||
| 101 | //========================================================================== | ||
| 102 | /// | ||
| 103 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 104 | /// @brief Construct a new control | ||
| 105 | /// | ||
| 106 | /// @param[in] window related window control class | ||
| 107 | /// @param[in] controlId Used skin xml control id | ||
| 108 | /// | ||
| 109 | CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 110 | { | ||
| 111 | m_controlHandle = m_interface->kodi_gui->window->get_control_edit( | ||
| 112 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 113 | if (!m_controlHandle) | ||
| 114 | kodi::Log(ADDON_LOG_FATAL, | ||
| 115 | "kodi::gui::control::CEdit can't create control class from Kodi !!!"); | ||
| 116 | } | ||
| 117 | //-------------------------------------------------------------------------- | ||
| 118 | |||
| 119 | //========================================================================== | ||
| 120 | /// | ||
| 121 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 122 | /// @brief Destructor | ||
| 123 | /// | ||
| 124 | ~CEdit() override = default; | ||
| 125 | //-------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //========================================================================== | ||
| 128 | /// | ||
| 129 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 130 | /// @brief Set the control on window to visible | ||
| 131 | /// | ||
| 132 | /// @param[in] visible If true visible, otherwise hidden | ||
| 133 | /// | ||
| 134 | void SetVisible(bool visible) | ||
| 135 | { | ||
| 136 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 137 | visible); | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 144 | /// @brief Set's the control's enabled/disabled state | ||
| 145 | /// | ||
| 146 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 147 | /// | ||
| 148 | void SetEnabled(bool enabled) | ||
| 149 | { | ||
| 150 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 151 | enabled); | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 158 | /// @brief To set the text string on edit control | ||
| 159 | /// | ||
| 160 | /// @param[in] label Text to show | ||
| 161 | /// | ||
| 162 | void SetLabel(const std::string& label) | ||
| 163 | { | ||
| 164 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 165 | label.c_str()); | ||
| 166 | } | ||
| 167 | //-------------------------------------------------------------------------- | ||
| 168 | |||
| 169 | //========================================================================== | ||
| 170 | /// | ||
| 171 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 172 | /// @brief Returns the text heading for this edit control. | ||
| 173 | /// | ||
| 174 | /// @return Heading text | ||
| 175 | /// | ||
| 176 | std::string GetLabel() const | ||
| 177 | { | ||
| 178 | std::string label; | ||
| 179 | char* ret = | ||
| 180 | m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 181 | if (ret != nullptr) | ||
| 182 | { | ||
| 183 | if (std::strlen(ret)) | ||
| 184 | label = ret; | ||
| 185 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 186 | } | ||
| 187 | return label; | ||
| 188 | } | ||
| 189 | //-------------------------------------------------------------------------- | ||
| 190 | |||
| 191 | //========================================================================== | ||
| 192 | /// | ||
| 193 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 194 | /// @brief Set's text heading for this edit control. | ||
| 195 | /// | ||
| 196 | /// @param[in] text string or unicode - text string. | ||
| 197 | /// | ||
| 198 | void SetText(const std::string& text) | ||
| 199 | { | ||
| 200 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 201 | text.c_str()); | ||
| 202 | } | ||
| 203 | //-------------------------------------------------------------------------- | ||
| 204 | |||
| 205 | //========================================================================== | ||
| 206 | /// | ||
| 207 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 208 | /// @brief Returns the text value for this edit control. | ||
| 209 | /// | ||
| 210 | /// @return Text value of control | ||
| 211 | /// | ||
| 212 | std::string GetText() const | ||
| 213 | { | ||
| 214 | std::string text; | ||
| 215 | char* ret = | ||
| 216 | m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 217 | if (ret != nullptr) | ||
| 218 | { | ||
| 219 | if (std::strlen(ret)) | ||
| 220 | text = ret; | ||
| 221 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 222 | } | ||
| 223 | return text; | ||
| 224 | } | ||
| 225 | //-------------------------------------------------------------------------- | ||
| 226 | |||
| 227 | //========================================================================== | ||
| 228 | /// | ||
| 229 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 230 | /// @brief Set the cursor position on text. | ||
| 231 | /// | ||
| 232 | /// @param[in] iPosition The position to set | ||
| 233 | /// | ||
| 234 | void SetCursorPosition(unsigned int iPosition) | ||
| 235 | { | ||
| 236 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, | ||
| 237 | iPosition); | ||
| 238 | } | ||
| 239 | //-------------------------------------------------------------------------- | ||
| 240 | |||
| 241 | //========================================================================== | ||
| 242 | /// | ||
| 243 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 244 | /// @brief To get current cursor position on text field | ||
| 245 | /// | ||
| 246 | /// @return The current cursor position | ||
| 247 | /// | ||
| 248 | unsigned int GetCursorPosition() | ||
| 249 | { | ||
| 250 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, | ||
| 251 | m_controlHandle); | ||
| 252 | } | ||
| 253 | //-------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //========================================================================== | ||
| 256 | /// | ||
| 257 | /// \ingroup cpp_kodi_gui_controls_CEdit | ||
| 258 | /// @brief To set field input type which are defined on \ref AddonGUIInputType | ||
| 259 | /// | ||
| 260 | /// @param[in] type The \ref AddonGUIInputType "Add-on input type" | ||
| 261 | /// to use | ||
| 262 | /// @param[in] heading The heading text for related keyboard | ||
| 263 | /// dialog | ||
| 264 | /// | ||
| 265 | void SetInputType(AddonGUIInputType type, const std::string& heading) | ||
| 266 | { | ||
| 267 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, | ||
| 268 | static_cast<int>(type), heading.c_str()); | ||
| 269 | } | ||
| 270 | //-------------------------------------------------------------------------- | ||
| 271 | }; | ||
| 272 | |||
| 273 | } /* namespace controls */ | ||
| 274 | } /* namespace gui */ | ||
| 275 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h deleted file mode 100644 index 02c843f..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h +++ /dev/null | |||
| @@ -1,153 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CFadeLabel } | ||
| 26 | /// **Window control used to show multiple pieces of text in the same position, | ||
| 27 | /// by fading from one to the other** | ||
| 28 | /// | ||
| 29 | /// The fade label control is used for displaying multiple pieces of text in | ||
| 30 | /// the same space in Kodi. You can choose the font, size, colour, location | ||
| 31 | /// and contents of the text to be displayed. The first piece of information | ||
| 32 | /// to display fades in over 50 frames, then scrolls off to the left. Once it | ||
| 33 | /// is finished scrolling off screen, the second piece of information fades | ||
| 34 | /// in and the process repeats. A fade label control is not supported in a | ||
| 35 | /// list container. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase | ||
| 46 | { | ||
| 47 | public: | ||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 51 | /// @brief Construct a new control. | ||
| 52 | /// | ||
| 53 | /// @param[in] window related window control class | ||
| 54 | /// @param[in] controlId Used skin xml control id | ||
| 55 | /// | ||
| 56 | CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 57 | { | ||
| 58 | m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label( | ||
| 59 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 60 | if (!m_controlHandle) | ||
| 61 | kodi::Log(ADDON_LOG_FATAL, | ||
| 62 | "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); | ||
| 63 | } | ||
| 64 | //-------------------------------------------------------------------------- | ||
| 65 | |||
| 66 | //========================================================================== | ||
| 67 | /// | ||
| 68 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 69 | /// @brief Destructor. | ||
| 70 | /// | ||
| 71 | ~CFadeLabel() override = default; | ||
| 72 | //-------------------------------------------------------------------------- | ||
| 73 | |||
| 74 | //========================================================================== | ||
| 75 | /// | ||
| 76 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 77 | /// @brief Set the control on window to visible. | ||
| 78 | /// | ||
| 79 | /// @param[in] visible If true visible, otherwise hidden | ||
| 80 | /// | ||
| 81 | void SetVisible(bool visible) | ||
| 82 | { | ||
| 83 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 84 | visible); | ||
| 85 | } | ||
| 86 | //-------------------------------------------------------------------------- | ||
| 87 | |||
| 88 | //========================================================================== | ||
| 89 | /// | ||
| 90 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 91 | /// @brief To add additional text string on fade label. | ||
| 92 | /// | ||
| 93 | /// @param[in] label Text to show | ||
| 94 | /// | ||
| 95 | void AddLabel(const std::string& label) | ||
| 96 | { | ||
| 97 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, | ||
| 98 | label.c_str()); | ||
| 99 | } | ||
| 100 | //-------------------------------------------------------------------------- | ||
| 101 | |||
| 102 | //========================================================================== | ||
| 103 | /// | ||
| 104 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 105 | /// @brief Get the used text from button | ||
| 106 | /// | ||
| 107 | /// @return Text shown | ||
| 108 | /// | ||
| 109 | std::string GetLabel() const | ||
| 110 | { | ||
| 111 | std::string label; | ||
| 112 | char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, | ||
| 113 | m_controlHandle); | ||
| 114 | if (ret != nullptr) | ||
| 115 | { | ||
| 116 | if (std::strlen(ret)) | ||
| 117 | label = ret; | ||
| 118 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 119 | } | ||
| 120 | return label; | ||
| 121 | } | ||
| 122 | //-------------------------------------------------------------------------- | ||
| 123 | |||
| 124 | //========================================================================== | ||
| 125 | /// | ||
| 126 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 127 | /// @brief To enable or disable scrolling on fade label | ||
| 128 | /// | ||
| 129 | /// @param[in] scroll To enable scrolling set to true, otherwise is | ||
| 130 | /// disabled | ||
| 131 | /// | ||
| 132 | void SetScrolling(bool scroll) | ||
| 133 | { | ||
| 134 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, | ||
| 135 | scroll); | ||
| 136 | } | ||
| 137 | //-------------------------------------------------------------------------- | ||
| 138 | |||
| 139 | //========================================================================== | ||
| 140 | /// | ||
| 141 | /// \ingroup cpp_kodi_gui_controls_CFadeLabel | ||
| 142 | /// @brief To reset al inserted labels. | ||
| 143 | /// | ||
| 144 | void Reset() | ||
| 145 | { | ||
| 146 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); | ||
| 147 | } | ||
| 148 | //-------------------------------------------------------------------------- | ||
| 149 | }; | ||
| 150 | |||
| 151 | } /* namespace controls */ | ||
| 152 | } /* namespace gui */ | ||
| 153 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h deleted file mode 100644 index b4d092f..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CImage Control Image | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CImage } | ||
| 26 | /// **Window control used to show an image.** | ||
| 27 | /// | ||
| 28 | /// The image control is used for displaying images in Kodi. You can choose | ||
| 29 | /// the position, size, transparency and contents of the image to be displayed. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref Image.h "#include <kodi/gui/controls/Image.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// Here you find the needed skin part for a \ref Image_Control "image control" | ||
| 35 | /// | ||
| 36 | /// @note The call of the control is only possible from the corresponding | ||
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | ||
| 39 | class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 45 | /// @brief Construct a new control | ||
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | ||
| 50 | CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 51 | { | ||
| 52 | m_controlHandle = m_interface->kodi_gui->window->get_control_image( | ||
| 53 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, | ||
| 56 | "kodi::gui::controls::CImage can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CImage() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 78 | visible); | ||
| 79 | } | ||
| 80 | //-------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | //========================================================================== | ||
| 83 | /// | ||
| 84 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 85 | /// @brief To set the filename used on image control. | ||
| 86 | /// | ||
| 87 | /// @param[in] filename Image file to use | ||
| 88 | /// @param[in] useCache To define storage of image, default is | ||
| 89 | /// in cache, if false becomes it loaded | ||
| 90 | /// always on changes again | ||
| 91 | /// | ||
| 92 | void SetFileName(const std::string& filename, bool useCache = true) | ||
| 93 | { | ||
| 94 | m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, | ||
| 95 | filename.c_str(), useCache); | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //========================================================================== | ||
| 100 | /// | ||
| 101 | /// \ingroup cpp_kodi_gui_controls_CImage | ||
| 102 | /// @brief To set set the diffuse color on image. | ||
| 103 | /// | ||
| 104 | /// @param[in] colorDiffuse Color to use for diffuse | ||
| 105 | /// | ||
| 106 | void SetColorDiffuse(uint32_t colorDiffuse) | ||
| 107 | { | ||
| 108 | m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, | ||
| 109 | colorDiffuse); | ||
| 110 | } | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | }; | ||
| 113 | |||
| 114 | } /* namespace controls */ | ||
| 115 | } /* namespace gui */ | ||
| 116 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h deleted file mode 100644 index 82604bd..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h +++ /dev/null | |||
| @@ -1,121 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CLabel Control Label | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CLabel } | ||
| 26 | /// **Window control used to show some lines of text.** | ||
| 27 | /// | ||
| 28 | /// The label control is used for displaying text in Kodi. You can choose | ||
| 29 | /// the font, size, colour, location and contents of the text to be displayed. | ||
| 30 | /// | ||
| 31 | /// It has the header \ref Label.h "#include <kodi/gui/controls/Label.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// Here you find the needed skin part for a \ref Label_Control "label control" | ||
| 35 | /// | ||
| 36 | /// @note The call of the control is only possible from the corresponding | ||
| 37 | /// window as its class and identification number is required. | ||
| 38 | /// | ||
| 39 | class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 45 | /// @brief Construct a new control | ||
| 46 | /// | ||
| 47 | /// @param[in] window related window control class | ||
| 48 | /// @param[in] controlId Used skin xml control id | ||
| 49 | /// | ||
| 50 | CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 51 | { | ||
| 52 | m_controlHandle = m_interface->kodi_gui->window->get_control_label( | ||
| 53 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 54 | if (!m_controlHandle) | ||
| 55 | kodi::Log(ADDON_LOG_FATAL, | ||
| 56 | "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //-------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 63 | /// @brief Destructor | ||
| 64 | /// | ||
| 65 | ~CLabel() override = default; | ||
| 66 | //-------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //========================================================================== | ||
| 69 | /// | ||
| 70 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 71 | /// @brief Set the control on window to visible | ||
| 72 | /// | ||
| 73 | /// @param[in] visible If true visible, otherwise hidden | ||
| 74 | /// | ||
| 75 | void SetVisible(bool visible) | ||
| 76 | { | ||
| 77 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 78 | visible); | ||
| 79 | } | ||
| 80 | //-------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | //========================================================================== | ||
| 83 | /// | ||
| 84 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 85 | /// @brief To set the text string on label | ||
| 86 | /// | ||
| 87 | /// @param[in] text Text to show | ||
| 88 | /// | ||
| 89 | void SetLabel(const std::string& text) | ||
| 90 | { | ||
| 91 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 92 | text.c_str()); | ||
| 93 | } | ||
| 94 | //-------------------------------------------------------------------------- | ||
| 95 | |||
| 96 | //========================================================================== | ||
| 97 | /// | ||
| 98 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 99 | /// @brief Get the used text from control | ||
| 100 | /// | ||
| 101 | /// @return Used text on label control | ||
| 102 | /// | ||
| 103 | std::string GetLabel() const | ||
| 104 | { | ||
| 105 | std::string label; | ||
| 106 | char* ret = | ||
| 107 | m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 108 | if (ret != nullptr) | ||
| 109 | { | ||
| 110 | if (std::strlen(ret)) | ||
| 111 | label = ret; | ||
| 112 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 113 | } | ||
| 114 | return label; | ||
| 115 | } | ||
| 116 | //-------------------------------------------------------------------------- | ||
| 117 | }; | ||
| 118 | |||
| 119 | } /* namespace controls */ | ||
| 120 | } /* namespace gui */ | ||
| 121 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h deleted file mode 100644 index 8cb582b..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h +++ /dev/null | |||
| @@ -1,114 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CProgress } | ||
| 26 | /// **Window control to show the progress of a particular operation** | ||
| 27 | /// | ||
| 28 | /// The progress control is used to show the progress of an item that may take | ||
| 29 | /// a long time, or to show how far through a movie you are. You can choose | ||
| 30 | /// the position, size, and look of the progress control. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Progress.h "#include <kodi/gui/controls/Progress.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Progress_Control "progress control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_progress( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 62 | /// | ||
| 63 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 64 | /// @brief Destructor | ||
| 65 | /// | ||
| 66 | ~CProgress() override = default; | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | ||
| 74 | /// @param[in] visible If true visible, otherwise hidden | ||
| 75 | /// | ||
| 76 | void SetVisible(bool visible) | ||
| 77 | { | ||
| 78 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 79 | visible); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 86 | /// @brief To set Percent position of control | ||
| 87 | /// | ||
| 88 | /// @param[in] percent The percent position to use | ||
| 89 | /// | ||
| 90 | void SetPercentage(float percent) | ||
| 91 | { | ||
| 92 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, | ||
| 93 | percent); | ||
| 94 | } | ||
| 95 | //-------------------------------------------------------------------------- | ||
| 96 | |||
| 97 | //========================================================================== | ||
| 98 | /// | ||
| 99 | /// \ingroup cpp_kodi_gui_controls_CProgress | ||
| 100 | /// @brief Get the active percent position of progress bar | ||
| 101 | /// | ||
| 102 | /// @return Progress position as percent | ||
| 103 | /// | ||
| 104 | float GetPercentage() const | ||
| 105 | { | ||
| 106 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, | ||
| 107 | m_controlHandle); | ||
| 108 | } | ||
| 109 | //-------------------------------------------------------------------------- | ||
| 110 | }; | ||
| 111 | |||
| 112 | } /* namespace controls */ | ||
| 113 | } /* namespace gui */ | ||
| 114 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h deleted file mode 100644 index 305195d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h +++ /dev/null | |||
| @@ -1,167 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } | ||
| 26 | /// **Window control for a radio button (as used for on/off settings)** | ||
| 27 | /// | ||
| 28 | /// The radio button control is used for creating push button on/off settings | ||
| 29 | /// in Kodi. You can choose the position, size, and look of the button. When | ||
| 30 | /// the user clicks on the radio button, the state will change, toggling the | ||
| 31 | /// extra textures (textureradioon and textureradiooff). Used for settings | ||
| 32 | /// controls. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | //========================================================================== | ||
| 46 | /// | ||
| 47 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 48 | /// @brief Construct a new control | ||
| 49 | /// | ||
| 50 | /// @param[in] window related window control class | ||
| 51 | /// @param[in] controlId Used skin xml control id | ||
| 52 | /// | ||
| 53 | CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 54 | { | ||
| 55 | m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button( | ||
| 56 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, | ||
| 59 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 64 | /// | ||
| 65 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 66 | /// @brief Destructor | ||
| 67 | /// | ||
| 68 | ~CRadioButton() override = default; | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 74 | /// @brief Set the control on window to visible | ||
| 75 | /// | ||
| 76 | /// @param[in] visible If true visible, otherwise hidden | ||
| 77 | /// | ||
| 78 | void SetVisible(bool visible) | ||
| 79 | { | ||
| 80 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 81 | visible); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 88 | /// @brief Set's the control's enabled/disabled state | ||
| 89 | /// | ||
| 90 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 91 | /// | ||
| 92 | void SetEnabled(bool enabled) | ||
| 93 | { | ||
| 94 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 95 | enabled); | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //========================================================================== | ||
| 100 | /// | ||
| 101 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 102 | /// @brief To set the text string on radio button | ||
| 103 | /// | ||
| 104 | /// @param[in] label Text to show | ||
| 105 | /// | ||
| 106 | void SetLabel(const std::string& label) | ||
| 107 | { | ||
| 108 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 109 | label.c_str()); | ||
| 110 | } | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// | ||
| 115 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 116 | /// @brief Get the used text from control | ||
| 117 | /// | ||
| 118 | /// @return Text shown | ||
| 119 | /// | ||
| 120 | std::string GetLabel() const | ||
| 121 | { | ||
| 122 | std::string label; | ||
| 123 | char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, | ||
| 124 | m_controlHandle); | ||
| 125 | if (ret != nullptr) | ||
| 126 | { | ||
| 127 | if (std::strlen(ret)) | ||
| 128 | label = ret; | ||
| 129 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 130 | } | ||
| 131 | return label; | ||
| 132 | } | ||
| 133 | //-------------------------------------------------------------------------- | ||
| 134 | |||
| 135 | //========================================================================== | ||
| 136 | /// | ||
| 137 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 138 | /// @brief To set radio button condition to on or off | ||
| 139 | /// | ||
| 140 | /// @param[in] selected true set radio button to selection on, otherwise | ||
| 141 | /// off | ||
| 142 | /// | ||
| 143 | void SetSelected(bool selected) | ||
| 144 | { | ||
| 145 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, | ||
| 146 | m_controlHandle, selected); | ||
| 147 | } | ||
| 148 | //-------------------------------------------------------------------------- | ||
| 149 | |||
| 150 | //========================================================================== | ||
| 151 | /// | ||
| 152 | /// \ingroup cpp_kodi_gui_controls_CRadioButton | ||
| 153 | /// @brief Get the current selected condition of radio button | ||
| 154 | /// | ||
| 155 | /// @return Selected condition | ||
| 156 | /// | ||
| 157 | bool IsSelected() const | ||
| 158 | { | ||
| 159 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, | ||
| 160 | m_controlHandle); | ||
| 161 | } | ||
| 162 | //-------------------------------------------------------------------------- | ||
| 163 | }; | ||
| 164 | |||
| 165 | } /* namespace controls */ | ||
| 166 | } /* namespace gui */ | ||
| 167 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h deleted file mode 100644 index 7cc9b24..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h +++ /dev/null | |||
| @@ -1,205 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | #include "../renderHelper.h" | ||
| 14 | |||
| 15 | namespace kodi | ||
| 16 | { | ||
| 17 | namespace gui | ||
| 18 | { | ||
| 19 | namespace controls | ||
| 20 | { | ||
| 21 | |||
| 22 | //============================================================================ | ||
| 23 | /// | ||
| 24 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | ||
| 25 | /// \ingroup cpp_kodi_gui | ||
| 26 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 27 | /// **Window control for rendering own parts** | ||
| 28 | /// | ||
| 29 | /// This rendering control is used when own parts are needed. You have the | ||
| 30 | /// control over them to render direct OpenGL or DirectX content to the | ||
| 31 | /// screen set by the size of them. | ||
| 32 | /// | ||
| 33 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 34 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | ||
| 35 | /// class is used as single and not as a parent class. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //============================================================================ | ||
| 47 | /// | ||
| 48 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 49 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 50 | /// @brief **Library definition values** | ||
| 51 | /// | ||
| 52 | |||
| 53 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 54 | { | ||
| 55 | public: | ||
| 56 | //========================================================================== | ||
| 57 | /// | ||
| 58 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 59 | /// @brief Construct a new control | ||
| 60 | /// | ||
| 61 | /// @param[in] window related window control class | ||
| 62 | /// @param[in] controlId Used skin xml control id | ||
| 63 | /// | ||
| 64 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 67 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 68 | if (m_controlHandle) | ||
| 69 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 70 | m_controlHandle, this, OnCreateCB, | ||
| 71 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 72 | else | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 74 | __FUNCTION__); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CRendering() override | ||
| 84 | { | ||
| 85 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 92 | /// @brief To create rendering control on Add-on | ||
| 93 | /// | ||
| 94 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 95 | /// handled and processed from Add-on | ||
| 96 | /// | ||
| 97 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 98 | /// for calls from add-on to this function. | ||
| 99 | /// | ||
| 100 | /// @param[in] x Horizontal position | ||
| 101 | /// @param[in] y Vertical position | ||
| 102 | /// @param[in] w Width of control | ||
| 103 | /// @param[in] h Height of control | ||
| 104 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 105 | /// on Direct X is the needed device send. | ||
| 106 | /// @return Add-on needs to return true if successed, | ||
| 107 | /// otherwise false. | ||
| 108 | /// | ||
| 109 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } | ||
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | |||
| 112 | //========================================================================== | ||
| 113 | /// | ||
| 114 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 115 | /// @brief Render process call from Kodi | ||
| 116 | /// | ||
| 117 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 118 | /// for calls from add-on to this function. | ||
| 119 | /// | ||
| 120 | virtual void Render() {} | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //========================================================================== | ||
| 124 | /// | ||
| 125 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 126 | /// @brief Call from Kodi to stop rendering process | ||
| 127 | /// | ||
| 128 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 129 | /// for calls from add-on to this function. | ||
| 130 | /// | ||
| 131 | virtual void Stop() {} | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 137 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 138 | /// region. | ||
| 139 | /// | ||
| 140 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 141 | /// for calls from add-on to this function. | ||
| 142 | /// | ||
| 143 | virtual bool Dirty() { return false; } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 149 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 150 | /// @brief If the class is used independent (with "new CRendering") | ||
| 151 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 152 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 153 | /// | ||
| 154 | void SetIndependentCallbacks( | ||
| 155 | GUIHANDLE cbhdl, | ||
| 156 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device), | ||
| 157 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 158 | void (*CBStop)(GUIHANDLE cbhdl), | ||
| 159 | bool (*CBDirty)(GUIHANDLE cbhdl)) | ||
| 160 | { | ||
| 161 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 162 | { | ||
| 163 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 164 | return; | ||
| 165 | } | ||
| 166 | |||
| 167 | m_interface->kodi_gui->control_rendering->set_callbacks( | ||
| 168 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); | ||
| 169 | } | ||
| 170 | //-------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | private: | ||
| 173 | /* | ||
| 174 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 175 | * (is private)! | ||
| 176 | */ | ||
| 177 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 178 | { | ||
| 179 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 180 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 181 | } | ||
| 182 | |||
| 183 | static void OnRenderCB(void* cbhdl) | ||
| 184 | { | ||
| 185 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) | ||
| 186 | return; | ||
| 187 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 188 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 189 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 190 | } | ||
| 191 | |||
| 192 | static void OnStopCB(void* cbhdl) | ||
| 193 | { | ||
| 194 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 196 | } | ||
| 197 | |||
| 198 | static bool OnDirtyCB(void* cbhdl) { return static_cast<CRendering*>(cbhdl)->Dirty(); } | ||
| 199 | |||
| 200 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 201 | }; | ||
| 202 | |||
| 203 | } /* namespace controls */ | ||
| 204 | } /* namespace gui */ | ||
| 205 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h deleted file mode 100644 index 76a02aa..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h +++ /dev/null | |||
| @@ -1,326 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } | ||
| 26 | /// **Window control for moveable slider with text name** | ||
| 27 | /// | ||
| 28 | /// The settings slider control is used in the settings screens for when an | ||
| 29 | /// option is best specified on a sliding scale. You can choose the position, | ||
| 30 | /// size, and look of the slider control. It is basically a cross between the | ||
| 31 | /// button control and a slider control. It has a label and focus and non | ||
| 32 | /// focus textures, as well as a slider control on the right. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | //========================================================================== | ||
| 46 | /// | ||
| 47 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 48 | /// @brief Construct a new control | ||
| 49 | /// | ||
| 50 | /// @param[in] window related window control class | ||
| 51 | /// @param[in] controlId Used skin xml control id | ||
| 52 | /// | ||
| 53 | CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 54 | { | ||
| 55 | m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider( | ||
| 56 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 57 | if (!m_controlHandle) | ||
| 58 | kodi::Log(ADDON_LOG_FATAL, | ||
| 59 | "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 64 | /// | ||
| 65 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 66 | /// @brief Destructor | ||
| 67 | /// | ||
| 68 | ~CSettingsSlider() override = default; | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 74 | /// @brief Set the control on window to visible | ||
| 75 | /// | ||
| 76 | /// @param[in] visible If true visible, otherwise hidden | ||
| 77 | /// | ||
| 78 | void SetVisible(bool visible) | ||
| 79 | { | ||
| 80 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, | ||
| 81 | m_controlHandle, visible); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 88 | /// @brief Set's the control's enabled/disabled state | ||
| 89 | /// | ||
| 90 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 91 | /// | ||
| 92 | void SetEnabled(bool enabled) | ||
| 93 | { | ||
| 94 | m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, | ||
| 95 | m_controlHandle, enabled); | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //========================================================================== | ||
| 100 | /// | ||
| 101 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 102 | /// @brief To set the text string on settings slider | ||
| 103 | /// | ||
| 104 | /// @param[in] text Text to show | ||
| 105 | /// | ||
| 106 | void SetText(const std::string& text) | ||
| 107 | { | ||
| 108 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 109 | text.c_str()); | ||
| 110 | } | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// | ||
| 115 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 116 | /// @brief To reset slider on defaults | ||
| 117 | /// | ||
| 118 | void Reset() | ||
| 119 | { | ||
| 120 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); | ||
| 121 | } | ||
| 122 | //-------------------------------------------------------------------------- | ||
| 123 | |||
| 124 | //========================================================================== | ||
| 125 | /// | ||
| 126 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 127 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 128 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 129 | /// end. | ||
| 130 | /// | ||
| 131 | /// Ad default is the range from 0 to 100. | ||
| 132 | /// | ||
| 133 | /// The integer interval is as default 1 and can be changed with | ||
| 134 | /// @ref SetIntInterval. | ||
| 135 | /// | ||
| 136 | /// @param[in] start Integer start value | ||
| 137 | /// @param[in] end Integer end value | ||
| 138 | /// | ||
| 139 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 140 | /// these different values can be not together and can, therefore, only | ||
| 141 | /// one each can be used. | ||
| 142 | /// | ||
| 143 | void SetIntRange(int start, int end) | ||
| 144 | { | ||
| 145 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, | ||
| 146 | m_controlHandle, start, end); | ||
| 147 | } | ||
| 148 | //-------------------------------------------------------------------------- | ||
| 149 | |||
| 150 | //========================================================================== | ||
| 151 | /// | ||
| 152 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 153 | /// @brief Set the slider position with the given integer value. The Range | ||
| 154 | /// must be defined with a call from \ref SetIntRange before. | ||
| 155 | /// | ||
| 156 | /// @param[in] value Position in range to set with integer | ||
| 157 | /// | ||
| 158 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 159 | /// these different values ​​can be not together and can, therefore, only | ||
| 160 | /// one each can be used. | ||
| 161 | /// | ||
| 162 | void SetIntValue(int value) | ||
| 163 | { | ||
| 164 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, | ||
| 165 | m_controlHandle, value); | ||
| 166 | } | ||
| 167 | //-------------------------------------------------------------------------- | ||
| 168 | |||
| 169 | //========================================================================== | ||
| 170 | /// | ||
| 171 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 172 | /// @brief To get the current position as integer value. | ||
| 173 | /// | ||
| 174 | /// @return The position as integer | ||
| 175 | /// | ||
| 176 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 177 | /// these different values ​​can be not together and can, therefore, only | ||
| 178 | /// one each can be used. | ||
| 179 | /// | ||
| 180 | int GetIntValue() const | ||
| 181 | { | ||
| 182 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, | ||
| 183 | m_controlHandle); | ||
| 184 | } | ||
| 185 | //-------------------------------------------------------------------------- | ||
| 186 | |||
| 187 | //========================================================================== | ||
| 188 | /// | ||
| 189 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 190 | /// @brief To set the interval steps of slider, as default is it 1. If it | ||
| 191 | /// becomes changed with this function will a step of the user with the | ||
| 192 | /// value fixed here be executed. | ||
| 193 | /// | ||
| 194 | /// @param[in] interval Intervall step to set. | ||
| 195 | /// | ||
| 196 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 197 | /// these different values ​​can be not together and can, therefore, only | ||
| 198 | /// one each can be used. | ||
| 199 | /// | ||
| 200 | void SetIntInterval(int interval) | ||
| 201 | { | ||
| 202 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, | ||
| 203 | m_controlHandle, interval); | ||
| 204 | } | ||
| 205 | //-------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | //========================================================================== | ||
| 208 | /// | ||
| 209 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 210 | /// @brief Sets the percent of the slider. | ||
| 211 | /// | ||
| 212 | /// @param[in] percent float - Percent value of slide | ||
| 213 | /// | ||
| 214 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 215 | /// these different values ​​can be not together and can, therefore, only | ||
| 216 | /// one each can be used. | ||
| 217 | /// | ||
| 218 | void SetPercentage(float percent) | ||
| 219 | { | ||
| 220 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, | ||
| 221 | m_controlHandle, percent); | ||
| 222 | } | ||
| 223 | //-------------------------------------------------------------------------- | ||
| 224 | |||
| 225 | //========================================================================== | ||
| 226 | /// | ||
| 227 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 228 | /// @brief Returns a float of the percent of the slider. | ||
| 229 | /// | ||
| 230 | /// @return float - Percent of slider | ||
| 231 | /// | ||
| 232 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 233 | /// these different values ​​can be not together and can, therefore, only | ||
| 234 | /// one each can be used. | ||
| 235 | /// | ||
| 236 | float GetPercentage() const | ||
| 237 | { | ||
| 238 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, | ||
| 239 | m_controlHandle); | ||
| 240 | } | ||
| 241 | //-------------------------------------------------------------------------- | ||
| 242 | |||
| 243 | //========================================================================== | ||
| 244 | /// | ||
| 245 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 246 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | ||
| 247 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 248 | /// the end. | ||
| 249 | /// | ||
| 250 | /// As default is the range 0.0 to 1.0. | ||
| 251 | /// | ||
| 252 | /// The float interval is as default 0.1 and can be changed with | ||
| 253 | /// @ref SetFloatInterval. | ||
| 254 | /// | ||
| 255 | /// @param[in] start Integer start value | ||
| 256 | /// @param[in] end Integer end value | ||
| 257 | /// | ||
| 258 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 259 | /// these different values ​​ can be not together and can, therefore, only | ||
| 260 | /// one each can be used. | ||
| 261 | /// | ||
| 262 | void SetFloatRange(float start, float end) | ||
| 263 | { | ||
| 264 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, | ||
| 265 | m_controlHandle, start, end); | ||
| 266 | } | ||
| 267 | //-------------------------------------------------------------------------- | ||
| 268 | |||
| 269 | //========================================================================== | ||
| 270 | /// | ||
| 271 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 272 | /// @brief Set the slider position with the given float value. The Range | ||
| 273 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 274 | /// is 0.0 to 1.0. | ||
| 275 | /// | ||
| 276 | /// @param[in] value Position in range to set with float | ||
| 277 | /// | ||
| 278 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 279 | /// these different values ​​can be not together and can, therefore, only | ||
| 280 | /// one each can be used. | ||
| 281 | /// | ||
| 282 | void SetFloatValue(float value) | ||
| 283 | { | ||
| 284 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, | ||
| 285 | m_controlHandle, value); | ||
| 286 | } | ||
| 287 | //-------------------------------------------------------------------------- | ||
| 288 | |||
| 289 | //========================================================================== | ||
| 290 | /// | ||
| 291 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 292 | /// @brief To get the current position as float value. | ||
| 293 | /// | ||
| 294 | /// @return The position as float | ||
| 295 | /// | ||
| 296 | float GetFloatValue() const | ||
| 297 | { | ||
| 298 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, | ||
| 299 | m_controlHandle); | ||
| 300 | } | ||
| 301 | //-------------------------------------------------------------------------- | ||
| 302 | |||
| 303 | //========================================================================== | ||
| 304 | /// | ||
| 305 | /// \ingroup cpp_kodi_gui_controls_CSettingsSlider | ||
| 306 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 307 | /// becomes changed with this function will a step of the user with the | ||
| 308 | /// value fixed here be executed. | ||
| 309 | /// | ||
| 310 | /// @param[in] interval Intervall step to set. | ||
| 311 | /// | ||
| 312 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 313 | /// these different values ​​can be not together and can, therefore, only | ||
| 314 | /// one each can be used. | ||
| 315 | /// | ||
| 316 | void SetFloatInterval(float interval) | ||
| 317 | { | ||
| 318 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, | ||
| 319 | m_controlHandle, interval); | ||
| 320 | } | ||
| 321 | //-------------------------------------------------------------------------- | ||
| 322 | }; | ||
| 323 | |||
| 324 | } /* namespace controls */ | ||
| 325 | } /* namespace gui */ | ||
| 326 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h deleted file mode 100644 index 715cc7d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h +++ /dev/null | |||
| @@ -1,339 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSlider } | ||
| 26 | /// **Window control for moveable slider** | ||
| 27 | /// | ||
| 28 | /// The slider control is used for things where a sliding bar best represents | ||
| 29 | /// the operation at hand (such as a volume control or seek control). You can | ||
| 30 | /// choose the position, size, and look of the slider control. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref Slider.h "#include <kodi/gui/controls/Slider.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Slider_Control "slider control" | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_slider( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 62 | /// | ||
| 63 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 64 | /// @brief Destructor | ||
| 65 | /// | ||
| 66 | ~CSlider() override = default; | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | ||
| 74 | /// @param[in] visible If true visible, otherwise hidden | ||
| 75 | /// | ||
| 76 | void SetVisible(bool visible) | ||
| 77 | { | ||
| 78 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 79 | visible); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 86 | /// @brief Set's the control's enabled/disabled state | ||
| 87 | /// | ||
| 88 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 89 | /// | ||
| 90 | void SetEnabled(bool enabled) | ||
| 91 | { | ||
| 92 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 93 | enabled); | ||
| 94 | } | ||
| 95 | //-------------------------------------------------------------------------- | ||
| 96 | |||
| 97 | //========================================================================== | ||
| 98 | /// | ||
| 99 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 100 | /// @brief To reset slider on defaults | ||
| 101 | /// | ||
| 102 | void Reset() | ||
| 103 | { | ||
| 104 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); | ||
| 105 | } | ||
| 106 | //-------------------------------------------------------------------------- | ||
| 107 | |||
| 108 | //========================================================================== | ||
| 109 | /// | ||
| 110 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 111 | /// @brief With GetDescription becomes a string value of position returned. | ||
| 112 | /// | ||
| 113 | /// @return Text string about current slider position | ||
| 114 | /// | ||
| 115 | /// The following are the text definition returned from this: | ||
| 116 | /// | Value | Without range selection | With range selection | | ||
| 117 | /// |:---------:|:------------------------|:-------------------------------| | ||
| 118 | /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> | | ||
| 119 | /// | integer | <c>%i</c> | <c>[%i, %i]</c> | | ||
| 120 | /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> | | ||
| 121 | /// | ||
| 122 | std::string GetDescription() const | ||
| 123 | { | ||
| 124 | std::string text; | ||
| 125 | char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, | ||
| 126 | m_controlHandle); | ||
| 127 | if (ret != nullptr) | ||
| 128 | { | ||
| 129 | if (std::strlen(ret)) | ||
| 130 | text = ret; | ||
| 131 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 132 | } | ||
| 133 | return text; | ||
| 134 | } | ||
| 135 | //-------------------------------------------------------------------------- | ||
| 136 | |||
| 137 | //========================================================================== | ||
| 138 | /// | ||
| 139 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 140 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 141 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 142 | /// end. | ||
| 143 | /// | ||
| 144 | /// Ad default is the range from 0 to 100. | ||
| 145 | /// | ||
| 146 | /// The integer interval is as default 1 and can be changed with | ||
| 147 | /// @ref SetIntInterval. | ||
| 148 | /// | ||
| 149 | /// @param[in] start Integer start value | ||
| 150 | /// @param[in] end Integer end value | ||
| 151 | /// | ||
| 152 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 153 | /// these different values can be not together and can, therefore, only one | ||
| 154 | /// each can be used. | ||
| 155 | /// | ||
| 156 | void SetIntRange(int start, int end) | ||
| 157 | { | ||
| 158 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 159 | start, end); | ||
| 160 | } | ||
| 161 | //-------------------------------------------------------------------------- | ||
| 162 | |||
| 163 | //========================================================================== | ||
| 164 | /// | ||
| 165 | /// \ingroup CSlider | ||
| 166 | /// @brief Set the slider position with the given integer value. The Range | ||
| 167 | /// must be defined with a call from \ref SetIntRange before. | ||
| 168 | /// | ||
| 169 | /// @param[in] value Position in range to set with integer | ||
| 170 | /// | ||
| 171 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 172 | /// these different values can be not together and can, therefore, only one | ||
| 173 | /// each can be used. | ||
| 174 | /// | ||
| 175 | void SetIntValue(int value) | ||
| 176 | { | ||
| 177 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 178 | value); | ||
| 179 | } | ||
| 180 | //-------------------------------------------------------------------------- | ||
| 181 | |||
| 182 | //========================================================================== | ||
| 183 | /// | ||
| 184 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 185 | /// @brief To get the current position as integer value. | ||
| 186 | /// | ||
| 187 | /// @return The position as integer | ||
| 188 | /// | ||
| 189 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 190 | /// these different values can be not together and can, therefore, only | ||
| 191 | /// one each can be used. | ||
| 192 | /// | ||
| 193 | int GetIntValue() const | ||
| 194 | { | ||
| 195 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, | ||
| 196 | m_controlHandle); | ||
| 197 | } | ||
| 198 | //-------------------------------------------------------------------------- | ||
| 199 | |||
| 200 | //========================================================================== | ||
| 201 | /// | ||
| 202 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 203 | /// @brief To set the interval steps of slider, as default is it 1. If it | ||
| 204 | /// becomes changed with this function will a step of the user with the | ||
| 205 | /// value fixed here be executed. | ||
| 206 | /// | ||
| 207 | /// @param[in] interval Intervall step to set. | ||
| 208 | /// | ||
| 209 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 210 | /// these different values can be not together and can, therefore, only one | ||
| 211 | /// each can be used. | ||
| 212 | /// | ||
| 213 | void SetIntInterval(int interval) | ||
| 214 | { | ||
| 215 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, | ||
| 216 | interval); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 223 | /// @brief Sets the percent of the slider. | ||
| 224 | /// | ||
| 225 | /// @param[in] percent float - Percent value of slide | ||
| 226 | /// | ||
| 227 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 228 | /// these different values can be not together and can, therefore, only one | ||
| 229 | /// each can be used. | ||
| 230 | /// | ||
| 231 | void SetPercentage(float percent) | ||
| 232 | { | ||
| 233 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, | ||
| 234 | percent); | ||
| 235 | } | ||
| 236 | //-------------------------------------------------------------------------- | ||
| 237 | |||
| 238 | //========================================================================== | ||
| 239 | /// | ||
| 240 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 241 | /// @brief Returns a float of the percent of the slider. | ||
| 242 | /// | ||
| 243 | /// @return float - Percent of slider | ||
| 244 | /// | ||
| 245 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 246 | /// these different values can be not together and can, therefore, only one | ||
| 247 | /// each can be used. | ||
| 248 | /// | ||
| 249 | float GetPercentage() const | ||
| 250 | { | ||
| 251 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, | ||
| 252 | m_controlHandle); | ||
| 253 | } | ||
| 254 | //-------------------------------------------------------------------------- | ||
| 255 | |||
| 256 | //========================================================================== | ||
| 257 | /// | ||
| 258 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 259 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | ||
| 260 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 261 | /// the end. | ||
| 262 | /// | ||
| 263 | /// As default is the range 0.0 to 1.0. | ||
| 264 | /// | ||
| 265 | /// The float interval is as default 0.1 and can be changed with | ||
| 266 | /// @ref SetFloatInterval. | ||
| 267 | /// | ||
| 268 | /// @param[in] start Integer start value | ||
| 269 | /// @param[in] end Integer end value | ||
| 270 | /// | ||
| 271 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 272 | /// these different values can be not together and can, therefore, only | ||
| 273 | /// one each can be used. | ||
| 274 | /// | ||
| 275 | void SetFloatRange(float start, float end) | ||
| 276 | { | ||
| 277 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 278 | start, end); | ||
| 279 | } | ||
| 280 | //-------------------------------------------------------------------------- | ||
| 281 | |||
| 282 | //========================================================================== | ||
| 283 | /// | ||
| 284 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 285 | /// @brief Set the slider position with the given float value. The Range | ||
| 286 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 287 | /// is 0.0 to 1.0. | ||
| 288 | /// | ||
| 289 | /// @param[in] value Position in range to set with float | ||
| 290 | /// | ||
| 291 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 292 | /// these different values can be not together and can, therefore, only one | ||
| 293 | /// each can be used. | ||
| 294 | /// | ||
| 295 | void SetFloatValue(float value) | ||
| 296 | { | ||
| 297 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 298 | value); | ||
| 299 | } | ||
| 300 | //-------------------------------------------------------------------------- | ||
| 301 | |||
| 302 | //========================================================================== | ||
| 303 | /// | ||
| 304 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 305 | /// @brief To get the current position as float value. | ||
| 306 | /// | ||
| 307 | /// @return The position as float | ||
| 308 | /// | ||
| 309 | float GetFloatValue() const | ||
| 310 | { | ||
| 311 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, | ||
| 312 | m_controlHandle); | ||
| 313 | } | ||
| 314 | //-------------------------------------------------------------------------- | ||
| 315 | |||
| 316 | //========================================================================== | ||
| 317 | /// | ||
| 318 | /// \ingroup cpp_kodi_gui_controls_CSlider | ||
| 319 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 320 | /// becomes changed with this function will a step of the user with the | ||
| 321 | /// value fixed here be executed. | ||
| 322 | /// | ||
| 323 | /// @param[in] interval Intervall step to set. | ||
| 324 | /// | ||
| 325 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 326 | /// these different values can be not together and can, therefore, only | ||
| 327 | /// one each can be used. | ||
| 328 | /// | ||
| 329 | void SetFloatInterval(float interval) | ||
| 330 | { | ||
| 331 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, | ||
| 332 | m_controlHandle, interval); | ||
| 333 | } | ||
| 334 | //-------------------------------------------------------------------------- | ||
| 335 | }; | ||
| 336 | |||
| 337 | } /* namespace controls */ | ||
| 338 | } /* namespace gui */ | ||
| 339 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h deleted file mode 100644 index db8d491..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h +++ /dev/null | |||
| @@ -1,365 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CSpin Control Spin | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CSpin } | ||
| 26 | /// **Window control used for cycling up/down controls** | ||
| 27 | /// | ||
| 28 | /// The settings spin control is used in the settings screens for when a list | ||
| 29 | /// of options can be chosen from using up/down arrows. You can choose the | ||
| 30 | /// position, size, and look of the spin control. It is basically a cross | ||
| 31 | /// between the button control and a spin control. It has a label and focus | ||
| 32 | /// and non focus textures, as well as a spin control on the right. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a \ref Spin_Control "spin control" | ||
| 38 | /// | ||
| 39 | /// @note The call of the control is only possible from the corresponding | ||
| 40 | /// window as its class and identification number is required. | ||
| 41 | /// | ||
| 42 | |||
| 43 | |||
| 44 | //============================================================================ | ||
| 45 | /// | ||
| 46 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 47 | /// @anchor AddonGUISpinControlType | ||
| 48 | /// @brief The values here defines the used value format for steps on | ||
| 49 | /// spin control. | ||
| 50 | /// | ||
| 51 | typedef enum AddonGUISpinControlType | ||
| 52 | { | ||
| 53 | /// One spin step interpreted as integer | ||
| 54 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 55 | /// One spin step interpreted as floating point value | ||
| 56 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 57 | /// One spin step interpreted as text string | ||
| 58 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 59 | /// One spin step interpreted as a page change value | ||
| 60 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 61 | } AddonGUISpinControlType; | ||
| 62 | //---------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase | ||
| 65 | { | ||
| 66 | public: | ||
| 67 | //========================================================================== | ||
| 68 | /// | ||
| 69 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 70 | /// @brief Construct a new control | ||
| 71 | /// | ||
| 72 | /// @param[in] window related window control class | ||
| 73 | /// @param[in] controlId Used skin xml control id | ||
| 74 | /// | ||
| 75 | CSpin(CWindow* window, int controlId) | ||
| 76 | : CAddonGUIControlBase(window) | ||
| 77 | { | ||
| 78 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 79 | if (!m_controlHandle) | ||
| 80 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 81 | } | ||
| 82 | //-------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //========================================================================== | ||
| 85 | /// | ||
| 86 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 87 | /// @brief Destructor | ||
| 88 | /// | ||
| 89 | ~CSpin() override = default; | ||
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //========================================================================== | ||
| 93 | /// | ||
| 94 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 95 | /// @brief Set the control on window to visible | ||
| 96 | /// | ||
| 97 | /// @param[in] visible If true visible, otherwise hidden | ||
| 98 | /// | ||
| 99 | void SetVisible(bool visible) | ||
| 100 | { | ||
| 101 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 102 | } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// | ||
| 107 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 108 | /// @brief Set's the control's enabled/disabled state | ||
| 109 | /// | ||
| 110 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 111 | /// | ||
| 112 | void SetEnabled(bool enabled) | ||
| 113 | { | ||
| 114 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | ||
| 115 | } | ||
| 116 | //-------------------------------------------------------------------------- | ||
| 117 | |||
| 118 | //========================================================================== | ||
| 119 | /// | ||
| 120 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 121 | /// @brief To set the text string on spin control | ||
| 122 | /// | ||
| 123 | /// @param[in] text Text to show as name for spin | ||
| 124 | /// | ||
| 125 | void SetText(const std::string& text) | ||
| 126 | { | ||
| 127 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 134 | /// @brief To reset spin control to defaults | ||
| 135 | /// | ||
| 136 | void Reset() | ||
| 137 | { | ||
| 138 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 139 | } | ||
| 140 | //-------------------------------------------------------------------------- | ||
| 141 | |||
| 142 | //========================================================================== | ||
| 143 | /// | ||
| 144 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 145 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 146 | /// | ||
| 147 | /// @param[in] type The type to use | ||
| 148 | /// | ||
| 149 | /// @note See description of \ref AddonGUISpinControlType for available types. | ||
| 150 | /// | ||
| 151 | void SetType(AddonGUISpinControlType type) | ||
| 152 | { | ||
| 153 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, (int)type); | ||
| 154 | } | ||
| 155 | //-------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //========================================================================== | ||
| 158 | /// | ||
| 159 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 160 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 161 | /// | ||
| 162 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 163 | /// | ||
| 164 | /// @param[in] label Label string to view on skin | ||
| 165 | /// @param[in] value String value to use for selection | ||
| 166 | /// of them. | ||
| 167 | /// | ||
| 168 | void AddLabel(const std::string& label, const std::string& value) | ||
| 169 | { | ||
| 170 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value.c_str()); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 177 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 178 | /// | ||
| 179 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 180 | /// | ||
| 181 | /// @param[in] label Label string to view on skin | ||
| 182 | /// @param[in] value Integer value to use for selection | ||
| 183 | /// of them. | ||
| 184 | /// | ||
| 185 | void AddLabel(const std::string& label, int value) | ||
| 186 | { | ||
| 187 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value); | ||
| 188 | } | ||
| 189 | //-------------------------------------------------------------------------- | ||
| 190 | |||
| 191 | //========================================================================== | ||
| 192 | /// | ||
| 193 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 194 | /// @brief To change the spin to position with them string as value. | ||
| 195 | /// | ||
| 196 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 197 | /// | ||
| 198 | /// @param[in] value String value to change to | ||
| 199 | /// | ||
| 200 | void SetStringValue(const std::string& value) | ||
| 201 | { | ||
| 202 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, value.c_str()); | ||
| 203 | } | ||
| 204 | //-------------------------------------------------------------------------- | ||
| 205 | |||
| 206 | //========================================================================== | ||
| 207 | /// | ||
| 208 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 209 | /// @brief To get the current spin control position with text string value. | ||
| 210 | /// | ||
| 211 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 212 | /// | ||
| 213 | /// @return Currently selected string value | ||
| 214 | /// | ||
| 215 | std::string GetStringValue() const | ||
| 216 | { | ||
| 217 | std::string value; | ||
| 218 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, m_controlHandle); | ||
| 219 | if (ret != nullptr) | ||
| 220 | { | ||
| 221 | if (std::strlen(ret)) | ||
| 222 | value = ret; | ||
| 223 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 224 | } | ||
| 225 | return value; | ||
| 226 | } | ||
| 227 | //-------------------------------------------------------------------------- | ||
| 228 | |||
| 229 | //========================================================================== | ||
| 230 | /// | ||
| 231 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 232 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 233 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 234 | /// end. | ||
| 235 | /// | ||
| 236 | /// Ad default is the range from 0 to 100. | ||
| 237 | /// | ||
| 238 | /// @param[in] start Integer start value | ||
| 239 | /// @param[in] end Integer end value | ||
| 240 | /// | ||
| 241 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 242 | /// these different values can be not together and can, therefore, only | ||
| 243 | /// one each can be used and must be defined with \ref SetType before. | ||
| 244 | /// | ||
| 245 | void SetIntRange(int start, int end) | ||
| 246 | { | ||
| 247 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 248 | } | ||
| 249 | //-------------------------------------------------------------------------- | ||
| 250 | |||
| 251 | //========================================================================== | ||
| 252 | /// | ||
| 253 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 254 | /// @brief Set the slider position with the given integer value. The Range | ||
| 255 | /// must be defined with a call from \ref SetIntRange before. | ||
| 256 | /// | ||
| 257 | /// @param[in] value Position in range to set with integer | ||
| 258 | /// | ||
| 259 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 260 | /// these different values can be not together and can, therefore, only | ||
| 261 | /// one each can be used and must be defined with \ref SetType before. | ||
| 262 | /// | ||
| 263 | void SetIntValue(int value) | ||
| 264 | { | ||
| 265 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 266 | } | ||
| 267 | //-------------------------------------------------------------------------- | ||
| 268 | |||
| 269 | //========================================================================== | ||
| 270 | /// | ||
| 271 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 272 | /// @brief To get the current position as integer value. | ||
| 273 | /// | ||
| 274 | /// @return The position as integer | ||
| 275 | /// | ||
| 276 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 277 | /// these different values can be not together and can, therefore, only | ||
| 278 | /// one each can be used and must be defined with \ref SetType before. | ||
| 279 | /// | ||
| 280 | int GetIntValue() const | ||
| 281 | { | ||
| 282 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, m_controlHandle); | ||
| 283 | } | ||
| 284 | //-------------------------------------------------------------------------- | ||
| 285 | |||
| 286 | //========================================================================== | ||
| 287 | /// | ||
| 288 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 289 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 290 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 291 | /// the end. | ||
| 292 | /// | ||
| 293 | /// As default is the range 0.0 to 1.0. | ||
| 294 | /// | ||
| 295 | /// The float interval is as default 0.1 and can be changed with | ||
| 296 | /// @ref SetFloatInterval. | ||
| 297 | /// | ||
| 298 | /// @param[in] start Integer start value | ||
| 299 | /// @param[in] end Integer end value | ||
| 300 | /// | ||
| 301 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 302 | /// these different values can be not together and can, therefore, only | ||
| 303 | /// one each can be used and must be defined with \ref SetType before. | ||
| 304 | /// | ||
| 305 | void SetFloatRange(float start, float end) | ||
| 306 | { | ||
| 307 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 308 | } | ||
| 309 | //-------------------------------------------------------------------------- | ||
| 310 | |||
| 311 | //========================================================================== | ||
| 312 | /// | ||
| 313 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 314 | /// @brief Set the spin position with the given float value. The Range | ||
| 315 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 316 | /// is 0.0 to 1.0. | ||
| 317 | /// | ||
| 318 | /// @param[in] value Position in range to set with float | ||
| 319 | /// | ||
| 320 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 321 | /// these different values can be not together and can, therefore, only | ||
| 322 | /// one each can be used and must be defined with \ref SetType before. | ||
| 323 | /// | ||
| 324 | void SetFloatValue(float value) | ||
| 325 | { | ||
| 326 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 327 | } | ||
| 328 | //-------------------------------------------------------------------------- | ||
| 329 | |||
| 330 | //========================================================================== | ||
| 331 | /// | ||
| 332 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 333 | /// @brief To get the current position as float value. | ||
| 334 | /// | ||
| 335 | /// @return The position as float | ||
| 336 | /// | ||
| 337 | float GetFloatValue() const | ||
| 338 | { | ||
| 339 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, m_controlHandle); | ||
| 340 | } | ||
| 341 | //-------------------------------------------------------------------------- | ||
| 342 | |||
| 343 | //========================================================================== | ||
| 344 | /// | ||
| 345 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 346 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 347 | /// becomes changed with this function will a step of the user with the | ||
| 348 | /// value fixed here be executed. | ||
| 349 | /// | ||
| 350 | /// @param[in] interval Intervall step to set. | ||
| 351 | /// | ||
| 352 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 353 | /// these different values can be not together and can, therefore, only | ||
| 354 | /// one each can be used and must be defined with \ref SetType before. | ||
| 355 | /// | ||
| 356 | void SetFloatInterval(float interval) | ||
| 357 | { | ||
| 358 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); | ||
| 359 | } | ||
| 360 | //-------------------------------------------------------------------------- | ||
| 361 | }; | ||
| 362 | |||
| 363 | } /* namespace controls */ | ||
| 364 | } /* namespace gui */ | ||
| 365 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h deleted file mode 100644 index b4e8ae0..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace controls | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CTextBox } | ||
| 26 | /// **Used to show a multi-page piece of text** | ||
| 27 | /// | ||
| 28 | /// The text box control can be used to display descriptions, help texts or | ||
| 29 | /// other larger texts. It corresponds to the representation which is also to | ||
| 30 | /// be seen on the CDialogTextViewer. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | /// Here you find the needed skin part for a \ref Text_Box "textbox control". | ||
| 36 | /// | ||
| 37 | /// @note The call of the control is only possible from the corresponding | ||
| 38 | /// window as its class and identification number is required. | ||
| 39 | /// | ||
| 40 | class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase | ||
| 41 | { | ||
| 42 | public: | ||
| 43 | //========================================================================== | ||
| 44 | /// | ||
| 45 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 46 | /// @brief Construct a new control | ||
| 47 | /// | ||
| 48 | /// @param[in] window related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_text_box( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //-------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //========================================================================== | ||
| 62 | /// | ||
| 63 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 64 | /// @brief Destructor | ||
| 65 | /// | ||
| 66 | ~CTextBox() override = default; | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 72 | /// @brief Set the control on window to visible | ||
| 73 | /// | ||
| 74 | /// @param[in] visible If true visible, otherwise hidden | ||
| 75 | /// | ||
| 76 | void SetVisible(bool visible) | ||
| 77 | { | ||
| 78 | m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 79 | visible); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 86 | /// @brief To reset box an remove all the text | ||
| 87 | /// | ||
| 88 | void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } | ||
| 89 | //-------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //========================================================================== | ||
| 92 | /// | ||
| 93 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 94 | /// @brief To set the text on box | ||
| 95 | /// | ||
| 96 | /// @param[in] text Text to show | ||
| 97 | /// | ||
| 98 | void SetText(const std::string& text) | ||
| 99 | { | ||
| 100 | m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 101 | text.c_str()); | ||
| 102 | } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// | ||
| 107 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 108 | /// @brief Get the used text from control | ||
| 109 | /// | ||
| 110 | /// @return Text shown | ||
| 111 | /// | ||
| 112 | std::string GetText() const | ||
| 113 | { | ||
| 114 | std::string text; | ||
| 115 | char* ret = | ||
| 116 | m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 117 | if (ret != nullptr) | ||
| 118 | { | ||
| 119 | if (std::strlen(ret)) | ||
| 120 | text = ret; | ||
| 121 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 122 | } | ||
| 123 | return text; | ||
| 124 | } | ||
| 125 | //-------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //========================================================================== | ||
| 128 | /// | ||
| 129 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 130 | /// @brief To scroll text on other position | ||
| 131 | /// | ||
| 132 | /// @param[in] position The line position to scroll to | ||
| 133 | /// | ||
| 134 | void Scroll(unsigned int position) | ||
| 135 | { | ||
| 136 | m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, | ||
| 137 | position); | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_controls_CTextBox | ||
| 144 | /// @brief To set automatic scrolling of textbox | ||
| 145 | /// | ||
| 146 | /// Specifies the timing and conditions of any autoscrolling this textbox | ||
| 147 | /// should have. Times are in milliseconds. The content is delayed for the | ||
| 148 | /// given delay, then scrolls at a rate of one line per time interval until | ||
| 149 | /// the end. If the repeat tag is present, it then delays for the repeat | ||
| 150 | /// time, fades out over 1 second, and repeats. It does not wrap or reset | ||
| 151 | /// to the top at the end of the scroll. | ||
| 152 | /// | ||
| 153 | /// @param[in] delay Content delay | ||
| 154 | /// @param[in] time One line per time interval | ||
| 155 | /// @param[in] repeat Delays with given time, fades out over 1 | ||
| 156 | /// second, and repeats | ||
| 157 | /// | ||
| 158 | void SetAutoScrolling(int delay, int time, int repeat) | ||
| 159 | { | ||
| 160 | m_interface->kodi_gui->control_text_box->set_auto_scrolling( | ||
| 161 | m_interface->kodiBase, m_controlHandle, delay, time, repeat); | ||
| 162 | } | ||
| 163 | //-------------------------------------------------------------------------- | ||
| 164 | }; | ||
| 165 | |||
| 166 | } /* namespace controls */ | ||
| 167 | } /* namespace gui */ | ||
| 168 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h deleted file mode 100644 index 4eb64c7..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h +++ /dev/null | |||
| @@ -1,433 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 <string> | ||
| 12 | #include <time.h> | ||
| 13 | |||
| 14 | /* | ||
| 15 | * Internal Structures to have "C"-Style data transfer | ||
| 16 | */ | ||
| 17 | extern "C" | ||
| 18 | { | ||
| 19 | |||
| 20 | typedef struct AddonToKodiFuncTable_kodi_gui_general | ||
| 21 | { | ||
| 22 | void (*lock)(); | ||
| 23 | void (*unlock)(); | ||
| 24 | int (*get_screen_height)(void* kodiBase); | ||
| 25 | int (*get_screen_width)(void* kodiBase); | ||
| 26 | int (*get_video_resolution)(void* kodiBase); | ||
| 27 | int (*get_current_window_dialog_id)(void* kodiBase); | ||
| 28 | int (*get_current_window_id)(void* kodiBase); | ||
| 29 | void* (*get_hw_context)(void* kodiBase); | ||
| 30 | } AddonToKodiFuncTable_kodi_gui_general; | ||
| 31 | |||
| 32 | typedef struct AddonToKodiFuncTable_kodi_gui_control_button | ||
| 33 | { | ||
| 34 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 35 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 36 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 37 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 38 | void (*set_label2)(void* kodiBase, void* handle, const char *label); | ||
| 39 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 40 | } AddonToKodiFuncTable_kodi_gui_control_button; | ||
| 41 | |||
| 42 | typedef struct AddonToKodiFuncTable_kodi_gui_control_edit | ||
| 43 | { | ||
| 44 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 45 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 46 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 47 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 48 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 49 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 50 | void (*set_cursor_position)(void* kodiBase, void* handle, unsigned int position); | ||
| 51 | unsigned int (*get_cursor_position)(void* kodiBase, void* handle); | ||
| 52 | void (*set_input_type)(void* kodiBase, void* handle, int type, const char* heading); | ||
| 53 | } AddonToKodiFuncTable_kodi_gui_control_edit; | ||
| 54 | |||
| 55 | typedef struct AddonToKodiFuncTable_kodi_gui_control_fade_label | ||
| 56 | { | ||
| 57 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 58 | void (*add_label)(void* kodiBase, void* handle, const char* text); | ||
| 59 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 60 | void (*set_scrolling)(void* kodiBase, void* handle, bool scroll); | ||
| 61 | void (*reset)(void* kodiBase, void* handle); | ||
| 62 | } AddonToKodiFuncTable_kodi_gui_control_fade_label; | ||
| 63 | |||
| 64 | typedef struct AddonToKodiFuncTable_kodi_gui_control_image | ||
| 65 | { | ||
| 66 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 67 | void (*set_filename)(void* kodiBase, void* handle, const char* filename, bool use_cache); | ||
| 68 | void (*set_color_diffuse)(void* kodiBase, void* handle, uint32_t color_diffuse); | ||
| 69 | } AddonToKodiFuncTable_kodi_gui_control_image; | ||
| 70 | |||
| 71 | typedef struct AddonToKodiFuncTable_kodi_gui_control_label | ||
| 72 | { | ||
| 73 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 74 | void (*set_label)(void* kodiBase, void* handle, const char* text); | ||
| 75 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 76 | } AddonToKodiFuncTable_kodi_gui_control_label; | ||
| 77 | |||
| 78 | typedef struct AddonToKodiFuncTable_kodi_gui_control_progress | ||
| 79 | { | ||
| 80 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 81 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 82 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 83 | } AddonToKodiFuncTable_kodi_gui_control_progress; | ||
| 84 | |||
| 85 | typedef struct AddonToKodiFuncTable_kodi_gui_control_radio_button | ||
| 86 | { | ||
| 87 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 88 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 89 | void (*set_label)(void* kodiBase, void* handle, const char* text); | ||
| 90 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 91 | void (*set_selected)(void* kodiBase, void* handle, bool selected); | ||
| 92 | bool (*is_selected)(void* kodiBase, void* handle); | ||
| 93 | } AddonToKodiFuncTable_kodi_gui_control_radio_button; | ||
| 94 | |||
| 95 | typedef struct AddonToKodiFuncTable_kodi_gui_control_rendering | ||
| 96 | { | ||
| 97 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 98 | bool (*createCB)(void*,int,int,int,int,void*), | ||
| 99 | void (*renderCB)(void*), | ||
| 100 | void (*stopCB)(void*), | ||
| 101 | bool (*dirtyCB)(void*)); | ||
| 102 | void (*destroy)(void *kodiBase, void* handle); | ||
| 103 | } AddonToKodiFuncTable_kodi_gui_control_rendering; | ||
| 104 | |||
| 105 | typedef struct AddonToKodiFuncTable_kodi_gui_control_settings_slider | ||
| 106 | { | ||
| 107 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 108 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 109 | void (*set_text)(void* kodiBase, void* handle, const char* label); | ||
| 110 | void (*reset)(void* kodiBase, void* handle); | ||
| 111 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 112 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 113 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 114 | void (*set_int_interval)(void* kodiBase, void* handle, int interval); | ||
| 115 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 116 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 117 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 118 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 119 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 120 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 121 | } AddonToKodiFuncTable_kodi_gui_control_settings_slider; | ||
| 122 | |||
| 123 | typedef struct AddonToKodiFuncTable_kodi_gui_control_slider | ||
| 124 | { | ||
| 125 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 126 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 127 | void (*reset)(void* kodiBase, void* handle); | ||
| 128 | char* (*get_description)(void* kodiBase, void* handle); | ||
| 129 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 130 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 131 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 132 | void (*set_int_interval)(void* kodiBase, void* handle, int interval); | ||
| 133 | void (*set_percentage)(void* kodiBase, void* handle, float percent); | ||
| 134 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 135 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 136 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 137 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 138 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 139 | } AddonToKodiFuncTable_kodi_gui_control_slider; | ||
| 140 | |||
| 141 | typedef struct AddonToKodiFuncTable_kodi_gui_control_spin | ||
| 142 | { | ||
| 143 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 144 | void (*set_enabled)(void* kodiBase, void* handle, bool enabled); | ||
| 145 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 146 | void (*reset)(void* kodiBase, void* handle); | ||
| 147 | void (*set_type)(void* kodiBase, void* handle, int type); | ||
| 148 | void (*add_string_label)(void* kodiBase, void* handle, const char* label, const char* value); | ||
| 149 | void (*set_string_value)(void* kodiBase, void* handle, const char* value); | ||
| 150 | char* (*get_string_value)(void* kodiBase, void* handle); | ||
| 151 | void (*add_int_label)(void* kodiBase, void* handle, const char* label, int value); | ||
| 152 | void (*set_int_range)(void* kodiBase, void* handle, int start, int end); | ||
| 153 | void (*set_int_value)(void* kodiBase, void* handle, int value); | ||
| 154 | int (*get_int_value)(void* kodiBase, void* handle); | ||
| 155 | void (*set_float_range)(void* kodiBase, void* handle, float start, float end); | ||
| 156 | void (*set_float_value)(void* kodiBase, void* handle, float value); | ||
| 157 | float (*get_float_value)(void* kodiBase, void* handle); | ||
| 158 | void (*set_float_interval)(void* kodiBase, void* handle, float interval); | ||
| 159 | } AddonToKodiFuncTable_kodi_gui_control_spin; | ||
| 160 | |||
| 161 | typedef struct AddonToKodiFuncTable_kodi_gui_control_text_box | ||
| 162 | { | ||
| 163 | void (*set_visible)(void* kodiBase, void* handle, bool visible); | ||
| 164 | void (*reset)(void* kodiBase, void* handle); | ||
| 165 | void (*set_text)(void* kodiBase, void* handle, const char* text); | ||
| 166 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 167 | void (*scroll)(void* kodiBase, void* handle, unsigned int scroll); | ||
| 168 | void (*set_auto_scrolling)(void* kodiBase, void* handle, int delay, int time, int repeat); | ||
| 169 | } AddonToKodiFuncTable_kodi_gui_control_text_box; | ||
| 170 | |||
| 171 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu | ||
| 172 | { | ||
| 173 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); | ||
| 174 | } AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 175 | |||
| 176 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress | ||
| 177 | { | ||
| 178 | void* (*new_dialog)(void* kodiBase, const char *title); | ||
| 179 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 180 | char* (*get_title)(void* kodiBase, void* handle); | ||
| 181 | void (*set_title)(void* kodiBase, void* handle, const char *title); | ||
| 182 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 183 | void (*set_text)(void* kodiBase, void* handle, const char *text); | ||
| 184 | bool (*is_finished)(void* kodiBase, void* handle); | ||
| 185 | void (*mark_finished)(void* kodiBase, void* handle); | ||
| 186 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 187 | void (*set_percentage)(void* kodiBase, void* handle, float percentage); | ||
| 188 | void (*set_progress)(void* kodiBase, void* handle, int currentItem, int itemCount); | ||
| 189 | } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 190 | |||
| 191 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | ||
| 192 | { | ||
| 193 | bool (*show_and_get_directory)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out, bool writeOnly); | ||
| 194 | bool (*show_and_get_file)(void* kodiBase, const char* shares, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories); | ||
| 195 | bool (*show_and_get_file_from_dir)(void* kodiBase, const char* directory, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories, bool singleList); | ||
| 196 | bool (*show_and_get_file_list)(void* kodiBase, const char* shares, const char* mask, const char* heading, char*** file_list, unsigned int* entries, bool use_thumbs, bool use_file_directories); | ||
| 197 | bool (*show_and_get_source)(void* kodiBase, const char* path_in, char** path_out, bool allow_network_shares, const char* additional_share, const char* type); | ||
| 198 | bool (*show_and_get_image)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out); | ||
| 199 | bool (*show_and_get_image_list)(void* kodiBase, const char* shares, const char* heading, char*** file_list, unsigned int* entries); | ||
| 200 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); | ||
| 201 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 202 | |||
| 203 | // typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString); | ||
| 204 | |||
| 205 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | ||
| 206 | { | ||
| 207 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); | ||
| 208 | bool (*show_and_get_input)(void* kodiBase, const char* text_in, char** text_out, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 209 | bool (*show_and_get_new_password_with_head)(void* kodiBase, const char* password_in, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 210 | bool (*show_and_get_new_password)(void* kodiBase, const char* password_in, char** password_out, unsigned int auto_close_ms); | ||
| 211 | bool (*show_and_verify_new_password_with_head)(void* kodiBase, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 212 | bool (*show_and_verify_new_password)(void* kodiBase, char** password_out, unsigned int auto_close_ms); | ||
| 213 | int (*show_and_verify_password)(void* kodiBase, const char* password_in, char** password_out, const char* heading, int retries, unsigned int auto_close_ms); | ||
| 214 | bool (*show_and_get_filter)(void* kodiBase, const char* text_in, char** text_out, bool searching, unsigned int auto_close_ms); | ||
| 215 | bool (*send_text_to_active_keyboard)(void* kodiBase, const char* text, bool close_keyboard); | ||
| 216 | bool (*is_keyboard_activated)(void* kodiBase); | ||
| 217 | } AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 218 | |||
| 219 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric | ||
| 220 | { | ||
| 221 | bool (*show_and_verify_new_password)(void* kodiBase, char** password); | ||
| 222 | int (*show_and_verify_password)(void* kodiBase, const char* password, const char *heading, int retries); | ||
| 223 | bool (*show_and_verify_input)(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input); | ||
| 224 | bool (*show_and_get_time)(void* kodiBase, tm *time, const char *heading); | ||
| 225 | bool (*show_and_get_date)(void* kodiBase, tm *date, const char *heading); | ||
| 226 | bool (*show_and_get_ip_address)(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading); | ||
| 227 | bool (*show_and_get_number)(void* kodiBase, const char* input_in, char** input_out, const char *heading, unsigned int auto_close_ms); | ||
| 228 | bool (*show_and_get_seconds)(void* kodiBase, const char* time_in, char** time_out, const char *heading); | ||
| 229 | } AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 230 | |||
| 231 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK | ||
| 232 | { | ||
| 233 | void (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text); | ||
| 234 | void (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 235 | } AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 236 | |||
| 237 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress | ||
| 238 | { | ||
| 239 | void* (*new_dialog)(void* kodiBase); | ||
| 240 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 241 | void (*open)(void* kodiBase, void* handle); | ||
| 242 | void (*set_heading)(void* kodiBase, void* handle, const char* heading); | ||
| 243 | void (*set_line)(void* kodiBase, void* handle, unsigned int lineNo, const char* line); | ||
| 244 | void (*set_can_cancel)(void* kodiBase, void* handle, bool canCancel); | ||
| 245 | bool (*is_canceled)(void* kodiBase, void* handle); | ||
| 246 | void (*set_percentage)(void* kodiBase, void* handle, int percentage); | ||
| 247 | int (*get_percentage)(void* kodiBase, void* handle); | ||
| 248 | void (*show_progress_bar)(void* kodiBase, void* handle, bool pnOff); | ||
| 249 | void (*set_progress_max)(void* kodiBase, void* handle, int max); | ||
| 250 | void (*set_progress_advance)(void* kodiBase, void* handle, int nSteps); | ||
| 251 | bool (*abort)(void* kodiBase, void* handle); | ||
| 252 | } AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 253 | |||
| 254 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect | ||
| 255 | { | ||
| 256 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, unsigned int autoclose); | ||
| 257 | bool (*open_multi_select)(void* kodiBase, const char* heading, const char* entryIDs[], const char* entryNames[], | ||
| 258 | bool entriesSelected[], unsigned int size, unsigned int autoclose); | ||
| 259 | } AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 260 | |||
| 261 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer | ||
| 262 | { | ||
| 263 | void (*open)(void* kodiBase, const char *heading, const char *text); | ||
| 264 | } AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 265 | |||
| 266 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo | ||
| 267 | { | ||
| 268 | bool (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 269 | bool (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 270 | bool (*show_and_get_input_line_button_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 271 | } AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 272 | |||
| 273 | typedef struct AddonToKodiFuncTable_kodi_gui_listItem | ||
| 274 | { | ||
| 275 | void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* path); | ||
| 276 | void (*destroy)(void* kodiBase, void* handle); | ||
| 277 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 278 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 279 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 280 | void (*set_label2)(void* kodiBase, void* handle, const char* label); | ||
| 281 | char* (*get_art)(void* kodiBase, void* handle, const char* type); | ||
| 282 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); | ||
| 283 | char* (*get_path)(void* kodiBase, void* handle); | ||
| 284 | void (*set_path)(void* kodiBase, void* handle, const char* path); | ||
| 285 | char* (*get_property)(void* kodiBase, void* handle, const char* key); | ||
| 286 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 287 | void (*select)(void* kodiBase, void* handle, bool select); | ||
| 288 | bool (*is_selected)(void* kodiBase, void* handle); | ||
| 289 | } AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 290 | |||
| 291 | #define ADDON_MAX_CONTEXT_ENTRIES 20 | ||
| 292 | #define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 | ||
| 293 | typedef struct gui_context_menu_pair | ||
| 294 | { | ||
| 295 | unsigned int id; | ||
| 296 | char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; | ||
| 297 | } gui_context_menu_pair; | ||
| 298 | |||
| 299 | typedef struct AddonToKodiFuncTable_kodi_gui_window | ||
| 300 | { | ||
| 301 | /* Window creation functions */ | ||
| 302 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); | ||
| 303 | void (*destroy)(void* kodiBase, void* handle); | ||
| 304 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 305 | bool (*CBInit)(void*), | ||
| 306 | bool (*CBFocus)(void*, int), | ||
| 307 | bool (*CBClick)(void*, int), | ||
| 308 | bool (*CBOnAction)(void*, int, uint32_t, wchar_t), | ||
| 309 | void (*CBGetContextButtons)(void*, int, gui_context_menu_pair*, unsigned int*), | ||
| 310 | bool (*CBOnContextButton)(void*, int, unsigned int)); | ||
| 311 | bool (*show)(void* kodiBase, void* handle); | ||
| 312 | bool (*close)(void* kodiBase, void* handle); | ||
| 313 | bool (*do_modal)(void* kodiBase, void* handle); | ||
| 314 | |||
| 315 | /* Window control functions */ | ||
| 316 | bool (*set_focus_id)(void* kodiBase, void* handle, int control_id); | ||
| 317 | int (*get_focus_id)(void* kodiBase, void* handle); | ||
| 318 | void (*set_control_label)(void* kodiBase, void* handle, int control_id, const char* label); | ||
| 319 | void (*set_control_visible)(void* kodiBase, void* handle, int control_id, bool visible); | ||
| 320 | void (*set_control_selected)(void* kodiBase, void* handle, int control_id, bool selected); | ||
| 321 | |||
| 322 | /* Window property functions */ | ||
| 323 | void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 324 | void (*set_property_int)(void* kodiBase, void* handle, const char* key, int value); | ||
| 325 | void (*set_property_bool)(void* kodiBase, void* handle, const char* key, bool value); | ||
| 326 | void (*set_property_double)(void* kodiBase, void* handle, const char* key, double value); | ||
| 327 | char* (*get_property)(void* kodiBase, void* handle, const char* key); | ||
| 328 | int (*get_property_int)(void* kodiBase, void* handle, const char* key); | ||
| 329 | bool (*get_property_bool)(void* kodiBase, void* handle, const char* key); | ||
| 330 | double (*get_property_double)(void* kodiBase, void* handle, const char* key); | ||
| 331 | void (*clear_properties)(void* kodiBase, void* handle); | ||
| 332 | void (*clear_property)(void* kodiBase, void* handle, const char* key); | ||
| 333 | |||
| 334 | /* List item functions */ | ||
| 335 | void (*clear_item_list)(void* kodiBase, void* handle); | ||
| 336 | void (*add_list_item)(void* kodiBase, void* handle, void* item, int list_position); | ||
| 337 | void (*remove_list_item_from_position)(void* kodiBase, void* handle, int list_position); | ||
| 338 | void (*remove_list_item)(void* kodiBase, void* handle, void* item); | ||
| 339 | void* (*get_list_item)(void* kodiBase, void* handle, int list_position); | ||
| 340 | void (*set_current_list_position)(void* kodiBase, void* handle, int list_position); | ||
| 341 | int (*get_current_list_position)(void* kodiBase, void* handle); | ||
| 342 | int (*get_list_size)(void* kodiBase, void* handle); | ||
| 343 | void (*set_container_property)(void* kodiBase, void* handle, const char* key, const char* value); | ||
| 344 | void (*set_container_content)(void* kodiBase, void* handle, const char* value); | ||
| 345 | int (*get_current_container_id)(void* kodiBase, void* handle); | ||
| 346 | |||
| 347 | /* Various functions */ | ||
| 348 | void (*mark_dirty_region)(void* kodiBase, void* handle); | ||
| 349 | |||
| 350 | /* GUI control access functions */ | ||
| 351 | void* (*get_control_button)(void* kodiBase, void* handle, int control_id); | ||
| 352 | void* (*get_control_edit)(void* kodiBase, void* handle, int control_id); | ||
| 353 | void* (*get_control_fade_label)(void* kodiBase, void* handle, int control_id); | ||
| 354 | void* (*get_control_image)(void* kodiBase, void* handle, int control_id); | ||
| 355 | void* (*get_control_label)(void* kodiBase, void* handle, int control_id); | ||
| 356 | void* (*get_control_progress)(void* kodiBase, void* handle, int control_id); | ||
| 357 | void* (*get_control_radio_button)(void* kodiBase, void* handle, int control_id); | ||
| 358 | void* (*get_control_render_addon)(void* kodiBase, void* handle, int control_id); | ||
| 359 | void* (*get_control_settings_slider)(void* kodiBase, void* handle, int control_id); | ||
| 360 | void* (*get_control_slider)(void* kodiBase, void* handle, int control_id); | ||
| 361 | void* (*get_control_spin)(void* kodiBase, void* handle, int control_id); | ||
| 362 | void* (*get_control_text_box)(void* kodiBase, void* handle, int control_id); | ||
| 363 | void* (*get_control_dummy1)(void* kodiBase, void* handle, int control_id); | ||
| 364 | void* (*get_control_dummy2)(void* kodiBase, void* handle, int control_id); | ||
| 365 | void* (*get_control_dummy3)(void* kodiBase, void* handle, int control_id); | ||
| 366 | void* (*get_control_dummy4)(void* kodiBase, void* handle, int control_id); | ||
| 367 | void* (*get_control_dummy5)(void* kodiBase, void* handle, int control_id); | ||
| 368 | void* (*get_control_dummy6)(void* kodiBase, void* handle, int control_id); | ||
| 369 | void* (*get_control_dummy7)(void* kodiBase, void* handle, int control_id); | ||
| 370 | void* (*get_control_dummy8)(void* kodiBase, void* handle, int control_id); | ||
| 371 | void* (*get_control_dummy9)(void* kodiBase, void* handle, int control_id); | ||
| 372 | void* (*get_control_dummy10)(void* kodiBase, void* handle, int control_id); /* This and above used to add new get_control_* functions */ | ||
| 373 | } AddonToKodiFuncTable_kodi_gui_window; | ||
| 374 | |||
| 375 | typedef struct AddonToKodiFuncTable_kodi_gui | ||
| 376 | { | ||
| 377 | AddonToKodiFuncTable_kodi_gui_general* general; | ||
| 378 | AddonToKodiFuncTable_kodi_gui_control_button* control_button; | ||
| 379 | AddonToKodiFuncTable_kodi_gui_control_edit* control_edit; | ||
| 380 | AddonToKodiFuncTable_kodi_gui_control_fade_label* control_fade_label; | ||
| 381 | AddonToKodiFuncTable_kodi_gui_control_label* control_label; | ||
| 382 | AddonToKodiFuncTable_kodi_gui_control_image* control_image; | ||
| 383 | AddonToKodiFuncTable_kodi_gui_control_progress* control_progress; | ||
| 384 | AddonToKodiFuncTable_kodi_gui_control_radio_button* control_radio_button; | ||
| 385 | AddonToKodiFuncTable_kodi_gui_control_rendering* control_rendering; | ||
| 386 | AddonToKodiFuncTable_kodi_gui_control_settings_slider* control_settings_slider; | ||
| 387 | AddonToKodiFuncTable_kodi_gui_control_slider* control_slider; | ||
| 388 | AddonToKodiFuncTable_kodi_gui_control_spin* control_spin; | ||
| 389 | AddonToKodiFuncTable_kodi_gui_control_text_box* control_text_box; | ||
| 390 | void* control_dummy1; | ||
| 391 | void* control_dummy2; | ||
| 392 | void* control_dummy3; | ||
| 393 | void* control_dummy4; | ||
| 394 | void* control_dummy5; | ||
| 395 | void* control_dummy6; | ||
| 396 | void* control_dummy7; | ||
| 397 | void* control_dummy8; | ||
| 398 | void* control_dummy9; | ||
| 399 | void* control_dummy10; /* This and above used to add new controls */ | ||
| 400 | AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; | ||
| 401 | AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; | ||
| 402 | AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; | ||
| 403 | AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; | ||
| 404 | AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; | ||
| 405 | AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; | ||
| 406 | AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; | ||
| 407 | AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; | ||
| 408 | AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; | ||
| 409 | AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; | ||
| 410 | void* dialog_dummy1; | ||
| 411 | void* dialog_dummy2; | ||
| 412 | void* dialog_dummy3; | ||
| 413 | void* dialog_dummy4; | ||
| 414 | void* dialog_dummy5; | ||
| 415 | void* dialog_dummy6; | ||
| 416 | void* dialog_dummy7; | ||
| 417 | void* dialog_dummy8; | ||
| 418 | void* dialog_dummy9; | ||
| 419 | void* dialog_dummy10; /* This and above used to add new dialogs */ | ||
| 420 | AddonToKodiFuncTable_kodi_gui_listItem* listItem; | ||
| 421 | AddonToKodiFuncTable_kodi_gui_window* window; | ||
| 422 | } AddonToKodiFuncTable_kodi_gui; | ||
| 423 | |||
| 424 | } /* extern "C" */ | ||
| 425 | |||
| 426 | //============================================================================ | ||
| 427 | /// | ||
| 428 | /// \ingroup cpp_kodi_gui_CControlRendering_Defs cpp_kodi_gui_CWindow_Defs | ||
| 429 | /// @{ | ||
| 430 | /// @brief Handle to use as independent pointer for GUI | ||
| 431 | typedef void* GUIHANDLE; | ||
| 432 | /// @} | ||
| 433 | //---------------------------------------------------------------------------- | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt deleted file mode 100644 index 7227343..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | set(HEADERS ContextMenu.h | ||
| 2 | ExtendedProgress.h | ||
| 3 | FileBrowser.h | ||
| 4 | Keyboard.h | ||
| 5 | Numeric.h | ||
| 6 | OK.h | ||
| 7 | Progress.h | ||
| 8 | Select.h | ||
| 9 | TextViewer.h | ||
| 10 | YesNo.h) | ||
| 11 | |||
| 12 | if(NOT ENABLE_STATIC_LIBS) | ||
| 13 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_dialogs) | ||
| 14 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h deleted file mode 100644 index d545030..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h +++ /dev/null | |||
| @@ -1,185 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu } | ||
| 26 | /// **Context menu dialog** | ||
| 27 | /// | ||
| 28 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 29 | /// select of an entry as a key | ||
| 30 | /// | ||
| 31 | /// It has the header \ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// | ||
| 35 | namespace ContextMenu | ||
| 36 | { | ||
| 37 | //========================================================================== | ||
| 38 | /// | ||
| 39 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 40 | /// @brief Show a context menu dialog about given parts. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading name | ||
| 43 | /// @param[in] entries String list about entries | ||
| 44 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 45 | /// | ||
| 46 | /// | ||
| 47 | ///------------------------------------------------------------------------- | ||
| 48 | /// | ||
| 49 | /// **Example:** | ||
| 50 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 51 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 52 | /// | ||
| 53 | /// const std::vector<std::string> entries | ||
| 54 | /// { | ||
| 55 | /// "Test 1", | ||
| 56 | /// "Test 2", | ||
| 57 | /// "Test 3", | ||
| 58 | /// "Test 4", | ||
| 59 | /// "Test 5" | ||
| 60 | /// }; | ||
| 61 | /// | ||
| 62 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 63 | /// if (selected < 0) | ||
| 64 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 65 | /// else | ||
| 66 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 67 | /// ~~~~~~~~~~~~~ | ||
| 68 | /// | ||
| 69 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 70 | const std::vector<std::string>& entries) | ||
| 71 | { | ||
| 72 | using namespace ::kodi::addon; | ||
| 73 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 74 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 75 | for (unsigned int i = 0; i < size; ++i) | ||
| 76 | { | ||
| 77 | cEntries[i] = entries[i].c_str(); | ||
| 78 | } | ||
| 79 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 80 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 81 | free(cEntries); | ||
| 82 | return ret; | ||
| 83 | } | ||
| 84 | //-------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 89 | /// @brief Show a context menu dialog about given parts. | ||
| 90 | /// | ||
| 91 | /// @param[in] heading Dialog heading name | ||
| 92 | /// @param[in] entries String list about entries | ||
| 93 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 94 | /// | ||
| 95 | /// | ||
| 96 | ///------------------------------------------------------------------------- | ||
| 97 | /// | ||
| 98 | /// **Example:** | ||
| 99 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 100 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 101 | /// | ||
| 102 | /// const std::vector<std::pair<std::string, std::string>> entries | ||
| 103 | /// { | ||
| 104 | /// { "ID 1", "Test 1" }, | ||
| 105 | /// { "ID 2", "Test 2" }, | ||
| 106 | /// { "ID 3", "Test 3" }, | ||
| 107 | /// { "ID 4", "Test 4" }, | ||
| 108 | /// { "ID 5", "Test 5" } | ||
| 109 | /// }; | ||
| 110 | /// | ||
| 111 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 112 | /// if (selected < 0) | ||
| 113 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 114 | /// else | ||
| 115 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 116 | /// ~~~~~~~~~~~~~ | ||
| 117 | /// | ||
| 118 | inline int ATTRIBUTE_HIDDEN Show( | ||
| 119 | const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries) | ||
| 120 | { | ||
| 121 | using namespace ::kodi::addon; | ||
| 122 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 123 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 124 | for (unsigned int i = 0; i < size; ++i) | ||
| 125 | { | ||
| 126 | cEntries[i] = entries[i].second.c_str(); | ||
| 127 | } | ||
| 128 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 129 | free(cEntries); | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 137 | /// @brief Show a context menu dialog about given parts. | ||
| 138 | /// | ||
| 139 | /// @param[in] heading Dialog heading name | ||
| 140 | /// @param[in] entries String list about entries | ||
| 141 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 142 | /// | ||
| 143 | /// | ||
| 144 | ///------------------------------------------------------------------------- | ||
| 145 | /// | ||
| 146 | /// **Example:** | ||
| 147 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 148 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 149 | /// | ||
| 150 | /// const std::vector<std::pair<int, std::string>> entries | ||
| 151 | /// { | ||
| 152 | /// { 1, "Test 1" }, | ||
| 153 | /// { 2, "Test 2" }, | ||
| 154 | /// { 3, "Test 3" }, | ||
| 155 | /// { 4, "Test 4" }, | ||
| 156 | /// { 5, "Test 5" } | ||
| 157 | /// }; | ||
| 158 | /// | ||
| 159 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 160 | /// if (selected < 0) | ||
| 161 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 162 | /// else | ||
| 163 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 164 | /// ~~~~~~~~~~~~~ | ||
| 165 | /// | ||
| 166 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 167 | const std::vector<std::pair<int, std::string>>& entries) | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 171 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 172 | for (unsigned int i = 0; i < size; ++i) | ||
| 173 | { | ||
| 174 | cEntries[i] = entries[i].second.c_str(); | ||
| 175 | } | ||
| 176 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 177 | free(cEntries); | ||
| 178 | return ret; | ||
| 179 | } | ||
| 180 | //-------------------------------------------------------------------------- | ||
| 181 | }; | ||
| 182 | |||
| 183 | } /* namespace dialogs */ | ||
| 184 | } /* namespace gui */ | ||
| 185 | } /* namespace kodi */ | ||
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 deleted file mode 100644 index 5a49b70..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h +++ /dev/null | |||
| @@ -1,250 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } | ||
| 26 | /// **Progress dialog shown for background work** | ||
| 27 | /// | ||
| 28 | /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>" | ||
| 29 | /// given class are basically used to create Kodi's extended progress. | ||
| 30 | /// | ||
| 31 | /// | ||
| 32 | /// -------------------------------------------------------------------------- | ||
| 33 | /// | ||
| 34 | /// **Example:** | ||
| 35 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 36 | /// #include <kodi/gui/dialogs/ExtendedProgress.h> | ||
| 37 | /// | ||
| 38 | /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); | ||
| 39 | /// ext_progress->SetText("Test progress"); | ||
| 40 | /// for (unsigned int i = 0; i < 50; i += 10) | ||
| 41 | /// { | ||
| 42 | /// ext_progress->SetProgress(i, 100); | ||
| 43 | /// sleep(1); | ||
| 44 | /// } | ||
| 45 | /// | ||
| 46 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | ||
| 47 | /// ext_progress->SetText("Test progress - Step 2"); | ||
| 48 | /// | ||
| 49 | /// for (unsigned int i = 50; i < 100; i += 10) | ||
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// delete ext_progress; | ||
| 55 | /// ~~~~~~~~~~~~~ | ||
| 56 | /// | ||
| 57 | class ATTRIBUTE_HIDDEN CExtendedProgress | ||
| 58 | { | ||
| 59 | public: | ||
| 60 | //========================================================================== | ||
| 61 | /// | ||
| 62 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 63 | /// Construct a new dialog | ||
| 64 | /// | ||
| 65 | /// @param[in] title Title string | ||
| 66 | /// | ||
| 67 | explicit CExtendedProgress(const std::string& title = "") | ||
| 68 | { | ||
| 69 | using namespace ::kodi::addon; | ||
| 70 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog( | ||
| 71 | CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 72 | if (!m_DialogHandle) | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, | ||
| 74 | "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 81 | /// Destructor | ||
| 82 | /// | ||
| 83 | ~CExtendedProgress() | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | if (m_DialogHandle) | ||
| 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( | ||
| 88 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 89 | } | ||
| 90 | //-------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //========================================================================== | ||
| 93 | /// | ||
| 94 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 95 | /// @brief Get the used title | ||
| 96 | /// | ||
| 97 | /// @return Title string | ||
| 98 | /// | ||
| 99 | std::string Title() const | ||
| 100 | { | ||
| 101 | using namespace ::kodi::addon; | ||
| 102 | std::string text; | ||
| 103 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title( | ||
| 104 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 105 | if (strMsg != nullptr) | ||
| 106 | { | ||
| 107 | if (std::strlen(strMsg)) | ||
| 108 | text = strMsg; | ||
| 109 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 110 | strMsg); | ||
| 111 | } | ||
| 112 | return text; | ||
| 113 | } | ||
| 114 | //-------------------------------------------------------------------------- | ||
| 115 | |||
| 116 | //========================================================================== | ||
| 117 | /// | ||
| 118 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 119 | /// @brief To set the title of dialog | ||
| 120 | /// | ||
| 121 | /// @param[in] title Title string | ||
| 122 | /// | ||
| 123 | void SetTitle(const std::string& title) | ||
| 124 | { | ||
| 125 | using namespace ::kodi::addon; | ||
| 126 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( | ||
| 127 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 134 | /// @brief Get the used text information string | ||
| 135 | /// | ||
| 136 | /// @return Text string | ||
| 137 | /// | ||
| 138 | std::string Text() const | ||
| 139 | { | ||
| 140 | using namespace ::kodi::addon; | ||
| 141 | std::string text; | ||
| 142 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text( | ||
| 143 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 144 | if (strMsg != nullptr) | ||
| 145 | { | ||
| 146 | if (std::strlen(strMsg)) | ||
| 147 | text = strMsg; | ||
| 148 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 149 | strMsg); | ||
| 150 | } | ||
| 151 | return text; | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 158 | /// @brief To set the used text information string | ||
| 159 | /// | ||
| 160 | /// @param[in] text information text to set | ||
| 161 | /// | ||
| 162 | void SetText(const std::string& text) | ||
| 163 | { | ||
| 164 | using namespace ::kodi::addon; | ||
| 165 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( | ||
| 166 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | ||
| 175 | /// @return True if on end | ||
| 176 | /// | ||
| 177 | bool IsFinished() const | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( | ||
| 181 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 182 | } | ||
| 183 | //-------------------------------------------------------------------------- | ||
| 184 | |||
| 185 | //========================================================================== | ||
| 186 | /// | ||
| 187 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 188 | /// @brief Mark progress finished | ||
| 189 | /// | ||
| 190 | void MarkFinished() | ||
| 191 | { | ||
| 192 | using namespace ::kodi::addon; | ||
| 193 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( | ||
| 194 | 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( | ||
| 209 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 210 | } | ||
| 211 | //-------------------------------------------------------------------------- | ||
| 212 | |||
| 213 | //========================================================================== | ||
| 214 | /// | ||
| 215 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 216 | /// @brief To set the current progress position as percent | ||
| 217 | /// | ||
| 218 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 219 | /// | ||
| 220 | void SetPercentage(float percentage) | ||
| 221 | { | ||
| 222 | using namespace ::kodi::addon; | ||
| 223 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( | ||
| 224 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 225 | } | ||
| 226 | //-------------------------------------------------------------------------- | ||
| 227 | |||
| 228 | //========================================================================== | ||
| 229 | /// | ||
| 230 | /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress | ||
| 231 | /// @brief To set progress position with predefined places | ||
| 232 | /// | ||
| 233 | /// @param[in] currentItem Place position to use | ||
| 234 | /// @param[in] itemCount Amount of used places | ||
| 235 | /// | ||
| 236 | void SetProgress(int currentItem, int itemCount) | ||
| 237 | { | ||
| 238 | using namespace ::kodi::addon; | ||
| 239 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( | ||
| 240 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | ||
| 241 | } | ||
| 242 | //-------------------------------------------------------------------------- | ||
| 243 | |||
| 244 | private: | ||
| 245 | void* m_DialogHandle; | ||
| 246 | }; | ||
| 247 | |||
| 248 | } /* namespace dialogs */ | ||
| 249 | } /* namespace gui */ | ||
| 250 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h deleted file mode 100644 index 90da063..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h +++ /dev/null | |||
| @@ -1,310 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::FileBrowser } | ||
| 26 | /// **File browser dialog** | ||
| 27 | /// | ||
| 28 | /// The functions listed below of the class "FileBrowser" offer | ||
| 29 | /// the possibility to select to a file by the user of the add-on. | ||
| 30 | /// | ||
| 31 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 32 | /// support file types. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace FileBrowser | ||
| 38 | { | ||
| 39 | //========================================================================== | ||
| 40 | /// | ||
| 41 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 42 | /// @brief Directory selection dialog | ||
| 43 | /// | ||
| 44 | /// @param[in] shares With Shares becomes the available start folders | ||
| 45 | /// be set. | ||
| 46 | /// @param[in] heading Dialog header name | ||
| 47 | /// @param[in,out] path As in the path to start and return value about | ||
| 48 | /// selected directory | ||
| 49 | /// @param[in] writeOnly If set only writeable folders are shown. | ||
| 50 | /// @return False if selection becomes canceled. | ||
| 51 | /// | ||
| 52 | /// **Example:** | ||
| 53 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 54 | /// #include <kodi/gui/dialogs/FileBrowser.h> | ||
| 55 | /// | ||
| 56 | /// /* | ||
| 57 | /// * Example show directory selection dialog with on 'share' (first value) | ||
| 58 | /// * defined directory types. | ||
| 59 | /// * | ||
| 60 | /// * If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 61 | /// * base path of the hard disk. | ||
| 62 | /// * | ||
| 63 | /// * Also can be with path written to 'directory' before the dialog forced | ||
| 64 | /// * to a start place. | ||
| 65 | /// */ | ||
| 66 | /// std::string directory; | ||
| 67 | /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 68 | /// "Test directory selection", | ||
| 69 | /// directory, | ||
| 70 | /// false); | ||
| 71 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 72 | /// ~~~~~~~~~~~~~ | ||
| 73 | /// | ||
| 74 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, | ||
| 75 | const std::string& heading, | ||
| 76 | std::string& path, | ||
| 77 | bool writeOnly = false) | ||
| 78 | { | ||
| 79 | using namespace ::kodi::addon; | ||
| 80 | char* retString = nullptr; | ||
| 81 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( | ||
| 82 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 83 | &retString, writeOnly); | ||
| 84 | if (retString != nullptr) | ||
| 85 | { | ||
| 86 | if (std::strlen(retString)) | ||
| 87 | path = retString; | ||
| 88 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 89 | retString); | ||
| 90 | } | ||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 98 | /// @brief File selection dialog | ||
| 99 | /// | ||
| 100 | /// @param[in] shares With Shares becomes the available start | ||
| 101 | /// folders be set. | ||
| 102 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 103 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 104 | /// @param[in] heading Dialog header name | ||
| 105 | /// @param[in,out] path As in the path to start and Return value | ||
| 106 | /// about selected file | ||
| 107 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 108 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 109 | /// handled as directories. | ||
| 110 | /// @return False if selection becomes canceled. | ||
| 111 | /// | ||
| 112 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, | ||
| 113 | const std::string& mask, | ||
| 114 | const std::string& heading, | ||
| 115 | std::string& path, | ||
| 116 | bool useThumbs = false, | ||
| 117 | bool useFileDirectories = false) | ||
| 118 | { | ||
| 119 | using namespace ::kodi::addon; | ||
| 120 | char* retString = nullptr; | ||
| 121 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, | ||
| 123 | useThumbs, useFileDirectories); | ||
| 124 | if (retString != nullptr) | ||
| 125 | { | ||
| 126 | if (std::strlen(retString)) | ||
| 127 | path = retString; | ||
| 128 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 137 | /// @brief File selection from a directory | ||
| 138 | /// | ||
| 139 | /// @param[in] directory The directory name where the dialog | ||
| 140 | /// start, possible are normal names and | ||
| 141 | /// kodi's special names. | ||
| 142 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 143 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 144 | /// @param[in] heading Dialog header name | ||
| 145 | /// @param[in,out] path As in the path to start and Return value | ||
| 146 | /// about selected file | ||
| 147 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 148 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 149 | /// handled as directories. | ||
| 150 | /// @param[in] singleList | ||
| 151 | /// @return False if selection becomes canceled. | ||
| 152 | /// | ||
| 153 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, | ||
| 154 | const std::string& mask, | ||
| 155 | const std::string& heading, | ||
| 156 | std::string& path, | ||
| 157 | bool useThumbs = false, | ||
| 158 | bool useFileDirectories = false, | ||
| 159 | bool singleList = false) | ||
| 160 | { | ||
| 161 | using namespace ::kodi::addon; | ||
| 162 | char* retString = nullptr; | ||
| 163 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 164 | directory.c_str(), mask.c_str(), heading.c_str(), | ||
| 165 | path.c_str(), &retString, useThumbs, | ||
| 166 | useFileDirectories, singleList); | ||
| 167 | if (retString != nullptr) | ||
| 168 | { | ||
| 169 | if (std::strlen(retString)) | ||
| 170 | path = retString; | ||
| 171 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 172 | } | ||
| 173 | return ret; | ||
| 174 | } | ||
| 175 | //-------------------------------------------------------------------------- | ||
| 176 | |||
| 177 | //========================================================================== | ||
| 178 | /// | ||
| 179 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 180 | /// @brief File selection dialog to get several in to a list | ||
| 181 | /// | ||
| 182 | /// @param[in] shares With Shares becomes the available start | ||
| 183 | /// folders be set. | ||
| 184 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 185 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 186 | /// @param[in] heading Dialog header name | ||
| 187 | /// @param[out] fileList Return value about selected files | ||
| 188 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 189 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 190 | /// handled as directories. | ||
| 191 | /// @return False if selection becomes canceled. | ||
| 192 | /// | ||
| 193 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, | ||
| 194 | const std::string& mask, | ||
| 195 | const std::string& heading, | ||
| 196 | std::vector<std::string>& fileList, | ||
| 197 | bool useThumbs = false, | ||
| 198 | bool useFileDirectories = false) | ||
| 199 | { | ||
| 200 | using namespace ::kodi::addon; | ||
| 201 | char** list = nullptr; | ||
| 202 | unsigned int listSize = 0; | ||
| 203 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 204 | shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, | ||
| 205 | useThumbs, useFileDirectories); | ||
| 206 | if (ret) | ||
| 207 | { | ||
| 208 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 209 | fileList.emplace_back(list[i]); | ||
| 210 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 211 | } | ||
| 212 | return ret; | ||
| 213 | } | ||
| 214 | //-------------------------------------------------------------------------- | ||
| 215 | |||
| 216 | //========================================================================== | ||
| 217 | /// | ||
| 218 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 219 | /// @brief Source selection dialog | ||
| 220 | /// | ||
| 221 | /// @param[in,out] path As in the path to start and Return value | ||
| 222 | /// about selected source | ||
| 223 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 224 | /// @param[in] additionalShare With additionalShare becomes the available | ||
| 225 | /// start folders be set (optional). | ||
| 226 | /// @param[in] type | ||
| 227 | /// @return False if selection becomes canceled. | ||
| 228 | /// | ||
| 229 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, | ||
| 230 | bool allowNetworkShares, | ||
| 231 | const std::string& additionalShare = "", | ||
| 232 | const std::string& type = "") | ||
| 233 | { | ||
| 234 | using namespace ::kodi::addon; | ||
| 235 | char* retString = nullptr; | ||
| 236 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, | ||
| 237 | allowNetworkShares, additionalShare.c_str(), type.c_str()); | ||
| 238 | if (retString != nullptr) | ||
| 239 | { | ||
| 240 | if (std::strlen(retString)) | ||
| 241 | path = retString; | ||
| 242 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 243 | } | ||
| 244 | return ret; | ||
| 245 | } | ||
| 246 | //-------------------------------------------------------------------------- | ||
| 247 | |||
| 248 | //========================================================================== | ||
| 249 | /// | ||
| 250 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 251 | /// @brief Image selection dialog | ||
| 252 | /// | ||
| 253 | /// @param[in] shares With Shares becomes the available start folders be | ||
| 254 | /// set. | ||
| 255 | /// @param[in] heading Dialog header name | ||
| 256 | /// @param[out] path Return value about selected image | ||
| 257 | /// @return False if selection becomes canceled. | ||
| 258 | /// | ||
| 259 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, | ||
| 260 | const std::string& heading, | ||
| 261 | std::string& path) | ||
| 262 | { | ||
| 263 | using namespace ::kodi::addon; | ||
| 264 | char* retString = nullptr; | ||
| 265 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 266 | shares.c_str(), heading.c_str(), path.c_str(), &retString); | ||
| 267 | if (retString != nullptr) | ||
| 268 | { | ||
| 269 | if (std::strlen(retString)) | ||
| 270 | path = retString; | ||
| 271 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 272 | } | ||
| 273 | return ret; | ||
| 274 | } | ||
| 275 | //-------------------------------------------------------------------------- | ||
| 276 | |||
| 277 | //========================================================================== | ||
| 278 | /// | ||
| 279 | /// \ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 280 | /// @brief Image selection dialog to get several in to a list | ||
| 281 | /// | ||
| 282 | /// @param[in] shares With Shares becomes the available start folders | ||
| 283 | /// be set. | ||
| 284 | /// @param[in] heading Dialog header name | ||
| 285 | /// @param[out] file_list Return value about selected images | ||
| 286 | /// @return False if selection becomes canceled. | ||
| 287 | /// | ||
| 288 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, | ||
| 289 | const std::string& heading, | ||
| 290 | std::vector<std::string>& file_list) | ||
| 291 | { | ||
| 292 | using namespace ::kodi::addon; | ||
| 293 | char** list = nullptr; | ||
| 294 | unsigned int listSize = 0; | ||
| 295 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 296 | shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 297 | if (ret) | ||
| 298 | { | ||
| 299 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 300 | file_list.emplace_back(list[i]); | ||
| 301 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 302 | } | ||
| 303 | return ret; | ||
| 304 | } | ||
| 305 | //-------------------------------------------------------------------------- | ||
| 306 | }; | ||
| 307 | |||
| 308 | } /* namespace dialogs */ | ||
| 309 | } /* namespace gui */ | ||
| 310 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h deleted file mode 100644 index 843bdfa..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h +++ /dev/null | |||
| @@ -1,422 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Keyboard } | ||
| 26 | /// **Keyboard dialogs** | ||
| 27 | /// | ||
| 28 | /// The functions listed below have to be permitted by the user for the | ||
| 29 | /// representation of a keyboard around an input. | ||
| 30 | /// | ||
| 31 | /// The class supports several kinds, from an easy text choice up to the | ||
| 32 | /// passport Word production and their confirmation for add-on. | ||
| 33 | /// | ||
| 34 | /// It has the header \ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace Keyboard | ||
| 38 | { | ||
| 39 | //========================================================================== | ||
| 40 | /// | ||
| 41 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 42 | /// @brief Show keyboard with initial value `text` and replace with result | ||
| 43 | /// string. | ||
| 44 | /// | ||
| 45 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 46 | /// @param[in] heading String shown on dialog title. | ||
| 47 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 48 | /// @param[in] hiddenInput The inserted input is not shown as text. | ||
| 49 | /// @param[in] autoCloseMs To close the dialog after a specified | ||
| 50 | /// time, in milliseconds, default is 0 which | ||
| 51 | /// keeps the dialog open indefinitely. | ||
| 52 | /// @return true if successful display and user input. | ||
| 53 | /// false if unsuccessful display, no user | ||
| 54 | /// input, or canceled editing. | ||
| 55 | /// | ||
| 56 | /// | ||
| 57 | ///------------------------------------------------------------------------- | ||
| 58 | /// | ||
| 59 | /// **Example:** | ||
| 60 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 61 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 62 | /// | ||
| 63 | /// /* | ||
| 64 | /// * The example shows the display of keyboard call dialog at Kodi from the add-on. | ||
| 65 | /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) | ||
| 66 | /// * to be released if not needed. | ||
| 67 | /// */ | ||
| 68 | /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a | ||
| 69 | /// entry text added */ | ||
| 70 | /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text, | ||
| 71 | /// "Demonstration text entry", | ||
| 72 | /// true, | ||
| 73 | /// false, | ||
| 74 | /// 0); | ||
| 75 | /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", | ||
| 76 | /// text.c_str(), bRet ? "OK" : "Canceled"); | ||
| 77 | /// ~~~~~~~~~~~~~ | ||
| 78 | /// | ||
| 79 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 80 | const std::string& heading, | ||
| 81 | bool allowEmptyResult, | ||
| 82 | bool hiddenInput = false, | ||
| 83 | unsigned int autoCloseMs = 0) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | char* retString = nullptr; | ||
| 87 | bool ret = | ||
| 88 | CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head( | ||
| 89 | CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(), | ||
| 90 | allowEmptyResult, hiddenInput, autoCloseMs); | ||
| 91 | if (retString != nullptr) | ||
| 92 | { | ||
| 93 | text = retString; | ||
| 94 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 95 | retString); | ||
| 96 | } | ||
| 97 | return ret; | ||
| 98 | } | ||
| 99 | //-------------------------------------------------------------------------- | ||
| 100 | |||
| 101 | //========================================================================== | ||
| 102 | /// | ||
| 103 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 104 | /// @brief The example shows the display of keyboard call dialog at Kodi | ||
| 105 | /// from the add-on. | ||
| 106 | /// | ||
| 107 | /// @param[out] text Overwritten with user input if return=true. | ||
| 108 | /// @param[in] allowEmptyResult If set to true keyboard can also exited | ||
| 109 | /// without entered text. | ||
| 110 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 111 | /// in milliseconds, default is 0 which keeps | ||
| 112 | /// the dialog open indefinitely. | ||
| 113 | /// @return true if successful display and user input. | ||
| 114 | /// false if unsuccessful display, no user | ||
| 115 | /// input, or canceled editing. | ||
| 116 | /// | ||
| 117 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, | ||
| 118 | bool allowEmptyResult, | ||
| 119 | unsigned int autoCloseMs = 0) | ||
| 120 | { | ||
| 121 | using namespace ::kodi::addon; | ||
| 122 | char* retString = nullptr; | ||
| 123 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 124 | text.c_str(), &retString, | ||
| 125 | allowEmptyResult, autoCloseMs); | ||
| 126 | if (retString != nullptr) | ||
| 127 | { | ||
| 128 | text = retString; | ||
| 129 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 130 | } | ||
| 131 | return ret; | ||
| 132 | } | ||
| 133 | //-------------------------------------------------------------------------- | ||
| 134 | |||
| 135 | //========================================================================== | ||
| 136 | /// | ||
| 137 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 138 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 139 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 140 | /// | ||
| 141 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 142 | /// @param[in] heading String shown on dialog title. | ||
| 143 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 144 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 145 | /// in milliseconds, default is 0 which keeps | ||
| 146 | /// the dialog open indefinitely. | ||
| 147 | /// @return true if successful display and user input. | ||
| 148 | /// false if unsuccessful display, no user | ||
| 149 | /// input, or canceled editing. | ||
| 150 | /// | ||
| 151 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 152 | const std::string& heading, | ||
| 153 | bool allowEmptyResult, | ||
| 154 | unsigned int autoCloseMs = 0) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | newPassword.c_str(), &retString, heading.c_str(), | ||
| 160 | allowEmptyResult, autoCloseMs); | ||
| 161 | if (retString != nullptr) | ||
| 162 | { | ||
| 163 | newPassword = retString; | ||
| 164 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 165 | } | ||
| 166 | return ret; | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 173 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 174 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 175 | /// | ||
| 176 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 177 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 178 | /// in milliseconds, default is 0 which keeps | ||
| 179 | /// the dialog open indefinitely. | ||
| 180 | /// @return true if successful display and user input. | ||
| 181 | /// false if unsuccessful display, no user | ||
| 182 | /// input, or canceled editing. | ||
| 183 | /// | ||
| 184 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, | ||
| 185 | unsigned int autoCloseMs = 0) | ||
| 186 | { | ||
| 187 | using namespace ::kodi::addon; | ||
| 188 | char* retString = nullptr; | ||
| 189 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 190 | newPassword.c_str(), &retString, autoCloseMs); | ||
| 191 | if (retString != nullptr) | ||
| 192 | { | ||
| 193 | newPassword = retString; | ||
| 194 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 195 | } | ||
| 196 | return ret; | ||
| 197 | } | ||
| 198 | //-------------------------------------------------------------------------- | ||
| 199 | |||
| 200 | //========================================================================== | ||
| 201 | /// | ||
| 202 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 203 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 204 | /// string. | ||
| 205 | /// | ||
| 206 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 207 | /// @param[in] heading String shown on dialog title. | ||
| 208 | /// @param[in] allowEmptyResult | ||
| 209 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 210 | /// in milliseconds, default is 0 which keeps | ||
| 211 | /// the dialog open indefinitely. | ||
| 212 | /// @return true if successful display and user input. | ||
| 213 | /// false if unsuccessful display, no user | ||
| 214 | /// input, or canceled editing. | ||
| 215 | /// | ||
| 216 | /// | ||
| 217 | ///------------------------------------------------------------------------- | ||
| 218 | /// | ||
| 219 | /// **Example:** | ||
| 220 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 221 | /// #include <kodi/General.h> | ||
| 222 | /// #include <kodi/gui/dialogs/Keyboard.h> | ||
| 223 | /// | ||
| 224 | /// /* | ||
| 225 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 226 | /// * check. If only one check from add-on needed can be function with retries | ||
| 227 | /// * set to '0' called alone. | ||
| 228 | /// * | ||
| 229 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 230 | /// */ | ||
| 231 | /// | ||
| 232 | /// int maxretries = 3; | ||
| 233 | /// /* | ||
| 234 | /// * Password names need to be send as md5 sum to kodi. | ||
| 235 | /// */ | ||
| 236 | /// std::string password; | ||
| 237 | /// kodi::GetMD5("kodi", password); | ||
| 238 | /// | ||
| 239 | /// /* | ||
| 240 | /// * To the loop about password checks. | ||
| 241 | /// */ | ||
| 242 | /// int ret; | ||
| 243 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 244 | /// { | ||
| 245 | /// /* | ||
| 246 | /// * Ask the user about the password. | ||
| 247 | /// */ | ||
| 248 | /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); | ||
| 249 | /// if (ret == 0) | ||
| 250 | /// { | ||
| 251 | /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); | ||
| 252 | /// break; | ||
| 253 | /// } | ||
| 254 | /// else if (ret < 0) | ||
| 255 | /// { | ||
| 256 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 257 | /// break; | ||
| 258 | /// } | ||
| 259 | /// else /* if (ret > 0) */ | ||
| 260 | /// { | ||
| 261 | /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); | ||
| 262 | /// } | ||
| 263 | /// } | ||
| 264 | /// ~~~~~~~~~~~~~ | ||
| 265 | /// | ||
| 266 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 267 | const std::string& heading, | ||
| 268 | bool allowEmptyResult, | ||
| 269 | unsigned int autoCloseMs = 0) | ||
| 270 | { | ||
| 271 | using namespace ::kodi::addon; | ||
| 272 | char* retString = nullptr; | ||
| 273 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 274 | &retString, heading.c_str(), allowEmptyResult, | ||
| 275 | autoCloseMs); | ||
| 276 | if (retString != nullptr) | ||
| 277 | { | ||
| 278 | newPassword = retString; | ||
| 279 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 280 | } | ||
| 281 | return ret; | ||
| 282 | } | ||
| 283 | //-------------------------------------------------------------------------- | ||
| 284 | |||
| 285 | //========================================================================== | ||
| 286 | /// | ||
| 287 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 288 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 289 | /// string. | ||
| 290 | /// | ||
| 291 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 292 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 293 | /// in milliseconds, default is 0 which keeps | ||
| 294 | /// the dialog open indefinitely. | ||
| 295 | /// @return true if successful display and user input. | ||
| 296 | /// false if unsuccessful display, no user | ||
| 297 | /// input, or canceled editing. | ||
| 298 | /// | ||
| 299 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, | ||
| 300 | unsigned int autoCloseMs = 0) | ||
| 301 | { | ||
| 302 | using namespace ::kodi::addon; | ||
| 303 | char* retString = nullptr; | ||
| 304 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 305 | &retString, autoCloseMs); | ||
| 306 | if (retString != nullptr) | ||
| 307 | { | ||
| 308 | newPassword = retString; | ||
| 309 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 310 | } | ||
| 311 | return ret; | ||
| 312 | } | ||
| 313 | //-------------------------------------------------------------------------- | ||
| 314 | |||
| 315 | //========================================================================== | ||
| 316 | /// | ||
| 317 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 318 | /// @brief Show keyboard and verify user input against `password`. | ||
| 319 | /// | ||
| 320 | /// @param[in,out] password Value to compare against user input. | ||
| 321 | /// @param[in] heading String shown on dialog title. | ||
| 322 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 323 | /// password, %d retries left" on dialog line 2, | ||
| 324 | /// else line 2 is blank. | ||
| 325 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 326 | /// in milliseconds, default is 0 which keeps | ||
| 327 | /// the dialog open indefinitely. | ||
| 328 | /// @return 0 if successful display and user input. 1 if | ||
| 329 | /// unsuccessful input. -1 if no user input or | ||
| 330 | /// canceled editing. | ||
| 331 | /// | ||
| 332 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password, | ||
| 333 | const std::string& heading, | ||
| 334 | int retries, | ||
| 335 | unsigned int autoCloseMs = 0) | ||
| 336 | { | ||
| 337 | using namespace ::kodi::addon; | ||
| 338 | char* retString = nullptr; | ||
| 339 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 340 | password.c_str(), &retString, heading.c_str(), | ||
| 341 | retries, autoCloseMs); | ||
| 342 | if (retString != nullptr) | ||
| 343 | { | ||
| 344 | password = retString; | ||
| 345 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 346 | } | ||
| 347 | return ret; | ||
| 348 | } | ||
| 349 | //-------------------------------------------------------------------------- | ||
| 350 | |||
| 351 | //========================================================================== | ||
| 352 | /// | ||
| 353 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 354 | /// @brief Shows a filter related keyboard | ||
| 355 | /// | ||
| 356 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 357 | /// @param[in] searching Use dialog for search and send our search | ||
| 358 | /// message in safe way (only the active window | ||
| 359 | /// needs it) | ||
| 360 | /// - header name if true is "Enter search string" | ||
| 361 | /// - header name if false is "Enter value" | ||
| 362 | /// @param autoCloseMs To close the dialog after a specified time, | ||
| 363 | /// in milliseconds, default is 0 which keeps | ||
| 364 | /// the dialog open indefinitely. | ||
| 365 | /// @return true if successful display and user input. | ||
| 366 | /// false if unsuccessful display, no user | ||
| 367 | /// input, or canceled editing. | ||
| 368 | /// | ||
| 369 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text, | ||
| 370 | bool searching, | ||
| 371 | unsigned int autoCloseMs = 0) | ||
| 372 | { | ||
| 373 | using namespace ::kodi::addon; | ||
| 374 | char* retString = nullptr; | ||
| 375 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 376 | text.c_str(), &retString, searching, autoCloseMs); | ||
| 377 | if (retString != nullptr) | ||
| 378 | { | ||
| 379 | text = retString; | ||
| 380 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 381 | } | ||
| 382 | return ret; | ||
| 383 | } | ||
| 384 | //-------------------------------------------------------------------------- | ||
| 385 | |||
| 386 | //========================================================================== | ||
| 387 | /// | ||
| 388 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 389 | /// @brief Send a text to a visible keyboard | ||
| 390 | /// | ||
| 391 | /// @param[in] text Overwritten with user input if return=true. | ||
| 392 | /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. | ||
| 393 | /// @return true if successful done, false if | ||
| 394 | /// unsuccessful or keyboard not present. | ||
| 395 | /// | ||
| 396 | inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text, | ||
| 397 | bool closeKeyboard = false) | ||
| 398 | { | ||
| 399 | using namespace ::kodi::addon; | ||
| 400 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 401 | text.c_str(), closeKeyboard); | ||
| 402 | } | ||
| 403 | //-------------------------------------------------------------------------- | ||
| 404 | |||
| 405 | //========================================================================== | ||
| 406 | /// | ||
| 407 | /// \ingroup cpp_kodi_gui_dialogs_Keyboard | ||
| 408 | /// @brief Check for visible keyboard on GUI | ||
| 409 | /// | ||
| 410 | /// @return true if keyboard present, false if not present | ||
| 411 | /// | ||
| 412 | inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated() | ||
| 413 | { | ||
| 414 | using namespace ::kodi::addon; | ||
| 415 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 416 | } | ||
| 417 | //-------------------------------------------------------------------------- | ||
| 418 | }; | ||
| 419 | |||
| 420 | } /* namespace dialogs */ | ||
| 421 | } /* namespace gui */ | ||
| 422 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h deleted file mode 100644 index bff7683..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h +++ /dev/null | |||
| @@ -1,362 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Numeric } | ||
| 27 | /// **Numeric dialogs** | ||
| 28 | /// | ||
| 29 | /// The functions listed below have to be permitted by the user for the | ||
| 30 | /// representation of a numeric keyboard around an input. | ||
| 31 | /// | ||
| 32 | /// The class supports several kinds, from an easy number choice up to the | ||
| 33 | /// passport Word production and their confirmation for add-on. | ||
| 34 | /// | ||
| 35 | /// It has the header \ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>" | ||
| 36 | /// be included to enjoy it. | ||
| 37 | /// | ||
| 38 | namespace Numeric | ||
| 39 | { | ||
| 40 | //========================================================================== | ||
| 41 | /// | ||
| 42 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 43 | /// @brief Use dialog to get numeric new password | ||
| 44 | /// | ||
| 45 | /// @param[out] newPassword String to preload into the keyboard | ||
| 46 | /// accumulator. Overwritten with user input | ||
| 47 | /// if return=true. Returned in MD5 format. | ||
| 48 | /// @return true if successful display and user | ||
| 49 | /// input entry/re-entry. | ||
| 50 | /// false if unsuccessful display, no user | ||
| 51 | /// input, or canceled editing. | ||
| 52 | /// | ||
| 53 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword) | ||
| 54 | { | ||
| 55 | using namespace ::kodi::addon; | ||
| 56 | char* pw = nullptr; | ||
| 57 | bool ret = | ||
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 60 | if (pw != nullptr) | ||
| 61 | { | ||
| 62 | newPassword = pw; | ||
| 63 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); | ||
| 64 | } | ||
| 65 | return ret; | ||
| 66 | } | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 72 | /// @brief Use dialog to verify numeric password. | ||
| 73 | /// | ||
| 74 | /// @param[in] password Password to compare with user input, need | ||
| 75 | /// in MD5 format. | ||
| 76 | /// @param[in] heading Heading to display | ||
| 77 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 78 | /// password, %d retries left" on dialog | ||
| 79 | /// line 2, else line 2 is blank. | ||
| 80 | /// @return Possible values: | ||
| 81 | /// - 0 if successful display and user input. | ||
| 82 | /// - 1 if unsuccessful input. | ||
| 83 | /// - -1 if no user input or canceled editing. | ||
| 84 | /// | ||
| 85 | /// | ||
| 86 | ///------------------------------------------------------------------------- | ||
| 87 | /// | ||
| 88 | /// **Example:** | ||
| 89 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 90 | /// #include <stdio.h> /* fprintf */ | ||
| 91 | /// #include <kodi/General.h> | ||
| 92 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 93 | /// | ||
| 94 | /// /* | ||
| 95 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 96 | /// * check. If only one check from add-on needed can be function with retries | ||
| 97 | /// * set to '0' called alone. | ||
| 98 | /// * | ||
| 99 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 100 | /// */ | ||
| 101 | /// | ||
| 102 | /// int maxretries = 3; | ||
| 103 | /// | ||
| 104 | /// /* | ||
| 105 | /// * Password names need to be send as md5 sum to kodi. | ||
| 106 | /// */ | ||
| 107 | /// std::string password = kodi::GetMD5("1234"); | ||
| 108 | /// | ||
| 109 | /// /* | ||
| 110 | /// * To the loop about password checks. | ||
| 111 | /// */ | ||
| 112 | /// int ret; | ||
| 113 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 114 | /// { | ||
| 115 | /// /* | ||
| 116 | /// * Ask the user about the password. | ||
| 117 | /// */ | ||
| 118 | /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); | ||
| 119 | /// if (ret == 0) | ||
| 120 | /// { | ||
| 121 | /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); | ||
| 122 | /// break; | ||
| 123 | /// } | ||
| 124 | /// else if (ret < 0) | ||
| 125 | /// { | ||
| 126 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 127 | /// break; | ||
| 128 | /// } | ||
| 129 | /// else /* if (ret > 0) */ | ||
| 130 | /// { | ||
| 131 | /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); | ||
| 132 | /// } | ||
| 133 | /// } | ||
| 134 | /// ~~~~~~~~~~~~~ | ||
| 135 | /// | ||
| 136 | inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password, | ||
| 137 | const std::string& heading, | ||
| 138 | int retries) | ||
| 139 | { | ||
| 140 | using namespace ::kodi::addon; | ||
| 141 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 142 | password.c_str(), heading.c_str(), retries); | ||
| 143 | } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 149 | /// @brief Use dialog to verify numeric password | ||
| 150 | /// | ||
| 151 | /// @param[in,out] toVerify Value to compare against user input. | ||
| 152 | /// @param[in] heading Heading to display | ||
| 153 | /// @param[in] verifyInput If set as true we verify the users input | ||
| 154 | /// versus toVerify. | ||
| 155 | /// @return true if successful display and user | ||
| 156 | /// input. false if unsuccessful display, no | ||
| 157 | /// user input, or canceled editing. | ||
| 158 | /// | ||
| 159 | inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify, | ||
| 160 | const std::string& heading, | ||
| 161 | bool verifyInput) | ||
| 162 | { | ||
| 163 | using namespace ::kodi::addon; | ||
| 164 | char* retString = nullptr; | ||
| 165 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 166 | toVerify.c_str(), &retString, heading.c_str(), verifyInput); | ||
| 167 | if (retString != nullptr) | ||
| 168 | { | ||
| 169 | toVerify = retString; | ||
| 170 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 171 | } | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | //-------------------------------------------------------------------------- | ||
| 175 | |||
| 176 | //========================================================================== | ||
| 177 | /// | ||
| 178 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 179 | /// @brief Use dialog to get time value. | ||
| 180 | /// | ||
| 181 | /// @param[out] time Overwritten with user input if | ||
| 182 | /// return=true and time inserted. | ||
| 183 | /// @param[in] heading Heading to display. | ||
| 184 | /// @return true if successful display and user | ||
| 185 | /// input. false if unsuccessful display, no | ||
| 186 | /// user input, or canceled editing. | ||
| 187 | /// | ||
| 188 | /// | ||
| 189 | ///------------------------------------------------------------------------- | ||
| 190 | /// | ||
| 191 | /// **Example:** | ||
| 192 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 193 | /// #include <stdio.h> /* printf */ | ||
| 194 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 195 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 196 | /// | ||
| 197 | /// time_t rawtime; | ||
| 198 | /// struct tm * timeinfo; | ||
| 199 | /// char buffer [10]; | ||
| 200 | /// | ||
| 201 | /// time (&rawtime); | ||
| 202 | /// timeinfo = localtime(&rawtime); | ||
| 203 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call"); | ||
| 204 | /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); | ||
| 205 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 206 | /// ~~~~~~~~~~~~~ | ||
| 207 | /// | ||
| 208 | inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading) | ||
| 209 | { | ||
| 210 | using namespace ::kodi::addon; | ||
| 211 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | ||
| 212 | } | ||
| 213 | //-------------------------------------------------------------------------- | ||
| 214 | |||
| 215 | //========================================================================== | ||
| 216 | /// | ||
| 217 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 218 | /// @brief Use dialog to get date value. | ||
| 219 | /// | ||
| 220 | /// @param[in,out] date Overwritten with user input if | ||
| 221 | /// return=true and date inserted. | ||
| 222 | /// @param[in] heading Heading to display | ||
| 223 | /// @return true if successful display and user | ||
| 224 | /// input. false if unsuccessful display, no | ||
| 225 | /// user input, or canceled editing. | ||
| 226 | /// | ||
| 227 | /// | ||
| 228 | ///------------------------------------------------------------------------- | ||
| 229 | /// | ||
| 230 | /// **Example:** | ||
| 231 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 232 | /// #include <stdio.h> /* printf */ | ||
| 233 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 234 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 235 | /// | ||
| 236 | /// time_t rawtime; | ||
| 237 | /// struct tm * timeinfo; | ||
| 238 | /// char buffer [20]; | ||
| 239 | /// | ||
| 240 | /// time (&rawtime); | ||
| 241 | /// timeinfo = localtime(&rawtime); | ||
| 242 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call"); | ||
| 243 | /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); | ||
| 244 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 245 | /// ~~~~~~~~~~~~~ | ||
| 246 | /// | ||
| 247 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading) | ||
| 248 | { | ||
| 249 | using namespace ::kodi::addon; | ||
| 250 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | ||
| 251 | } | ||
| 252 | //-------------------------------------------------------------------------- | ||
| 253 | |||
| 254 | //========================================================================== | ||
| 255 | /// | ||
| 256 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 257 | /// @brief Use dialog to get a IP | ||
| 258 | /// | ||
| 259 | /// @param[in,out] ipAddress Overwritten with user input if | ||
| 260 | /// return=true and IP address inserted. | ||
| 261 | /// @param[in] heading Heading to display. | ||
| 262 | /// @return true if successful display and | ||
| 263 | /// user input. false if unsuccessful | ||
| 264 | /// display, no user input, or canceled | ||
| 265 | /// editing. | ||
| 266 | /// | ||
| 267 | inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, | ||
| 268 | const std::string& heading) | ||
| 269 | { | ||
| 270 | using namespace ::kodi::addon; | ||
| 271 | char* retString = nullptr; | ||
| 272 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 273 | ipAddress.c_str(), &retString, heading.c_str()); | ||
| 274 | if (retString != nullptr) | ||
| 275 | { | ||
| 276 | ipAddress = retString; | ||
| 277 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 278 | } | ||
| 279 | return ret; | ||
| 280 | } | ||
| 281 | //-------------------------------------------------------------------------- | ||
| 282 | |||
| 283 | //========================================================================== | ||
| 284 | /// | ||
| 285 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 286 | /// @brief Use dialog to get normal number. | ||
| 287 | /// | ||
| 288 | /// @param[in,out] input Overwritten with user input if | ||
| 289 | /// return=true and time in seconds inserted | ||
| 290 | /// @param[in] heading Heading to display | ||
| 291 | /// @param[in] autoCloseTimeoutMs To close the dialog after a specified | ||
| 292 | /// time, in milliseconds, default is 0 | ||
| 293 | /// which keeps the dialog open | ||
| 294 | /// indefinitely. | ||
| 295 | /// @return true if successful display and user | ||
| 296 | /// input. false if unsuccessful display, no | ||
| 297 | /// user input, or canceled editing. | ||
| 298 | /// | ||
| 299 | /// | ||
| 300 | ///------------------------------------------------------------------------- | ||
| 301 | /// | ||
| 302 | /// **Example:** | ||
| 303 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 304 | /// #include <stdio.h> /* printf */ | ||
| 305 | /// #include <stdlib.h> /* strtoull (C++11) */ | ||
| 306 | /// #include <kodi/gui/dialogs/Numeric.h> | ||
| 307 | /// | ||
| 308 | /// std::string number; | ||
| 309 | /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call"); | ||
| 310 | /// printf("Written number input is : %llu and was %s\n", | ||
| 311 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | ||
| 312 | /// ~~~~~~~~~~~~~ | ||
| 313 | /// | ||
| 314 | inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input, | ||
| 315 | const std::string& heading, | ||
| 316 | unsigned int autoCloseTimeoutMs = 0) | ||
| 317 | { | ||
| 318 | using namespace ::kodi::addon; | ||
| 319 | char* retString = nullptr; | ||
| 320 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 321 | input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); | ||
| 322 | if (retString != nullptr) | ||
| 323 | { | ||
| 324 | input = retString; | ||
| 325 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 326 | } | ||
| 327 | return ret; | ||
| 328 | } | ||
| 329 | //-------------------------------------------------------------------------- | ||
| 330 | |||
| 331 | //========================================================================== | ||
| 332 | /// | ||
| 333 | /// \ingroup cpp_kodi_gui_dialogs_Numeric | ||
| 334 | /// @brief Show numeric keypad to get seconds. | ||
| 335 | /// | ||
| 336 | /// @param[in,out] time Overwritten with user input if return=true and | ||
| 337 | /// time in seconds inserted. | ||
| 338 | /// @param[in] heading Heading to display | ||
| 339 | /// @return true if successful display and user input. false | ||
| 340 | /// if unsuccessful display, no user input, or | ||
| 341 | /// canceled editing. | ||
| 342 | /// | ||
| 343 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading) | ||
| 344 | { | ||
| 345 | using namespace ::kodi::addon; | ||
| 346 | char* retString = nullptr; | ||
| 347 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 348 | time.c_str(), &retString, heading.c_str()); | ||
| 349 | if (retString != nullptr) | ||
| 350 | { | ||
| 351 | time = retString; | ||
| 352 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 353 | } | ||
| 354 | return ret; | ||
| 355 | } | ||
| 356 | //-------------------------------------------------------------------------- | ||
| 357 | }; | ||
| 358 | /// @} | ||
| 359 | |||
| 360 | } /* namespace dialogs */ | ||
| 361 | } /* namespace gui */ | ||
| 362 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h deleted file mode 100644 index b9a3a0d..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../../AddonBase.h" | ||
| 12 | #include "../definitions.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_OK Dialog OK | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::OK } | ||
| 27 | /// **OK dialog** | ||
| 28 | /// | ||
| 29 | /// The functions listed below permit the call of a dialogue of information, a | ||
| 30 | /// confirmation of the user by press from OK required. | ||
| 31 | /// | ||
| 32 | /// It has the header \ref OK.h "#include <kodi/gui/dialogs/OK.h>" | ||
| 33 | /// be included to enjoy it. | ||
| 34 | /// | ||
| 35 | namespace OK | ||
| 36 | { | ||
| 37 | //========================================================================== | ||
| 38 | /// | ||
| 39 | /// \ingroup cpp_kodi_gui_dialogs_OK | ||
| 40 | /// @brief Use dialog to inform user with text and confirmation with OK with continued string. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading. | ||
| 43 | /// @param[in] text Multi-line text. | ||
| 44 | /// | ||
| 45 | /// | ||
| 46 | ///------------------------------------------------------------------------- | ||
| 47 | /// | ||
| 48 | /// **Example:** | ||
| 49 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 50 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 51 | /// ... | ||
| 52 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | ||
| 53 | /// ~~~~~~~~~~~~~ | ||
| 54 | /// | ||
| 55 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text) | ||
| 56 | { | ||
| 57 | using namespace ::kodi::addon; | ||
| 58 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text( | ||
| 59 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 60 | } | ||
| 61 | //-------------------------------------------------------------------------- | ||
| 62 | |||
| 63 | //========================================================================== | ||
| 64 | /// | ||
| 65 | /// \ingroup cpp_kodi_gui_dialogs_OK | ||
| 66 | /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. | ||
| 67 | /// | ||
| 68 | /// @param[in] heading Dialog heading. | ||
| 69 | /// @param[in] line0 Line #1 text. | ||
| 70 | /// @param[in] line1 Line #2 text. | ||
| 71 | /// @param[in] line2 Line #3 text. | ||
| 72 | /// | ||
| 73 | /// | ||
| 74 | ///------------------------------------------------------------------------- | ||
| 75 | /// | ||
| 76 | /// **Example:** | ||
| 77 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 78 | /// #include <kodi/gui/dialogs/OK.h> | ||
| 79 | /// ... | ||
| 80 | /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 84 | const std::string& line0, | ||
| 85 | const std::string& line1, | ||
| 86 | const std::string& line2) | ||
| 87 | { | ||
| 88 | using namespace ::kodi::addon; | ||
| 89 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 90 | heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 91 | line2.c_str()); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | } | ||
| 95 | /// @} | ||
| 96 | |||
| 97 | } /* namespace dialogs */ | ||
| 98 | } /* namespace gui */ | ||
| 99 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h deleted file mode 100644 index b1f8cc5..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h +++ /dev/null | |||
| @@ -1,255 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_class{ kodi::gui::dialogs::CProgress } | ||
| 26 | /// **Progress dialog shown in center** | ||
| 27 | /// | ||
| 28 | /// The with \ref DialogProgress.h "#include <kodi/gui/dialogs/Progress.h>" | ||
| 29 | /// given class are basically used to create Kodi's progress dialog with named | ||
| 30 | /// text fields. | ||
| 31 | /// | ||
| 32 | /// **Example:** | ||
| 33 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 34 | /// #include <kodi/gui/dialogs/Progress.h> | ||
| 35 | /// | ||
| 36 | /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; | ||
| 37 | /// progress->SetHeading("Test progress"); | ||
| 38 | /// progress->SetLine(1, "line 1"); | ||
| 39 | /// progress->SetLine(2, "line 2"); | ||
| 40 | /// progress->SetLine(3, "line 3"); | ||
| 41 | /// progress->SetCanCancel(true); | ||
| 42 | /// progress->ShowProgressBar(true); | ||
| 43 | /// progress->Open(); | ||
| 44 | /// for (unsigned int i = 0; i < 100; i += 10) | ||
| 45 | /// { | ||
| 46 | /// progress->SetPercentage(i); | ||
| 47 | /// sleep(1); | ||
| 48 | /// } | ||
| 49 | /// delete progress; | ||
| 50 | /// ~~~~~~~~~~~~~ | ||
| 51 | /// | ||
| 52 | class ATTRIBUTE_HIDDEN CProgress | ||
| 53 | { | ||
| 54 | public: | ||
| 55 | //========================================================================== | ||
| 56 | /// | ||
| 57 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 58 | /// @brief Construct a new dialog | ||
| 59 | /// | ||
| 60 | CProgress() | ||
| 61 | { | ||
| 62 | using namespace ::kodi::addon; | ||
| 63 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog( | ||
| 64 | CAddonBase::m_interface->toKodi->kodiBase); | ||
| 65 | if (!m_DialogHandle) | ||
| 66 | kodi::Log(ADDON_LOG_FATAL, | ||
| 67 | "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); | ||
| 68 | } | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 74 | /// @brief Destructor | ||
| 75 | /// | ||
| 76 | ~CProgress() | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | if (m_DialogHandle) | ||
| 80 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( | ||
| 81 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 88 | /// @brief To open the dialog | ||
| 89 | /// | ||
| 90 | void Open() | ||
| 91 | { | ||
| 92 | using namespace ::kodi::addon; | ||
| 93 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( | ||
| 94 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// | ||
| 100 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 101 | /// @brief Set the heading title of dialog | ||
| 102 | /// | ||
| 103 | /// @param[in] heading Title string to use | ||
| 104 | /// | ||
| 105 | void SetHeading(const std::string& heading) | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( | ||
| 109 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 110 | } | ||
| 111 | //-------------------------------------------------------------------------- | ||
| 112 | |||
| 113 | //========================================================================== | ||
| 114 | /// | ||
| 115 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 116 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 117 | /// | ||
| 118 | /// @param[in] iLine Line number | ||
| 119 | /// @param[in] line Text string | ||
| 120 | /// | ||
| 121 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 122 | { | ||
| 123 | using namespace ::kodi::addon; | ||
| 124 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( | ||
| 125 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 126 | } | ||
| 127 | //-------------------------------------------------------------------------- | ||
| 128 | |||
| 129 | //========================================================================== | ||
| 130 | /// | ||
| 131 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 132 | /// @brief To enable and show cancel button on dialog | ||
| 133 | /// | ||
| 134 | /// @param[in] canCancel if true becomes it shown | ||
| 135 | /// | ||
| 136 | void SetCanCancel(bool canCancel) | ||
| 137 | { | ||
| 138 | using namespace ::kodi::addon; | ||
| 139 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( | ||
| 140 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 141 | } | ||
| 142 | //-------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //========================================================================== | ||
| 145 | /// | ||
| 146 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 147 | /// @brief To check dialog for clicked cancel button | ||
| 148 | /// | ||
| 149 | /// @return True if canceled | ||
| 150 | /// | ||
| 151 | bool IsCanceled() const | ||
| 152 | { | ||
| 153 | using namespace ::kodi::addon; | ||
| 154 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( | ||
| 155 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 156 | } | ||
| 157 | //-------------------------------------------------------------------------- | ||
| 158 | |||
| 159 | //========================================================================== | ||
| 160 | /// | ||
| 161 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 162 | /// @brief Get the current progress position as percent | ||
| 163 | /// | ||
| 164 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 165 | /// | ||
| 166 | void SetPercentage(int percentage) | ||
| 167 | { | ||
| 168 | using namespace ::kodi::addon; | ||
| 169 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( | ||
| 170 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 177 | /// @brief To set the current progress position as percent | ||
| 178 | /// | ||
| 179 | /// @return Current Position used from 0 to 100 | ||
| 180 | /// | ||
| 181 | int GetPercentage() const | ||
| 182 | { | ||
| 183 | using namespace ::kodi::addon; | ||
| 184 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( | ||
| 185 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 186 | } | ||
| 187 | //-------------------------------------------------------------------------- | ||
| 188 | |||
| 189 | //========================================================================== | ||
| 190 | /// | ||
| 191 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 192 | /// @brief To show or hide progress bar dialog | ||
| 193 | /// | ||
| 194 | /// @param[in] onOff If true becomes it shown | ||
| 195 | /// | ||
| 196 | void ShowProgressBar(bool onOff) | ||
| 197 | { | ||
| 198 | using namespace ::kodi::addon; | ||
| 199 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( | ||
| 200 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 201 | } | ||
| 202 | //-------------------------------------------------------------------------- | ||
| 203 | |||
| 204 | //========================================================================== | ||
| 205 | /// | ||
| 206 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 207 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 208 | /// | ||
| 209 | /// @param[in] max Biggest usable position to use | ||
| 210 | /// | ||
| 211 | void SetProgressMax(int max) | ||
| 212 | { | ||
| 213 | using namespace ::kodi::addon; | ||
| 214 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( | ||
| 215 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 216 | } | ||
| 217 | //-------------------------------------------------------------------------- | ||
| 218 | |||
| 219 | //========================================================================== | ||
| 220 | /// | ||
| 221 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 222 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 223 | /// | ||
| 224 | /// @param[in] steps Step size to increase, default is 1 | ||
| 225 | /// | ||
| 226 | void SetProgressAdvance(int steps = 1) | ||
| 227 | { | ||
| 228 | using namespace ::kodi::addon; | ||
| 229 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( | ||
| 230 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 231 | } | ||
| 232 | //-------------------------------------------------------------------------- | ||
| 233 | |||
| 234 | //========================================================================== | ||
| 235 | /// | ||
| 236 | /// \ingroup cpp_kodi_gui_dialogs_CProgress | ||
| 237 | /// @brief To check progress was canceled on work | ||
| 238 | /// | ||
| 239 | /// @return True if aborted | ||
| 240 | /// | ||
| 241 | bool Abort() | ||
| 242 | { | ||
| 243 | using namespace ::kodi::addon; | ||
| 244 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( | ||
| 245 | CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 246 | } | ||
| 247 | //-------------------------------------------------------------------------- | ||
| 248 | |||
| 249 | private: | ||
| 250 | void* m_DialogHandle; | ||
| 251 | }; | ||
| 252 | |||
| 253 | } /* namespace dialogs */ | ||
| 254 | } /* namespace gui */ | ||
| 255 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h deleted file mode 100644 index 39a98fe..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h +++ /dev/null | |||
| @@ -1,269 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | //============================================================================== | ||
| 15 | /// \defgroup cpp_kodi_vfs_Defs Definitions, structures and enumerators | ||
| 16 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 17 | /// @brief **Dialog Select definition values** | ||
| 18 | //------------------------------------------------------------------------------ | ||
| 19 | |||
| 20 | //============================================================================== | ||
| 21 | /// \ingroup cpp_kodi_vfs_Defs | ||
| 22 | /// @brief **Selection entry structure** | ||
| 23 | /// | ||
| 24 | typedef struct SSelectionEntry | ||
| 25 | { | ||
| 26 | //============================================================================ | ||
| 27 | /// Structure constructor | ||
| 28 | /// | ||
| 29 | /// There becomes selected always set to false. | ||
| 30 | /// | ||
| 31 | SSelectionEntry() = default; | ||
| 32 | //---------------------------------------------------------------------------- | ||
| 33 | |||
| 34 | /// Entry identfication string | ||
| 35 | std::string id; | ||
| 36 | |||
| 37 | /// Entry name to show on GUI dialog | ||
| 38 | std::string name; | ||
| 39 | |||
| 40 | /// Place where entry can be preselected and after return the from user | ||
| 41 | /// selected is set. | ||
| 42 | bool selected = false; | ||
| 43 | } SSelectionEntry; | ||
| 44 | //------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | namespace kodi | ||
| 47 | { | ||
| 48 | namespace gui | ||
| 49 | { | ||
| 50 | namespace dialogs | ||
| 51 | { | ||
| 52 | |||
| 53 | //============================================================================ | ||
| 54 | /// | ||
| 55 | /// \defgroup cpp_kodi_gui_dialogs_Select Dialog Select | ||
| 56 | /// \ingroup cpp_kodi_gui | ||
| 57 | /// @{ | ||
| 58 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Select } | ||
| 59 | /// **Selection dialog** | ||
| 60 | /// | ||
| 61 | /// The function listed below permits the call of a dialogue to select of an | ||
| 62 | /// entry as a key | ||
| 63 | /// | ||
| 64 | /// It has the header \ref Select.h "#include <kodi/gui/dialogs/Select.h>" | ||
| 65 | /// be included to enjoy it. | ||
| 66 | /// | ||
| 67 | /// | ||
| 68 | namespace Select | ||
| 69 | { | ||
| 70 | //========================================================================== | ||
| 71 | /// | ||
| 72 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 73 | /// @brief Show a selection dialog about given parts. | ||
| 74 | /// | ||
| 75 | /// @param[in] heading Dialog heading name | ||
| 76 | /// @param[in] entries String list about entries | ||
| 77 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 78 | /// <tt>-1</tt> for the first) | ||
| 79 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 80 | /// time in ms. As '0' it stays open. | ||
| 81 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 82 | /// nothing selected or canceled | ||
| 83 | /// | ||
| 84 | /// | ||
| 85 | ///------------------------------------------------------------------------- | ||
| 86 | /// | ||
| 87 | /// **Example:** | ||
| 88 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 89 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 90 | /// | ||
| 91 | /// const std::vector<std::string> entries | ||
| 92 | /// { | ||
| 93 | /// "Test 1", | ||
| 94 | /// "Test 2", | ||
| 95 | /// "Test 3", | ||
| 96 | /// "Test 4", | ||
| 97 | /// "Test 5" | ||
| 98 | /// }; | ||
| 99 | /// | ||
| 100 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 101 | /// if (selected < 0) | ||
| 102 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 103 | /// else | ||
| 104 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 105 | /// ~~~~~~~~~~~~~ | ||
| 106 | /// | ||
| 107 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 108 | const std::vector<std::string>& entries, | ||
| 109 | int selected = -1, | ||
| 110 | unsigned int autoclose = 0) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 114 | const char** cEntries = (const char**)malloc(size * sizeof(const char**)); | ||
| 115 | for (unsigned int i = 0; i < size; ++i) | ||
| 116 | { | ||
| 117 | cEntries[i] = entries[i].c_str(); | ||
| 118 | } | ||
| 119 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( | ||
| 120 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, | ||
| 121 | autoclose); | ||
| 122 | free(cEntries); | ||
| 123 | return ret; | ||
| 124 | } | ||
| 125 | //-------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //========================================================================== | ||
| 128 | /// | ||
| 129 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 130 | /// @brief Show a selection dialog about given parts. | ||
| 131 | /// | ||
| 132 | /// This function is mostly equal to the other, only becomes the string list | ||
| 133 | /// here done by a SSelectionEntry, where a ID string can be defined. | ||
| 134 | /// | ||
| 135 | /// @param[in] heading Dialog heading name | ||
| 136 | /// @param[in] entries SSelectionEntry list about entries | ||
| 137 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 138 | /// <tt>-1</tt> for the first) | ||
| 139 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 140 | /// time in ms. As '0' it stays open. | ||
| 141 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 142 | /// nothing selected or canceled | ||
| 143 | /// | ||
| 144 | /// | ||
| 145 | ///------------------------------------------------------------------------- | ||
| 146 | /// | ||
| 147 | /// **Example:** | ||
| 148 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 149 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 150 | /// | ||
| 151 | /// std::vector<SSelectionEntry> entries | ||
| 152 | /// { | ||
| 153 | /// { "ID 1", "Test 1", false }, | ||
| 154 | /// { "ID 2", "Test 2", false }, | ||
| 155 | /// { "ID 3", "Test 3", false }, | ||
| 156 | /// { "ID 4", "Test 4", false }, | ||
| 157 | /// { "ID 5", "Test 5", false } | ||
| 158 | /// }; | ||
| 159 | /// | ||
| 160 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 161 | /// if (selected < 0) | ||
| 162 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 163 | /// else | ||
| 164 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 165 | /// ~~~~~~~~~~~~~ | ||
| 166 | /// | ||
| 167 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 168 | std::vector<SSelectionEntry>& entries, | ||
| 169 | int selected = -1, | ||
| 170 | unsigned int autoclose = 0) | ||
| 171 | { | ||
| 172 | using namespace ::kodi::addon; | ||
| 173 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 174 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 175 | for (unsigned int i = 0; i < size; ++i) | ||
| 176 | { | ||
| 177 | cEntries[i] = entries[i].name.c_str(); | ||
| 178 | if (selected == -1 && entries[i].selected) | ||
| 179 | selected = i; | ||
| 180 | } | ||
| 181 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), | ||
| 182 | cEntries, size, selected, autoclose); | ||
| 183 | if (ret >= 0) | ||
| 184 | { | ||
| 185 | entries[ret].selected = true; | ||
| 186 | } | ||
| 187 | free(cEntries); | ||
| 188 | return ret; | ||
| 189 | } | ||
| 190 | //-------------------------------------------------------------------------- | ||
| 191 | |||
| 192 | //========================================================================== | ||
| 193 | /// | ||
| 194 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 195 | /// @brief Show a multiple selection dialog about given parts. | ||
| 196 | /// | ||
| 197 | /// @param[in] heading Dialog heading name | ||
| 198 | /// @param[in] entries SSelectionEntry list about entries | ||
| 199 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 200 | /// time in ms. As '0' it stays open. | ||
| 201 | /// @return The selected entries, if return <tt>empty</tt> was | ||
| 202 | /// nothing selected or canceled | ||
| 203 | /// | ||
| 204 | /// With selected on SSelectionEntry can be a pre selection defined. | ||
| 205 | /// | ||
| 206 | ///------------------------------------------------------------------------- | ||
| 207 | /// | ||
| 208 | /// **Example:** | ||
| 209 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 210 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 211 | /// | ||
| 212 | /// std::vector<SSelectionEntry> entries | ||
| 213 | /// { | ||
| 214 | /// { "ID 1", "Test 1", false }, | ||
| 215 | /// { "ID 2", "Test 2", false }, | ||
| 216 | /// { "ID 3", "Test 3", false }, | ||
| 217 | /// { "ID 4", "Test 4", false }, | ||
| 218 | /// { "ID 5", "Test 5", false } | ||
| 219 | /// }; | ||
| 220 | /// | ||
| 221 | /// bool ret = kodi::gui::dialogs::Select::ShowMultiSelect("Test selection", entries); | ||
| 222 | /// if (!ret) | ||
| 223 | /// fprintf(stderr, "Selection canceled\n"); | ||
| 224 | /// else | ||
| 225 | /// { | ||
| 226 | /// fprintf(stderr, "Selected items:\n"); | ||
| 227 | /// for (const auto& entry : entries) | ||
| 228 | /// { | ||
| 229 | /// if (entry.selected) | ||
| 230 | /// fprintf(stderr, " - %s\n", entry.selected.id.c_str()); | ||
| 231 | /// } | ||
| 232 | /// } | ||
| 233 | /// ~~~~~~~~~~~~~ | ||
| 234 | /// | ||
| 235 | inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading, | ||
| 236 | std::vector<SSelectionEntry>& entries, | ||
| 237 | int autoclose = 0) | ||
| 238 | { | ||
| 239 | using namespace ::kodi::addon; | ||
| 240 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 241 | const char** cEntryIDs = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 242 | const char** cEntryNames = static_cast<const char**>(malloc(size*sizeof(const char*))); | ||
| 243 | bool* cEntriesSelected = static_cast<bool*>(malloc(size*sizeof(bool))); | ||
| 244 | for (unsigned int i = 0; i < size; ++i) | ||
| 245 | { | ||
| 246 | cEntryIDs[i] = entries[i].id.c_str(); | ||
| 247 | cEntryNames[i] = entries[i].name.c_str(); | ||
| 248 | cEntriesSelected[i] = entries[i].selected; | ||
| 249 | } | ||
| 250 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open_multi_select(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 251 | heading.c_str(), cEntryIDs, cEntryNames, | ||
| 252 | cEntriesSelected, size, autoclose); | ||
| 253 | if (ret) | ||
| 254 | { | ||
| 255 | for (unsigned int i = 0; i < size; ++i) | ||
| 256 | entries[i].selected = cEntriesSelected[i]; | ||
| 257 | } | ||
| 258 | free(cEntryNames); | ||
| 259 | free(cEntryIDs); | ||
| 260 | free(cEntriesSelected); | ||
| 261 | return ret; | ||
| 262 | } | ||
| 263 | //-------------------------------------------------------------------------- | ||
| 264 | }; | ||
| 265 | /// @} | ||
| 266 | |||
| 267 | } /* namespace dialogs */ | ||
| 268 | } /* namespace gui */ | ||
| 269 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h deleted file mode 100644 index 5c81837..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h +++ /dev/null | |||
| @@ -1,108 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::TextViewer } | ||
| 27 | /// **Text viewer dialog** | ||
| 28 | /// | ||
| 29 | /// The text viewer dialog can be used to display descriptions, help texts or | ||
| 30 | /// other larger texts. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | namespace TextViewer | ||
| 40 | { | ||
| 41 | //========================================================================== | ||
| 42 | /// | ||
| 43 | /// \ingroup cpp_kodi_gui_dialogs_TextViewer | ||
| 44 | /// @brief Show info text dialog | ||
| 45 | /// | ||
| 46 | /// @param[in] heading Small heading text | ||
| 47 | /// @param[in] text Showed text on dialog | ||
| 48 | /// | ||
| 49 | /// | ||
| 50 | ///------------------------------------------------------------------------- | ||
| 51 | /// | ||
| 52 | /// **Example:** | ||
| 53 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 54 | /// #include <kodi/gui/dialogs/TextViewer.h> | ||
| 55 | /// | ||
| 56 | /// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)", | ||
| 57 | /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " | ||
| 58 | /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " | ||
| 59 | /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " | ||
| 60 | /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" | ||
| 61 | /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " | ||
| 62 | /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " | ||
| 63 | /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" | ||
| 64 | /// "\n" | ||
| 65 | /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " | ||
| 66 | /// "unusual characters, over the years it has become an icon of American popular " | ||
| 67 | /// "culture. It was nominated for six Academy Awards, including Best Picture but " | ||
| 68 | /// "lost to Gone with the Wind. It did win in two other categories including Best " | ||
| 69 | /// "Original Song for \"Over the Rainbow\". However, the film was a box office " | ||
| 70 | /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " | ||
| 71 | /// "budget, despite receiving largely positive reviews. It was MGM's most " | ||
| 72 | /// "expensive production at that time, and did not completely recoup the studio's " | ||
| 73 | /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" | ||
| 74 | /// "\n" | ||
| 75 | /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " | ||
| 76 | /// "film to the wider public and eventually made the presentation an annual " | ||
| 77 | /// "tradition, making it one of the most known films in cinema history. The " | ||
| 78 | /// "film was named the most-viewed motion picture on television syndication by " | ||
| 79 | /// "the Library of Congress who also included the film in its National Film " | ||
| 80 | /// "Registry in its inaugural year in 1989. Designation on the registry calls " | ||
| 81 | /// "for efforts to preserve it for being \"culturally, historically, and " | ||
| 82 | /// "aesthetically significant\". It is also one of the few films on UNESCO's " | ||
| 83 | /// "Memory of the World Register.\n" | ||
| 84 | /// "\n" | ||
| 85 | /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " | ||
| 86 | /// "polls. It is the source of many quotes referenced in modern popular culture. " | ||
| 87 | /// "It was directed primarily by Victor Fleming (who left production to take " | ||
| 88 | /// "over direction on the troubled Gone with the Wind production). Noel Langley, " | ||
| 89 | /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " | ||
| 90 | /// "but there were uncredited contributions by others. The songs were written " | ||
| 91 | /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " | ||
| 92 | /// "music, based largely on the songs, was composed by Herbert Stothart, with " | ||
| 93 | /// "interspersed renderings from classical composers.\n"); | ||
| 94 | /// ~~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text) | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open( | ||
| 100 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 101 | } | ||
| 102 | //-------------------------------------------------------------------------- | ||
| 103 | }; | ||
| 104 | /// @} | ||
| 105 | |||
| 106 | } /* namespace dialogs */ | ||
| 107 | } /* namespace gui */ | ||
| 108 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h deleted file mode 100644 index 67c2fc4..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h +++ /dev/null | |||
| @@ -1,188 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @{ | ||
| 26 | /// @brief \cpp_namespace{ kodi::gui::dialogs::YesNo } | ||
| 27 | /// **Yes / No dialog** | ||
| 28 | /// | ||
| 29 | /// The Yes / No dialog can be used to inform the user about questions and get | ||
| 30 | /// the answer. | ||
| 31 | /// | ||
| 32 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 33 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 34 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 35 | /// | ||
| 36 | /// It has the header \ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// | ||
| 40 | namespace YesNo | ||
| 41 | { | ||
| 42 | //========================================================================== | ||
| 43 | /// | ||
| 44 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 45 | /// @brief Use dialog to get numeric new password with one text string shown | ||
| 46 | /// everywhere and cancel return field | ||
| 47 | /// | ||
| 48 | /// @param[in] heading Dialog heading | ||
| 49 | /// @param[in] text Multi-line text | ||
| 50 | /// @param[out] canceled Return value about cancel button | ||
| 51 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 52 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 53 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 54 | /// | ||
| 55 | /// @note It is preferred to only use this as it is actually a multi-line text. | ||
| 56 | /// | ||
| 57 | /// | ||
| 58 | ///------------------------------------------------------------------------- | ||
| 59 | /// | ||
| 60 | /// **Example:** | ||
| 61 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 62 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 63 | /// | ||
| 64 | /// bool canceled; | ||
| 65 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 66 | /// "Yes / No test call", /* The Header */ | ||
| 67 | /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", | ||
| 68 | /// canceled, /* return value about cancel button */ | ||
| 69 | /// "Not really", /* No label, is optional and if empty "No" */ | ||
| 70 | /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ | ||
| 71 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 72 | /// ret ? "yes" : "no", | ||
| 73 | /// canceled ? "canceled" : "not canceled"); | ||
| 74 | /// ~~~~~~~~~~~~~ | ||
| 75 | /// | ||
| 76 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 77 | const std::string& text, | ||
| 78 | bool& canceled, | ||
| 79 | const std::string& noLabel = "", | ||
| 80 | const std::string& yesLabel = "") | ||
| 81 | { | ||
| 82 | using namespace ::kodi::addon; | ||
| 83 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( | ||
| 84 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, | ||
| 85 | noLabel.c_str(), yesLabel.c_str()); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// | ||
| 91 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 92 | /// @brief Use dialog to get numeric new password with separated line strings | ||
| 93 | /// | ||
| 94 | /// @param[in] heading Dialog heading | ||
| 95 | /// @param[in] line0 Line #0 text | ||
| 96 | /// @param[in] line1 Line #1 text | ||
| 97 | /// @param[in] line2 Line #2 text | ||
| 98 | /// @param[in] noLabel [opt] label to put on the no button. | ||
| 99 | /// @param[in] yesLabel [opt] label to put on the yes button. | ||
| 100 | /// @return Returns True if 'Yes' was pressed, else False. | ||
| 101 | /// | ||
| 102 | /// | ||
| 103 | ///------------------------------------------------------------------------- | ||
| 104 | /// | ||
| 105 | /// **Example:** | ||
| 106 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 107 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 108 | /// | ||
| 109 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 110 | /// "Yes / No test call", // The Header | ||
| 111 | /// "You has opened Yes / No dialog for test", | ||
| 112 | /// "", | ||
| 113 | /// "Is this OK for you?", | ||
| 114 | /// "Not really", // No label, is optional and if empty "No" | ||
| 115 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 116 | /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", | ||
| 117 | /// ret ? "yes" : "no"); | ||
| 118 | /// ~~~~~~~~~~~~~ | ||
| 119 | /// | ||
| 120 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 121 | const std::string& line0, | ||
| 122 | const std::string& line1, | ||
| 123 | const std::string& line2, | ||
| 124 | const std::string& noLabel = "", | ||
| 125 | const std::string& yesLabel = "") | ||
| 126 | { | ||
| 127 | using namespace ::kodi::addon; | ||
| 128 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 129 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 130 | noLabel.c_str(), yesLabel.c_str()); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 137 | /// @brief Use dialog to get numeric new password with separated line strings and cancel return field | ||
| 138 | /// | ||
| 139 | /// @param[in] heading Dialog heading | ||
| 140 | /// @param[in] line0 Line #0 text | ||
| 141 | /// @param[in] line1 Line #1 text | ||
| 142 | /// @param[in] line2 Line #2 text | ||
| 143 | /// @param[out] canceled Return value about cancel button | ||
| 144 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 145 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 146 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 147 | /// | ||
| 148 | /// | ||
| 149 | ///------------------------------------------------------------------------- | ||
| 150 | /// | ||
| 151 | /// **Example:** | ||
| 152 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 153 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 154 | /// | ||
| 155 | /// bool canceled; | ||
| 156 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 157 | /// "Yes / No test call", // The Header | ||
| 158 | /// "You has opened Yes / No dialog for test", | ||
| 159 | /// "", | ||
| 160 | /// "Is this OK for you?", | ||
| 161 | /// canceled, // return value about cancel button | ||
| 162 | /// "Not really", // No label, is optional and if empty "No" | ||
| 163 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 164 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 165 | /// ret ? "yes" : "no", | ||
| 166 | /// canceled ? "canceled" : "not canceled"); | ||
| 167 | /// ~~~~~~~~~~~~~ | ||
| 168 | /// | ||
| 169 | inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, | ||
| 170 | const std::string& line0, | ||
| 171 | const std::string& line1, | ||
| 172 | const std::string& line2, | ||
| 173 | bool& canceled, | ||
| 174 | const std::string& noLabel = "", | ||
| 175 | const std::string& yesLabel = "") | ||
| 176 | { | ||
| 177 | using namespace ::kodi::addon; | ||
| 178 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 179 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 180 | &canceled, noLabel.c_str(), yesLabel.c_str()); | ||
| 181 | } | ||
| 182 | //-------------------------------------------------------------------------- | ||
| 183 | }; | ||
| 184 | /// @} | ||
| 185 | |||
| 186 | } /* namespace dialogs */ | ||
| 187 | } /* namespace gui */ | ||
| 188 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt deleted file mode 100644 index a9ab70c..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | set(HEADERS GL.h | ||
| 2 | GLonDX.h | ||
| 3 | Shader.h) | ||
| 4 | |||
| 5 | if(NOT ENABLE_STATIC_LIBS) | ||
| 6 | core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_gl) | ||
| 7 | endif() | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h deleted file mode 100644 index 943c7d0..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h +++ /dev/null | |||
| @@ -1,111 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 | //============================================================================== | ||
| 12 | /// | ||
| 13 | /// \defgroup cpp_kodi_gui_gl OpenGL helpers | ||
| 14 | /// \ingroup cpp_kodi_gui | ||
| 15 | /// \brief Auxiliary functions for Open GL | ||
| 16 | /// | ||
| 17 | /// This group includes help for definitions, functions, and classes for | ||
| 18 | /// OpenGL. | ||
| 19 | /// | ||
| 20 | /// To use OpenGL for your system, add the \ref GL.h "#include <kodi/gui/gl/GL.h>". | ||
| 21 | /// | ||
| 22 | /// | ||
| 23 | ///----------------------------------------------------------------------------- | ||
| 24 | /// | ||
| 25 | /// The \ref HAS_GL is declared if Open GL is required and \ref HAS_GLES if Open GL | ||
| 26 | /// Embedded Systems (ES) is required, with ES the version is additionally given | ||
| 27 | /// in the definition, this can be "2" or "3". | ||
| 28 | /// | ||
| 29 | /// | ||
| 30 | ///----------------------------------------------------------------------------- | ||
| 31 | /// | ||
| 32 | /// Following \ref GL_TYPE_STRING define can be used, for example, to manage | ||
| 33 | /// different folders for GL and GLES and make the selection easier. | ||
| 34 | /// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>. | ||
| 35 | /// | ||
| 36 | /// **Example:** | ||
| 37 | /// ~~~~~~~~~~~~~~~~~{.cpp} | ||
| 38 | /// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); | ||
| 39 | /// ~~~~~~~~~~~~~~~~~ | ||
| 40 | /// | ||
| 41 | /// | ||
| 42 | ///---------------------------------------------------------------------------- | ||
| 43 | /// | ||
| 44 | /// In addition, \ref BUFFER_OFFSET is declared in it which can be used to give an | ||
| 45 | /// offset on the array to GL. | ||
| 46 | /// | ||
| 47 | /// **Example:** | ||
| 48 | /// ~~~~~~~~~~~~~~~~~{.cpp} | ||
| 49 | /// const struct PackedVertex { | ||
| 50 | /// float position[3]; // Position x, y, z | ||
| 51 | /// float color[4]; // Color r, g, b, a | ||
| 52 | /// } vertices[3] = { | ||
| 53 | /// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, | ||
| 54 | /// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, | ||
| 55 | /// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } } | ||
| 56 | /// }; | ||
| 57 | /// | ||
| 58 | /// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position))); | ||
| 59 | /// glEnableVertexAttribArray(m_aPosition); | ||
| 60 | /// | ||
| 61 | /// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color))); | ||
| 62 | /// glEnableVertexAttribArray(m_aColor); | ||
| 63 | /// ~~~~~~~~~~~~~~~~~ | ||
| 64 | |||
| 65 | #if HAS_GL | ||
| 66 | #define GL_TYPE_STRING "GL" | ||
| 67 | // always define GL_GLEXT_PROTOTYPES before include gl headers | ||
| 68 | #if !defined(GL_GLEXT_PROTOTYPES) | ||
| 69 | #define GL_GLEXT_PROTOTYPES | ||
| 70 | #endif | ||
| 71 | #if defined(TARGET_LINUX) | ||
| 72 | #include <GL/gl.h> | ||
| 73 | #include <GL/glext.h> | ||
| 74 | #elif defined(TARGET_FREEBSD) | ||
| 75 | #include <GL/gl.h> | ||
| 76 | #elif defined(TARGET_DARWIN) | ||
| 77 | #include <OpenGL/gl3.h> | ||
| 78 | #include <OpenGL/gl3ext.h> | ||
| 79 | #elif defined(WIN32) | ||
| 80 | #error Use of GL under Windows is not possible | ||
| 81 | #endif | ||
| 82 | #elif HAS_GLES >= 2 | ||
| 83 | #define GL_TYPE_STRING "GLES" | ||
| 84 | #if defined(WIN32) | ||
| 85 | #if defined(HAS_ANGLE) | ||
| 86 | #include <angle_gl.h> | ||
| 87 | #else | ||
| 88 | #error Use of GLES only be available under Windows by the use of angle | ||
| 89 | #endif | ||
| 90 | #elif defined(TARGET_DARWIN) | ||
| 91 | #if HAS_GLES == 3 | ||
| 92 | #include <OpenGLES/ES3/gl.h> | ||
| 93 | #include <OpenGLES/ES3/glext.h> | ||
| 94 | #else | ||
| 95 | #include <OpenGLES/ES2/gl.h> | ||
| 96 | #include <OpenGLES/ES2/glext.h> | ||
| 97 | #endif | ||
| 98 | #else | ||
| 99 | #if HAS_GLES == 3 | ||
| 100 | #include <GLES3/gl3.h> | ||
| 101 | #include <GLES3/gl3ext.h> | ||
| 102 | #else | ||
| 103 | #include <GLES2/gl2.h> | ||
| 104 | #include <GLES2/gl2ext.h> | ||
| 105 | #endif | ||
| 106 | #endif | ||
| 107 | #endif | ||
| 108 | |||
| 109 | #ifndef BUFFER_OFFSET | ||
| 110 | #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) | ||
| 111 | #endif | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h deleted file mode 100644 index 7a6a0a1..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h +++ /dev/null | |||
| @@ -1,369 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 <angle_gl.h> | ||
| 12 | #include <d3d11.h> | ||
| 13 | #include <d3dcompiler.h> | ||
| 14 | #include <EGL/egl.h> | ||
| 15 | #include <EGL/eglext.h> | ||
| 16 | #include <kodi/AddonBase.h> | ||
| 17 | #include <kodi/gui/General.h> | ||
| 18 | #include <wrl/client.h> | ||
| 19 | |||
| 20 | #pragma comment( lib, "d3dcompiler.lib" ) | ||
| 21 | #ifndef GL_CLIENT_VERSION | ||
| 22 | #define GL_CLIENT_VERSION 3 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | namespace gl | ||
| 30 | { | ||
| 31 | |||
| 32 | class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper | ||
| 33 | { | ||
| 34 | public: | ||
| 35 | explicit CGLonDX() : m_pContext(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())) {} | ||
| 36 | ~CGLonDX() override { destruct(); } | ||
| 37 | |||
| 38 | bool Init() override | ||
| 39 | { | ||
| 40 | EGLint egl_display_attrs[] = | ||
| 41 | { | ||
| 42 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, | ||
| 43 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | ||
| 44 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, | ||
| 45 | EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE, | ||
| 46 | EGL_NONE | ||
| 47 | }; | ||
| 48 | EGLint egl_config_attrs[] = | ||
| 49 | { | ||
| 50 | EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, | ||
| 51 | EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, | ||
| 52 | EGL_RENDERABLE_TYPE, GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, | ||
| 53 | EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, | ||
| 54 | EGL_NONE | ||
| 55 | }; | ||
| 56 | EGLint egl_context_attrs[] = | ||
| 57 | { | ||
| 58 | EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE | ||
| 59 | }; | ||
| 60 | |||
| 61 | m_eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs); | ||
| 62 | if (m_eglDisplay == EGL_NO_DISPLAY) | ||
| 63 | { | ||
| 64 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString()); | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | |||
| 68 | if (eglInitialize(m_eglDisplay, nullptr, nullptr) != EGL_TRUE) | ||
| 69 | { | ||
| 70 | Log(ADDON_LOG_ERROR, "GLonDX: unable to init EGL display (%s)", eglGetErrorString()); | ||
| 71 | return false; | ||
| 72 | } | ||
| 73 | |||
| 74 | EGLint numConfigs = 0; | ||
| 75 | if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE || numConfigs == 0) | ||
| 76 | { | ||
| 77 | Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString()); | ||
| 78 | return false; | ||
| 79 | } | ||
| 80 | |||
| 81 | m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, egl_context_attrs); | ||
| 82 | if (m_eglContext == EGL_NO_CONTEXT) | ||
| 83 | { | ||
| 84 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL context (%s)", eglGetErrorString()); | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | |||
| 88 | if (!createD3DResources()) | ||
| 89 | return false; | ||
| 90 | |||
| 91 | if (eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext) != EGL_TRUE) | ||
| 92 | { | ||
| 93 | Log(ADDON_LOG_ERROR, "GLonDX: unable to make current EGL (%s)", eglGetErrorString()); | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | return true; | ||
| 97 | } | ||
| 98 | |||
| 99 | void CheckGL(ID3D11DeviceContext* device) | ||
| 100 | { | ||
| 101 | if (m_pContext != device) | ||
| 102 | { | ||
| 103 | m_pSRView = nullptr; | ||
| 104 | m_pVShader = nullptr; | ||
| 105 | m_pPShader = nullptr; | ||
| 106 | m_pContext = device; | ||
| 107 | |||
| 108 | if (m_eglBuffer != EGL_NO_SURFACE) | ||
| 109 | { | ||
| 110 | eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||
| 111 | eglDestroySurface(m_eglDisplay, m_eglBuffer); | ||
| 112 | m_eglBuffer = EGL_NO_SURFACE; | ||
| 113 | } | ||
| 114 | |||
| 115 | // create new resources | ||
| 116 | if (!createD3DResources()) | ||
| 117 | return; | ||
| 118 | |||
| 119 | eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | void Begin() override | ||
| 124 | { | ||
| 125 | // confirm on begin D3D context is correct | ||
| 126 | CheckGL(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext())); | ||
| 127 | |||
| 128 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | ||
| 129 | glClear(GL_COLOR_BUFFER_BIT); | ||
| 130 | } | ||
| 131 | |||
| 132 | void End() override | ||
| 133 | { | ||
| 134 | glFlush(); | ||
| 135 | |||
| 136 | // set our primitive shaders | ||
| 137 | m_pContext->VSSetShader(m_pVShader.Get(), nullptr, 0); | ||
| 138 | m_pContext->PSSetShader(m_pPShader.Get(), nullptr, 0); | ||
| 139 | m_pContext->PSSetShaderResources(0, 1, m_pSRView.GetAddressOf()); | ||
| 140 | // draw texture | ||
| 141 | m_pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); | ||
| 142 | m_pContext->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr); | ||
| 143 | m_pContext->IASetInputLayout(nullptr); | ||
| 144 | m_pContext->Draw(4, 0); | ||
| 145 | // unset shaders | ||
| 146 | m_pContext->PSSetShader(nullptr, nullptr, 0); | ||
| 147 | m_pContext->VSSetShader(nullptr, nullptr, 0); | ||
| 148 | // unbind our view | ||
| 149 | ID3D11ShaderResourceView* views[1] = {}; | ||
| 150 | m_pContext->PSSetShaderResources(0, 1, views); | ||
| 151 | } | ||
| 152 | |||
| 153 | private: | ||
| 154 | enum ShaderType | ||
| 155 | { | ||
| 156 | VERTEX_SHADER, | ||
| 157 | PIXEL_SHADER | ||
| 158 | }; | ||
| 159 | |||
| 160 | bool createD3DResources() | ||
| 161 | { | ||
| 162 | HANDLE sharedHandle; | ||
| 163 | Microsoft::WRL::ComPtr<ID3D11Device> pDevice; | ||
| 164 | Microsoft::WRL::ComPtr<ID3D11RenderTargetView> pRTView; | ||
| 165 | Microsoft::WRL::ComPtr<ID3D11Resource> pRTResource; | ||
| 166 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pRTTexture; | ||
| 167 | Microsoft::WRL::ComPtr<ID3D11Texture2D> pOffScreenTexture; | ||
| 168 | Microsoft::WRL::ComPtr<IDXGIResource> dxgiResource; | ||
| 169 | |||
| 170 | m_pContext->GetDevice(&pDevice); | ||
| 171 | m_pContext->OMGetRenderTargets(1, &pRTView, nullptr); | ||
| 172 | if (!pRTView) | ||
| 173 | return false; | ||
| 174 | |||
| 175 | pRTView->GetResource(&pRTResource); | ||
| 176 | if (FAILED(pRTResource.As(&pRTTexture))) | ||
| 177 | return false; | ||
| 178 | |||
| 179 | D3D11_TEXTURE2D_DESC texDesc; | ||
| 180 | pRTTexture->GetDesc(&texDesc); | ||
| 181 | texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; | ||
| 182 | texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; | ||
| 183 | texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; | ||
| 184 | if (FAILED(pDevice->CreateTexture2D(&texDesc, nullptr, &pOffScreenTexture))) | ||
| 185 | { | ||
| 186 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create intermediate texture"); | ||
| 187 | return false; | ||
| 188 | } | ||
| 189 | |||
| 190 | CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D); | ||
| 191 | if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView))) | ||
| 192 | { | ||
| 193 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view"); | ||
| 194 | return false; | ||
| 195 | } | ||
| 196 | |||
| 197 | if (FAILED(pOffScreenTexture.As(&dxgiResource)) || | ||
| 198 | FAILED(dxgiResource->GetSharedHandle(&sharedHandle))) | ||
| 199 | { | ||
| 200 | Log(ADDON_LOG_ERROR, "GLonDX: unable get shared handle for texture"); | ||
| 201 | return false; | ||
| 202 | } | ||
| 203 | |||
| 204 | // initiate simple shaders | ||
| 205 | if (FAILED(d3dCreateShader(VERTEX_SHADER, vs_out_shader_text, &m_pVShader))) | ||
| 206 | { | ||
| 207 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create vertex shader view"); | ||
| 208 | return false; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (FAILED(d3dCreateShader(PIXEL_SHADER, ps_out_shader_text, &m_pPShader))) | ||
| 212 | { | ||
| 213 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create pixel shader view"); | ||
| 214 | return false; | ||
| 215 | } | ||
| 216 | |||
| 217 | // create EGL buffer from D3D shared texture | ||
| 218 | EGLint egl_buffer_attrs[] = | ||
| 219 | { | ||
| 220 | EGL_WIDTH, static_cast<EGLint>(texDesc.Width), | ||
| 221 | EGL_HEIGHT, static_cast<EGLint>(texDesc.Height), | ||
| 222 | EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, | ||
| 223 | EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, | ||
| 224 | EGL_NONE | ||
| 225 | }; | ||
| 226 | |||
| 227 | m_eglBuffer = eglCreatePbufferFromClientBuffer(m_eglDisplay, | ||
| 228 | EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | ||
| 229 | sharedHandle, m_eglConfig, egl_buffer_attrs); | ||
| 230 | |||
| 231 | if (m_eglBuffer == EGL_NO_SURFACE) | ||
| 232 | { | ||
| 233 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL buffer (%s)", eglGetErrorString()); | ||
| 234 | return false; | ||
| 235 | } | ||
| 236 | return true; | ||
| 237 | } | ||
| 238 | |||
| 239 | HRESULT d3dCreateShader(ShaderType shaderType, const std::string& source, IUnknown** ppShader) const | ||
| 240 | { | ||
| 241 | Microsoft::WRL::ComPtr<ID3DBlob> pBlob; | ||
| 242 | Microsoft::WRL::ComPtr<ID3DBlob> pErrors; | ||
| 243 | |||
| 244 | auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main", | ||
| 245 | shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors); | ||
| 246 | |||
| 247 | if (SUCCEEDED(hr)) | ||
| 248 | { | ||
| 249 | Microsoft::WRL::ComPtr<ID3D11Device> pDevice; | ||
| 250 | m_pContext->GetDevice(&pDevice); | ||
| 251 | |||
| 252 | if (shaderType == PIXEL_SHADER) | ||
| 253 | { | ||
| 254 | hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | ||
| 255 | reinterpret_cast<ID3D11PixelShader**>(ppShader)); | ||
| 256 | } | ||
| 257 | else | ||
| 258 | { | ||
| 259 | hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, | ||
| 260 | reinterpret_cast<ID3D11VertexShader**>(ppShader)); | ||
| 261 | } | ||
| 262 | |||
| 263 | if (FAILED(hr)) | ||
| 264 | { | ||
| 265 | Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader", | ||
| 266 | shaderType == PIXEL_SHADER ? "pixel" : "vertex"); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | else | ||
| 270 | { | ||
| 271 | Log(ADDON_LOG_ERROR, "GLonDX: unable to compile shader (%s)", pErrors->GetBufferPointer()); | ||
| 272 | } | ||
| 273 | return hr; | ||
| 274 | } | ||
| 275 | |||
| 276 | static const char* eglGetErrorString() | ||
| 277 | { | ||
| 278 | #define CASE_STR( value ) case value: return #value | ||
| 279 | switch (eglGetError()) | ||
| 280 | { | ||
| 281 | CASE_STR(EGL_SUCCESS); | ||
| 282 | CASE_STR(EGL_NOT_INITIALIZED); | ||
| 283 | CASE_STR(EGL_BAD_ACCESS); | ||
| 284 | CASE_STR(EGL_BAD_ALLOC); | ||
| 285 | CASE_STR(EGL_BAD_ATTRIBUTE); | ||
| 286 | CASE_STR(EGL_BAD_CONTEXT); | ||
| 287 | CASE_STR(EGL_BAD_CONFIG); | ||
| 288 | CASE_STR(EGL_BAD_CURRENT_SURFACE); | ||
| 289 | CASE_STR(EGL_BAD_DISPLAY); | ||
| 290 | CASE_STR(EGL_BAD_SURFACE); | ||
| 291 | CASE_STR(EGL_BAD_MATCH); | ||
| 292 | CASE_STR(EGL_BAD_PARAMETER); | ||
| 293 | CASE_STR(EGL_BAD_NATIVE_PIXMAP); | ||
| 294 | CASE_STR(EGL_BAD_NATIVE_WINDOW); | ||
| 295 | CASE_STR(EGL_CONTEXT_LOST); | ||
| 296 | default: | ||
| 297 | return "Unknown"; | ||
| 298 | } | ||
| 299 | #undef CASE_STR | ||
| 300 | } | ||
| 301 | |||
| 302 | void destruct() | ||
| 303 | { | ||
| 304 | if (m_eglDisplay != EGL_NO_DISPLAY) | ||
| 305 | { | ||
| 306 | eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||
| 307 | |||
| 308 | if (m_eglBuffer != EGL_NO_SURFACE) | ||
| 309 | { | ||
| 310 | eglDestroySurface(m_eglDisplay, m_eglBuffer); | ||
| 311 | m_eglBuffer = EGL_NO_SURFACE; | ||
| 312 | } | ||
| 313 | |||
| 314 | if (m_eglContext != EGL_NO_CONTEXT) | ||
| 315 | { | ||
| 316 | eglDestroyContext(m_eglDisplay, m_eglContext); | ||
| 317 | m_eglContext = EGL_NO_CONTEXT; | ||
| 318 | } | ||
| 319 | |||
| 320 | eglTerminate(m_eglDisplay); | ||
| 321 | m_eglDisplay = EGL_NO_DISPLAY; | ||
| 322 | } | ||
| 323 | |||
| 324 | m_pSRView = nullptr; | ||
| 325 | m_pVShader = nullptr; | ||
| 326 | m_pPShader = nullptr; | ||
| 327 | m_pContext = nullptr; | ||
| 328 | } | ||
| 329 | |||
| 330 | EGLConfig m_eglConfig = EGL_NO_CONFIG_KHR; | ||
| 331 | EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; | ||
| 332 | EGLContext m_eglContext = EGL_NO_CONTEXT; | ||
| 333 | EGLSurface m_eglBuffer = EGL_NO_SURFACE; | ||
| 334 | |||
| 335 | ID3D11DeviceContext* m_pContext = nullptr; // don't hold context | ||
| 336 | Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_pSRView = nullptr; | ||
| 337 | Microsoft::WRL::ComPtr<ID3D11VertexShader> m_pVShader = nullptr; | ||
| 338 | Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pPShader = nullptr; | ||
| 339 | |||
| 340 | #define TO_STRING(...) #__VA_ARGS__ | ||
| 341 | std::string vs_out_shader_text = TO_STRING( | ||
| 342 | void main(uint id : SV_VertexId, out float2 tex : TEXCOORD0, out float4 pos : SV_POSITION) | ||
| 343 | { | ||
| 344 | tex = float2(id % 2, (id % 4) >> 1); | ||
| 345 | pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1); | ||
| 346 | }); | ||
| 347 | |||
| 348 | std::string ps_out_shader_text = TO_STRING( | ||
| 349 | Texture2D texMain : register(t0); | ||
| 350 | SamplerState Sampler | ||
| 351 | { | ||
| 352 | Filter = MIN_MAG_MIP_LINEAR; | ||
| 353 | AddressU = CLAMP; | ||
| 354 | AddressV = CLAMP; | ||
| 355 | Comparison = NEVER; | ||
| 356 | }; | ||
| 357 | |||
| 358 | float4 main(in float2 tex : TEXCOORD0) : SV_TARGET | ||
| 359 | { | ||
| 360 | return texMain.Sample(Sampler, tex); | ||
| 361 | }); | ||
| 362 | #undef TO_STRING | ||
| 363 | }; /* class CGLonDX */ | ||
| 364 | |||
| 365 | } /* namespace gl */ | ||
| 366 | |||
| 367 | using CRenderHelper = gl::CGLonDX; | ||
| 368 | } /* namespace gui */ | ||
| 369 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h deleted file mode 100644 index 209f274..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h +++ /dev/null | |||
| @@ -1,594 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 "GL.h" | ||
| 12 | |||
| 13 | #include <stdio.h> | ||
| 14 | #include <vector> | ||
| 15 | #include <string> | ||
| 16 | |||
| 17 | #include <kodi/AddonBase.h> | ||
| 18 | #include <kodi/Filesystem.h> | ||
| 19 | |||
| 20 | #define LOG_SIZE 1024 | ||
| 21 | #define GLchar char | ||
| 22 | |||
| 23 | namespace kodi | ||
| 24 | { | ||
| 25 | namespace gui | ||
| 26 | { | ||
| 27 | namespace gl | ||
| 28 | { | ||
| 29 | |||
| 30 | //======================================================================== | ||
| 31 | /// CShader - base class | ||
| 32 | class ATTRIBUTE_HIDDEN CShader | ||
| 33 | { | ||
| 34 | public: | ||
| 35 | CShader() = default; | ||
| 36 | virtual ~CShader() = default; | ||
| 37 | virtual bool Compile(const std::string& extraBegin = "", | ||
| 38 | const std::string& extraEnd = "") = 0; | ||
| 39 | virtual void Free() = 0; | ||
| 40 | virtual GLuint Handle() = 0; | ||
| 41 | |||
| 42 | bool LoadSource(const std::string& file) | ||
| 43 | { | ||
| 44 | char buffer[16384]; | ||
| 45 | |||
| 46 | kodi::vfs::CFile source; | ||
| 47 | if (!source.OpenFile(file)) | ||
| 48 | { | ||
| 49 | kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, file.c_str()); | ||
| 50 | return false; | ||
| 51 | } | ||
| 52 | size_t len = source.Read(buffer, sizeof(buffer)); | ||
| 53 | m_source.assign(buffer); | ||
| 54 | m_source[len] = 0; | ||
| 55 | source.Close(); | ||
| 56 | return true; | ||
| 57 | } | ||
| 58 | |||
| 59 | bool OK() const { return m_compiled; } | ||
| 60 | |||
| 61 | protected: | ||
| 62 | std::string m_source; | ||
| 63 | std::string m_lastLog; | ||
| 64 | bool m_compiled = false; | ||
| 65 | }; | ||
| 66 | //------------------------------------------------------------------------ | ||
| 67 | |||
| 68 | //======================================================================== | ||
| 69 | /// CVertexShader | ||
| 70 | class ATTRIBUTE_HIDDEN CVertexShader : public CShader | ||
| 71 | { | ||
| 72 | public: | ||
| 73 | CVertexShader() = default; | ||
| 74 | ~CVertexShader() override { Free(); } | ||
| 75 | |||
| 76 | void Free() override | ||
| 77 | { | ||
| 78 | if (m_vertexShader) | ||
| 79 | glDeleteShader(m_vertexShader); | ||
| 80 | m_vertexShader = 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | bool Compile(const std::string& extraBegin = "", | ||
| 84 | const std::string& extraEnd = "") override | ||
| 85 | { | ||
| 86 | GLint params[4]; | ||
| 87 | |||
| 88 | Free(); | ||
| 89 | |||
| 90 | m_vertexShader = glCreateShader(GL_VERTEX_SHADER); | ||
| 91 | |||
| 92 | GLsizei count = 0; | ||
| 93 | const char *sources[3]; | ||
| 94 | if (!extraBegin.empty()) | ||
| 95 | sources[count++] = extraBegin.c_str(); | ||
| 96 | if (!m_source.empty()) | ||
| 97 | sources[count++] = m_source.c_str(); | ||
| 98 | if (!extraEnd.empty()) | ||
| 99 | sources[count++] = extraEnd.c_str(); | ||
| 100 | |||
| 101 | glShaderSource(m_vertexShader, count, sources, nullptr); | ||
| 102 | glCompileShader(m_vertexShader); | ||
| 103 | glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params); | ||
| 104 | if (params[0] != GL_TRUE) | ||
| 105 | { | ||
| 106 | GLchar log[LOG_SIZE]; | ||
| 107 | glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); | ||
| 108 | kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); | ||
| 109 | fprintf(stderr, "CVertexShader::%s: %s\n", __FUNCTION__, log); | ||
| 110 | m_lastLog = log; | ||
| 111 | m_compiled = false; | ||
| 112 | } | ||
| 113 | else | ||
| 114 | { | ||
| 115 | GLchar log[LOG_SIZE]; | ||
| 116 | glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); | ||
| 117 | m_lastLog = log; | ||
| 118 | m_compiled = true; | ||
| 119 | } | ||
| 120 | return m_compiled; | ||
| 121 | } | ||
| 122 | |||
| 123 | GLuint Handle() override { return m_vertexShader; } | ||
| 124 | |||
| 125 | protected: | ||
| 126 | GLuint m_vertexShader = 0; | ||
| 127 | }; | ||
| 128 | //------------------------------------------------------------------------ | ||
| 129 | |||
| 130 | //======================================================================== | ||
| 131 | /// CPixelShader | ||
| 132 | class ATTRIBUTE_HIDDEN CPixelShader : public CShader | ||
| 133 | { | ||
| 134 | public: | ||
| 135 | CPixelShader() = default; | ||
| 136 | ~CPixelShader() { Free(); } | ||
| 137 | void Free() override | ||
| 138 | { | ||
| 139 | if (m_pixelShader) | ||
| 140 | glDeleteShader(m_pixelShader); | ||
| 141 | m_pixelShader = 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | bool Compile(const std::string& extraBegin = "", | ||
| 145 | const std::string& extraEnd = "") override | ||
| 146 | { | ||
| 147 | GLint params[4]; | ||
| 148 | |||
| 149 | Free(); | ||
| 150 | |||
| 151 | m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); | ||
| 152 | |||
| 153 | GLsizei count = 0; | ||
| 154 | const char *sources[3]; | ||
| 155 | if (!extraBegin.empty()) | ||
| 156 | sources[count++] = extraBegin.c_str(); | ||
| 157 | if (!m_source.empty()) | ||
| 158 | sources[count++] = m_source.c_str(); | ||
| 159 | if (!extraEnd.empty()) | ||
| 160 | sources[count++] = extraEnd.c_str(); | ||
| 161 | |||
| 162 | glShaderSource(m_pixelShader, count, sources, 0); | ||
| 163 | glCompileShader(m_pixelShader); | ||
| 164 | glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params); | ||
| 165 | if (params[0] != GL_TRUE) | ||
| 166 | { | ||
| 167 | GLchar log[LOG_SIZE]; | ||
| 168 | glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); | ||
| 169 | kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); | ||
| 170 | fprintf(stderr, "CPixelShader::%s: %s\n", __FUNCTION__, log); | ||
| 171 | m_lastLog = log; | ||
| 172 | m_compiled = false; | ||
| 173 | } | ||
| 174 | else | ||
| 175 | { | ||
| 176 | GLchar log[LOG_SIZE]; | ||
| 177 | glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); | ||
| 178 | m_lastLog = log; | ||
| 179 | m_compiled = true; | ||
| 180 | } | ||
| 181 | return m_compiled; | ||
| 182 | } | ||
| 183 | |||
| 184 | GLuint Handle() override { return m_pixelShader; } | ||
| 185 | |||
| 186 | protected: | ||
| 187 | GLuint m_pixelShader = 0; | ||
| 188 | }; | ||
| 189 | //------------------------------------------------------------------------ | ||
| 190 | |||
| 191 | //============================================================================ | ||
| 192 | /// | ||
| 193 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram GL Shader Program | ||
| 194 | /// \ingroup cpp_kodi_gui_gl | ||
| 195 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram } | ||
| 196 | /// **Class to manage an OpenGL shader program** | ||
| 197 | /// | ||
| 198 | /// With this class the used GL shader code can be defined on the GPU and | ||
| 199 | /// its variables can be managed between CPU and GPU. | ||
| 200 | /// | ||
| 201 | /// It has the header \ref Shader.h "#include <kodi/gui/gl/Shader.h>" | ||
| 202 | /// be included to enjoy it. | ||
| 203 | /// | ||
| 204 | /// ---------------------------------------------------------------------------- | ||
| 205 | /// | ||
| 206 | /// <b>Example:</b> | ||
| 207 | /// | ||
| 208 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 209 | /// | ||
| 210 | /// #include <kodi/gui/gl/Shader.h> | ||
| 211 | /// ... | ||
| 212 | /// | ||
| 213 | /// class ATTRIBUTE_HIDDEN CExample | ||
| 214 | /// : ..., | ||
| 215 | /// public kodi::gui::gl::CShaderProgram | ||
| 216 | /// { | ||
| 217 | /// public: | ||
| 218 | /// CExample() = default; | ||
| 219 | /// | ||
| 220 | /// bool Start(); | ||
| 221 | /// void Render(); | ||
| 222 | /// | ||
| 223 | /// // override functions for kodi::gui::gl::CShaderProgram | ||
| 224 | /// void OnCompiledAndLinked() override; | ||
| 225 | /// bool OnEnabled() override; | ||
| 226 | /// | ||
| 227 | /// private: | ||
| 228 | /// ... | ||
| 229 | /// GLint m_aPosition = -1; | ||
| 230 | /// GLint m_aColor = -1; | ||
| 231 | /// }; | ||
| 232 | /// | ||
| 233 | /// bool CExample::Start() | ||
| 234 | /// { | ||
| 235 | /// // Define shaders and load | ||
| 236 | /// std::string fraqShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.frag"); | ||
| 237 | /// std::string vertShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.vert"); | ||
| 238 | /// if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink()) | ||
| 239 | /// return false; | ||
| 240 | /// | ||
| 241 | /// ... | ||
| 242 | /// return true; | ||
| 243 | /// } | ||
| 244 | /// | ||
| 245 | /// ... | ||
| 246 | /// | ||
| 247 | /// void CExample::Render() | ||
| 248 | /// { | ||
| 249 | /// ... | ||
| 250 | /// | ||
| 251 | /// EnableShader(); | ||
| 252 | /// ... | ||
| 253 | /// DO WORK | ||
| 254 | /// ... | ||
| 255 | /// DisableShader(); | ||
| 256 | /// } | ||
| 257 | /// | ||
| 258 | /// void CExample::OnCompiledAndLinked() | ||
| 259 | /// { | ||
| 260 | /// ... | ||
| 261 | /// DO YOUR WORK HERE FOR WHAT IS ONE TIME REQUIRED DURING COMPILE OF SHADER, E.G.: | ||
| 262 | /// | ||
| 263 | /// m_aPosition = glGetAttribLocation(ProgramHandle(), "a_position"); | ||
| 264 | /// m_aColor = glGetAttribLocation(ProgramHandle(), "a_color"); | ||
| 265 | /// } | ||
| 266 | /// | ||
| 267 | /// bool OnEnabled() override | ||
| 268 | /// { | ||
| 269 | /// ... | ||
| 270 | /// DO YOUR WORK HERE FOR WHAT REQUIRED DURING ENABLE OF SHADER | ||
| 271 | /// ... | ||
| 272 | /// return true; | ||
| 273 | /// } | ||
| 274 | /// | ||
| 275 | /// ADDONCREATOR(CExample); | ||
| 276 | /// ~~~~~~~~~~~~~ | ||
| 277 | /// | ||
| 278 | |||
| 279 | //======================================================================== | ||
| 280 | /// CShaderProgram | ||
| 281 | class ATTRIBUTE_HIDDEN CShaderProgram | ||
| 282 | { | ||
| 283 | public: | ||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 287 | /// @brief Construct a new shader | ||
| 288 | /// | ||
| 289 | /// Load must be done later with \ref LoadShaderFiles. | ||
| 290 | /// | ||
| 291 | CShaderProgram() = default; | ||
| 292 | //-------------------------------------------------------------------------- | ||
| 293 | |||
| 294 | //========================================================================== | ||
| 295 | /// | ||
| 296 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 297 | /// @brief Construct a new shader and load defined shader files | ||
| 298 | /// | ||
| 299 | /// @param[in] vert Path to used GL vertext shader | ||
| 300 | /// @param[in] frag Path to used GL fragment shader | ||
| 301 | /// | ||
| 302 | CShaderProgram(const std::string& vert, const std::string& frag) | ||
| 303 | { | ||
| 304 | LoadShaderFiles(vert, frag); | ||
| 305 | } | ||
| 306 | //-------------------------------------------------------------------------- | ||
| 307 | |||
| 308 | //========================================================================== | ||
| 309 | /// | ||
| 310 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 311 | /// @brief Destructor | ||
| 312 | /// | ||
| 313 | virtual ~CShaderProgram() | ||
| 314 | { | ||
| 315 | ShaderFree(); | ||
| 316 | } | ||
| 317 | //-------------------------------------------------------------------------- | ||
| 318 | |||
| 319 | //========================================================================== | ||
| 320 | /// | ||
| 321 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 322 | /// @brief To load manually the needed shader files | ||
| 323 | /// | ||
| 324 | /// @param[in] vert Path to used GL vertext shader | ||
| 325 | /// @param[in] frag Path to used GL fragment shader | ||
| 326 | /// | ||
| 327 | /// | ||
| 328 | /// @note The use of the files is optional, but it must either be passed over | ||
| 329 | /// here or via \ref CompileAndLink, or both of the source code. | ||
| 330 | /// | ||
| 331 | bool LoadShaderFiles(const std::string& vert, const std::string& frag) | ||
| 332 | { | ||
| 333 | if (!kodi::vfs::FileExists(vert) || !m_pVP.LoadSource(vert)) | ||
| 334 | { | ||
| 335 | kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, vert.c_str()); | ||
| 336 | return false; | ||
| 337 | } | ||
| 338 | |||
| 339 | if (!kodi::vfs::FileExists(frag) || !m_pFP.LoadSource(frag)) | ||
| 340 | { | ||
| 341 | kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, frag.c_str()); | ||
| 342 | return false; | ||
| 343 | } | ||
| 344 | |||
| 345 | return true; | ||
| 346 | } | ||
| 347 | //-------------------------------------------------------------------------- | ||
| 348 | |||
| 349 | //========================================================================== | ||
| 350 | /// | ||
| 351 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 352 | /// @brief To compile and link the shader to the GL interface | ||
| 353 | /// | ||
| 354 | /// Optionally, additional source code can be transferred here, or it can be | ||
| 355 | /// used independently without any files | ||
| 356 | /// | ||
| 357 | /// @param[in] vertexExtraBegin [opt] To additionally add vextex source | ||
| 358 | /// code to the beginning of the loaded file | ||
| 359 | /// source code | ||
| 360 | /// @param[in] vertexExtraEnd [opt] To additionally add vextex source | ||
| 361 | /// code to the end of the loaded file | ||
| 362 | /// source code | ||
| 363 | /// @param[in] fragmentExtraBegin [opt] To additionally add fragment source | ||
| 364 | /// code to the beginning of the loaded file | ||
| 365 | /// source code | ||
| 366 | /// @param[in] fragmentExtraEnd [opt] To additionally add fragment source | ||
| 367 | /// code to the end of the loaded file | ||
| 368 | /// source code | ||
| 369 | /// @return true if compile was successed | ||
| 370 | /// | ||
| 371 | /// | ||
| 372 | /// @note In the case of a compile error, it will be written once into the Kodi | ||
| 373 | /// log and in addition to the console output to quickly detect the errors when | ||
| 374 | /// writing the damage. | ||
| 375 | /// | ||
| 376 | /// | ||
| 377 | bool CompileAndLink(const std::string& vertexExtraBegin = "", | ||
| 378 | const std::string& vertexExtraEnd = "", | ||
| 379 | const std::string& fragmentExtraBegin = "", | ||
| 380 | const std::string& fragmentExtraEnd = "") | ||
| 381 | { | ||
| 382 | GLint params[4]; | ||
| 383 | |||
| 384 | // free resources | ||
| 385 | ShaderFree(); | ||
| 386 | m_ok = false; | ||
| 387 | |||
| 388 | // compiled vertex shader | ||
| 389 | if (!m_pVP.Compile(vertexExtraBegin, vertexExtraEnd)) | ||
| 390 | { | ||
| 391 | kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader"); | ||
| 392 | return false; | ||
| 393 | } | ||
| 394 | |||
| 395 | // compile pixel shader | ||
| 396 | if (!m_pFP.Compile(fragmentExtraBegin, fragmentExtraEnd)) | ||
| 397 | { | ||
| 398 | m_pVP.Free(); | ||
| 399 | kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling fragment shader"); | ||
| 400 | return false; | ||
| 401 | } | ||
| 402 | |||
| 403 | // create program object | ||
| 404 | m_shaderProgram = glCreateProgram(); | ||
| 405 | if (!m_shaderProgram) | ||
| 406 | { | ||
| 407 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: Failed to create GL program", __FUNCTION__); | ||
| 408 | ShaderFree(); | ||
| 409 | return false; | ||
| 410 | } | ||
| 411 | |||
| 412 | // attach the vertex shader | ||
| 413 | glAttachShader(m_shaderProgram, m_pVP.Handle()); | ||
| 414 | glAttachShader(m_shaderProgram, m_pFP.Handle()); | ||
| 415 | |||
| 416 | // link the program | ||
| 417 | glLinkProgram(m_shaderProgram); | ||
| 418 | glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); | ||
| 419 | if (params[0] != GL_TRUE) | ||
| 420 | { | ||
| 421 | GLchar log[LOG_SIZE]; | ||
| 422 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); | ||
| 423 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); | ||
| 424 | fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); | ||
| 425 | ShaderFree(); | ||
| 426 | return false; | ||
| 427 | } | ||
| 428 | |||
| 429 | m_validated = false; | ||
| 430 | m_ok = true; | ||
| 431 | OnCompiledAndLinked(); | ||
| 432 | return true; | ||
| 433 | } | ||
| 434 | //-------------------------------------------------------------------------- | ||
| 435 | |||
| 436 | //========================================================================== | ||
| 437 | /// | ||
| 438 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 439 | /// @brief To activate the shader and use it on the GPU | ||
| 440 | /// | ||
| 441 | /// @return true if enable was successfull done | ||
| 442 | /// | ||
| 443 | /// | ||
| 444 | /// @note During this call, the \ref OnEnabled stored in the child is also | ||
| 445 | /// called | ||
| 446 | /// | ||
| 447 | bool EnableShader() | ||
| 448 | { | ||
| 449 | if (ShaderOK()) | ||
| 450 | { | ||
| 451 | glUseProgram(m_shaderProgram); | ||
| 452 | if (OnEnabled()) | ||
| 453 | { | ||
| 454 | if (!m_validated) | ||
| 455 | { | ||
| 456 | // validate the program | ||
| 457 | GLint params[4]; | ||
| 458 | glValidateProgram(m_shaderProgram); | ||
| 459 | glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params); | ||
| 460 | if (params[0] != GL_TRUE) | ||
| 461 | { | ||
| 462 | GLchar log[LOG_SIZE]; | ||
| 463 | glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); | ||
| 464 | kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); | ||
| 465 | fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); | ||
| 466 | } | ||
| 467 | m_validated = true; | ||
| 468 | } | ||
| 469 | return true; | ||
| 470 | } | ||
| 471 | else | ||
| 472 | { | ||
| 473 | glUseProgram(0); | ||
| 474 | return false; | ||
| 475 | } | ||
| 476 | return true; | ||
| 477 | } | ||
| 478 | return false; | ||
| 479 | } | ||
| 480 | //-------------------------------------------------------------------------- | ||
| 481 | |||
| 482 | //========================================================================== | ||
| 483 | /// | ||
| 484 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 485 | /// @brief To deactivate the shader use on the GPU | ||
| 486 | /// | ||
| 487 | void DisableShader() | ||
| 488 | { | ||
| 489 | if (ShaderOK()) | ||
| 490 | { | ||
| 491 | glUseProgram(0); | ||
| 492 | OnDisabled(); | ||
| 493 | } | ||
| 494 | } | ||
| 495 | //-------------------------------------------------------------------------- | ||
| 496 | |||
| 497 | //========================================================================== | ||
| 498 | /// | ||
| 499 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 500 | /// @brief Used to check if shader has been loaded before. | ||
| 501 | /// | ||
| 502 | /// @return true if enable was successfull done | ||
| 503 | /// | ||
| 504 | /// @note The CompileAndLink call sets these values | ||
| 505 | /// | ||
| 506 | ATTRIBUTE_FORCEINLINE bool ShaderOK() const { return m_ok; } | ||
| 507 | //-------------------------------------------------------------------------- | ||
| 508 | |||
| 509 | //========================================================================== | ||
| 510 | /// | ||
| 511 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 512 | /// @brief To get the vertex shader class used by Kodi at the addon | ||
| 513 | /// | ||
| 514 | /// @return pointer to vertex shader class | ||
| 515 | /// | ||
| 516 | ATTRIBUTE_FORCEINLINE CVertexShader& VertexShader() { return m_pVP; } | ||
| 517 | //-------------------------------------------------------------------------- | ||
| 518 | |||
| 519 | //========================================================================== | ||
| 520 | /// | ||
| 521 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 522 | /// @brief To get the fragment shader class used by Kodi at the addon | ||
| 523 | /// | ||
| 524 | /// @return pointer to fragment shader class | ||
| 525 | /// | ||
| 526 | ATTRIBUTE_FORCEINLINE CPixelShader& PixelShader() { return m_pFP; } | ||
| 527 | //-------------------------------------------------------------------------- | ||
| 528 | |||
| 529 | //========================================================================== | ||
| 530 | /// | ||
| 531 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 532 | /// @brief Used to get the definition created in the OpenGL itself | ||
| 533 | /// | ||
| 534 | /// @return GLuint of GL shader program handler | ||
| 535 | /// | ||
| 536 | ATTRIBUTE_FORCEINLINE GLuint ProgramHandle() { return m_shaderProgram; } | ||
| 537 | //-------------------------------------------------------------------------- | ||
| 538 | |||
| 539 | //========================================================================== | ||
| 540 | /// | ||
| 541 | /// \defgroup cpp_kodi_gui_gl_CShaderProgram_child Child Functions | ||
| 542 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram | ||
| 543 | /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram child functions } | ||
| 544 | /// | ||
| 545 | /// Functions that are added by parent in the child | ||
| 546 | //@{ | ||
| 547 | //========================================================================== | ||
| 548 | /// | ||
| 549 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 550 | /// @brief Mandatory child function to set the necessary CPU to GPU data | ||
| 551 | /// | ||
| 552 | virtual void OnCompiledAndLinked() {}; | ||
| 553 | //-------------------------------------------------------------------------- | ||
| 554 | |||
| 555 | //========================================================================== | ||
| 556 | /// | ||
| 557 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 558 | /// @brief Optional function to exchange data between CPU and GPU while | ||
| 559 | /// activating the shader | ||
| 560 | /// | ||
| 561 | /// @return true if enable was successfull done | ||
| 562 | /// | ||
| 563 | virtual bool OnEnabled() { return true; }; | ||
| 564 | //-------------------------------------------------------------------------- | ||
| 565 | |||
| 566 | //========================================================================== | ||
| 567 | /// | ||
| 568 | /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child | ||
| 569 | /// @brief Optional child function that may have to be performed when | ||
| 570 | /// switching off the shader | ||
| 571 | virtual void OnDisabled() {}; | ||
| 572 | //-------------------------------------------------------------------------- | ||
| 573 | //@} | ||
| 574 | |||
| 575 | private: | ||
| 576 | void ShaderFree() | ||
| 577 | { | ||
| 578 | if (m_shaderProgram) | ||
| 579 | glDeleteProgram(m_shaderProgram); | ||
| 580 | m_shaderProgram = 0; | ||
| 581 | m_ok = false; | ||
| 582 | } | ||
| 583 | |||
| 584 | CVertexShader m_pVP; | ||
| 585 | CPixelShader m_pFP; | ||
| 586 | GLuint m_shaderProgram = 0; | ||
| 587 | bool m_ok = false; | ||
| 588 | bool m_validated = false; | ||
| 589 | }; | ||
| 590 | //------------------------------------------------------------------------ | ||
| 591 | |||
| 592 | } /* namespace gl */ | ||
| 593 | } /* namespace gui */ | ||
| 594 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h deleted file mode 100644 index 2e96d21..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h +++ /dev/null | |||
| @@ -1,78 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2019 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 "../AddonBase.h" | ||
| 12 | |||
| 13 | namespace kodi | ||
| 14 | { | ||
| 15 | namespace gui | ||
| 16 | { | ||
| 17 | struct ATTRIBUTE_HIDDEN IRenderHelper | ||
| 18 | { | ||
| 19 | virtual ~IRenderHelper() = default; | ||
| 20 | virtual bool Init() = 0; | ||
| 21 | virtual void Begin() = 0; | ||
| 22 | virtual void End() = 0; | ||
| 23 | }; /* class IRenderHelper */ | ||
| 24 | } /* namespace gui */ | ||
| 25 | } /* namespace kodi */ | ||
| 26 | |||
| 27 | #if defined(WIN32) && defined(HAS_ANGLE) | ||
| 28 | #include "gl/GLonDX.h" | ||
| 29 | #else | ||
| 30 | /* | ||
| 31 | * Default background GUI render helper class | ||
| 32 | */ | ||
| 33 | namespace kodi | ||
| 34 | { | ||
| 35 | namespace gui | ||
| 36 | { | ||
| 37 | struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper | ||
| 38 | { | ||
| 39 | bool Init() override { return true; } | ||
| 40 | void Begin() override { } | ||
| 41 | void End() override { } | ||
| 42 | }; /* class CRenderHelperStub */ | ||
| 43 | |||
| 44 | using CRenderHelper = CRenderHelperStub; | ||
| 45 | } /* namespace gui */ | ||
| 46 | } /* namespace kodi */ | ||
| 47 | #endif | ||
| 48 | |||
| 49 | namespace kodi | ||
| 50 | { | ||
| 51 | namespace gui | ||
| 52 | { | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Create render background handler, e.g. becomes on "Windows" Angle used | ||
| 56 | * to emulate GL. | ||
| 57 | * | ||
| 58 | * This only be used internal and not from addon's direct. | ||
| 59 | * | ||
| 60 | * Function defines here and not in CAddonBase because of a hen and egg problem. | ||
| 61 | */ | ||
| 62 | inline std::shared_ptr<IRenderHelper> ATTRIBUTE_HIDDEN GetRenderHelper() | ||
| 63 | { | ||
| 64 | using namespace ::kodi::addon; | ||
| 65 | if (static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper) | ||
| 66 | return static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper; | ||
| 67 | |||
| 68 | const std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper()); | ||
| 69 | if (!renderHelper->Init()) | ||
| 70 | return nullptr; | ||
| 71 | |||
| 72 | static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper = | ||
| 73 | renderHelper; // Hold on base for other types | ||
| 74 | return renderHelper; | ||
| 75 | } | ||
| 76 | |||
| 77 | } /* namespace gui */ | ||
| 78 | } /* namespace kodi */ | ||
