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-dev-kit/include/kodi/gui/controls | |
| 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-dev-kit/include/kodi/gui/controls')
13 files changed, 2540 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h new file mode 100644 index 0000000..873a549 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h | |||
| @@ -0,0 +1,166 @@ | |||
| 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 "../../c-api/gui/controls/button.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CButton Control Button | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CButton } | ||
| 27 | /// **Standard push button control for window**\n | ||
| 28 | /// The button control is used for creating push buttons in Kodi. | ||
| 29 | /// | ||
| 30 | /// You can choose the position, size, and look of the button, as well as | ||
| 31 | /// choosing what action(s) should be performed when pushed. | ||
| 32 | /// | ||
| 33 | /// It has the header @ref Button.h "#include <kodi/gui/controls/Button.h>" | ||
| 34 | /// be included to enjoy it. | ||
| 35 | /// | ||
| 36 | /// Here you find the needed skin part for a @ref skin_Button_control "button 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 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase | ||
| 42 | { | ||
| 43 | public: | ||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_gui_windows_controls_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 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 62 | /// @brief Destructor. | ||
| 63 | /// | ||
| 64 | ~CButton() override = default; | ||
| 65 | //---------------------------------------------------------------------------- | ||
| 66 | |||
| 67 | //============================================================================ | ||
| 68 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 69 | /// @brief Set the control on window to visible. | ||
| 70 | /// | ||
| 71 | /// @param[in] visible If true visible, otherwise hidden | ||
| 72 | /// | ||
| 73 | void SetVisible(bool visible) | ||
| 74 | { | ||
| 75 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 76 | visible); | ||
| 77 | } | ||
| 78 | //---------------------------------------------------------------------------- | ||
| 79 | |||
| 80 | //============================================================================ | ||
| 81 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 82 | /// @brief Set's the control's enabled/disabled state. | ||
| 83 | /// | ||
| 84 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 85 | /// | ||
| 86 | void SetEnabled(bool enabled) | ||
| 87 | { | ||
| 88 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 89 | enabled); | ||
| 90 | } | ||
| 91 | //---------------------------------------------------------------------------- | ||
| 92 | |||
| 93 | //============================================================================ | ||
| 94 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 95 | /// @brief To set the text string on button. | ||
| 96 | /// | ||
| 97 | /// @param[in] label Text to show | ||
| 98 | /// | ||
| 99 | void SetLabel(const std::string& label) | ||
| 100 | { | ||
| 101 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 102 | label.c_str()); | ||
| 103 | } | ||
| 104 | //---------------------------------------------------------------------------- | ||
| 105 | |||
| 106 | //============================================================================ | ||
| 107 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 108 | /// @brief Get the used text from button. | ||
| 109 | /// | ||
| 110 | /// @return Text shown | ||
| 111 | /// | ||
| 112 | std::string GetLabel() const | ||
| 113 | { | ||
| 114 | std::string label; | ||
| 115 | char* ret = | ||
| 116 | m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 117 | if (ret != nullptr) | ||
| 118 | { | ||
| 119 | if (std::strlen(ret)) | ||
| 120 | label = ret; | ||
| 121 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 122 | } | ||
| 123 | return label; | ||
| 124 | } | ||
| 125 | //---------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //============================================================================ | ||
| 128 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 129 | /// @brief If two labels are used for button becomes it set with them. | ||
| 130 | /// | ||
| 131 | /// @param[in] label Text for second label | ||
| 132 | /// | ||
| 133 | void SetLabel2(const std::string& label) | ||
| 134 | { | ||
| 135 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, | ||
| 136 | label.c_str()); | ||
| 137 | } | ||
| 138 | //---------------------------------------------------------------------------- | ||
| 139 | |||
| 140 | //============================================================================ | ||
| 141 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 142 | /// @brief Get the second label if present. | ||
| 143 | /// | ||
| 144 | /// @return Second label | ||
| 145 | /// | ||
| 146 | std::string GetLabel2() const | ||
| 147 | { | ||
| 148 | std::string label; | ||
| 149 | char* ret = | ||
| 150 | m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 151 | if (ret != nullptr) | ||
| 152 | { | ||
| 153 | if (std::strlen(ret)) | ||
| 154 | label = ret; | ||
| 155 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 156 | } | ||
| 157 | return label; | ||
| 158 | } | ||
| 159 | //---------------------------------------------------------------------------- | ||
| 160 | }; | ||
| 161 | |||
| 162 | } /* namespace controls */ | ||
| 163 | } /* namespace gui */ | ||
| 164 | } /* namespace kodi */ | ||
| 165 | |||
| 166 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt new file mode 100644 index 0000000..3fdab01 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt | |||
| @@ -0,0 +1,16 @@ | |||
| 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-dev-kit_include_kodi_gui_controls) | ||
| 16 | endif() | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h new file mode 100644 index 0000000..00c6231 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h | |||
| @@ -0,0 +1,217 @@ | |||
| 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 "../../c-api/gui/controls/edit.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CEdit Control Edit | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CEdit } | ||
| 27 | /// **Editable window text control used as an input control for the osd keyboard | ||
| 28 | /// and other input fields**\n | ||
| 29 | /// The edit control allows a user to input text in Kodi. | ||
| 30 | /// | ||
| 31 | /// You can choose the font, size, colour, location and header of the text to be | ||
| 32 | /// displayed. | ||
| 33 | /// | ||
| 34 | /// It has the header @ref Edit.h "#include <kodi/gui/controls/Edit.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin partfor a @ref skin_Edit_control "edit 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 | // see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs" | ||
| 45 | /// | ||
| 46 | /// @defgroup cpp_kodi_gui_windows_controls_CEdit_Defs Definitions, structures and enumerators | ||
| 47 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 48 | /// @brief **Library definition values** | ||
| 49 | /// | ||
| 50 | |||
| 51 | class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase | ||
| 52 | { | ||
| 53 | public: | ||
| 54 | //============================================================================ | ||
| 55 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 56 | /// @brief Construct a new control. | ||
| 57 | /// | ||
| 58 | /// @param[in] window Related window control class | ||
| 59 | /// @param[in] controlId Used skin xml control id | ||
| 60 | /// | ||
| 61 | CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 62 | { | ||
| 63 | m_controlHandle = m_interface->kodi_gui->window->get_control_edit( | ||
| 64 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 65 | if (!m_controlHandle) | ||
| 66 | kodi::Log(ADDON_LOG_FATAL, | ||
| 67 | "kodi::gui::control::CEdit can't create control class from Kodi !!!"); | ||
| 68 | } | ||
| 69 | //---------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //============================================================================ | ||
| 72 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 73 | /// @brief Destructor. | ||
| 74 | /// | ||
| 75 | ~CEdit() override = default; | ||
| 76 | //---------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //============================================================================ | ||
| 79 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 80 | /// @brief Set the control on window to visible. | ||
| 81 | /// | ||
| 82 | /// @param[in] visible If true visible, otherwise hidden | ||
| 83 | /// | ||
| 84 | void SetVisible(bool visible) | ||
| 85 | { | ||
| 86 | m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 87 | visible); | ||
| 88 | } | ||
| 89 | //---------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //============================================================================ | ||
| 92 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 93 | /// @brief Set's the control's enabled/disabled state. | ||
| 94 | /// | ||
| 95 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 96 | /// | ||
| 97 | void SetEnabled(bool enabled) | ||
| 98 | { | ||
| 99 | m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 100 | enabled); | ||
| 101 | } | ||
| 102 | //---------------------------------------------------------------------------- | ||
| 103 | |||
| 104 | //============================================================================ | ||
| 105 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 106 | /// @brief To set the text string on edit control. | ||
| 107 | /// | ||
| 108 | /// @param[in] label Text to show | ||
| 109 | /// | ||
| 110 | void SetLabel(const std::string& label) | ||
| 111 | { | ||
| 112 | m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 113 | label.c_str()); | ||
| 114 | } | ||
| 115 | //---------------------------------------------------------------------------- | ||
| 116 | |||
| 117 | //============================================================================ | ||
| 118 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 119 | /// @brief Returns the text heading for this edit control. | ||
| 120 | /// | ||
| 121 | /// @return Heading text | ||
| 122 | /// | ||
| 123 | std::string GetLabel() const | ||
| 124 | { | ||
| 125 | std::string label; | ||
| 126 | char* ret = | ||
| 127 | m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 128 | if (ret != nullptr) | ||
| 129 | { | ||
| 130 | if (std::strlen(ret)) | ||
| 131 | label = ret; | ||
| 132 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 133 | } | ||
| 134 | return label; | ||
| 135 | } | ||
| 136 | //---------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //============================================================================ | ||
| 139 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 140 | /// @brief Set's text heading for this edit control. | ||
| 141 | /// | ||
| 142 | /// @param[in] text string or unicode - text string. | ||
| 143 | /// | ||
| 144 | void SetText(const std::string& text) | ||
| 145 | { | ||
| 146 | m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 147 | text.c_str()); | ||
| 148 | } | ||
| 149 | //---------------------------------------------------------------------------- | ||
| 150 | |||
| 151 | //============================================================================ | ||
| 152 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 153 | /// @brief Returns the text value for this edit control. | ||
| 154 | /// | ||
| 155 | /// @return Text value of control | ||
| 156 | /// | ||
| 157 | std::string GetText() const | ||
| 158 | { | ||
| 159 | std::string text; | ||
| 160 | char* ret = | ||
| 161 | m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 162 | if (ret != nullptr) | ||
| 163 | { | ||
| 164 | if (std::strlen(ret)) | ||
| 165 | text = ret; | ||
| 166 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 167 | } | ||
| 168 | return text; | ||
| 169 | } | ||
| 170 | //---------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | //============================================================================ | ||
| 173 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 174 | /// @brief Set the cursor position on text. | ||
| 175 | /// | ||
| 176 | /// @param[in] position The position to set | ||
| 177 | /// | ||
| 178 | void SetCursorPosition(unsigned int position) | ||
| 179 | { | ||
| 180 | m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, | ||
| 181 | position); | ||
| 182 | } | ||
| 183 | //---------------------------------------------------------------------------- | ||
| 184 | |||
| 185 | //============================================================================ | ||
| 186 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 187 | /// @brief To get current cursor position on text field. | ||
| 188 | /// | ||
| 189 | /// @return The current cursor position | ||
| 190 | /// | ||
| 191 | unsigned int GetCursorPosition() | ||
| 192 | { | ||
| 193 | return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, | ||
| 194 | m_controlHandle); | ||
| 195 | } | ||
| 196 | //---------------------------------------------------------------------------- | ||
| 197 | |||
| 198 | //============================================================================ | ||
| 199 | /// @ingroup cpp_kodi_gui_windows_controls_CEdit | ||
| 200 | /// @brief To set field input type which are defined on @ref AddonGUIInputType. | ||
| 201 | /// | ||
| 202 | /// @param[in] type The @ref AddonGUIInputType "Add-on input type" to use | ||
| 203 | /// @param[in] heading The heading text for related keyboard dialog | ||
| 204 | /// | ||
| 205 | void SetInputType(AddonGUIInputType type, const std::string& heading) | ||
| 206 | { | ||
| 207 | m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, | ||
| 208 | static_cast<int>(type), heading.c_str()); | ||
| 209 | } | ||
| 210 | //---------------------------------------------------------------------------- | ||
| 211 | }; | ||
| 212 | |||
| 213 | } /* namespace controls */ | ||
| 214 | } /* namespace gui */ | ||
| 215 | } /* namespace kodi */ | ||
| 216 | |||
| 217 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h new file mode 100644 index 0000000..01847fb --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h | |||
| @@ -0,0 +1,148 @@ | |||
| 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 "../../c-api/gui/controls/fade_label.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CFadeLabel Control Fade Label | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CFadeLabel } | ||
| 27 | /// **Window control used to show multiple pieces of text in the same position, | ||
| 28 | /// by fading from one to the other**\n | ||
| 29 | /// The fade label control is used for displaying multiple pieces of text in | ||
| 30 | /// the same space in Kodi. | ||
| 31 | /// | ||
| 32 | /// You can choose the font, size, colour, location and contents of the text to | ||
| 33 | /// be displayed. The first piece of information to display fades in over 50 | ||
| 34 | /// frames, then scrolls off to the left. Once it is finished scrolling off | ||
| 35 | /// screen, the second piece of information fades in and the process repeats. | ||
| 36 | /// A fade label control is not supported in a list container. | ||
| 37 | /// | ||
| 38 | /// It has the header @ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>" | ||
| 39 | /// be included to enjoy it. | ||
| 40 | /// | ||
| 41 | /// Here you find the needed skin part for a @ref Fade_Label_Control "fade label control". | ||
| 42 | /// | ||
| 43 | /// @note The call of the control is only possible from the corresponding | ||
| 44 | /// window as its class and identification number is required. | ||
| 45 | /// | ||
| 46 | class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase | ||
| 47 | { | ||
| 48 | public: | ||
| 49 | //============================================================================ | ||
| 50 | /// @ingroup cpp_kodi_gui_windows_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 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 68 | /// @brief Destructor. | ||
| 69 | /// | ||
| 70 | ~CFadeLabel() override = default; | ||
| 71 | //---------------------------------------------------------------------------- | ||
| 72 | |||
| 73 | //============================================================================ | ||
| 74 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 75 | /// @brief Set the control on window to visible. | ||
| 76 | /// | ||
| 77 | /// @param[in] visible If true visible, otherwise hidden | ||
| 78 | /// | ||
| 79 | void SetVisible(bool visible) | ||
| 80 | { | ||
| 81 | m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 82 | visible); | ||
| 83 | } | ||
| 84 | //---------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //============================================================================ | ||
| 87 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 88 | /// @brief To add additional text string on fade label. | ||
| 89 | /// | ||
| 90 | /// @param[in] label Text to show | ||
| 91 | /// | ||
| 92 | void AddLabel(const std::string& label) | ||
| 93 | { | ||
| 94 | m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, | ||
| 95 | label.c_str()); | ||
| 96 | } | ||
| 97 | //---------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //============================================================================ | ||
| 100 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 101 | /// @brief Get the used text from button. | ||
| 102 | /// | ||
| 103 | /// @return Text shown | ||
| 104 | /// | ||
| 105 | std::string GetLabel() const | ||
| 106 | { | ||
| 107 | std::string label; | ||
| 108 | char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, | ||
| 109 | m_controlHandle); | ||
| 110 | if (ret != nullptr) | ||
| 111 | { | ||
| 112 | if (std::strlen(ret)) | ||
| 113 | label = ret; | ||
| 114 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 115 | } | ||
| 116 | return label; | ||
| 117 | } | ||
| 118 | //---------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 122 | /// @brief To enable or disable scrolling on fade label. | ||
| 123 | /// | ||
| 124 | /// @param[in] scroll To enable scrolling set to true, otherwise is disabled | ||
| 125 | /// | ||
| 126 | void SetScrolling(bool scroll) | ||
| 127 | { | ||
| 128 | m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, | ||
| 129 | scroll); | ||
| 130 | } | ||
| 131 | //---------------------------------------------------------------------------- | ||
| 132 | |||
| 133 | //============================================================================ | ||
| 134 | /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel | ||
| 135 | /// @brief To reset al inserted labels. | ||
| 136 | /// | ||
| 137 | void Reset() | ||
| 138 | { | ||
| 139 | m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); | ||
| 140 | } | ||
| 141 | //---------------------------------------------------------------------------- | ||
| 142 | }; | ||
| 143 | |||
| 144 | } /* namespace controls */ | ||
| 145 | } /* namespace gui */ | ||
| 146 | } /* namespace kodi */ | ||
| 147 | |||
| 148 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h new file mode 100644 index 0000000..9dc493e --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h | |||
| @@ -0,0 +1,112 @@ | |||
| 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 "../../c-api/gui/controls/image.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================ | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CImage Control Image | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CImage } | ||
| 27 | /// **Window control used to show an image.**\n | ||
| 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 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 44 | /// @brief Construct a new control. | ||
| 45 | /// | ||
| 46 | /// @param[in] window Related window control class | ||
| 47 | /// @param[in] controlId Used skin xml control id | ||
| 48 | /// | ||
| 49 | CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 50 | { | ||
| 51 | m_controlHandle = m_interface->kodi_gui->window->get_control_image( | ||
| 52 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 53 | if (!m_controlHandle) | ||
| 54 | kodi::Log(ADDON_LOG_FATAL, | ||
| 55 | "kodi::gui::controls::CImage can't create control class from Kodi !!!"); | ||
| 56 | } | ||
| 57 | //-------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //========================================================================== | ||
| 60 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 61 | /// @brief Destructor. | ||
| 62 | /// | ||
| 63 | ~CImage() override = default; | ||
| 64 | //-------------------------------------------------------------------------- | ||
| 65 | |||
| 66 | //========================================================================== | ||
| 67 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 68 | /// @brief Set the control on window to visible. | ||
| 69 | /// | ||
| 70 | /// @param[in] visible If true visible, otherwise hidden | ||
| 71 | /// | ||
| 72 | void SetVisible(bool visible) | ||
| 73 | { | ||
| 74 | m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 75 | visible); | ||
| 76 | } | ||
| 77 | //-------------------------------------------------------------------------- | ||
| 78 | |||
| 79 | //========================================================================== | ||
| 80 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 81 | /// @brief To set the filename used on image control. | ||
| 82 | /// | ||
| 83 | /// @param[in] filename Image file to use | ||
| 84 | /// @param[in] useCache To define storage of image, default is in cache, if | ||
| 85 | /// false becomes it loaded always on changes again | ||
| 86 | /// | ||
| 87 | void SetFileName(const std::string& filename, bool useCache = true) | ||
| 88 | { | ||
| 89 | m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, | ||
| 90 | filename.c_str(), useCache); | ||
| 91 | } | ||
| 92 | //-------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | //========================================================================== | ||
| 95 | /// @ingroup cpp_kodi_gui_windows_controls_CImage | ||
| 96 | /// @brief To set set the diffuse color on image. | ||
| 97 | /// | ||
| 98 | /// @param[in] colorDiffuse Color to use for diffuse | ||
| 99 | /// | ||
| 100 | void SetColorDiffuse(uint32_t colorDiffuse) | ||
| 101 | { | ||
| 102 | m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, | ||
| 103 | colorDiffuse); | ||
| 104 | } | ||
| 105 | //-------------------------------------------------------------------------- | ||
| 106 | }; | ||
| 107 | |||
| 108 | } /* namespace controls */ | ||
| 109 | } /* namespace gui */ | ||
| 110 | } /* namespace kodi */ | ||
| 111 | |||
| 112 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h new file mode 100644 index 0000000..d10b85f --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h | |||
| @@ -0,0 +1,118 @@ | |||
| 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 "../../c-api/gui/controls/label.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CLabel Control Label | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CLabel } | ||
| 27 | /// **Window control used to show some lines of text**\n | ||
| 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 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 44 | /// @brief Construct a new control. | ||
| 45 | /// | ||
| 46 | /// @param[in] window Related window control class | ||
| 47 | /// @param[in] controlId Used skin xml control id | ||
| 48 | /// | ||
| 49 | CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 50 | { | ||
| 51 | m_controlHandle = m_interface->kodi_gui->window->get_control_label( | ||
| 52 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 53 | if (!m_controlHandle) | ||
| 54 | kodi::Log(ADDON_LOG_FATAL, | ||
| 55 | "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | ||
| 56 | } | ||
| 57 | //---------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //============================================================================ | ||
| 60 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 61 | /// @brief Destructor. | ||
| 62 | /// | ||
| 63 | ~CLabel() override = default; | ||
| 64 | //---------------------------------------------------------------------------- | ||
| 65 | |||
| 66 | //============================================================================ | ||
| 67 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 68 | /// @brief Set the control on window to visible. | ||
| 69 | /// | ||
| 70 | /// @param[in] visible If true visible, otherwise hidden | ||
| 71 | /// | ||
| 72 | void SetVisible(bool visible) | ||
| 73 | { | ||
| 74 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 75 | visible); | ||
| 76 | } | ||
| 77 | //---------------------------------------------------------------------------- | ||
| 78 | |||
| 79 | //============================================================================ | ||
| 80 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 81 | /// @brief To set the text string on label. | ||
| 82 | /// | ||
| 83 | /// @param[in] text Text to show | ||
| 84 | /// | ||
| 85 | void SetLabel(const std::string& text) | ||
| 86 | { | ||
| 87 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 88 | text.c_str()); | ||
| 89 | } | ||
| 90 | //---------------------------------------------------------------------------- | ||
| 91 | |||
| 92 | //============================================================================ | ||
| 93 | /// @ingroup cpp_kodi_gui_windows_controls_CLabel | ||
| 94 | /// @brief Get the used text from control. | ||
| 95 | /// | ||
| 96 | /// @return Used text on label control | ||
| 97 | /// | ||
| 98 | std::string GetLabel() const | ||
| 99 | { | ||
| 100 | std::string label; | ||
| 101 | char* ret = | ||
| 102 | m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 103 | if (ret != nullptr) | ||
| 104 | { | ||
| 105 | if (std::strlen(ret)) | ||
| 106 | label = ret; | ||
| 107 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 108 | } | ||
| 109 | return label; | ||
| 110 | } | ||
| 111 | //---------------------------------------------------------------------------- | ||
| 112 | }; | ||
| 113 | |||
| 114 | } /* namespace controls */ | ||
| 115 | } /* namespace gui */ | ||
| 116 | } /* namespace kodi */ | ||
| 117 | |||
| 118 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h new file mode 100644 index 0000000..83b16aa --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h | |||
| @@ -0,0 +1,112 @@ | |||
| 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 "../../c-api/gui/controls/progress.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CProgress Control Progress | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CProgress } | ||
| 27 | /// **Window control to show the progress of a particular operation**\n | ||
| 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. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the progress control. | ||
| 32 | /// | ||
| 33 | /// It has the header @ref Progress.h "#include <kodi/gui/controls/Progress.h>" | ||
| 34 | /// be included to enjoy it. | ||
| 35 | /// | ||
| 36 | /// Here you find the needed skin part for a @ref Progress_Control "progress 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 | class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase | ||
| 42 | { | ||
| 43 | public: | ||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_gui_windows_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 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress | ||
| 63 | /// @brief Destructor. | ||
| 64 | /// | ||
| 65 | ~CProgress() override = default; | ||
| 66 | //---------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //============================================================================ | ||
| 69 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress | ||
| 70 | /// @brief Set the control on window to visible. | ||
| 71 | /// | ||
| 72 | /// @param[in] visible If true visible, otherwise hidden | ||
| 73 | /// | ||
| 74 | void SetVisible(bool visible) | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 77 | visible); | ||
| 78 | } | ||
| 79 | //---------------------------------------------------------------------------- | ||
| 80 | |||
| 81 | //============================================================================ | ||
| 82 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress | ||
| 83 | /// @brief To set Percent position of control. | ||
| 84 | /// | ||
| 85 | /// @param[in] percent The percent position to use | ||
| 86 | /// | ||
| 87 | void SetPercentage(float percent) | ||
| 88 | { | ||
| 89 | m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, | ||
| 90 | percent); | ||
| 91 | } | ||
| 92 | //---------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | //============================================================================ | ||
| 95 | /// @ingroup cpp_kodi_gui_windows_controls_CProgress | ||
| 96 | /// @brief Get the active percent position of progress bar. | ||
| 97 | /// | ||
| 98 | /// @return Progress position as percent | ||
| 99 | /// | ||
| 100 | float GetPercentage() const | ||
| 101 | { | ||
| 102 | return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, | ||
| 103 | m_controlHandle); | ||
| 104 | } | ||
| 105 | //---------------------------------------------------------------------------- | ||
| 106 | }; | ||
| 107 | |||
| 108 | } /* namespace controls */ | ||
| 109 | } /* namespace gui */ | ||
| 110 | } /* namespace kodi */ | ||
| 111 | |||
| 112 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h new file mode 100644 index 0000000..3b6a23c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h | |||
| @@ -0,0 +1,214 @@ | |||
| 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 "../../c-api/gui/controls/radio_button.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CRadioButton Control Radio Button | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CRadioButton } | ||
| 27 | /// **Window control for a radio button (as used for on/off settings)**\n | ||
| 28 | /// The radio button control is used for creating push button on/off settings | ||
| 29 | /// in Kodi. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the button. When the user | ||
| 32 | /// clicks on the radio button, the state will change, toggling the extra | ||
| 33 | /// textures (textureradioon and textureradiooff). Used for settings | ||
| 34 | /// controls. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Radio_button_control "radio button control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | /// | ||
| 45 | /// -------------------------------------------------------------------------- | ||
| 46 | /// **Example:** | ||
| 47 | /// ~~~~~~~~~~~~cpp | ||
| 48 | /// #include <kodi/gui/Window.h> | ||
| 49 | /// | ||
| 50 | /// #define MY_RADIO_BUTTON_CONTROL 1 | ||
| 51 | /// | ||
| 52 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 53 | /// { | ||
| 54 | /// public: | ||
| 55 | /// CMyWindow() | ||
| 56 | /// | ||
| 57 | /// void ShowWindow(); | ||
| 58 | /// | ||
| 59 | /// bool OnInit() override; | ||
| 60 | /// bool OnClick(int controlId) override; | ||
| 61 | /// | ||
| 62 | /// private: | ||
| 63 | /// kodi::gui::controls::CSpin m_myRadioButtonControl; | ||
| 64 | /// }; | ||
| 65 | /// | ||
| 66 | /// CMyWindow::CMyWindow() | ||
| 67 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 68 | /// m_myRadioButtonControl(this, MY_RADIO_BUTTON_CONTROL) | ||
| 69 | /// { | ||
| 70 | /// } | ||
| 71 | /// | ||
| 72 | /// void CMyWindow::ShowWindow() | ||
| 73 | /// { | ||
| 74 | /// kodi::gui::CWindow::DoModal(); | ||
| 75 | /// } | ||
| 76 | /// | ||
| 77 | /// bool CMyWindow::OnInit() | ||
| 78 | /// { | ||
| 79 | /// m_myRadioButtonControl.SetSelected(false); // can also on skin set to default | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_RADIO_BUTTON_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// bool selected = m_myRadioButtonControl.IsSelected(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase | ||
| 97 | { | ||
| 98 | public: | ||
| 99 | //============================================================================ | ||
| 100 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 101 | /// @brief Construct a new control. | ||
| 102 | /// | ||
| 103 | /// @param[in] window Related window control class | ||
| 104 | /// @param[in] controlId Used skin xml control id | ||
| 105 | /// | ||
| 106 | CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 107 | { | ||
| 108 | m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button( | ||
| 109 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 110 | if (!m_controlHandle) | ||
| 111 | kodi::Log(ADDON_LOG_FATAL, | ||
| 112 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | ||
| 113 | } | ||
| 114 | //---------------------------------------------------------------------------- | ||
| 115 | |||
| 116 | //============================================================================ | ||
| 117 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 118 | /// @brief Destructor. | ||
| 119 | /// | ||
| 120 | ~CRadioButton() override = default; | ||
| 121 | //---------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //============================================================================ | ||
| 124 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton. | ||
| 125 | /// @brief Set the control on window to visible. | ||
| 126 | /// | ||
| 127 | /// @param[in] visible If true visible, otherwise hidden | ||
| 128 | /// | ||
| 129 | void SetVisible(bool visible) | ||
| 130 | { | ||
| 131 | m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 132 | visible); | ||
| 133 | } | ||
| 134 | //---------------------------------------------------------------------------- | ||
| 135 | |||
| 136 | //============================================================================ | ||
| 137 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 138 | /// @brief Set's the control's enabled/disabled state. | ||
| 139 | /// | ||
| 140 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 141 | /// | ||
| 142 | void SetEnabled(bool enabled) | ||
| 143 | { | ||
| 144 | m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 145 | enabled); | ||
| 146 | } | ||
| 147 | //---------------------------------------------------------------------------- | ||
| 148 | |||
| 149 | //============================================================================ | ||
| 150 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 151 | /// @brief To set the text string on radio button. | ||
| 152 | /// | ||
| 153 | /// @param[in] label Text to show | ||
| 154 | /// | ||
| 155 | void SetLabel(const std::string& label) | ||
| 156 | { | ||
| 157 | m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 158 | label.c_str()); | ||
| 159 | } | ||
| 160 | //---------------------------------------------------------------------------- | ||
| 161 | |||
| 162 | //============================================================================ | ||
| 163 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 164 | /// @brief Get the used text from control. | ||
| 165 | /// | ||
| 166 | /// @return Text shown | ||
| 167 | /// | ||
| 168 | std::string GetLabel() const | ||
| 169 | { | ||
| 170 | std::string label; | ||
| 171 | char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, | ||
| 172 | m_controlHandle); | ||
| 173 | if (ret != nullptr) | ||
| 174 | { | ||
| 175 | if (std::strlen(ret)) | ||
| 176 | label = ret; | ||
| 177 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 178 | } | ||
| 179 | return label; | ||
| 180 | } | ||
| 181 | //---------------------------------------------------------------------------- | ||
| 182 | |||
| 183 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 185 | /// @brief To set radio button condition to on or off. | ||
| 186 | /// | ||
| 187 | /// @param[in] selected true set radio button to selection on, otherwise off | ||
| 188 | /// | ||
| 189 | void SetSelected(bool selected) | ||
| 190 | { | ||
| 191 | m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, | ||
| 192 | m_controlHandle, selected); | ||
| 193 | } | ||
| 194 | //---------------------------------------------------------------------------- | ||
| 195 | |||
| 196 | //============================================================================ | ||
| 197 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 198 | /// @brief Get the current selected condition of radio button. | ||
| 199 | /// | ||
| 200 | /// @return Selected condition | ||
| 201 | /// | ||
| 202 | bool IsSelected() const | ||
| 203 | { | ||
| 204 | return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, | ||
| 205 | m_controlHandle); | ||
| 206 | } | ||
| 207 | //---------------------------------------------------------------------------- | ||
| 208 | }; | ||
| 209 | |||
| 210 | } /* namespace controls */ | ||
| 211 | } /* namespace gui */ | ||
| 212 | } /* namespace kodi */ | ||
| 213 | |||
| 214 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h new file mode 100644 index 0000000..7f5feef --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h | |||
| @@ -0,0 +1,217 @@ | |||
| 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 "../../c-api/gui/controls/rendering.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | #include "../renderHelper.h" | ||
| 14 | |||
| 15 | #ifdef __cplusplus | ||
| 16 | |||
| 17 | namespace kodi | ||
| 18 | { | ||
| 19 | namespace gui | ||
| 20 | { | ||
| 21 | namespace controls | ||
| 22 | { | ||
| 23 | |||
| 24 | //============================================================================ | ||
| 25 | /// @defgroup cpp_kodi_gui_windows_controls_CRendering Control Rendering | ||
| 26 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 27 | /// @brief @cpp_class{ kodi::gui::controls::CRendering } | ||
| 28 | /// **Window control for rendering own parts**\n | ||
| 29 | /// This rendering control is used when own parts are needed. | ||
| 30 | /// | ||
| 31 | /// You have the control over them to render direct OpenGL or DirectX content | ||
| 32 | /// to the screen set by the size of them. | ||
| 33 | /// | ||
| 34 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 35 | /// callbacks are defined by the @ref CRendering_SetIndependentCallbacks | ||
| 36 | /// function and class is used as single and not as a parent class. | ||
| 37 | /// | ||
| 38 | /// It has the header @ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 39 | /// be included to enjoy it. | ||
| 40 | /// | ||
| 41 | /// Here you find the needed skin part for a @ref Addon_Rendering_control "rendering control". | ||
| 42 | /// | ||
| 43 | /// @note The call of the control is only possible from the corresponding | ||
| 44 | /// window as its class and identification number is required. | ||
| 45 | /// | ||
| 46 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 47 | { | ||
| 48 | public: | ||
| 49 | //========================================================================== | ||
| 50 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 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 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 57 | { | ||
| 58 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 59 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 60 | if (m_controlHandle) | ||
| 61 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 62 | m_controlHandle, this, OnCreateCB, | ||
| 63 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 64 | else | ||
| 65 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 66 | __FUNCTION__); | ||
| 67 | } | ||
| 68 | //-------------------------------------------------------------------------- | ||
| 69 | |||
| 70 | //========================================================================== | ||
| 71 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 72 | /// @brief Destructor. | ||
| 73 | /// | ||
| 74 | ~CRendering() override | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 77 | } | ||
| 78 | //-------------------------------------------------------------------------- | ||
| 79 | |||
| 80 | //========================================================================== | ||
| 81 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 82 | /// @brief To create rendering control on Add-on. | ||
| 83 | /// | ||
| 84 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 85 | /// handled and processed from Add-on | ||
| 86 | /// | ||
| 87 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 88 | /// for calls from add-on to this function. | ||
| 89 | /// | ||
| 90 | /// @param[in] x Horizontal position | ||
| 91 | /// @param[in] y Vertical position | ||
| 92 | /// @param[in] w Width of control | ||
| 93 | /// @param[in] h Height of control | ||
| 94 | /// @param[in] device The device to use. For OpenGL is empty on Direct X is | ||
| 95 | /// the needed device send. | ||
| 96 | /// @return Add-on needs to return true if successed, otherwise false. | ||
| 97 | /// | ||
| 98 | /// @note The @ref kodi::HardwareContext is basically a simple pointer which | ||
| 99 | /// has to be changed to the desired format at the corresponding places using | ||
| 100 | /// <b>`static_cast<...>(...)`</b>. | ||
| 101 | /// | ||
| 102 | virtual bool Create(int x, int y, int w, int h, kodi::HardwareContext device) { return false; } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 107 | /// @brief Render process call from Kodi. | ||
| 108 | /// | ||
| 109 | /// @note This is callback function from Kodi to Add-on and not to use for | ||
| 110 | /// calls from add-on to this function. | ||
| 111 | /// | ||
| 112 | virtual void Render() {} | ||
| 113 | //-------------------------------------------------------------------------- | ||
| 114 | |||
| 115 | //========================================================================== | ||
| 116 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 117 | /// @brief Call from Kodi to stop rendering process. | ||
| 118 | /// | ||
| 119 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 120 | /// for calls from add-on to this function. | ||
| 121 | /// | ||
| 122 | virtual void Stop() {} | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | |||
| 125 | //========================================================================== | ||
| 126 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 127 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 128 | /// region. | ||
| 129 | /// | ||
| 130 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 131 | /// for calls from add-on to this function. | ||
| 132 | /// | ||
| 133 | /// @return True if a render region is dirty and need rendering. | ||
| 134 | /// | ||
| 135 | virtual bool Dirty() { return false; } | ||
| 136 | //-------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //========================================================================== | ||
| 139 | /// @ingroup cpp_kodi_gui_windows_controls_CRendering | ||
| 140 | /// @anchor CRendering_SetIndependentCallbacks | ||
| 141 | /// @brief If the class is used independent (with "new CRendering") | ||
| 142 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 143 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 144 | /// | ||
| 145 | /// @param[in] cbhdl Addon related class point where becomes given as value on | ||
| 146 | /// related functions. | ||
| 147 | /// @param[in] CBCreate External creation function pointer, see also @ref Create | ||
| 148 | /// about related values | ||
| 149 | /// @param[in] CBRender External render function pointer, see also @ref Render | ||
| 150 | /// about related values | ||
| 151 | /// @param[in] CBStop External stop function pointer, see also @ref Stop | ||
| 152 | /// about related values | ||
| 153 | /// @param[in] CBDirty External dirty function pointer, see also @ref Dirty | ||
| 154 | /// about related values | ||
| 155 | /// | ||
| 156 | void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl, | ||
| 157 | bool (*CBCreate)(kodi::gui::ClientHandle cbhdl, | ||
| 158 | int x, | ||
| 159 | int y, | ||
| 160 | int w, | ||
| 161 | int h, | ||
| 162 | kodi::HardwareContext device), | ||
| 163 | void (*CBRender)(kodi::gui::ClientHandle cbhdl), | ||
| 164 | void (*CBStop)(kodi::gui::ClientHandle cbhdl), | ||
| 165 | bool (*CBDirty)(kodi::gui::ClientHandle cbhdl)) | ||
| 166 | { | ||
| 167 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 168 | { | ||
| 169 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 170 | return; | ||
| 171 | } | ||
| 172 | |||
| 173 | m_interface->kodi_gui->control_rendering->set_callbacks( | ||
| 174 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); | ||
| 175 | } | ||
| 176 | //-------------------------------------------------------------------------- | ||
| 177 | |||
| 178 | private: | ||
| 179 | /* | ||
| 180 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 181 | * (is private)! | ||
| 182 | */ | ||
| 183 | static bool OnCreateCB( | ||
| 184 | KODI_GUI_CLIENT_HANDLE cbhdl, int x, int y, int w, int h, ADDON_HARDWARE_CONTEXT device) | ||
| 185 | { | ||
| 186 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 187 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 188 | } | ||
| 189 | |||
| 190 | static void OnRenderCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 191 | { | ||
| 192 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) | ||
| 193 | return; | ||
| 194 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 196 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 197 | } | ||
| 198 | |||
| 199 | static void OnStopCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 200 | { | ||
| 201 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 202 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 203 | } | ||
| 204 | |||
| 205 | static bool OnDirtyCB(KODI_GUI_CLIENT_HANDLE cbhdl) | ||
| 206 | { | ||
| 207 | return static_cast<CRendering*>(cbhdl)->Dirty(); | ||
| 208 | } | ||
| 209 | |||
| 210 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; | ||
| 211 | }; | ||
| 212 | |||
| 213 | } /* namespace controls */ | ||
| 214 | } /* namespace gui */ | ||
| 215 | } /* namespace kodi */ | ||
| 216 | |||
| 217 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h new file mode 100644 index 0000000..5557fc4 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h | |||
| @@ -0,0 +1,314 @@ | |||
| 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 "../../c-api/gui/controls/settings_slider.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSettingsSlider Control Settings Slider | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSettingsSlider } | ||
| 27 | /// **Window control for moveable slider with text name**\n | ||
| 28 | /// The settings slider control is used in the settings screens for when an | ||
| 29 | /// option is best specified on a sliding scale. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the slider control. It is | ||
| 32 | /// basically a cross between the button control and a slider control. It has a | ||
| 33 | /// label and focus and non focus textures, as well as a slider control on the | ||
| 34 | /// right. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Settings_Slider_Control "settings slider control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase | ||
| 45 | { | ||
| 46 | public: | ||
| 47 | //============================================================================ | ||
| 48 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 49 | /// @brief Construct a new control. | ||
| 50 | /// | ||
| 51 | /// @param[in] window Related window control class | ||
| 52 | /// @param[in] controlId Used skin xml control id | ||
| 53 | /// | ||
| 54 | CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 55 | { | ||
| 56 | m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider( | ||
| 57 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 58 | if (!m_controlHandle) | ||
| 59 | kodi::Log(ADDON_LOG_FATAL, | ||
| 60 | "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); | ||
| 61 | } | ||
| 62 | //---------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | //============================================================================ | ||
| 65 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 66 | /// @brief Destructor. | ||
| 67 | /// | ||
| 68 | ~CSettingsSlider() override = default; | ||
| 69 | //---------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //============================================================================ | ||
| 72 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 73 | /// @brief Set the control on window to visible. | ||
| 74 | /// | ||
| 75 | /// @param[in] visible If true visible, otherwise hidden | ||
| 76 | /// | ||
| 77 | void SetVisible(bool visible) | ||
| 78 | { | ||
| 79 | m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, | ||
| 80 | m_controlHandle, visible); | ||
| 81 | } | ||
| 82 | //---------------------------------------------------------------------------- | ||
| 83 | |||
| 84 | //============================================================================ | ||
| 85 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 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_settings_slider->set_enabled(m_interface->kodiBase, | ||
| 93 | m_controlHandle, enabled); | ||
| 94 | } | ||
| 95 | //---------------------------------------------------------------------------- | ||
| 96 | |||
| 97 | //============================================================================ | ||
| 98 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 99 | /// @brief To set the text string on settings slider. | ||
| 100 | /// | ||
| 101 | /// @param[in] text Text to show | ||
| 102 | /// | ||
| 103 | void SetText(const std::string& text) | ||
| 104 | { | ||
| 105 | m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 106 | text.c_str()); | ||
| 107 | } | ||
| 108 | //---------------------------------------------------------------------------- | ||
| 109 | |||
| 110 | //============================================================================ | ||
| 111 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 112 | /// @brief To reset slider on defaults. | ||
| 113 | /// | ||
| 114 | void Reset() | ||
| 115 | { | ||
| 116 | m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); | ||
| 117 | } | ||
| 118 | //---------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 122 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 123 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 124 | /// end. | ||
| 125 | /// | ||
| 126 | /// Ad default is the range from 0 to 100. | ||
| 127 | /// | ||
| 128 | /// The integer interval is as default 1 and can be changed with | ||
| 129 | /// @ref SetIntInterval. | ||
| 130 | /// | ||
| 131 | /// @param[in] start Integer start value | ||
| 132 | /// @param[in] end Integer end value | ||
| 133 | /// | ||
| 134 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 135 | /// these different values can be not together and can, therefore, only | ||
| 136 | /// one each can be used. | ||
| 137 | /// | ||
| 138 | void SetIntRange(int start, int end) | ||
| 139 | { | ||
| 140 | m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, | ||
| 141 | m_controlHandle, start, end); | ||
| 142 | } | ||
| 143 | //---------------------------------------------------------------------------- | ||
| 144 | |||
| 145 | //============================================================================ | ||
| 146 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 147 | /// @brief Set the slider position with the given integer value. The Range | ||
| 148 | /// must be defined with a call from @ref SetIntRange before. | ||
| 149 | /// | ||
| 150 | /// @param[in] value Position in range to set with integer | ||
| 151 | /// | ||
| 152 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 153 | /// these different values can be not together and can, therefore, only | ||
| 154 | /// one each can be used. | ||
| 155 | /// | ||
| 156 | void SetIntValue(int value) | ||
| 157 | { | ||
| 158 | m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, | ||
| 159 | m_controlHandle, value); | ||
| 160 | } | ||
| 161 | //---------------------------------------------------------------------------- | ||
| 162 | |||
| 163 | //============================================================================ | ||
| 164 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 165 | /// @brief To get the current position as integer value. | ||
| 166 | /// | ||
| 167 | /// @return The position as integer | ||
| 168 | /// | ||
| 169 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 170 | /// these different values can be not together and can, therefore, only | ||
| 171 | /// one each can be used. | ||
| 172 | /// | ||
| 173 | int GetIntValue() const | ||
| 174 | { | ||
| 175 | return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, | ||
| 176 | m_controlHandle); | ||
| 177 | } | ||
| 178 | //---------------------------------------------------------------------------- | ||
| 179 | |||
| 180 | //============================================================================ | ||
| 181 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 182 | /// @brief To set the interval steps of slider, as default is it 1. If it | ||
| 183 | /// becomes changed with this function will a step of the user with the | ||
| 184 | /// value fixed here be executed. | ||
| 185 | /// | ||
| 186 | /// @param[in] interval Intervall step to set. | ||
| 187 | /// | ||
| 188 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 189 | /// these different values can be not together and can, therefore, only | ||
| 190 | /// one each can be used. | ||
| 191 | /// | ||
| 192 | void SetIntInterval(int interval) | ||
| 193 | { | ||
| 194 | m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, | ||
| 195 | m_controlHandle, interval); | ||
| 196 | } | ||
| 197 | //---------------------------------------------------------------------------- | ||
| 198 | |||
| 199 | //============================================================================ | ||
| 200 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 201 | /// @brief Sets the percent of the slider. | ||
| 202 | /// | ||
| 203 | /// @param[in] percent float - Percent value of slide | ||
| 204 | /// | ||
| 205 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 206 | /// these different values can be not together and can, therefore, only | ||
| 207 | /// one each can be used. | ||
| 208 | /// | ||
| 209 | void SetPercentage(float percent) | ||
| 210 | { | ||
| 211 | m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, | ||
| 212 | m_controlHandle, percent); | ||
| 213 | } | ||
| 214 | //---------------------------------------------------------------------------- | ||
| 215 | |||
| 216 | //============================================================================ | ||
| 217 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 218 | /// @brief Returns a float of the percent of the slider. | ||
| 219 | /// | ||
| 220 | /// @return float - Percent of slider | ||
| 221 | /// | ||
| 222 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 223 | /// these different values can be not together and can, therefore, only | ||
| 224 | /// one each can be used. | ||
| 225 | /// | ||
| 226 | float GetPercentage() const | ||
| 227 | { | ||
| 228 | return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, | ||
| 229 | m_controlHandle); | ||
| 230 | } | ||
| 231 | //---------------------------------------------------------------------------- | ||
| 232 | |||
| 233 | //============================================================================ | ||
| 234 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 235 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | ||
| 236 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 237 | /// the end. | ||
| 238 | /// | ||
| 239 | /// As default is the range 0.0 to 1.0. | ||
| 240 | /// | ||
| 241 | /// The float interval is as default 0.1 and can be changed with | ||
| 242 | /// @ref SetFloatInterval. | ||
| 243 | /// | ||
| 244 | /// @param[in] start Integer start value | ||
| 245 | /// @param[in] end Integer end value | ||
| 246 | /// | ||
| 247 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 248 | /// these different values can be not together and can, therefore, only | ||
| 249 | /// one each can be used. | ||
| 250 | /// | ||
| 251 | void SetFloatRange(float start, float end) | ||
| 252 | { | ||
| 253 | m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, | ||
| 254 | m_controlHandle, start, end); | ||
| 255 | } | ||
| 256 | //---------------------------------------------------------------------------- | ||
| 257 | |||
| 258 | //============================================================================ | ||
| 259 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 260 | /// @brief Set the slider position with the given float value. The Range can | ||
| 261 | /// be defined with a call from @ref SetIntRange before, as default it | ||
| 262 | /// is 0.0 to 1.0. | ||
| 263 | /// | ||
| 264 | /// @param[in] value Position in range to set with float | ||
| 265 | /// | ||
| 266 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 267 | /// these different values can be not together and can, therefore, only | ||
| 268 | /// one each can be used. | ||
| 269 | /// | ||
| 270 | void SetFloatValue(float value) | ||
| 271 | { | ||
| 272 | m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, | ||
| 273 | m_controlHandle, value); | ||
| 274 | } | ||
| 275 | //---------------------------------------------------------------------------- | ||
| 276 | |||
| 277 | //============================================================================ | ||
| 278 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 279 | /// @brief To get the current position as float value. | ||
| 280 | /// | ||
| 281 | /// @return The position as float | ||
| 282 | /// | ||
| 283 | float GetFloatValue() const | ||
| 284 | { | ||
| 285 | return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, | ||
| 286 | m_controlHandle); | ||
| 287 | } | ||
| 288 | //---------------------------------------------------------------------------- | ||
| 289 | |||
| 290 | //============================================================================ | ||
| 291 | /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider | ||
| 292 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 293 | /// becomes changed with this function will a step of the user with the | ||
| 294 | /// value fixed here be executed. | ||
| 295 | /// | ||
| 296 | /// @param[in] interval Intervall step to set. | ||
| 297 | /// | ||
| 298 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 299 | /// these different values can be not together and can, therefore, only | ||
| 300 | /// one each can be used. | ||
| 301 | /// | ||
| 302 | void SetFloatInterval(float interval) | ||
| 303 | { | ||
| 304 | m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, | ||
| 305 | m_controlHandle, interval); | ||
| 306 | } | ||
| 307 | //---------------------------------------------------------------------------- | ||
| 308 | }; | ||
| 309 | |||
| 310 | } /* namespace controls */ | ||
| 311 | } /* namespace gui */ | ||
| 312 | } /* namespace kodi */ | ||
| 313 | |||
| 314 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h new file mode 100644 index 0000000..077def8 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h | |||
| @@ -0,0 +1,326 @@ | |||
| 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 "../../c-api/gui/controls/slider.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSlider Control Slider | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSlider } | ||
| 27 | /// **Window control for moveable slider**\n | ||
| 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). | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the slider control. | ||
| 32 | /// | ||
| 33 | /// It has the header @ref Slider.h "#include <kodi/gui/controls/Slider.h>" | ||
| 34 | /// be included to enjoy it. | ||
| 35 | /// | ||
| 36 | /// Here you find the needed skin part for a @ref Slider_Control "slider 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 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase | ||
| 42 | { | ||
| 43 | public: | ||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_gui_windows_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 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 63 | /// @brief Destructor. | ||
| 64 | /// | ||
| 65 | ~CSlider() override = default; | ||
| 66 | //---------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //============================================================================ | ||
| 69 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 70 | /// @brief Set the control on window to visible. | ||
| 71 | /// | ||
| 72 | /// @param[in] visible If true visible, otherwise hidden | ||
| 73 | /// | ||
| 74 | void SetVisible(bool visible) | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 77 | visible); | ||
| 78 | } | ||
| 79 | //---------------------------------------------------------------------------- | ||
| 80 | |||
| 81 | //============================================================================ | ||
| 82 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 83 | /// @brief Set's the control's enabled/disabled state. | ||
| 84 | /// | ||
| 85 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 86 | /// | ||
| 87 | void SetEnabled(bool enabled) | ||
| 88 | { | ||
| 89 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 90 | enabled); | ||
| 91 | } | ||
| 92 | //---------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | //============================================================================ | ||
| 95 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 96 | /// @brief To reset slider on defaults. | ||
| 97 | /// | ||
| 98 | void Reset() | ||
| 99 | { | ||
| 100 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); | ||
| 101 | } | ||
| 102 | //---------------------------------------------------------------------------- | ||
| 103 | |||
| 104 | //============================================================================ | ||
| 105 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 106 | /// @brief With GetDescription becomes a string value of position returned. | ||
| 107 | /// | ||
| 108 | /// @return Text string about current slider position | ||
| 109 | /// | ||
| 110 | /// The following are the text definition returned from this: | ||
| 111 | /// | Value | Without range selection | With range selection | | ||
| 112 | /// |:---------:|:------------------------|:-------------------------------| | ||
| 113 | /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> | | ||
| 114 | /// | integer | <c>%i</c> | <c>[%i, %i]</c> | | ||
| 115 | /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> | | ||
| 116 | /// | ||
| 117 | std::string GetDescription() const | ||
| 118 | { | ||
| 119 | std::string text; | ||
| 120 | char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, | ||
| 121 | m_controlHandle); | ||
| 122 | if (ret != nullptr) | ||
| 123 | { | ||
| 124 | if (std::strlen(ret)) | ||
| 125 | text = ret; | ||
| 126 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 127 | } | ||
| 128 | return text; | ||
| 129 | } | ||
| 130 | //---------------------------------------------------------------------------- | ||
| 131 | |||
| 132 | //============================================================================ | ||
| 133 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 134 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 135 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 136 | /// end. | ||
| 137 | /// | ||
| 138 | /// Ad default is the range from 0 to 100. | ||
| 139 | /// | ||
| 140 | /// The integer interval is as default 1 and can be changed with | ||
| 141 | /// @ref SetIntInterval. | ||
| 142 | /// | ||
| 143 | /// @param[in] start Integer start value | ||
| 144 | /// @param[in] end Integer end value | ||
| 145 | /// | ||
| 146 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 147 | /// these different values can be not together and can, therefore, only one | ||
| 148 | /// each can be used. | ||
| 149 | /// | ||
| 150 | void SetIntRange(int start, int end) | ||
| 151 | { | ||
| 152 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 153 | start, end); | ||
| 154 | } | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 159 | /// @brief Set the slider position with the given integer value. The Range | ||
| 160 | /// must be defined with a call from @ref SetIntRange before. | ||
| 161 | /// | ||
| 162 | /// @param[in] value Position in range to set with integer | ||
| 163 | /// | ||
| 164 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 165 | /// these different values can be not together and can, therefore, only one | ||
| 166 | /// each can be used. | ||
| 167 | /// | ||
| 168 | void SetIntValue(int value) | ||
| 169 | { | ||
| 170 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 171 | value); | ||
| 172 | } | ||
| 173 | //---------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //============================================================================ | ||
| 176 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 177 | /// @brief To get the current position as integer value. | ||
| 178 | /// | ||
| 179 | /// @return The position as integer | ||
| 180 | /// | ||
| 181 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 182 | /// these different values can be not together and can, therefore, only | ||
| 183 | /// one each can be used. | ||
| 184 | /// | ||
| 185 | int GetIntValue() const | ||
| 186 | { | ||
| 187 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, | ||
| 188 | m_controlHandle); | ||
| 189 | } | ||
| 190 | //---------------------------------------------------------------------------- | ||
| 191 | |||
| 192 | //============================================================================ | ||
| 193 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 194 | /// @brief To set the interval steps of slider, as default is it 1. If it | ||
| 195 | /// becomes changed with this function will a step of the user with the | ||
| 196 | /// value fixed here be executed. | ||
| 197 | /// | ||
| 198 | /// @param[in] interval Intervall step to set. | ||
| 199 | /// | ||
| 200 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 201 | /// these different values can be not together and can, therefore, only one | ||
| 202 | /// each can be used. | ||
| 203 | /// | ||
| 204 | void SetIntInterval(int interval) | ||
| 205 | { | ||
| 206 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, | ||
| 207 | interval); | ||
| 208 | } | ||
| 209 | //---------------------------------------------------------------------------- | ||
| 210 | |||
| 211 | //============================================================================ | ||
| 212 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 213 | /// @brief Sets the percent of the slider. | ||
| 214 | /// | ||
| 215 | /// @param[in] percent float - Percent value of slide | ||
| 216 | /// | ||
| 217 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 218 | /// these different values can be not together and can, therefore, only one | ||
| 219 | /// each can be used. | ||
| 220 | /// | ||
| 221 | void SetPercentage(float percent) | ||
| 222 | { | ||
| 223 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, | ||
| 224 | percent); | ||
| 225 | } | ||
| 226 | //---------------------------------------------------------------------------- | ||
| 227 | |||
| 228 | //============================================================================ | ||
| 229 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 230 | /// @brief Returns a float of the percent of the slider. | ||
| 231 | /// | ||
| 232 | /// @return float - Percent of slider | ||
| 233 | /// | ||
| 234 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 235 | /// these different values can be not together and can, therefore, only one | ||
| 236 | /// each can be used. | ||
| 237 | /// | ||
| 238 | float GetPercentage() const | ||
| 239 | { | ||
| 240 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, | ||
| 241 | m_controlHandle); | ||
| 242 | } | ||
| 243 | //---------------------------------------------------------------------------- | ||
| 244 | |||
| 245 | //============================================================================ | ||
| 246 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 247 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | ||
| 248 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 249 | /// the end. | ||
| 250 | /// | ||
| 251 | /// As default is the range 0.0 to 1.0. | ||
| 252 | /// | ||
| 253 | /// The float interval is as default 0.1 and can be changed with | ||
| 254 | /// @ref SetFloatInterval. | ||
| 255 | /// | ||
| 256 | /// @param[in] start Integer start value | ||
| 257 | /// @param[in] end Integer end value | ||
| 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. | ||
| 262 | /// | ||
| 263 | void SetFloatRange(float start, float end) | ||
| 264 | { | ||
| 265 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 266 | start, end); | ||
| 267 | } | ||
| 268 | //---------------------------------------------------------------------------- | ||
| 269 | |||
| 270 | //============================================================================ | ||
| 271 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 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 one | ||
| 280 | /// each can be used. | ||
| 281 | /// | ||
| 282 | void SetFloatValue(float value) | ||
| 283 | { | ||
| 284 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 285 | value); | ||
| 286 | } | ||
| 287 | //---------------------------------------------------------------------------- | ||
| 288 | |||
| 289 | //============================================================================ | ||
| 290 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 291 | /// @brief To get the current position as float value. | ||
| 292 | /// | ||
| 293 | /// @return The position as float | ||
| 294 | /// | ||
| 295 | float GetFloatValue() const | ||
| 296 | { | ||
| 297 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, | ||
| 298 | m_controlHandle); | ||
| 299 | } | ||
| 300 | //---------------------------------------------------------------------------- | ||
| 301 | |||
| 302 | //============================================================================ | ||
| 303 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 304 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 305 | /// becomes changed with this function will a step of the user with the | ||
| 306 | /// value fixed here be executed. | ||
| 307 | /// | ||
| 308 | /// @param[in] interval Intervall step to set. | ||
| 309 | /// | ||
| 310 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 311 | /// these different values can be not together and can, therefore, only | ||
| 312 | /// one each can be used. | ||
| 313 | /// | ||
| 314 | void SetFloatInterval(float interval) | ||
| 315 | { | ||
| 316 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, | ||
| 317 | m_controlHandle, interval); | ||
| 318 | } | ||
| 319 | //---------------------------------------------------------------------------- | ||
| 320 | }; | ||
| 321 | |||
| 322 | } /* namespace controls */ | ||
| 323 | } /* namespace gui */ | ||
| 324 | } /* namespace kodi */ | ||
| 325 | |||
| 326 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..6c55243 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h | |||
| @@ -0,0 +1,416 @@ | |||
| 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 "../../c-api/gui/controls/spin.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSpin Control Spin | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSpin } | ||
| 27 | /// **Window control used for cycling up/down controls**\n | ||
| 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. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the spin control. It is | ||
| 32 | /// basically a cross between the button control and a spin control. It has a | ||
| 33 | /// label and focus and non focus textures, as well as a spin control on the | ||
| 34 | /// right. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Spin_Control "spin control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | /// -------------------------------------------------------------------------- | ||
| 45 | /// **Example:** | ||
| 46 | /// ~~~~~~~~~~~~cpp | ||
| 47 | /// #include <kodi/gui/Window.h> | ||
| 48 | /// | ||
| 49 | /// #define MY_SPIN_CONTROL 1 | ||
| 50 | /// | ||
| 51 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 52 | /// { | ||
| 53 | /// public: | ||
| 54 | /// CMyWindow() | ||
| 55 | /// | ||
| 56 | /// void ShowWindow(); | ||
| 57 | /// | ||
| 58 | /// bool OnInit() override; | ||
| 59 | /// bool OnClick(int controlId) override; | ||
| 60 | /// | ||
| 61 | /// private: | ||
| 62 | /// kodi::gui::controls::CSpin m_mySpinControl; | ||
| 63 | /// }; | ||
| 64 | /// | ||
| 65 | /// CMyWindow::CMyWindow() | ||
| 66 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 67 | /// m_mySpinControl(this, MY_SPIN_CONTROL) | ||
| 68 | /// { | ||
| 69 | /// } | ||
| 70 | /// | ||
| 71 | /// void CMyWindow::ShowWindow() | ||
| 72 | /// { | ||
| 73 | /// kodi::gui::CWindow::DoModal(); | ||
| 74 | /// } | ||
| 75 | /// | ||
| 76 | /// bool CMyWindow::OnInit() | ||
| 77 | /// { | ||
| 78 | /// m_mySpinControl.SetType(kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT); | ||
| 79 | /// m_mySpinControl.SetIntRange(1, 80); | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_SPIN_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// int value = m_mySpinControl.GetIntValue(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | |||
| 97 | |||
| 98 | //============================================================================== | ||
| 99 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 100 | /// @anchor AddonGUISpinControlType | ||
| 101 | /// @brief The values here defines the used value format for steps on | ||
| 102 | /// spin control. | ||
| 103 | /// | ||
| 104 | typedef enum AddonGUISpinControlType | ||
| 105 | { | ||
| 106 | /// One spin step interpreted as integer | ||
| 107 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 108 | /// One spin step interpreted as floating point value | ||
| 109 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 110 | /// One spin step interpreted as text string | ||
| 111 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 112 | /// One spin step interpreted as a page change value | ||
| 113 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 114 | } AddonGUISpinControlType; | ||
| 115 | //------------------------------------------------------------------------------ | ||
| 116 | |||
| 117 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase | ||
| 118 | { | ||
| 119 | public: | ||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 122 | /// @brief Construct a new control. | ||
| 123 | /// | ||
| 124 | /// @param[in] window Related window control class | ||
| 125 | /// @param[in] controlId Used skin xml control id | ||
| 126 | /// | ||
| 127 | CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 128 | { | ||
| 129 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin( | ||
| 130 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 131 | if (!m_controlHandle) | ||
| 132 | kodi::Log(ADDON_LOG_FATAL, | ||
| 133 | "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 134 | } | ||
| 135 | //---------------------------------------------------------------------------- | ||
| 136 | |||
| 137 | //============================================================================ | ||
| 138 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 139 | /// @brief Destructor. | ||
| 140 | /// | ||
| 141 | ~CSpin() override = default; | ||
| 142 | //---------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //============================================================================ | ||
| 145 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 146 | /// @brief Set the control on window to visible. | ||
| 147 | /// | ||
| 148 | /// @param[in] visible If true visible, otherwise hidden | ||
| 149 | /// | ||
| 150 | void SetVisible(bool visible) | ||
| 151 | { | ||
| 152 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 153 | visible); | ||
| 154 | } | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 159 | /// @brief Set's the control's enabled/disabled state. | ||
| 160 | /// | ||
| 161 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 162 | /// | ||
| 163 | void SetEnabled(bool enabled) | ||
| 164 | { | ||
| 165 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 166 | enabled); | ||
| 167 | } | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //============================================================================ | ||
| 171 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 172 | /// @brief To set the text string on spin control. | ||
| 173 | /// | ||
| 174 | /// @param[in] text Text to show as name for spin | ||
| 175 | /// | ||
| 176 | void SetText(const std::string& text) | ||
| 177 | { | ||
| 178 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 179 | text.c_str()); | ||
| 180 | } | ||
| 181 | //---------------------------------------------------------------------------- | ||
| 182 | |||
| 183 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 185 | /// @brief To reset spin control to defaults. | ||
| 186 | /// | ||
| 187 | void Reset() | ||
| 188 | { | ||
| 189 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 190 | } | ||
| 191 | //---------------------------------------------------------------------------- | ||
| 192 | |||
| 193 | //============================================================================ | ||
| 194 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 195 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 196 | /// | ||
| 197 | /// @param[in] type The type to use | ||
| 198 | /// | ||
| 199 | /// @note See description of @ref AddonGUISpinControlType for available types. | ||
| 200 | /// | ||
| 201 | void SetType(AddonGUISpinControlType type) | ||
| 202 | { | ||
| 203 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, | ||
| 204 | (int)type); | ||
| 205 | } | ||
| 206 | //---------------------------------------------------------------------------- | ||
| 207 | |||
| 208 | //============================================================================ | ||
| 209 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 210 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 211 | /// | ||
| 212 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 213 | /// | ||
| 214 | /// @param[in] label Label string to view on skin | ||
| 215 | /// @param[in] value String value to use for selection of them | ||
| 216 | /// | ||
| 217 | void AddLabel(const std::string& label, const std::string& value) | ||
| 218 | { | ||
| 219 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, | ||
| 220 | label.c_str(), value.c_str()); | ||
| 221 | } | ||
| 222 | //---------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //============================================================================ | ||
| 225 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 226 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 227 | /// | ||
| 228 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 229 | /// | ||
| 230 | /// @param[in] label Label string to view on skin | ||
| 231 | /// @param[in] value Integer value to use for selection of them. | ||
| 232 | /// | ||
| 233 | void AddLabel(const std::string& label, int value) | ||
| 234 | { | ||
| 235 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, | ||
| 236 | label.c_str(), value); | ||
| 237 | } | ||
| 238 | //---------------------------------------------------------------------------- | ||
| 239 | |||
| 240 | //============================================================================ | ||
| 241 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 242 | /// @brief To change the spin to position with them string as value. | ||
| 243 | /// | ||
| 244 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 245 | /// | ||
| 246 | /// @param[in] value String value to change to | ||
| 247 | /// | ||
| 248 | void SetStringValue(const std::string& value) | ||
| 249 | { | ||
| 250 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, | ||
| 251 | value.c_str()); | ||
| 252 | } | ||
| 253 | //---------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //============================================================================ | ||
| 256 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 257 | /// @brief To get the current spin control position with text string value. | ||
| 258 | /// | ||
| 259 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 260 | /// | ||
| 261 | /// @return Currently selected string value | ||
| 262 | /// | ||
| 263 | std::string GetStringValue() const | ||
| 264 | { | ||
| 265 | std::string value; | ||
| 266 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, | ||
| 267 | m_controlHandle); | ||
| 268 | if (ret != nullptr) | ||
| 269 | { | ||
| 270 | if (std::strlen(ret)) | ||
| 271 | value = ret; | ||
| 272 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 273 | } | ||
| 274 | return value; | ||
| 275 | } | ||
| 276 | //---------------------------------------------------------------------------- | ||
| 277 | |||
| 278 | //============================================================================ | ||
| 279 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 280 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 281 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 282 | /// end. | ||
| 283 | /// | ||
| 284 | /// Ad default is the range from 0 to 100. | ||
| 285 | /// | ||
| 286 | /// @param[in] start Integer start value | ||
| 287 | /// @param[in] end Integer end value | ||
| 288 | /// | ||
| 289 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 290 | /// these different values can be not together and can, therefore, only | ||
| 291 | /// one each can be used and must be defined with @ref SetType before. | ||
| 292 | /// | ||
| 293 | void SetIntRange(int start, int end) | ||
| 294 | { | ||
| 295 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 296 | start, end); | ||
| 297 | } | ||
| 298 | //---------------------------------------------------------------------------- | ||
| 299 | |||
| 300 | //============================================================================ | ||
| 301 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 302 | /// @brief Set the slider position with the given integer value. The Range | ||
| 303 | /// must be defined with a call from @ref SetIntRange before. | ||
| 304 | /// | ||
| 305 | /// @param[in] value Position in range to set with integer | ||
| 306 | /// | ||
| 307 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 308 | /// these different values can be not together and can, therefore, only | ||
| 309 | /// one each can be used and must be defined with @ref SetType before. | ||
| 310 | /// | ||
| 311 | void SetIntValue(int value) | ||
| 312 | { | ||
| 313 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 314 | value); | ||
| 315 | } | ||
| 316 | //---------------------------------------------------------------------------- | ||
| 317 | |||
| 318 | //============================================================================ | ||
| 319 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 320 | /// @brief To get the current position as integer value. | ||
| 321 | /// | ||
| 322 | /// @return The position as integer | ||
| 323 | /// | ||
| 324 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 325 | /// these different values can be not together and can, therefore, only | ||
| 326 | /// one each can be used and must be defined with @ref SetType before. | ||
| 327 | /// | ||
| 328 | int GetIntValue() const | ||
| 329 | { | ||
| 330 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, | ||
| 331 | m_controlHandle); | ||
| 332 | } | ||
| 333 | //---------------------------------------------------------------------------- | ||
| 334 | |||
| 335 | //============================================================================ | ||
| 336 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 337 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 338 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 339 | /// the end. | ||
| 340 | /// | ||
| 341 | /// As default is the range 0.0 to 1.0. | ||
| 342 | /// | ||
| 343 | /// The float interval is as default 0.1 and can be changed with | ||
| 344 | /// @ref SetFloatInterval. | ||
| 345 | /// | ||
| 346 | /// @param[in] start Integer start value | ||
| 347 | /// @param[in] end Integer end value | ||
| 348 | /// | ||
| 349 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 350 | /// these different values can be not together and can, therefore, only | ||
| 351 | /// one each can be used and must be defined with @ref SetType before. | ||
| 352 | /// | ||
| 353 | void SetFloatRange(float start, float end) | ||
| 354 | { | ||
| 355 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 356 | start, end); | ||
| 357 | } | ||
| 358 | //---------------------------------------------------------------------------- | ||
| 359 | |||
| 360 | //============================================================================ | ||
| 361 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 362 | /// @brief Set the spin position with the given float value. The Range | ||
| 363 | /// can be defined with a call from @ref SetIntRange before, as default it | ||
| 364 | /// is 0.0 to 1.0. | ||
| 365 | /// | ||
| 366 | /// @param[in] value Position in range to set with float | ||
| 367 | /// | ||
| 368 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 369 | /// these different values can be not together and can, therefore, only | ||
| 370 | /// one each can be used and must be defined with @ref SetType before. | ||
| 371 | /// | ||
| 372 | void SetFloatValue(float value) | ||
| 373 | { | ||
| 374 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 375 | value); | ||
| 376 | } | ||
| 377 | //---------------------------------------------------------------------------- | ||
| 378 | |||
| 379 | //============================================================================ | ||
| 380 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 381 | /// @brief To get the current position as float value. | ||
| 382 | /// | ||
| 383 | /// @return The position as float | ||
| 384 | /// | ||
| 385 | float GetFloatValue() const | ||
| 386 | { | ||
| 387 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, | ||
| 388 | m_controlHandle); | ||
| 389 | } | ||
| 390 | //---------------------------------------------------------------------------- | ||
| 391 | |||
| 392 | //============================================================================ | ||
| 393 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 394 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 395 | /// becomes changed with this function will a step of the user with the | ||
| 396 | /// value fixed here be executed. | ||
| 397 | /// | ||
| 398 | /// @param[in] interval Intervall step to set. | ||
| 399 | /// | ||
| 400 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 401 | /// these different values can be not together and can, therefore, only | ||
| 402 | /// one each can be used and must be defined with @ref SetType before. | ||
| 403 | /// | ||
| 404 | void SetFloatInterval(float interval) | ||
| 405 | { | ||
| 406 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, | ||
| 407 | interval); | ||
| 408 | } | ||
| 409 | //---------------------------------------------------------------------------- | ||
| 410 | }; | ||
| 411 | |||
| 412 | } /* namespace controls */ | ||
| 413 | } /* namespace gui */ | ||
| 414 | } /* namespace kodi */ | ||
| 415 | |||
| 416 | #endif /* __cplusplus */ | ||
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h new file mode 100644 index 0000000..2634568 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h | |||
| @@ -0,0 +1,164 @@ | |||
| 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 "../../c-api/gui/controls/text_box.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================ | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CTextBox Control Text Box | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CTextBox } | ||
| 27 | /// **Used to show a multi-page piece of text**\n | ||
| 28 | /// The text box control can be used to display descriptions, help texts or | ||
| 29 | /// other larger texts. | ||
| 30 | /// | ||
| 31 | /// It corresponds to the representation which is also to be seen on the | ||
| 32 | /// @ref CDialogTextViewer. | ||
| 33 | /// | ||
| 34 | /// It has the header @ref TextBox.h "#include <kodi/gui/controls/TextBox.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | /// Here you find the needed skin part for a @ref Text_Box "textbox 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 CTextBox : public CAddonGUIControlBase | ||
| 43 | { | ||
| 44 | public: | ||
| 45 | //========================================================================== | ||
| 46 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 47 | /// @brief Construct a new control. | ||
| 48 | /// | ||
| 49 | /// @param[in] window related window control class | ||
| 50 | /// @param[in] controlId Used skin xml control id | ||
| 51 | /// | ||
| 52 | CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 53 | { | ||
| 54 | m_controlHandle = m_interface->kodi_gui->window->get_control_text_box( | ||
| 55 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 56 | if (!m_controlHandle) | ||
| 57 | kodi::Log(ADDON_LOG_FATAL, | ||
| 58 | "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); | ||
| 59 | } | ||
| 60 | //-------------------------------------------------------------------------- | ||
| 61 | |||
| 62 | //========================================================================== | ||
| 63 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 64 | /// @brief Destructor. | ||
| 65 | /// | ||
| 66 | ~CTextBox() override = default; | ||
| 67 | //-------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | //========================================================================== | ||
| 70 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 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_text_box->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 78 | visible); | ||
| 79 | } | ||
| 80 | //-------------------------------------------------------------------------- | ||
| 81 | |||
| 82 | //========================================================================== | ||
| 83 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 84 | /// @brief To reset box an remove all the text. | ||
| 85 | /// | ||
| 86 | void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 90 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 91 | /// @brief To set the text on box. | ||
| 92 | /// | ||
| 93 | /// @param[in] text Text to show | ||
| 94 | /// | ||
| 95 | void SetText(const std::string& text) | ||
| 96 | { | ||
| 97 | m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 98 | text.c_str()); | ||
| 99 | } | ||
| 100 | //-------------------------------------------------------------------------- | ||
| 101 | |||
| 102 | //========================================================================== | ||
| 103 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 104 | /// @brief Get the used text from control. | ||
| 105 | /// | ||
| 106 | /// @return Text shown | ||
| 107 | /// | ||
| 108 | std::string GetText() const | ||
| 109 | { | ||
| 110 | std::string text; | ||
| 111 | char* ret = | ||
| 112 | m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); | ||
| 113 | if (ret != nullptr) | ||
| 114 | { | ||
| 115 | if (std::strlen(ret)) | ||
| 116 | text = ret; | ||
| 117 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 118 | } | ||
| 119 | return text; | ||
| 120 | } | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //========================================================================== | ||
| 124 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 125 | /// @brief To scroll text on other position. | ||
| 126 | /// | ||
| 127 | /// @param[in] position The line position to scroll to | ||
| 128 | /// | ||
| 129 | void Scroll(unsigned int position) | ||
| 130 | { | ||
| 131 | m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, | ||
| 132 | position); | ||
| 133 | } | ||
| 134 | //-------------------------------------------------------------------------- | ||
| 135 | |||
| 136 | //========================================================================== | ||
| 137 | /// @ingroup cpp_kodi_gui_windows_controls_CTextBox | ||
| 138 | /// @brief To set automatic scrolling of textbox | ||
| 139 | /// | ||
| 140 | /// Specifies the timing and conditions of any autoscrolling this textbox | ||
| 141 | /// should have. Times are in milliseconds. The content is delayed for the | ||
| 142 | /// given delay, then scrolls at a rate of one line per time interval until | ||
| 143 | /// the end. If the repeat tag is present, it then delays for the repeat | ||
| 144 | /// time, fades out over 1 second, and repeats. It does not wrap or reset | ||
| 145 | /// to the top at the end of the scroll. | ||
| 146 | /// | ||
| 147 | /// @param[in] delay Content delay | ||
| 148 | /// @param[in] time One line per time interval | ||
| 149 | /// @param[in] repeat Delays with given time, fades out over 1 second, and | ||
| 150 | /// repeats | ||
| 151 | /// | ||
| 152 | void SetAutoScrolling(int delay, int time, int repeat) | ||
| 153 | { | ||
| 154 | m_interface->kodi_gui->control_text_box->set_auto_scrolling( | ||
| 155 | m_interface->kodiBase, m_controlHandle, delay, time, repeat); | ||
| 156 | } | ||
| 157 | //-------------------------------------------------------------------------- | ||
| 158 | }; | ||
| 159 | |||
| 160 | } /* namespace controls */ | ||
| 161 | } /* namespace gui */ | ||
| 162 | } /* namespace kodi */ | ||
| 163 | |||
| 164 | #endif /* __cplusplus */ | ||
