From 4c3251ec645c8b71820dab7e51e612e5919d4e75 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 23 Jul 2017 16:59:43 +0200 Subject: sync with upstream --- .../include/kodi/gui/controls/Button.h | 176 ++++++++++ .../include/kodi/gui/controls/Edit.h | 276 +++++++++++++++ .../include/kodi/gui/controls/FadeLabel.h | 159 +++++++++ .../include/kodi/gui/controls/Image.h | 123 +++++++ .../include/kodi/gui/controls/Label.h | 128 +++++++ .../include/kodi/gui/controls/Progress.h | 121 +++++++ .../include/kodi/gui/controls/RadioButton.h | 171 ++++++++++ .../include/kodi/gui/controls/Rendering.h | 215 ++++++++++++ .../include/kodi/gui/controls/SettingsSlider.h | 323 ++++++++++++++++++ .../include/kodi/gui/controls/Slider.h | 336 ++++++++++++++++++ .../include/kodi/gui/controls/Spin.h | 376 +++++++++++++++++++++ .../include/kodi/gui/controls/TextBox.h | 176 ++++++++++ 12 files changed, 2580 insertions(+) create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h new file mode 100644 index 0000000..5892d24 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h @@ -0,0 +1,176 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CButton Control Button + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CButton } + /// **Standard push button control for window** + /// + /// 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 CButton : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_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_control_CButton + /// @brief Destructor + /// + ~CButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_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_control_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_control_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_control_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_control_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_control_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h new file mode 100644 index 0000000..83eeede --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h @@ -0,0 +1,276 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CEdit Control Edit + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CEdit } + /// **Editable window text control used as an input control for the osd keyboard + /// and other input fields** + /// + /// 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 part for 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_controls_CEdit_Defs" + /// + /// \defgroup cpp_kodi_gui_controls_CEdit_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief **Library definition values** + /// + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +//============================================================================ +/// +/// \ingroup cpp_kodi_gui_controls_CEdit_Defs +/// @{ +/// @anchor AddonGUIInputType +/// @brief Text input types used on kodi::gui::controls::CEdit +enum AddonGUIInputType +{ + /// Text inside edit control only readable + ADDON_INPUT_TYPE_READONLY = -1, + /// Normal text entries + ADDON_INPUT_TYPE_TEXT = 0, + /// To use on edit control only numeric numbers + ADDON_INPUT_TYPE_NUMBER, + /// To insert seconds + ADDON_INPUT_TYPE_SECONDS, + /// To insert time + ADDON_INPUT_TYPE_TIME, + /// To insert a date + ADDON_INPUT_TYPE_DATE, + /// Used for write in IP addresses + ADDON_INPUT_TYPE_IPADDRESS, + /// Text field used as password entry field with not visible text + ADDON_INPUT_TYPE_PASSWORD, + /// Text field used as password entry field with not visible text but + /// returned as MD5 value + ADDON_INPUT_TYPE_PASSWORD_MD5, + /// Use text field for search purpose + ADDON_INPUT_TYPE_SEARCH, + /// Text field as filter + ADDON_INPUT_TYPE_FILTER, + /// + ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW +}; +/// @} +//---------------------------------------------------------------------------- + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + class CEdit : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CEdit + /// @brief Destructor + /// + ~CEdit() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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_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_controls_CEdit + /// @brief Set the cursor position on text. + /// + /// @param[in] iPosition The position to set + /// + void SetCursorPosition(unsigned int iPosition) + { + m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, iPosition); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h new file mode 100644 index 0000000..82d17ff --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h @@ -0,0 +1,159 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label + /// \ingroup cpp_kodi_gui + /// @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** + /// + /// 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 CFadeLabel : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CFadeLabel + /// @brief Destructor. + /// + ~CFadeLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h new file mode 100644 index 0000000..1179fab --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h @@ -0,0 +1,123 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CImage Control Image + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CImage } + /// **Window control used to show an image.** + /// + /// 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 CImage : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CImage + /// @brief Destructor + /// + ~CImage() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h new file mode 100644 index 0000000..f74ac03 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h @@ -0,0 +1,128 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CLabel Control Label + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CLabel } + /// **Window control used to show some lines of text.** + /// + /// 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 CLabel : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CLabel + /// @brief Destructor + /// + ~CLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h new file mode 100644 index 0000000..44310ed --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h @@ -0,0 +1,121 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CProgress } + /// **Window control to show the progress of a particular operation** + /// + /// 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 CProgress : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CProgress + /// @brief Destructor + /// + ~CProgress() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h new file mode 100644 index 0000000..b87920d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h @@ -0,0 +1,171 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } + /// **Window control for a radio button (as used for on/off settings)** + /// + /// 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. + /// + class CRadioButton : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CRadioButton + /// @brief Destructor + /// + ~CRadioButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h new file mode 100644 index 0000000..f80fcfa --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h @@ -0,0 +1,215 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CRendering } + /// **Window control for rendering own parts** + /// + /// 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. + /// + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief **Library definition values** + /// + + class CRendering : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CRendering + /// @brief Destructor + /// + ~CRendering() override + { + m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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. + /// + virtual bool Create(int x, int y, int w, int h, void* device) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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. + /// + virtual bool Dirty() { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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! + /// + void SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBCreate)(GUIHANDLE cbhdl, + int x, + int y, + int w, + int h, + void* device), + void (*CBRender)(GUIHANDLE cbhdl), + void (*CBStop) (GUIHANDLE cbhdl), + bool (*CBDirty) (GUIHANDLE 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(void* cbhdl, int x, int y, int w, int h, void* device) + { + return static_cast(cbhdl)->Create(x, y, w, h, device); + } + + static void OnRenderCB(void* cbhdl) + { + static_cast(cbhdl)->Render(); + } + + static void OnStopCB(void* cbhdl) + { + static_cast(cbhdl)->Stop(); + } + + static bool OnDirtyCB(void* cbhdl) + { + return static_cast(cbhdl)->Dirty(); + } + + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h new file mode 100644 index 0000000..e51433a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h @@ -0,0 +1,323 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } + /// **Window control for moveable slider with text name** + /// + /// 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 CSettingsSlider : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CSettingsSlider + /// @brief Destructor + /// + ~CSettingsSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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_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_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_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_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_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_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_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h new file mode 100644 index 0000000..cbb9b8f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h @@ -0,0 +1,336 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSlider } + /// **Window control for moveable slider** + /// + /// 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 CSlider : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CSlider + /// @brief Destructor + /// + ~CSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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 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_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_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_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_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_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_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..b39cd06 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h @@ -0,0 +1,376 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSpin Control Spin + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSpin } + /// **Window control used for cycling up/down controls** + /// + /// 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. + /// + + + //============================================================================ + /// + /// \ingroup cpp_kodi_gui_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 CSpin : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CSpin + /// @brief Destructor + /// + ~CSpin() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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_controls_CSpin + /// @brief To add a label entry in spin defined with a value as string. + /// + /// Format must be set to 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_controls_CSpin + /// @brief To add a label entry in spin defined with a value as integer. + /// + /// Format must be set to 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_controls_CSpin + /// @brief To change the spin to position with them string as value. + /// + /// Format must be set to 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_controls_CSpin + /// @brief To get the current spin control position with text string value. + /// + /// Format must be set to 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_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_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_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_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_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_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_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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h new file mode 100644 index 0000000..9d8976e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h @@ -0,0 +1,176 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CTextBox } + /// **Used to show a multi-page piece of text** + /// + /// 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 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 CTextBox : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_controls_CTextBox + /// @brief Destructor + /// + ~CTextBox() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_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_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_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_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_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_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 */ -- cgit v1.2.3