From be933ef2241d79558f91796cc5b3a161f72ebf9c Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 19 Oct 2020 00:52:24 +0200 Subject: sync with upstream --- .../include/kodi/gui/controls/Button.h | 166 ++++++++ .../include/kodi/gui/controls/CMakeLists.txt | 16 + .../kodi-dev-kit/include/kodi/gui/controls/Edit.h | 217 +++++++++++ .../include/kodi/gui/controls/FadeLabel.h | 148 ++++++++ .../kodi-dev-kit/include/kodi/gui/controls/Image.h | 112 ++++++ .../kodi-dev-kit/include/kodi/gui/controls/Label.h | 118 ++++++ .../include/kodi/gui/controls/Progress.h | 112 ++++++ .../include/kodi/gui/controls/RadioButton.h | 214 +++++++++++ .../include/kodi/gui/controls/Rendering.h | 217 +++++++++++ .../include/kodi/gui/controls/SettingsSlider.h | 314 ++++++++++++++++ .../include/kodi/gui/controls/Slider.h | 326 ++++++++++++++++ .../kodi-dev-kit/include/kodi/gui/controls/Spin.h | 416 +++++++++++++++++++++ .../include/kodi/gui/controls/TextBox.h | 164 ++++++++ 13 files changed, 2540 insertions(+) create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/controls') 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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/button.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CButton Control Button +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CButton } +/// **Standard push button control for window**\n +/// The button control is used for creating push buttons in Kodi. +/// +/// You can choose the position, size, and look of the button, as well as +/// choosing what action(s) should be performed when pushed. +/// +/// It has the header @ref Button.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref skin_Button_control "button control" +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_button( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Destructor. + /// + ~CButton() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, + enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief To set the text string on button. + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, + label.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Get the used text from button. + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = + m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief If two labels are used for button becomes it set with them. + /// + /// @param[in] label Text for second label + /// + void SetLabel2(const std::string& label) + { + m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, + label.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CButton + /// @brief Get the second label if present. + /// + /// @return Second label + /// + std::string GetLabel2() const + { + std::string label; + char* ret = + m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +set(HEADERS Button.h + Edit.h + FadeLabel.h + Image.h + Label.h + Progress.h + RadioButton.h + Rendering.h + SettingsSlider.h + Slider.h + Spin.h + TextBox.h) + +if(NOT ENABLE_STATIC_LIBS) + core_add_library(addons_kodi-dev-kit_include_kodi_gui_controls) +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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/edit.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CEdit Control Edit +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CEdit } +/// **Editable window text control used as an input control for the osd keyboard +/// and other input fields**\n +/// The edit control allows a user to input text in Kodi. +/// +/// You can choose the font, size, colour, location and header of the text to be +/// displayed. +/// +/// It has the header @ref Edit.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin partfor a @ref skin_Edit_control "edit control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// + +//============================================================================== +// see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs" +/// +/// @defgroup cpp_kodi_gui_windows_controls_CEdit_Defs Definitions, structures and enumerators +/// @ingroup cpp_kodi_gui_windows_controls_CEdit +/// @brief **Library definition values** +/// + +class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_edit( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::control::CEdit can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Destructor. + /// + ~CEdit() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, + enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief To set the text string on edit control. + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, + label.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Returns the text heading for this edit control. + /// + /// @return Heading text + /// + std::string GetLabel() const + { + std::string label; + char* ret = + m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Set's text heading for this edit control. + /// + /// @param[in] text string or unicode - text string. + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, + text.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Returns the text value for this edit control. + /// + /// @return Text value of control + /// + std::string GetText() const + { + std::string text; + char* ret = + m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief Set the cursor position on text. + /// + /// @param[in] position The position to set + /// + void SetCursorPosition(unsigned int position) + { + m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, + position); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief To get current cursor position on text field. + /// + /// @return The current cursor position + /// + unsigned int GetCursorPosition() + { + return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CEdit + /// @brief To set field input type which are defined on @ref AddonGUIInputType. + /// + /// @param[in] type The @ref AddonGUIInputType "Add-on input type" to use + /// @param[in] heading The heading text for related keyboard dialog + /// + void SetInputType(AddonGUIInputType type, const std::string& heading) + { + m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, + static_cast(type), heading.c_str()); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/fade_label.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CFadeLabel Control Fade Label +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CFadeLabel } +/// **Window control used to show multiple pieces of text in the same position, +/// by fading from one to the other**\n +/// The fade label control is used for displaying multiple pieces of text in +/// the same space in Kodi. +/// +/// You can choose the font, size, colour, location and contents of the text to +/// be displayed. The first piece of information to display fades in over 50 +/// frames, then scrolls off to the left. Once it is finished scrolling off +/// screen, the second piece of information fades in and the process repeats. +/// A fade label control is not supported in a list container. +/// +/// It has the header @ref FadeLabel.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Fade_Label_Control "fade label control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief Destructor. + /// + ~CFadeLabel() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief To add additional text string on fade label. + /// + /// @param[in] label Text to show + /// + void AddLabel(const std::string& label) + { + m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, + label.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief Get the used text from button. + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, + m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief To enable or disable scrolling on fade label. + /// + /// @param[in] scroll To enable scrolling set to true, otherwise is disabled + /// + void SetScrolling(bool scroll) + { + m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, + scroll); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel + /// @brief To reset al inserted labels. + /// + void Reset() + { + m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/image.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================ +/// @defgroup cpp_kodi_gui_windows_controls_CImage Control Image +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CImage } +/// **Window control used to show an image.**\n +/// The image control is used for displaying images in Kodi. You can choose +/// the position, size, transparency and contents of the image to be displayed. +/// +/// It has the header @ref Image.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Image_Control "image control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CImage + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_image( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CImage can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CImage + /// @brief Destructor. + /// + ~CImage() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CImage + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CImage + /// @brief To set the filename used on image control. + /// + /// @param[in] filename Image file to use + /// @param[in] useCache To define storage of image, default is in cache, if + /// false becomes it loaded always on changes again + /// + void SetFileName(const std::string& filename, bool useCache = true) + { + m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, + filename.c_str(), useCache); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CImage + /// @brief To set set the diffuse color on image. + /// + /// @param[in] colorDiffuse Color to use for diffuse + /// + void SetColorDiffuse(uint32_t colorDiffuse) + { + m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, + colorDiffuse); + } + //-------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/label.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CLabel Control Label +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CLabel } +/// **Window control used to show some lines of text**\n +/// The label control is used for displaying text in Kodi. You can choose +/// the font, size, colour, location and contents of the text to be displayed. +/// +/// It has the header @ref Label.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Label_Control "label control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CLabel + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_label( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CLabel + /// @brief Destructor. + /// + ~CLabel() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CLabel + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CLabel + /// @brief To set the text string on label. + /// + /// @param[in] text Text to show + /// + void SetLabel(const std::string& text) + { + m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, + text.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CLabel + /// @brief Get the used text from control. + /// + /// @return Used text on label control + /// + std::string GetLabel() const + { + std::string label; + char* ret = + m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/progress.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CProgress Control Progress +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CProgress } +/// **Window control to show the progress of a particular operation**\n +/// The progress control is used to show the progress of an item that may take +/// a long time, or to show how far through a movie you are. +/// +/// You can choose the position, size, and look of the progress control. +/// +/// It has the header @ref Progress.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Progress_Control "progress control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CProgress + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_progress( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CProgress + /// @brief Destructor. + /// + ~CProgress() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CProgress + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CProgress + /// @brief To set Percent position of control. + /// + /// @param[in] percent The percent position to use + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, + percent); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CProgress + /// @brief Get the active percent position of progress bar. + /// + /// @return Progress position as percent + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/radio_button.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CRadioButton Control Radio Button +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CRadioButton } +/// **Window control for a radio button (as used for on/off settings)**\n +/// The radio button control is used for creating push button on/off settings +/// in Kodi. +/// +/// You can choose the position, size, and look of the button. When the user +/// clicks on the radio button, the state will change, toggling the extra +/// textures (textureradioon and textureradiooff). Used for settings +/// controls. +/// +/// It has the header @ref RadioButton.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Radio_button_control "radio button control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +/// +/// -------------------------------------------------------------------------- +/// **Example:** +/// ~~~~~~~~~~~~cpp +/// #include +/// +/// #define MY_RADIO_BUTTON_CONTROL 1 +/// +/// class CMyWindow : public kodi::gui::CWindow +/// { +/// public: +/// CMyWindow() +/// +/// void ShowWindow(); +/// +/// bool OnInit() override; +/// bool OnClick(int controlId) override; +/// +/// private: +/// kodi::gui::controls::CSpin m_myRadioButtonControl; +/// }; +/// +/// CMyWindow::CMyWindow() +/// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), +/// m_myRadioButtonControl(this, MY_RADIO_BUTTON_CONTROL) +/// { +/// } +/// +/// void CMyWindow::ShowWindow() +/// { +/// kodi::gui::CWindow::DoModal(); +/// } +/// +/// bool CMyWindow::OnInit() +/// { +/// m_myRadioButtonControl.SetSelected(false); // can also on skin set to default +/// return true; +/// } +/// +/// bool CMyWindow::OnClick(int controlId) +/// { +/// if (controlId == MY_RADIO_BUTTON_CONTROL) +/// { +/// bool selected = m_myRadioButtonControl.IsSelected(); +/// ... +/// } +/// return true; +/// } +/// return false; +/// } +/// ~~~~~~~~~~~~ +/// +class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief Destructor. + /// + ~CRadioButton() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton. + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, + enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief To set the text string on radio button. + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, + label.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief Get the used text from control. + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, + m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief To set radio button condition to on or off. + /// + /// @param[in] selected true set radio button to selection on, otherwise off + /// + void SetSelected(bool selected) + { + m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, + m_controlHandle, selected); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton + /// @brief Get the current selected condition of radio button. + /// + /// @return Selected condition + /// + bool IsSelected() const + { + return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/rendering.h" +#include "../Window.h" +#include "../renderHelper.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================ +/// @defgroup cpp_kodi_gui_windows_controls_CRendering Control Rendering +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CRendering } +/// **Window control for rendering own parts**\n +/// This rendering control is used when own parts are needed. +/// +/// You have the control over them to render direct OpenGL or DirectX content +/// to the screen set by the size of them. +/// +/// Alternative can be the virtual functions from t his been ignored if the +/// callbacks are defined by the @ref CRendering_SetIndependentCallbacks +/// function and class is used as single and not as a parent class. +/// +/// It has the header @ref Rendering.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Addon_Rendering_control "rendering control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (m_controlHandle) + m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, + m_controlHandle, this, OnCreateCB, + OnRenderCB, OnStopCB, OnDirtyCB); + else + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", + __FUNCTION__); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief Destructor. + /// + ~CRendering() override + { + m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief To create rendering control on Add-on. + /// + /// Function creates the needed rendering control for Kodi which becomes + /// handled and processed from Add-on + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + /// @param[in] x Horizontal position + /// @param[in] y Vertical position + /// @param[in] w Width of control + /// @param[in] h Height of control + /// @param[in] device The device to use. For OpenGL is empty on Direct X is + /// the needed device send. + /// @return Add-on needs to return true if successed, otherwise false. + /// + /// @note The @ref kodi::HardwareContext is basically a simple pointer which + /// has to be changed to the desired format at the corresponding places using + /// `static_cast<...>(...)`. + /// + virtual bool Create(int x, int y, int w, int h, kodi::HardwareContext device) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief Render process call from Kodi. + /// + /// @note This is callback function from Kodi to Add-on and not to use for + /// calls from add-on to this function. + /// + virtual void Render() {} + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief Call from Kodi to stop rendering process. + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual void Stop() {} + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @brief Call from Kodi where add-on becomes asked about dirty rendering + /// region. + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + /// @return True if a render region is dirty and need rendering. + /// + virtual bool Dirty() { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CRendering + /// @anchor CRendering_SetIndependentCallbacks + /// @brief If the class is used independent (with "new CRendering") + /// and not as parent (with "cCLASS_own : CRendering") from own must + /// be the callback from Kodi to add-on overdriven with own functions! + /// + /// @param[in] cbhdl Addon related class point where becomes given as value on + /// related functions. + /// @param[in] CBCreate External creation function pointer, see also @ref Create + /// about related values + /// @param[in] CBRender External render function pointer, see also @ref Render + /// about related values + /// @param[in] CBStop External stop function pointer, see also @ref Stop + /// about related values + /// @param[in] CBDirty External dirty function pointer, see also @ref Dirty + /// about related values + /// + void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl, + bool (*CBCreate)(kodi::gui::ClientHandle cbhdl, + int x, + int y, + int w, + int h, + kodi::HardwareContext device), + void (*CBRender)(kodi::gui::ClientHandle cbhdl), + void (*CBStop)(kodi::gui::ClientHandle cbhdl), + bool (*CBDirty)(kodi::gui::ClientHandle cbhdl)) + { + if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) + { + kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); + return; + } + + m_interface->kodi_gui->control_rendering->set_callbacks( + m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); + } + //-------------------------------------------------------------------------- + +private: + /* + * Defined callback functions from Kodi to add-on, for use in parent / child system + * (is private)! + */ + static bool OnCreateCB( + KODI_GUI_CLIENT_HANDLE cbhdl, int x, int y, int w, int h, ADDON_HARDWARE_CONTEXT device) + { + static_cast(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); + return static_cast(cbhdl)->Create(x, y, w, h, device); + } + + static void OnRenderCB(KODI_GUI_CLIENT_HANDLE cbhdl) + { + if (!static_cast(cbhdl)->m_renderHelper) + return; + static_cast(cbhdl)->m_renderHelper->Begin(); + static_cast(cbhdl)->Render(); + static_cast(cbhdl)->m_renderHelper->End(); + } + + static void OnStopCB(KODI_GUI_CLIENT_HANDLE cbhdl) + { + static_cast(cbhdl)->Stop(); + static_cast(cbhdl)->m_renderHelper = nullptr; + } + + static bool OnDirtyCB(KODI_GUI_CLIENT_HANDLE cbhdl) + { + return static_cast(cbhdl)->Dirty(); + } + + std::shared_ptr m_renderHelper; +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/settings_slider.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CSettingsSlider Control Settings Slider +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CSettingsSlider } +/// **Window control for moveable slider with text name**\n +/// The settings slider control is used in the settings screens for when an +/// option is best specified on a sliding scale. +/// +/// You can choose the position, size, and look of the slider control. It is +/// basically a cross between the button control and a slider control. It has a +/// label and focus and non focus textures, as well as a slider control on the +/// right. +/// +/// It has the header @ref SettingsSlider.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Settings_Slider_Control "settings slider control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Destructor. + /// + ~CSettingsSlider() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, + m_controlHandle, visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, + m_controlHandle, enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To set the text string on settings slider. + /// + /// @param[in] text Text to show + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, + text.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To reset slider on defaults. + /// + void Reset() + { + m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// The integer interval is as default 1 and can be changed with + /// @ref SetIntInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, + m_controlHandle, start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from @ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, + m_controlHandle, value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To set the interval steps of slider, as default is it 1. If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntInterval(int interval) + { + m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, + m_controlHandle, interval); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Sets the percent of the slider. + /// + /// @param[in] percent float - Percent value of slide + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, + m_controlHandle, percent); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Returns a float of the percent of the slider. + /// + /// @return float - Percent of slider + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To set the the range as float of slider, e.g. -25.0 is the slider + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, + m_controlHandle, start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief Set the slider position with the given float value. The Range can + /// be defined with a call from @ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, + m_controlHandle, value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider + /// @brief To set the interval steps of slider, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, + m_controlHandle, interval); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/slider.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CSlider Control Slider +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CSlider } +/// **Window control for moveable slider**\n +/// The slider control is used for things where a sliding bar best represents +/// the operation at hand (such as a volume control or seek control). +/// +/// You can choose the position, size, and look of the slider control. +/// +/// It has the header @ref Slider.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Slider_Control "slider control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_slider( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Destructor. + /// + ~CSlider() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, + enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To reset slider on defaults. + /// + void Reset() + { + m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief With GetDescription becomes a string value of position returned. + /// + /// @return Text string about current slider position + /// + /// The following are the text definition returned from this: + /// | Value | Without range selection | With range selection | + /// |:---------:|:------------------------|:-------------------------------| + /// | float | %2.2f | [%2.2f, %2.2f] | + /// | integer | %i | [%i, %i] | + /// | percent | %i%% | [%i%%, %i%%] | + /// + std::string GetDescription() const + { + std::string text; + char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, + m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// The integer interval is as default 1 and can be changed with + /// @ref SetIntInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, + start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from @ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, + value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To set the interval steps of slider, as default is it 1. If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntInterval(int interval) + { + m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, + interval); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Sets the percent of the slider. + /// + /// @param[in] percent float - Percent value of slide + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, + percent); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Returns a float of the percent of the slider. + /// + /// @return float - Percent of slider + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To set the the range as float of slider, e.g. -25.0 is the slider + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, + start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief Set the slider position with the given float value. The Range + /// can be defined with a call from @ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, + value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSlider + /// @brief To set the interval steps of slider, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, + m_controlHandle, interval); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/spin.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================== +/// @defgroup cpp_kodi_gui_windows_controls_CSpin Control Spin +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CSpin } +/// **Window control used for cycling up/down controls**\n +/// The settings spin control is used in the settings screens for when a list +/// of options can be chosen from using up/down arrows. +/// +/// You can choose the position, size, and look of the spin control. It is +/// basically a cross between the button control and a spin control. It has a +/// label and focus and non focus textures, as well as a spin control on the +/// right. +/// +/// It has the header @ref Spin.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Spin_Control "spin control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +/// -------------------------------------------------------------------------- +/// **Example:** +/// ~~~~~~~~~~~~cpp +/// #include +/// +/// #define MY_SPIN_CONTROL 1 +/// +/// class CMyWindow : public kodi::gui::CWindow +/// { +/// public: +/// CMyWindow() +/// +/// void ShowWindow(); +/// +/// bool OnInit() override; +/// bool OnClick(int controlId) override; +/// +/// private: +/// kodi::gui::controls::CSpin m_mySpinControl; +/// }; +/// +/// CMyWindow::CMyWindow() +/// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), +/// m_mySpinControl(this, MY_SPIN_CONTROL) +/// { +/// } +/// +/// void CMyWindow::ShowWindow() +/// { +/// kodi::gui::CWindow::DoModal(); +/// } +/// +/// bool CMyWindow::OnInit() +/// { +/// m_mySpinControl.SetType(kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT); +/// m_mySpinControl.SetIntRange(1, 80); +/// return true; +/// } +/// +/// bool CMyWindow::OnClick(int controlId) +/// { +/// if (controlId == MY_SPIN_CONTROL) +/// { +/// int value = m_mySpinControl.GetIntValue(); +/// ... +/// } +/// return true; +/// } +/// return false; +/// } +/// ~~~~~~~~~~~~ +/// + + +//============================================================================== +/// @ingroup cpp_kodi_gui_windows_controls_CSpin +/// @anchor AddonGUISpinControlType +/// @brief The values here defines the used value format for steps on +/// spin control. +/// +typedef enum AddonGUISpinControlType +{ + /// One spin step interpreted as integer + ADDON_SPIN_CONTROL_TYPE_INT = 1, + /// One spin step interpreted as floating point value + ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, + /// One spin step interpreted as text string + ADDON_SPIN_CONTROL_TYPE_TEXT = 3, + /// One spin step interpreted as a page change value + ADDON_SPIN_CONTROL_TYPE_PAGE = 4 +} AddonGUISpinControlType; +//------------------------------------------------------------------------------ + +class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase +{ +public: + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Construct a new control. + /// + /// @param[in] window Related window control class + /// @param[in] controlId Used skin xml control id + /// + CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_spin( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Destructor. + /// + ~CSpin() override = default; + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Set's the control's enabled/disabled state. + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, + enabled); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To set the text string on spin control. + /// + /// @param[in] text Text to show as name for spin + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, + text.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To reset spin control to defaults. + /// + void Reset() + { + m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To set the with SpinControlType defined types of spin. + /// + /// @param[in] type The type to use + /// + /// @note See description of @ref AddonGUISpinControlType for available types. + /// + void SetType(AddonGUISpinControlType type) + { + m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, + (int)type); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To add a label entry in spin defined with a value as string. + /// + /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @param[in] label Label string to view on skin + /// @param[in] value String value to use for selection of them + /// + void AddLabel(const std::string& label, const std::string& value) + { + m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, + label.c_str(), value.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To add a label entry in spin defined with a value as integer. + /// + /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_INT to use this function. + /// + /// @param[in] label Label string to view on skin + /// @param[in] value Integer value to use for selection of them. + /// + void AddLabel(const std::string& label, int value) + { + m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, + label.c_str(), value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To change the spin to position with them string as value. + /// + /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @param[in] value String value to change to + /// + void SetStringValue(const std::string& value) + { + m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, + value.c_str()); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To get the current spin control position with text string value. + /// + /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @return Currently selected string value + /// + std::string GetStringValue() const + { + std::string value; + char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, + m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + value = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return value; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, + start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from @ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, + value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To set the the range as float of spin, e.g. -25.0 is the spin + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, + start, end); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief Set the spin position with the given float value. The Range + /// can be defined with a call from @ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, + value); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, + m_controlHandle); + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_gui_windows_controls_CSpin + /// @brief To set the interval steps of spin, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with @ref SetType before. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, + interval); + } + //---------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#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 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../c-api/gui/controls/text_box.h" +#include "../Window.h" + +#ifdef __cplusplus + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + +//============================================================================ +/// @defgroup cpp_kodi_gui_windows_controls_CTextBox Control Text Box +/// @ingroup cpp_kodi_gui_windows_controls +/// @brief @cpp_class{ kodi::gui::controls::CTextBox } +/// **Used to show a multi-page piece of text**\n +/// The text box control can be used to display descriptions, help texts or +/// other larger texts. +/// +/// It corresponds to the representation which is also to be seen on the +/// @ref CDialogTextViewer. +/// +/// It has the header @ref TextBox.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a @ref Text_Box "textbox control". +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// +class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief Construct a new control. + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_text_box( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief Destructor. + /// + ~CTextBox() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief To reset box an remove all the text. + /// + void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief To set the text on box. + /// + /// @param[in] text Text to show + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, + text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief Get the used text from control. + /// + /// @return Text shown + /// + std::string GetText() const + { + std::string text; + char* ret = + m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief To scroll text on other position. + /// + /// @param[in] position The line position to scroll to + /// + void Scroll(unsigned int position) + { + m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, + position); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// @ingroup cpp_kodi_gui_windows_controls_CTextBox + /// @brief To set automatic scrolling of textbox + /// + /// Specifies the timing and conditions of any autoscrolling this textbox + /// should have. Times are in milliseconds. The content is delayed for the + /// given delay, then scrolls at a rate of one line per time interval until + /// the end. If the repeat tag is present, it then delays for the repeat + /// time, fades out over 1 second, and repeats. It does not wrap or reset + /// to the top at the end of the scroll. + /// + /// @param[in] delay Content delay + /// @param[in] time One line per time interval + /// @param[in] repeat Delays with given time, fades out over 1 second, and + /// repeats + /// + void SetAutoScrolling(int delay, int time, int repeat) + { + m_interface->kodi_gui->control_text_box->set_auto_scrolling( + m_interface->kodiBase, m_controlHandle, delay, time, repeat); + } + //-------------------------------------------------------------------------- +}; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +#endif /* __cplusplus */ -- cgit v1.2.3