From 5f8335c1e49ce108ef3481863833c98efa00411b Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 2 Jul 2020 23:09:26 +0200 Subject: sync with upstream --- .../include/kodi/gui/CMakeLists.txt | 3 +- .../kodi-addon-dev-kit/include/kodi/gui/General.h | 14 +- .../kodi-addon-dev-kit/include/kodi/gui/ListItem.h | 41 +- .../kodi-addon-dev-kit/include/kodi/gui/Window.h | 40 +- .../include/kodi/gui/controls/Button.h | 256 ++++----- .../include/kodi/gui/controls/Edit.h | 308 +++++------ .../include/kodi/gui/controls/FadeLabel.h | 227 ++++---- .../include/kodi/gui/controls/Image.h | 162 +++--- .../include/kodi/gui/controls/Label.h | 168 +++--- .../include/kodi/gui/controls/Progress.h | 158 +++--- .../include/kodi/gui/controls/RadioButton.h | 251 ++++----- .../include/kodi/gui/controls/Rendering.h | 323 +++++------ .../include/kodi/gui/controls/SettingsSlider.h | 550 +++++++++---------- .../include/kodi/gui/controls/Slider.h | 572 ++++++++++---------- .../include/kodi/gui/controls/Spin.h | 2 +- .../include/kodi/gui/controls/TextBox.h | 257 ++++----- .../include/kodi/gui/definitions.h | 18 +- .../include/kodi/gui/dialogs/ContextMenu.h | 20 +- .../include/kodi/gui/dialogs/ExtendedProgress.h | 410 +++++++------- .../include/kodi/gui/dialogs/FileBrowser.h | 55 +- .../include/kodi/gui/dialogs/Keyboard.h | 50 +- .../include/kodi/gui/dialogs/Numeric.h | 27 +- .../include/kodi/gui/dialogs/OK.h | 11 +- .../include/kodi/gui/dialogs/Progress.h | 446 ++++++++-------- .../include/kodi/gui/dialogs/Select.h | 26 +- .../include/kodi/gui/dialogs/TextViewer.h | 5 +- .../include/kodi/gui/dialogs/YesNo.h | 33 +- .../include/kodi/gui/gl/CMakeLists.txt | 7 + .../kodi-addon-dev-kit/include/kodi/gui/gl/GL.h | 111 ++++ .../include/kodi/gui/gl/GLonDX.h | 369 +++++++++++++ .../include/kodi/gui/gl/Shader.h | 594 +++++++++++++++++++++ .../include/kodi/gui/renderHelper.h | 78 +++ 32 files changed, 3465 insertions(+), 2127 deletions(-) create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt index 91cef7f..834ec00 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/CMakeLists.txt @@ -1,7 +1,8 @@ set(HEADERS General.h ListItem.h Window.h - definitions.h) + definitions.h + renderHelper.h) if(NOT ENABLE_STATIC_LIBS) core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui) diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h index a3b8bcb..b5a6393 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h @@ -37,7 +37,7 @@ namespace gui /// \ingroup cpp_kodi_gui /// @brief Performs a graphical lock of rendering engine /// - inline void Lock() + inline void ATTRIBUTE_HIDDEN Lock() { using namespace ::kodi::addon; CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); @@ -50,7 +50,7 @@ namespace gui /// \ingroup cpp_kodi_gui /// @brief Performs a graphical unlock of previous locked rendering engine /// - inline void Unlock() + inline void ATTRIBUTE_HIDDEN Unlock() { using namespace ::kodi::addon; CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); @@ -62,7 +62,7 @@ namespace gui /// \ingroup cpp_kodi_gui /// @brief Return the the current screen height with pixel /// - inline int GetScreenHeight() + inline int ATTRIBUTE_HIDDEN GetScreenHeight() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); @@ -74,7 +74,7 @@ namespace gui /// \ingroup cpp_kodi_gui /// @brief Return the the current screen width with pixel /// - inline int GetScreenWidth() + inline int ATTRIBUTE_HIDDEN GetScreenWidth() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); @@ -86,7 +86,7 @@ namespace gui /// \ingroup cpp_kodi_gui /// @brief Return the the current screen rendering resolution /// - inline int GetVideoResolution() + inline int ATTRIBUTE_HIDDEN GetVideoResolution() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); @@ -110,7 +110,7 @@ namespace gui /// .. /// ~~~~~~~~~~~~~ /// - inline int GetCurrentWindowDialogId() + inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); @@ -134,7 +134,7 @@ namespace gui /// .. /// ~~~~~~~~~~~~~ /// - inline int GetCurrentWindowId() + inline int ATTRIBUTE_HIDDEN GetCurrentWindowId() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h index f13b96e..1af4863 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h @@ -20,7 +20,7 @@ namespace gui class CWindow; - class CAddonGUIControlBase + class ATTRIBUTE_HIDDEN CAddonGUIControlBase { public: GUIHANDLE GetControlHandle() const { return m_controlHandle; } @@ -69,7 +69,7 @@ namespace gui /// @brief **Library definition values** /// - class CListItem : public CAddonGUIControlBase + class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase { public: //========================================================================== @@ -185,43 +185,6 @@ namespace gui } //-------------------------------------------------------------------------- - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_CListItem - /// @brief To get current icon image of entry - /// - /// @return The current icon image path (if present) - /// - std::string GetIconImage() - { - std::string image; - char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); - if (ret != nullptr) - { - if (std::strlen(ret)) - image = ret; - m_interface->free_string(m_interface->kodiBase, ret); - } - return image; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_CListItem - /// @brief To set icon image of entry - /// - /// @param image The image to use for. - /// - /// @note Alternative can be \ref SetArt used - /// - /// - void SetIconImage(const std::string& image) - { - m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); - } - //-------------------------------------------------------------------------- - //========================================================================== /// /// \ingroup cpp_kodi_gui_CListItem diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h index e7a8a05..5011374 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h @@ -60,7 +60,7 @@ namespace gui /// @brief Library definition values /// - class CWindow : public CAddonGUIControlBase + class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase { public: //========================================================================== @@ -202,6 +202,36 @@ namespace gui } //-------------------------------------------------------------------------- + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To set the visibility on given control id + /// + /// @param[in] controlId Control id where visibility is changed + /// @param[in] visible Boolean value with `true` for visible, `false` for hidden + /// + /// + void SetControlVisible(int controlId, bool visible) + { + m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle, controlId, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To set the selection on given control id + /// + /// @param[in] controlId Control id where selection is changed + /// @param[in] selected Boolean value with `true` for selected, `false` for not + /// + /// + void SetControlSelected(int controlId, bool selected) + { + m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle, controlId, selected); + } + //-------------------------------------------------------------------------- + //========================================================================== /// /// \ingroup cpp_kodi_gui_CWindow @@ -705,7 +735,7 @@ namespace gui /// .. /// ~~~~~~~~~~~~~ /// - virtual bool OnAction(int actionId) + virtual bool OnAction(int actionId, uint32_t buttoncode, wchar_t unicode) { switch (actionId) { @@ -811,7 +841,7 @@ namespace gui bool (*CBOnInit) (GUIHANDLE cbhdl), bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), - bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId), + bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode), void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) { @@ -845,9 +875,9 @@ namespace gui return static_cast(cbhdl)->OnClick(controlId); } - static bool CBOnAction(GUIHANDLE cbhdl, int actionId) + static bool CBOnAction(GUIHANDLE cbhdl, int actionId, uint32_t buttoncode, wchar_t unicode) { - return static_cast(cbhdl)->OnAction(actionId); + return static_cast(cbhdl)->OnAction(actionId, buttoncode, unicode); } static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) 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 index a38de1a..081ab06 100644 --- 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 @@ -18,147 +18,153 @@ 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 ATTRIBUTE_HIDDEN 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 /// - /// \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** + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Destructor /// - /// It has the header \ref Button.h "#include " - /// be included to enjoy it. + ~CButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref skin_Button_control "button control" + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CButton : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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 !!!"); - } - //-------------------------------------------------------------------------- + m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //-------------------------------------------------------------------------- - //========================================================================== - /// - /// @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 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 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 + //========================================================================== + /// + /// @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) { - 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; + 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 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 + //========================================================================== + /// + /// @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) { - 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; + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); } - //-------------------------------------------------------------------------- - }; + return label; + } + //-------------------------------------------------------------------------- +}; } /* namespace controls */ } /* namespace gui */ 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 index 5d30160..99c01de 100644 --- 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 @@ -95,170 +95,180 @@ namespace gui namespace controls { - class CEdit : public CAddonGUIControlBase +class ATTRIBUTE_HIDDEN 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) { - 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 !!!"); - } - //-------------------------------------------------------------------------- + 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 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 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 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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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 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()); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index aab8929..02c843f 100644 --- 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 @@ -18,130 +18,135 @@ 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 ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase +{ +public: + //========================================================================== /// - /// \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** + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Construct a new control. /// - /// 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. + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id /// - /// It has the header \ref FadeLabel.h "#include " - /// be included to enjoy it. + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Destructor. + /// + ~CFadeLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// @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_CFadeLabel + /// @brief Set the control on window to visible. /// - class CFadeLabel : public CAddonGUIControlBase + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) { - 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; - //-------------------------------------------------------------------------- + m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, + visible); + } + //-------------------------------------------------------------------------- - //========================================================================== - /// - /// \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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index a872ab0..b4d092f 100644 --- 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 @@ -18,94 +18,98 @@ 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 ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Construct a new control /// - /// \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.** + /// @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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Destructor /// - /// It has the header \ref Image.h "#include " - /// be included to enjoy it. + ~CImage() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Image_Control "image control" + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CImage : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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); - } - //-------------------------------------------------------------------------- + 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index eecfd8b..82604bd 100644 --- 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 @@ -18,99 +18,103 @@ 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 ATTRIBUTE_HIDDEN 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 /// - /// \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.** + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Destructor /// - /// It has the header \ref Label.h "#include " - /// be included to enjoy it. + ~CLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Label_Control "label control" + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CLabel : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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); - } - //-------------------------------------------------------------------------- + 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 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 + //========================================================================== + /// + /// \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) { - 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; + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); } - //-------------------------------------------------------------------------- - }; + return label; + } + //-------------------------------------------------------------------------- +}; } /* namespace controls */ } /* namespace gui */ 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 index 78880c4..8cb582b 100644 --- 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 @@ -18,92 +18,96 @@ 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 ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Construct a new control /// - /// \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** + /// @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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Destructor /// - /// It has the header \ref Progress.h "#include " - /// be included to enjoy it. + ~CProgress() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Progress_Control "progress control" + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CProgress : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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); - } - //-------------------------------------------------------------------------- + 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index 1721759..305195d 100644 --- 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 @@ -18,142 +18,149 @@ 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 ATTRIBUTE_HIDDEN 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 /// - /// \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)** + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Destructor /// - /// It has the header \ref RadioButton.h "#include " - /// be included to enjoy it. + ~CRadioButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CRadioButton : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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); - } - //-------------------------------------------------------------------------- + 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 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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index b3dadcd..7cc9b24 100644 --- 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 @@ -10,6 +10,7 @@ #include "../../AddonBase.h" #include "../Window.h" +#include "../renderHelper.h" namespace kodi { @@ -18,186 +19,186 @@ 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 ATTRIBUTE_HIDDEN 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); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// \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** + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief To create rendering control on Add-on /// - /// 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. + /// Function creates the needed rendering control for Kodi which becomes + /// handled and processed from Add-on /// - /// 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. + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. /// - /// It has the header \ref Rendering.h "#include " - /// be included to enjoy it. + /// @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. /// - /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" + 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 The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @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() {} + //-------------------------------------------------------------------------- - //============================================================================ + //========================================================================== /// - /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief **Library definition values** + /// @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() {} + //-------------------------------------------------------------------------- - class CRendering : public CAddonGUIControlBase + //========================================================================== + /// + /// \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)) { - 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) + if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) { - return static_cast(cbhdl)->Create(x, y, w, h, device); + kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); + return; } - static void OnRenderCB(void* cbhdl) - { - static_cast(cbhdl)->Render(); - } + 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) + { + static_cast(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); + return static_cast(cbhdl)->Create(x, y, w, h, device); + } - static void OnStopCB(void* cbhdl) - { - static_cast(cbhdl)->Stop(); - } + static void OnRenderCB(void* cbhdl) + { + if (!static_cast(cbhdl)->m_renderHelper) + return; + static_cast(cbhdl)->m_renderHelper->Begin(); + static_cast(cbhdl)->Render(); + static_cast(cbhdl)->m_renderHelper->End(); + } + + static void OnStopCB(void* cbhdl) + { + static_cast(cbhdl)->Stop(); + static_cast(cbhdl)->m_renderHelper = nullptr; + } - static bool OnDirtyCB(void* cbhdl) - { - return static_cast(cbhdl)->Dirty(); - } + static bool OnDirtyCB(void* cbhdl) { return static_cast(cbhdl)->Dirty(); } - }; + std::shared_ptr m_renderHelper; +}; } /* namespace controls */ } /* namespace gui */ 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 index 4f97ba5..76a02aa 100644 --- 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 @@ -18,294 +18,308 @@ 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 ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase +{ +public: + //========================================================================== /// - /// \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** + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Construct a new control /// - /// 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. + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id /// - /// It has the header \ref SettingsSlider.h "#include " - /// be included to enjoy it. + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Destructor + /// + ~CSettingsSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// @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_CSettingsSlider + /// @brief Set the control on window to visible /// - class CSettingsSlider : public CAddonGUIControlBase + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) { - 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; - //-------------------------------------------------------------------------- + m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, + m_controlHandle, visible); + } + //-------------------------------------------------------------------------- - //========================================================================== - /// - /// \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 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 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 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 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 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 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 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 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 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 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 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index 6eae70a..715cc7d 100644 --- 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 @@ -18,307 +18,321 @@ 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 ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase +{ +public: + //========================================================================== /// - /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::controls::CSlider } - /// **Window control for moveable slider** + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Construct a new control /// - /// 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. + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id /// - /// It has the header \ref Slider.h "#include " - /// be included to enjoy it. + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Slider_Control "slider control" + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Destructor /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + ~CSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - class CSlider : public CAddonGUIControlBase + /// \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) { - 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); - } - //-------------------------------------------------------------------------- + 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 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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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 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 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 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 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 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 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 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ 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 index f3017b5..db8d491 100644 --- 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 @@ -61,7 +61,7 @@ namespace controls } AddonGUISpinControlType; //---------------------------------------------------------------------------- - class CSpin : public CAddonGUIControlBase + class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase { public: //========================================================================== 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 index 13ce1da..b4e8ae0 100644 --- 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 @@ -18,147 +18,150 @@ 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 ATTRIBUTE_HIDDEN 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 /// - /// \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** + 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 !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// 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. + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Destructor /// - /// It has the header \ref TextBox.h "#include " - /// be included to enjoy it. + ~CTextBox() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// Here you find the needed skin part for a \ref Text_Box "textbox control". + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Set the control on window to visible /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @param[in] visible If true visible, otherwise hidden /// - class CTextBox : public CAddonGUIControlBase + void SetVisible(bool visible) { - 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); - } - //-------------------------------------------------------------------------- + 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 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 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 + //========================================================================== + /// + /// \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) { - 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; + 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 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); - } - //-------------------------------------------------------------------------- - }; + //========================================================================== + /// + /// \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 */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h index b8b4cbf..4eb64c7 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h @@ -200,6 +200,8 @@ typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; +// typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString); + typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard { bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); @@ -276,8 +278,6 @@ typedef struct AddonToKodiFuncTable_kodi_gui_listItem void (*set_label)(void* kodiBase, void* handle, const char* label); char* (*get_label2)(void* kodiBase, void* handle); void (*set_label2)(void* kodiBase, void* handle, const char* label); - char* (*get_icon_image)(void* kodiBase, void* handle); - void (*set_icon_image)(void* kodiBase, void* handle, const char* image); char* (*get_art)(void* kodiBase, void* handle, const char* type); void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); char* (*get_path)(void* kodiBase, void* handle); @@ -302,12 +302,12 @@ typedef struct AddonToKodiFuncTable_kodi_gui_window void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); void (*destroy)(void* kodiBase, void* handle); void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, - bool (*)(void* handle), - bool (*)(void* handle, int), - bool (*)(void* handle, int), - bool (*)(void* handle, int), - void (*)(void* handle, int, gui_context_menu_pair*, unsigned int*), - bool (*)(void* handle, int, unsigned int)); + bool (*CBInit)(void*), + bool (*CBFocus)(void*, int), + bool (*CBClick)(void*, int), + bool (*CBOnAction)(void*, int, uint32_t, wchar_t), + void (*CBGetContextButtons)(void*, int, gui_context_menu_pair*, unsigned int*), + bool (*CBOnContextButton)(void*, int, unsigned int)); bool (*show)(void* kodiBase, void* handle); bool (*close)(void* kodiBase, void* handle); bool (*do_modal)(void* kodiBase, void* handle); @@ -316,6 +316,8 @@ typedef struct AddonToKodiFuncTable_kodi_gui_window bool (*set_focus_id)(void* kodiBase, void* handle, int control_id); int (*get_focus_id)(void* kodiBase, void* handle); void (*set_control_label)(void* kodiBase, void* handle, int control_id, const char* label); + void (*set_control_visible)(void* kodiBase, void* handle, int control_id, bool visible); + void (*set_control_selected)(void* kodiBase, void* handle, int control_id, bool selected); /* Window property functions */ void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h index 26d6386..d545030 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h @@ -66,16 +66,18 @@ namespace dialogs /// fprintf(stderr, "Selected item is: %i\n", selected); /// ~~~~~~~~~~~~~ /// - inline int Show(const std::string& heading, const std::vector& entries) + inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, + const std::vector& entries) { using namespace ::kodi::addon; - unsigned int size = entries.size(); - const char** cEntries = static_cast(malloc(size*sizeof(const char**))); + unsigned int size = static_cast(entries.size()); + const char** cEntries = static_cast(malloc(size * sizeof(const char**))); for (unsigned int i = 0; i < size; ++i) { cEntries[i] = entries[i].c_str(); } - int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); free(cEntries); return ret; } @@ -113,10 +115,11 @@ namespace dialogs /// fprintf(stderr, "Selected item is: %i\n", selected); /// ~~~~~~~~~~~~~ /// - inline int Show(const std::string& heading, const std::vector>& entries) + inline int ATTRIBUTE_HIDDEN Show( + const std::string& heading, const std::vector>& entries) { using namespace ::kodi::addon; - unsigned int size = entries.size(); + unsigned int size = static_cast(entries.size()); const char** cEntries = static_cast(malloc(size*sizeof(const char**))); for (unsigned int i = 0; i < size; ++i) { @@ -160,10 +163,11 @@ namespace dialogs /// fprintf(stderr, "Selected item is: %i\n", selected); /// ~~~~~~~~~~~~~ /// - inline int Show(const std::string& heading, const std::vector>& entries) + inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, + const std::vector>& entries) { using namespace ::kodi::addon; - unsigned int size = entries.size(); + unsigned int size = static_cast(entries.size()); const char** cEntries = static_cast(malloc(size*sizeof(const char**))); for (unsigned int i = 0; i < size; ++i) { diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h index 417d5db..5a49b70 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h @@ -18,218 +18,232 @@ namespace gui namespace dialogs { - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } - /// **Progress dialog shown for background work** +//============================================================================ +/// +/// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress +/// \ingroup cpp_kodi_gui +/// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress } +/// **Progress dialog shown for background work** +/// +/// The with \ref ExtendedProgress.h "#include " +/// given class are basically used to create Kodi's extended progress. +/// +/// +/// -------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); +/// ext_progress->SetText("Test progress"); +/// for (unsigned int i = 0; i < 50; i += 10) +/// { +/// ext_progress->SetProgress(i, 100); +/// sleep(1); +/// } +/// +/// ext_progress->SetTitle("Test Extended progress - Second round"); +/// ext_progress->SetText("Test progress - Step 2"); +/// +/// for (unsigned int i = 50; i < 100; i += 10) +/// { +/// ext_progress->SetProgress(i, 100); +/// sleep(1); +/// } +/// delete ext_progress; +/// ~~~~~~~~~~~~~ +/// +class ATTRIBUTE_HIDDEN CExtendedProgress +{ +public: + //========================================================================== /// - /// The with \ref ExtendedProgress.h "#include " - /// given class are basically used to create Kodi's extended progress. + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// Construct a new dialog /// + /// @param[in] title Title string /// - /// -------------------------------------------------------------------------- + explicit CExtendedProgress(const std::string& title = "") + { + using namespace ::kodi::addon; + m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog( + CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); + if (!m_DialogHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// Destructor /// - /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress"); - /// ext_progress->SetText("Test progress"); - /// for (unsigned int i = 0; i < 50; i += 10) - /// { - /// ext_progress->SetProgress(i, 100); - /// sleep(1); - /// } + ~CExtendedProgress() + { + using namespace ::kodi::addon; + if (m_DialogHandle) + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// ext_progress->SetTitle("Test Extended progress - Second round"); - /// ext_progress->SetText("Test progress - Step 2"); + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief Get the used title /// - /// for (unsigned int i = 50; i < 100; i += 10) - /// { - /// ext_progress->SetProgress(i, 100); - /// sleep(1); - /// } - /// delete ext_progress; - /// ~~~~~~~~~~~~~ + /// @return Title string /// - class CExtendedProgress + std::string Title() const { - public: - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// Construct a new dialog - /// - /// @param[in] title Title string - /// - explicit CExtendedProgress(const std::string& title = "") - { - using namespace ::kodi::addon; - m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); - if (!m_DialogHandle) - kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// Destructor - /// - ~CExtendedProgress() - { - using namespace ::kodi::addon; - if (m_DialogHandle) - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief Get the used title - /// - /// @return Title string - /// - std::string Title() const - { - using namespace ::kodi::addon; - std::string text; - char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - if (strMsg != nullptr) - { - if (std::strlen(strMsg)) - text = strMsg; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); - } - return text; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief To set the title of dialog - /// - /// @param[in] title Title string - /// - void SetTitle(const std::string& title) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief Get the used text information string - /// - /// @return Text string - /// - std::string Text() const - { - using namespace ::kodi::addon; - std::string text; - char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - if (strMsg != nullptr) - { - if (std::strlen(strMsg)) - text = strMsg; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); - } - return text; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief To set the used text information string - /// - /// @param[in] text information text to set - /// - void SetText(const std::string& text) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief To ask dialog is finished - /// - /// @return True if on end - /// - bool IsFinished() const - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief Mark progress finished - /// - void MarkFinished() - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief Get the current progress position as percent - /// - /// @return Position - /// - float Percentage() const - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief To set the current progress position as percent - /// - /// @param[in] percentage Position to use from 0.0 to 100.0 - /// - void SetPercentage(float percentage) + using namespace ::kodi::addon; + std::string text; + char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + if (strMsg != nullptr) { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); + if (std::strlen(strMsg)) + text = strMsg; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, + strMsg); } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress - /// @brief To set progress position with predefined places - /// - /// @param[in] currentItem Place position to use - /// @param[in] itemCount Amount of used places - /// - void SetProgress(int currentItem, int itemCount) + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief To set the title of dialog + /// + /// @param[in] title Title string + /// + void SetTitle(const std::string& title) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief Get the used text information string + /// + /// @return Text string + /// + std::string Text() const + { + using namespace ::kodi::addon; + std::string text; + char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + if (strMsg != nullptr) { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); + if (std::strlen(strMsg)) + text = strMsg; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, + strMsg); } - //-------------------------------------------------------------------------- + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief To set the used text information string + /// + /// @param[in] text information text to set + /// + void SetText(const std::string& text) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief To ask dialog is finished + /// + /// @return True if on end + /// + bool IsFinished() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief Mark progress finished + /// + void MarkFinished() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief Get the current progress position as percent + /// + /// @return Position + /// + float Percentage() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- - private: - void* m_DialogHandle; - }; + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief To set the current progress position as percent + /// + /// @param[in] percentage Position to use from 0.0 to 100.0 + /// + void SetPercentage(float percentage) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// @brief To set progress position with predefined places + /// + /// @param[in] currentItem Place position to use + /// @param[in] itemCount Amount of used places + /// + void SetProgress(int currentItem, int itemCount) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); + } + //-------------------------------------------------------------------------- + +private: + void* m_DialogHandle; +}; } /* namespace dialogs */ } /* namespace gui */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h index bb1065d..90da063 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h @@ -71,17 +71,22 @@ namespace dialogs /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false) + inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, + const std::string& heading, + std::string& path, + bool writeOnly = false) { using namespace ::kodi::addon; char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase, - shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly); + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( + CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), + &retString, writeOnly); if (retString != nullptr) { if (std::strlen(retString)) path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, + retString); } return ret; } @@ -104,8 +109,12 @@ namespace dialogs /// handled as directories. /// @return False if selection becomes canceled. /// - inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading, - std::string& path, bool useThumbs = false, bool useFileDirectories = false) + inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, + const std::string& mask, + const std::string& heading, + std::string& path, + bool useThumbs = false, + bool useFileDirectories = false) { using namespace ::kodi::addon; char* retString = nullptr; @@ -141,8 +150,13 @@ namespace dialogs /// @param[in] singleList /// @return False if selection becomes canceled. /// - inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path, - bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) + inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, + const std::string& mask, + const std::string& heading, + std::string& path, + bool useThumbs = false, + bool useFileDirectories = false, + bool singleList = false) { using namespace ::kodi::addon; char* retString = nullptr; @@ -176,8 +190,12 @@ namespace dialogs /// handled as directories. /// @return False if selection becomes canceled. /// - inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading, - std::vector& fileList, bool useThumbs = false, bool useFileDirectories = false) + inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, + const std::string& mask, + const std::string& heading, + std::vector& fileList, + bool useThumbs = false, + bool useFileDirectories = false) { using namespace ::kodi::addon; char** list = nullptr; @@ -188,7 +206,7 @@ namespace dialogs if (ret) { for (unsigned int i = 0; i < listSize; ++i) - fileList.push_back(list[i]); + fileList.emplace_back(list[i]); CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); } return ret; @@ -208,7 +226,10 @@ namespace dialogs /// @param[in] type /// @return False if selection becomes canceled. /// - inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "") + inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, + bool allowNetworkShares, + const std::string& additionalShare = "", + const std::string& type = "") { using namespace ::kodi::addon; char* retString = nullptr; @@ -235,7 +256,9 @@ namespace dialogs /// @param[out] path Return value about selected image /// @return False if selection becomes canceled. /// - inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path) + inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, + const std::string& heading, + std::string& path) { using namespace ::kodi::addon; char* retString = nullptr; @@ -262,7 +285,9 @@ namespace dialogs /// @param[out] file_list Return value about selected images /// @return False if selection becomes canceled. /// - inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector& file_list) + inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, + const std::string& heading, + std::vector& file_list) { using namespace ::kodi::addon; char** list = nullptr; @@ -272,7 +297,7 @@ namespace dialogs if (ret) { for (unsigned int i = 0; i < listSize; ++i) - file_list.push_back(list[i]); + file_list.emplace_back(list[i]); CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); } return ret; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h index 76284d8..843bdfa 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h @@ -76,17 +76,23 @@ namespace dialogs /// text.c_str(), bRet ? "OK" : "Canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, + const std::string& heading, + bool allowEmptyResult, + bool hiddenInput = false, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase, - text.c_str(), &retString, heading.c_str(), allowEmptyResult, - hiddenInput, autoCloseMs); + bool ret = + CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head( + CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(), + allowEmptyResult, hiddenInput, autoCloseMs); if (retString != nullptr) { text = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, + retString); } return ret; } @@ -108,7 +114,9 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text, + bool allowEmptyResult, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -140,7 +148,10 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, + const std::string& heading, + bool allowEmptyResult, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -170,7 +181,8 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -251,7 +263,10 @@ namespace dialogs /// } /// ~~~~~~~~~~~~~ /// - inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, + const std::string& heading, + bool allowEmptyResult, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -281,7 +296,8 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -313,7 +329,10 @@ namespace dialogs /// unsuccessful input. -1 if no user input or /// canceled editing. /// - inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0) + inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password, + const std::string& heading, + int retries, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -347,7 +366,9 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text, + bool searching, + unsigned int autoCloseMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -372,7 +393,8 @@ namespace dialogs /// @return true if successful done, false if /// unsuccessful or keyboard not present. /// - inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false) + inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text, + bool closeKeyboard = false) { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, @@ -387,7 +409,7 @@ namespace dialogs /// /// @return true if keyboard present, false if not present /// - inline bool IsKeyboardActivated() + inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated() { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h index 4a8eccb..bff7683 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h @@ -50,11 +50,13 @@ namespace dialogs /// false if unsuccessful display, no user /// input, or canceled editing. /// - inline bool ShowAndVerifyNewPassword(std::string& newPassword) + inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword) { using namespace ::kodi::addon; char* pw = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw); + bool ret = + CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password( + CAddonBase::m_interface->toKodi->kodiBase, &pw); if (pw != nullptr) { newPassword = pw; @@ -131,7 +133,9 @@ namespace dialogs /// } /// ~~~~~~~~~~~~~ /// - inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries) + inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password, + const std::string& heading, + int retries) { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, @@ -152,7 +156,9 @@ namespace dialogs /// input. false if unsuccessful display, no /// user input, or canceled editing. /// - inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) + inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify, + const std::string& heading, + bool verifyInput) { using namespace ::kodi::addon; char* retString = nullptr; @@ -199,7 +205,7 @@ namespace dialogs /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetTime(tm& time, const std::string& heading) + inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading) { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); @@ -238,7 +244,7 @@ namespace dialogs /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetDate(tm& date, const std::string& heading) + inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading) { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); @@ -258,7 +264,8 @@ namespace dialogs /// display, no user input, or canceled /// editing. /// - inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) + inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, + const std::string& heading) { using namespace ::kodi::addon; char* retString = nullptr; @@ -304,7 +311,9 @@ namespace dialogs /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) + inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input, + const std::string& heading, + unsigned int autoCloseTimeoutMs = 0) { using namespace ::kodi::addon; char* retString = nullptr; @@ -331,7 +340,7 @@ namespace dialogs /// if unsuccessful display, no user input, or /// canceled editing. /// - inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) + inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading) { using namespace ::kodi::addon; char* retString = nullptr; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h index a47880f..b9a3a0d 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h @@ -52,11 +52,11 @@ namespace dialogs /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); /// ~~~~~~~~~~~~~ /// - inline void ShowAndGetInput(const std::string& heading, const std::string& text) + inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text) { using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, - heading.c_str(), text.c_str()); + CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); } //-------------------------------------------------------------------------- @@ -80,7 +80,10 @@ namespace dialogs /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); /// ~~~~~~~~~~~~~ /// - inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2) + inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2) { using namespace ::kodi::addon; CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h index bbaa98d..b1f8cc5 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h @@ -18,223 +18,237 @@ namespace gui namespace dialogs { - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::dialogs::CProgress } - /// **Progress dialog shown in center** - /// - /// The with \ref DialogProgress.h "#include " - /// given class are basically used to create Kodi's progress dialog with named - /// text fields. - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; - /// progress->SetHeading("Test progress"); - /// progress->SetLine(1, "line 1"); - /// progress->SetLine(2, "line 2"); - /// progress->SetLine(3, "line 3"); - /// progress->SetCanCancel(true); - /// progress->ShowProgressBar(true); - /// progress->Open(); - /// for (unsigned int i = 0; i < 100; i += 10) - /// { - /// progress->SetPercentage(i); - /// sleep(1); - /// } - /// delete progress; - /// ~~~~~~~~~~~~~ - /// - class CProgress +//============================================================================ +/// +/// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress +/// \ingroup cpp_kodi_gui +/// @brief \cpp_class{ kodi::gui::dialogs::CProgress } +/// **Progress dialog shown in center** +/// +/// The with \ref DialogProgress.h "#include " +/// given class are basically used to create Kodi's progress dialog with named +/// text fields. +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress; +/// progress->SetHeading("Test progress"); +/// progress->SetLine(1, "line 1"); +/// progress->SetLine(2, "line 2"); +/// progress->SetLine(3, "line 3"); +/// progress->SetCanCancel(true); +/// progress->ShowProgressBar(true); +/// progress->Open(); +/// for (unsigned int i = 0; i < 100; i += 10) +/// { +/// progress->SetPercentage(i); +/// sleep(1); +/// } +/// delete progress; +/// ~~~~~~~~~~~~~ +/// +class ATTRIBUTE_HIDDEN CProgress +{ +public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief Construct a new dialog + /// + CProgress() + { + using namespace ::kodi::addon; + m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog( + CAddonBase::m_interface->toKodi->kodiBase); + if (!m_DialogHandle) + kodi::Log(ADDON_LOG_FATAL, + "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief Destructor + /// + ~CProgress() + { + using namespace ::kodi::addon; + if (m_DialogHandle) + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To open the dialog + /// + void Open() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief Set the heading title of dialog + /// + /// @param[in] heading Title string to use + /// + void SetHeading(const std::string& heading) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To set the line text field on dialog from 0 - 2 + /// + /// @param[in] iLine Line number + /// @param[in] line Text string + /// + void SetLine(unsigned int iLine, const std::string& line) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To enable and show cancel button on dialog + /// + /// @param[in] canCancel if true becomes it shown + /// + void SetCanCancel(bool canCancel) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To check dialog for clicked cancel button + /// + /// @return True if canceled + /// + bool IsCanceled() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief Get the current progress position as percent + /// + /// @param[in] percentage Position to use from 0 to 100 + /// + void SetPercentage(int percentage) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To set the current progress position as percent + /// + /// @return Current Position used from 0 to 100 + /// + int GetPercentage() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To show or hide progress bar dialog + /// + /// @param[in] onOff If true becomes it shown + /// + void ShowProgressBar(bool onOff) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used + /// + /// @param[in] max Biggest usable position to use + /// + void SetProgressMax(int max) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To increase progress bar by defined step size until reach of maximum position + /// + /// @param[in] steps Step size to increase, default is 1 + /// + void SetProgressAdvance(int steps = 1) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CProgress + /// @brief To check progress was canceled on work + /// + /// @return True if aborted + /// + bool Abort() { - public: - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief Construct a new dialog - /// - CProgress() - { - using namespace ::kodi::addon; - m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase); - if (!m_DialogHandle) - kodi::Log(ADDON_LOG_FATAL, "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!"); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief Destructor - /// - ~CProgress() - { - using namespace ::kodi::addon; - if (m_DialogHandle) - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To open the dialog - /// - void Open() - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief Set the heading title of dialog - /// - /// @param[in] heading Title string to use - /// - void SetHeading(const std::string& heading) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To set the line text field on dialog from 0 - 2 - /// - /// @param[in] iLine Line number - /// @param[in] line Text string - /// - void SetLine(unsigned int iLine, const std::string& line) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To enable and show cancel button on dialog - /// - /// @param[in] canCancel if true becomes it shown - /// - void SetCanCancel(bool canCancel) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To check dialog for clicked cancel button - /// - /// @return True if canceled - /// - bool IsCanceled() const - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief Get the current progress position as percent - /// - /// @param[in] percentage Position to use from 0 to 100 - /// - void SetPercentage(int percentage) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To set the current progress position as percent - /// - /// @return Current Position used from 0 to 100 - /// - int GetPercentage() const - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To show or hide progress bar dialog - /// - /// @param[in] onOff If true becomes it shown - /// - void ShowProgressBar(bool onOff) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used - /// - /// @param[in] max Biggest usable position to use - /// - void SetProgressMax(int max) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To increase progress bar by defined step size until reach of maximum position - /// - /// @param[in] steps Step size to increase, default is 1 - /// - void SetProgressAdvance(int steps=1) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_dialogs_CProgress - /// @brief To check progress was canceled on work - /// - /// @return True if aborted - /// - bool Abort() - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); - } - //-------------------------------------------------------------------------- - - private: - void* m_DialogHandle; - }; + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort( + CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + +private: + void* m_DialogHandle; +}; } /* namespace dialogs */ } /* namespace gui */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h index ba0db1d..39a98fe 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h @@ -104,16 +104,21 @@ namespace dialogs /// fprintf(stderr, "Selected item is: %i\n", selected); /// ~~~~~~~~~~~~~ /// - inline int Show(const std::string& heading, const std::vector& entries, int selected = -1, unsigned int autoclose = 0) + inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, + const std::vector& entries, + int selected = -1, + unsigned int autoclose = 0) { using namespace ::kodi::addon; - unsigned int size = entries.size(); - const char** cEntries = (const char**)malloc(size*sizeof(const char**)); + unsigned int size = static_cast(entries.size()); + const char** cEntries = (const char**)malloc(size * sizeof(const char**)); for (unsigned int i = 0; i < size; ++i) { cEntries[i] = entries[i].c_str(); } - int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, + autoclose); free(cEntries); return ret; } @@ -159,10 +164,13 @@ namespace dialogs /// fprintf(stderr, "Selected item is: %i\n", selected); /// ~~~~~~~~~~~~~ /// - inline int Show(const std::string& heading, std::vector& entries, int selected = -1, unsigned int autoclose = 0) + inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, + std::vector& entries, + int selected = -1, + unsigned int autoclose = 0) { using namespace ::kodi::addon; - unsigned int size = entries.size(); + unsigned int size = static_cast(entries.size()); const char** cEntries = static_cast(malloc(size*sizeof(const char*))); for (unsigned int i = 0; i < size; ++i) { @@ -224,10 +232,12 @@ namespace dialogs /// } /// ~~~~~~~~~~~~~ /// - inline bool ShowMultiSelect(const std::string& heading, std::vector& entries, int autoclose = 0) + inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading, + std::vector& entries, + int autoclose = 0) { using namespace ::kodi::addon; - unsigned int size = entries.size(); + unsigned int size = static_cast(entries.size()); const char** cEntryIDs = static_cast(malloc(size*sizeof(const char*))); const char** cEntryNames = static_cast(malloc(size*sizeof(const char*))); bool* cEntriesSelected = static_cast(malloc(size*sizeof(bool))); diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h index da38f7c..5c81837 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h @@ -93,10 +93,11 @@ namespace dialogs /// "interspersed renderings from classical composers.\n"); /// ~~~~~~~~~~~~~ /// - inline void Show(const std::string& heading, const std::string& text) + inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text) { using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); + CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); } //-------------------------------------------------------------------------- }; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h index c694bf5..67c2fc4 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h @@ -73,14 +73,16 @@ namespace dialogs /// canceled ? "canceled" : "not canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetInput(const std::string& heading, const std::string& text, - bool& canceled, const std::string& noLabel = "", - const std::string& yesLabel = "") + inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& text, + bool& canceled, + const std::string& noLabel = "", + const std::string& yesLabel = "") { using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, - heading.c_str(), text.c_str(), &canceled, - noLabel.c_str(), yesLabel.c_str()); + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text( + CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled, + noLabel.c_str(), yesLabel.c_str()); } //-------------------------------------------------------------------------- @@ -115,9 +117,12 @@ namespace dialogs /// ret ? "yes" : "no"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, - const std::string& line2, const std::string& noLabel = "", - const std::string& yesLabel = "") + inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + const std::string& noLabel = "", + const std::string& yesLabel = "") { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, @@ -161,9 +166,13 @@ namespace dialogs /// canceled ? "canceled" : "not canceled"); /// ~~~~~~~~~~~~~ /// - inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, - const std::string& line2, bool& canceled, const std::string& noLabel = "", - const std::string& yesLabel = "") + inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, + const std::string& line0, + const std::string& line1, + const std::string& line2, + bool& canceled, + const std::string& noLabel = "", + const std::string& yesLabel = "") { using namespace ::kodi::addon; return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt new file mode 100644 index 0000000..a9ab70c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/CMakeLists.txt @@ -0,0 +1,7 @@ +set(HEADERS GL.h + GLonDX.h + Shader.h) + +if(NOT ENABLE_STATIC_LIBS) + core_add_library(addons_kodi-addon-dev-kit_include_kodi_gui_gl) +endif() diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h new file mode 100644 index 0000000..943c7d0 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GL.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +//============================================================================== +/// +/// \defgroup cpp_kodi_gui_gl OpenGL helpers +/// \ingroup cpp_kodi_gui +/// \brief Auxiliary functions for Open GL +/// +/// This group includes help for definitions, functions, and classes for +/// OpenGL. +/// +/// To use OpenGL for your system, add the \ref GL.h "#include ". +/// +/// +///----------------------------------------------------------------------------- +/// +/// The \ref HAS_GL is declared if Open GL is required and \ref HAS_GLES if Open GL +/// Embedded Systems (ES) is required, with ES the version is additionally given +/// in the definition, this can be "2" or "3". +/// +/// +///----------------------------------------------------------------------------- +/// +/// Following \ref GL_TYPE_STRING define can be used, for example, to manage +/// different folders for GL and GLES and make the selection easier. +/// This are on OpenGL "GL" and on Open GL|ES "GLES". +/// +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); +/// ~~~~~~~~~~~~~~~~~ +/// +/// +///---------------------------------------------------------------------------- +/// +/// In addition, \ref BUFFER_OFFSET is declared in it which can be used to give an +/// offset on the array to GL. +/// +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// const struct PackedVertex { +/// float position[3]; // Position x, y, z +/// float color[4]; // Color r, g, b, a +/// } vertices[3] = { +/// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, +/// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, +/// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } } +/// }; +/// +/// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position))); +/// glEnableVertexAttribArray(m_aPosition); +/// +/// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color))); +/// glEnableVertexAttribArray(m_aColor); +/// ~~~~~~~~~~~~~~~~~ + +#if HAS_GL + #define GL_TYPE_STRING "GL" + // always define GL_GLEXT_PROTOTYPES before include gl headers + #if !defined(GL_GLEXT_PROTOTYPES) + #define GL_GLEXT_PROTOTYPES + #endif + #if defined(TARGET_LINUX) + #include + #include + #elif defined(TARGET_FREEBSD) + #include + #elif defined(TARGET_DARWIN) + #include + #include + #elif defined(WIN32) + #error Use of GL under Windows is not possible + #endif +#elif HAS_GLES >= 2 + #define GL_TYPE_STRING "GLES" + #if defined(WIN32) + #if defined(HAS_ANGLE) + #include + #else + #error Use of GLES only be available under Windows by the use of angle + #endif + #elif defined(TARGET_DARWIN) + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #else + #if HAS_GLES == 3 + #include + #include + #else + #include + #include + #endif + #endif +#endif + +#ifndef BUFFER_OFFSET +#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) +#endif diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h new file mode 100644 index 0000000..7a6a0a1 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/GLonDX.h @@ -0,0 +1,369 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma comment( lib, "d3dcompiler.lib" ) +#ifndef GL_CLIENT_VERSION +#define GL_CLIENT_VERSION 3 +#endif + +namespace kodi +{ +namespace gui +{ +namespace gl +{ + +class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper +{ +public: + explicit CGLonDX() : m_pContext(reinterpret_cast(kodi::gui::GetHWContext())) {} + ~CGLonDX() override { destruct(); } + + bool Init() override + { + EGLint egl_display_attrs[] = + { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE, + EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE, + EGL_NONE + }; + EGLint egl_config_attrs[] = + { + EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, + EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, + EGL_RENDERABLE_TYPE, GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_NONE + }; + EGLint egl_context_attrs[] = + { + EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE + }; + + m_eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs); + if (m_eglDisplay == EGL_NO_DISPLAY) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString()); + return false; + } + + if (eglInitialize(m_eglDisplay, nullptr, nullptr) != EGL_TRUE) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to init EGL display (%s)", eglGetErrorString()); + return false; + } + + EGLint numConfigs = 0; + if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE || numConfigs == 0) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString()); + return false; + } + + m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, egl_context_attrs); + if (m_eglContext == EGL_NO_CONTEXT) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL context (%s)", eglGetErrorString()); + return false; + } + + if (!createD3DResources()) + return false; + + if (eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext) != EGL_TRUE) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to make current EGL (%s)", eglGetErrorString()); + return false; + } + return true; + } + + void CheckGL(ID3D11DeviceContext* device) + { + if (m_pContext != device) + { + m_pSRView = nullptr; + m_pVShader = nullptr; + m_pPShader = nullptr; + m_pContext = device; + + if (m_eglBuffer != EGL_NO_SURFACE) + { + eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(m_eglDisplay, m_eglBuffer); + m_eglBuffer = EGL_NO_SURFACE; + } + + // create new resources + if (!createD3DResources()) + return; + + eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext); + } + } + + void Begin() override + { + // confirm on begin D3D context is correct + CheckGL(reinterpret_cast(kodi::gui::GetHWContext())); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } + + void End() override + { + glFlush(); + + // set our primitive shaders + m_pContext->VSSetShader(m_pVShader.Get(), nullptr, 0); + m_pContext->PSSetShader(m_pPShader.Get(), nullptr, 0); + m_pContext->PSSetShaderResources(0, 1, m_pSRView.GetAddressOf()); + // draw texture + m_pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + m_pContext->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr); + m_pContext->IASetInputLayout(nullptr); + m_pContext->Draw(4, 0); + // unset shaders + m_pContext->PSSetShader(nullptr, nullptr, 0); + m_pContext->VSSetShader(nullptr, nullptr, 0); + // unbind our view + ID3D11ShaderResourceView* views[1] = {}; + m_pContext->PSSetShaderResources(0, 1, views); + } + +private: + enum ShaderType + { + VERTEX_SHADER, + PIXEL_SHADER + }; + + bool createD3DResources() + { + HANDLE sharedHandle; + Microsoft::WRL::ComPtr pDevice; + Microsoft::WRL::ComPtr pRTView; + Microsoft::WRL::ComPtr pRTResource; + Microsoft::WRL::ComPtr pRTTexture; + Microsoft::WRL::ComPtr pOffScreenTexture; + Microsoft::WRL::ComPtr dxgiResource; + + m_pContext->GetDevice(&pDevice); + m_pContext->OMGetRenderTargets(1, &pRTView, nullptr); + if (!pRTView) + return false; + + pRTView->GetResource(&pRTResource); + if (FAILED(pRTResource.As(&pRTTexture))) + return false; + + D3D11_TEXTURE2D_DESC texDesc; + pRTTexture->GetDesc(&texDesc); + texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; + if (FAILED(pDevice->CreateTexture2D(&texDesc, nullptr, &pOffScreenTexture))) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create intermediate texture"); + return false; + } + + CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(), D3D11_SRV_DIMENSION_TEXTURE2D); + if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView))) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view"); + return false; + } + + if (FAILED(pOffScreenTexture.As(&dxgiResource)) || + FAILED(dxgiResource->GetSharedHandle(&sharedHandle))) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable get shared handle for texture"); + return false; + } + + // initiate simple shaders + if (FAILED(d3dCreateShader(VERTEX_SHADER, vs_out_shader_text, &m_pVShader))) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create vertex shader view"); + return false; + } + + if (FAILED(d3dCreateShader(PIXEL_SHADER, ps_out_shader_text, &m_pPShader))) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create pixel shader view"); + return false; + } + + // create EGL buffer from D3D shared texture + EGLint egl_buffer_attrs[] = + { + EGL_WIDTH, static_cast(texDesc.Width), + EGL_HEIGHT, static_cast(texDesc.Height), + EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, + EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, + EGL_NONE + }; + + m_eglBuffer = eglCreatePbufferFromClientBuffer(m_eglDisplay, + EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, + sharedHandle, m_eglConfig, egl_buffer_attrs); + + if (m_eglBuffer == EGL_NO_SURFACE) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL buffer (%s)", eglGetErrorString()); + return false; + } + return true; + } + + HRESULT d3dCreateShader(ShaderType shaderType, const std::string& source, IUnknown** ppShader) const + { + Microsoft::WRL::ComPtr pBlob; + Microsoft::WRL::ComPtr pErrors; + + auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main", + shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors); + + if (SUCCEEDED(hr)) + { + Microsoft::WRL::ComPtr pDevice; + m_pContext->GetDevice(&pDevice); + + if (shaderType == PIXEL_SHADER) + { + hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, + reinterpret_cast(ppShader)); + } + else + { + hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr, + reinterpret_cast(ppShader)); + } + + if (FAILED(hr)) + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader", + shaderType == PIXEL_SHADER ? "pixel" : "vertex"); + } + } + else + { + Log(ADDON_LOG_ERROR, "GLonDX: unable to compile shader (%s)", pErrors->GetBufferPointer()); + } + return hr; + } + + static const char* eglGetErrorString() + { +#define CASE_STR( value ) case value: return #value + switch (eglGetError()) + { + CASE_STR(EGL_SUCCESS); + CASE_STR(EGL_NOT_INITIALIZED); + CASE_STR(EGL_BAD_ACCESS); + CASE_STR(EGL_BAD_ALLOC); + CASE_STR(EGL_BAD_ATTRIBUTE); + CASE_STR(EGL_BAD_CONTEXT); + CASE_STR(EGL_BAD_CONFIG); + CASE_STR(EGL_BAD_CURRENT_SURFACE); + CASE_STR(EGL_BAD_DISPLAY); + CASE_STR(EGL_BAD_SURFACE); + CASE_STR(EGL_BAD_MATCH); + CASE_STR(EGL_BAD_PARAMETER); + CASE_STR(EGL_BAD_NATIVE_PIXMAP); + CASE_STR(EGL_BAD_NATIVE_WINDOW); + CASE_STR(EGL_CONTEXT_LOST); + default: + return "Unknown"; + } +#undef CASE_STR + } + + void destruct() + { + if (m_eglDisplay != EGL_NO_DISPLAY) + { + eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (m_eglBuffer != EGL_NO_SURFACE) + { + eglDestroySurface(m_eglDisplay, m_eglBuffer); + m_eglBuffer = EGL_NO_SURFACE; + } + + if (m_eglContext != EGL_NO_CONTEXT) + { + eglDestroyContext(m_eglDisplay, m_eglContext); + m_eglContext = EGL_NO_CONTEXT; + } + + eglTerminate(m_eglDisplay); + m_eglDisplay = EGL_NO_DISPLAY; + } + + m_pSRView = nullptr; + m_pVShader = nullptr; + m_pPShader = nullptr; + m_pContext = nullptr; + } + + EGLConfig m_eglConfig = EGL_NO_CONFIG_KHR; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; + EGLContext m_eglContext = EGL_NO_CONTEXT; + EGLSurface m_eglBuffer = EGL_NO_SURFACE; + + ID3D11DeviceContext* m_pContext = nullptr; // don't hold context + Microsoft::WRL::ComPtr m_pSRView = nullptr; + Microsoft::WRL::ComPtr m_pVShader = nullptr; + Microsoft::WRL::ComPtr m_pPShader = nullptr; + +#define TO_STRING(...) #__VA_ARGS__ + std::string vs_out_shader_text = TO_STRING( + void main(uint id : SV_VertexId, out float2 tex : TEXCOORD0, out float4 pos : SV_POSITION) + { + tex = float2(id % 2, (id % 4) >> 1); + pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1); + }); + + std::string ps_out_shader_text = TO_STRING( + Texture2D texMain : register(t0); + SamplerState Sampler + { + Filter = MIN_MAG_MIP_LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + Comparison = NEVER; + }; + + float4 main(in float2 tex : TEXCOORD0) : SV_TARGET + { + return texMain.Sample(Sampler, tex); + }); +#undef TO_STRING +}; /* class CGLonDX */ + +} /* namespace gl */ + +using CRenderHelper = gl::CGLonDX; +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h new file mode 100644 index 0000000..209f274 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/gl/Shader.h @@ -0,0 +1,594 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "GL.h" + +#include +#include +#include + +#include +#include + +#define LOG_SIZE 1024 +#define GLchar char + +namespace kodi +{ +namespace gui +{ +namespace gl +{ + +//======================================================================== +/// CShader - base class +class ATTRIBUTE_HIDDEN CShader +{ +public: + CShader() = default; + virtual ~CShader() = default; + virtual bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") = 0; + virtual void Free() = 0; + virtual GLuint Handle() = 0; + + bool LoadSource(const std::string& file) + { + char buffer[16384]; + + kodi::vfs::CFile source; + if (!source.OpenFile(file)) + { + kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__, file.c_str()); + return false; + } + size_t len = source.Read(buffer, sizeof(buffer)); + m_source.assign(buffer); + m_source[len] = 0; + source.Close(); + return true; + } + + bool OK() const { return m_compiled; } + +protected: + std::string m_source; + std::string m_lastLog; + bool m_compiled = false; +}; +//------------------------------------------------------------------------ + +//======================================================================== +/// CVertexShader +class ATTRIBUTE_HIDDEN CVertexShader : public CShader +{ +public: + CVertexShader() = default; + ~CVertexShader() override { Free(); } + + void Free() override + { + if (m_vertexShader) + glDeleteShader(m_vertexShader); + m_vertexShader = 0; + } + + bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") override + { + GLint params[4]; + + Free(); + + m_vertexShader = glCreateShader(GL_VERTEX_SHADER); + + GLsizei count = 0; + const char *sources[3]; + if (!extraBegin.empty()) + sources[count++] = extraBegin.c_str(); + if (!m_source.empty()) + sources[count++] = m_source.c_str(); + if (!extraEnd.empty()) + sources[count++] = extraEnd.c_str(); + + glShaderSource(m_vertexShader, count, sources, nullptr); + glCompileShader(m_vertexShader); + glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CVertexShader::%s: %s\n", __FUNCTION__, log); + m_lastLog = log; + m_compiled = false; + } + else + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log); + m_lastLog = log; + m_compiled = true; + } + return m_compiled; + } + + GLuint Handle() override { return m_vertexShader; } + +protected: + GLuint m_vertexShader = 0; +}; +//------------------------------------------------------------------------ + +//======================================================================== +/// CPixelShader +class ATTRIBUTE_HIDDEN CPixelShader : public CShader +{ +public: + CPixelShader() = default; + ~CPixelShader() { Free(); } + void Free() override + { + if (m_pixelShader) + glDeleteShader(m_pixelShader); + m_pixelShader = 0; + } + + bool Compile(const std::string& extraBegin = "", + const std::string& extraEnd = "") override + { + GLint params[4]; + + Free(); + + m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER); + + GLsizei count = 0; + const char *sources[3]; + if (!extraBegin.empty()) + sources[count++] = extraBegin.c_str(); + if (!m_source.empty()) + sources[count++] = m_source.c_str(); + if (!extraEnd.empty()) + sources[count++] = extraEnd.c_str(); + + glShaderSource(m_pixelShader, count, sources, 0); + glCompileShader(m_pixelShader); + glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CPixelShader::%s: %s\n", __FUNCTION__, log); + m_lastLog = log; + m_compiled = false; + } + else + { + GLchar log[LOG_SIZE]; + glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log); + m_lastLog = log; + m_compiled = true; + } + return m_compiled; + } + + GLuint Handle() override { return m_pixelShader; } + +protected: + GLuint m_pixelShader = 0; +}; +//------------------------------------------------------------------------ + +//============================================================================ +/// +/// \defgroup cpp_kodi_gui_gl_CShaderProgram GL Shader Program +/// \ingroup cpp_kodi_gui_gl +/// @brief \cpp_class{ kodi::gui::gl::CShaderProgram } +/// **Class to manage an OpenGL shader program** +/// +/// With this class the used GL shader code can be defined on the GPU and +/// its variables can be managed between CPU and GPU. +/// +/// It has the header \ref Shader.h "#include " +/// be included to enjoy it. +/// +/// ---------------------------------------------------------------------------- +/// +/// Example: +/// +/// ~~~~~~~~~~~~~{.cpp} +/// +/// #include +/// ... +/// +/// class ATTRIBUTE_HIDDEN CExample +/// : ..., +/// public kodi::gui::gl::CShaderProgram +/// { +/// public: +/// CExample() = default; +/// +/// bool Start(); +/// void Render(); +/// +/// // override functions for kodi::gui::gl::CShaderProgram +/// void OnCompiledAndLinked() override; +/// bool OnEnabled() override; +/// +/// private: +/// ... +/// GLint m_aPosition = -1; +/// GLint m_aColor = -1; +/// }; +/// +/// bool CExample::Start() +/// { +/// // Define shaders and load +/// std::string fraqShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.frag"); +/// std::string vertShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.vert"); +/// if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink()) +/// return false; +/// +/// ... +/// return true; +/// } +/// +/// ... +/// +/// void CExample::Render() +/// { +/// ... +/// +/// EnableShader(); +/// ... +/// DO WORK +/// ... +/// DisableShader(); +/// } +/// +/// void CExample::OnCompiledAndLinked() +/// { +/// ... +/// DO YOUR WORK HERE FOR WHAT IS ONE TIME REQUIRED DURING COMPILE OF SHADER, E.G.: +/// +/// m_aPosition = glGetAttribLocation(ProgramHandle(), "a_position"); +/// m_aColor = glGetAttribLocation(ProgramHandle(), "a_color"); +/// } +/// +/// bool OnEnabled() override +/// { +/// ... +/// DO YOUR WORK HERE FOR WHAT REQUIRED DURING ENABLE OF SHADER +/// ... +/// return true; +/// } +/// +/// ADDONCREATOR(CExample); +/// ~~~~~~~~~~~~~ +/// + +//======================================================================== +/// CShaderProgram +class ATTRIBUTE_HIDDEN CShaderProgram +{ +public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief Construct a new shader + /// + /// Load must be done later with \ref LoadShaderFiles. + /// + CShaderProgram() = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief Construct a new shader and load defined shader files + /// + /// @param[in] vert Path to used GL vertext shader + /// @param[in] frag Path to used GL fragment shader + /// + CShaderProgram(const std::string& vert, const std::string& frag) + { + LoadShaderFiles(vert, frag); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief Destructor + /// + virtual ~CShaderProgram() + { + ShaderFree(); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To load manually the needed shader files + /// + /// @param[in] vert Path to used GL vertext shader + /// @param[in] frag Path to used GL fragment shader + /// + /// + /// @note The use of the files is optional, but it must either be passed over + /// here or via \ref CompileAndLink, or both of the source code. + /// + bool LoadShaderFiles(const std::string& vert, const std::string& frag) + { + if (!kodi::vfs::FileExists(vert) || !m_pVP.LoadSource(vert)) + { + kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, vert.c_str()); + return false; + } + + if (!kodi::vfs::FileExists(frag) || !m_pFP.LoadSource(frag)) + { + kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, frag.c_str()); + return false; + } + + return true; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To compile and link the shader to the GL interface + /// + /// Optionally, additional source code can be transferred here, or it can be + /// used independently without any files + /// + /// @param[in] vertexExtraBegin [opt] To additionally add vextex source + /// code to the beginning of the loaded file + /// source code + /// @param[in] vertexExtraEnd [opt] To additionally add vextex source + /// code to the end of the loaded file + /// source code + /// @param[in] fragmentExtraBegin [opt] To additionally add fragment source + /// code to the beginning of the loaded file + /// source code + /// @param[in] fragmentExtraEnd [opt] To additionally add fragment source + /// code to the end of the loaded file + /// source code + /// @return true if compile was successed + /// + /// + /// @note In the case of a compile error, it will be written once into the Kodi + /// log and in addition to the console output to quickly detect the errors when + /// writing the damage. + /// + /// + bool CompileAndLink(const std::string& vertexExtraBegin = "", + const std::string& vertexExtraEnd = "", + const std::string& fragmentExtraBegin = "", + const std::string& fragmentExtraEnd = "") + { + GLint params[4]; + + // free resources + ShaderFree(); + m_ok = false; + + // compiled vertex shader + if (!m_pVP.Compile(vertexExtraBegin, vertexExtraEnd)) + { + kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader"); + return false; + } + + // compile pixel shader + if (!m_pFP.Compile(fragmentExtraBegin, fragmentExtraEnd)) + { + m_pVP.Free(); + kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling fragment shader"); + return false; + } + + // create program object + m_shaderProgram = glCreateProgram(); + if (!m_shaderProgram) + { + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: Failed to create GL program", __FUNCTION__); + ShaderFree(); + return false; + } + + // attach the vertex shader + glAttachShader(m_shaderProgram, m_pVP.Handle()); + glAttachShader(m_shaderProgram, m_pFP.Handle()); + + // link the program + glLinkProgram(m_shaderProgram); + glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); + ShaderFree(); + return false; + } + + m_validated = false; + m_ok = true; + OnCompiledAndLinked(); + return true; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To activate the shader and use it on the GPU + /// + /// @return true if enable was successfull done + /// + /// + /// @note During this call, the \ref OnEnabled stored in the child is also + /// called + /// + bool EnableShader() + { + if (ShaderOK()) + { + glUseProgram(m_shaderProgram); + if (OnEnabled()) + { + if (!m_validated) + { + // validate the program + GLint params[4]; + glValidateProgram(m_shaderProgram); + glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params); + if (params[0] != GL_TRUE) + { + GLchar log[LOG_SIZE]; + glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log); + kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log); + fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log); + } + m_validated = true; + } + return true; + } + else + { + glUseProgram(0); + return false; + } + return true; + } + return false; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To deactivate the shader use on the GPU + /// + void DisableShader() + { + if (ShaderOK()) + { + glUseProgram(0); + OnDisabled(); + } + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief Used to check if shader has been loaded before. + /// + /// @return true if enable was successfull done + /// + /// @note The CompileAndLink call sets these values + /// + ATTRIBUTE_FORCEINLINE bool ShaderOK() const { return m_ok; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To get the vertex shader class used by Kodi at the addon + /// + /// @return pointer to vertex shader class + /// + ATTRIBUTE_FORCEINLINE CVertexShader& VertexShader() { return m_pVP; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief To get the fragment shader class used by Kodi at the addon + /// + /// @return pointer to fragment shader class + /// + ATTRIBUTE_FORCEINLINE CPixelShader& PixelShader() { return m_pFP; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief Used to get the definition created in the OpenGL itself + /// + /// @return GLuint of GL shader program handler + /// + ATTRIBUTE_FORCEINLINE GLuint ProgramHandle() { return m_shaderProgram; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \defgroup cpp_kodi_gui_gl_CShaderProgram_child Child Functions + /// \ingroup cpp_kodi_gui_gl_CShaderProgram + /// @brief \cpp_class{ kodi::gui::gl::CShaderProgram child functions } + /// + /// Functions that are added by parent in the child + //@{ + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child + /// @brief Mandatory child function to set the necessary CPU to GPU data + /// + virtual void OnCompiledAndLinked() {}; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child + /// @brief Optional function to exchange data between CPU and GPU while + /// activating the shader + /// + /// @return true if enable was successfull done + /// + virtual bool OnEnabled() { return true; }; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_gl_CShaderProgram_child + /// @brief Optional child function that may have to be performed when + /// switching off the shader + virtual void OnDisabled() {}; + //-------------------------------------------------------------------------- + //@} + +private: + void ShaderFree() + { + if (m_shaderProgram) + glDeleteProgram(m_shaderProgram); + m_shaderProgram = 0; + m_ok = false; + } + + CVertexShader m_pVP; + CPixelShader m_pFP; + GLuint m_shaderProgram = 0; + bool m_ok = false; + bool m_validated = false; +}; +//------------------------------------------------------------------------ + +} /* namespace gl */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h new file mode 100644 index 0000000..2e96d21 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/renderHelper.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +struct ATTRIBUTE_HIDDEN IRenderHelper +{ + virtual ~IRenderHelper() = default; + virtual bool Init() = 0; + virtual void Begin() = 0; + virtual void End() = 0; +}; /* class IRenderHelper */ +} /* namespace gui */ +} /* namespace kodi */ + +#if defined(WIN32) && defined(HAS_ANGLE) +#include "gl/GLonDX.h" +#else +/* + * Default background GUI render helper class + */ +namespace kodi +{ +namespace gui +{ +struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper +{ + bool Init() override { return true; } + void Begin() override { } + void End() override { } +}; /* class CRenderHelperStub */ + +using CRenderHelper = CRenderHelperStub; +} /* namespace gui */ +} /* namespace kodi */ +#endif + +namespace kodi +{ +namespace gui +{ + +/* + * Create render background handler, e.g. becomes on "Windows" Angle used + * to emulate GL. + * + * This only be used internal and not from addon's direct. + * + * Function defines here and not in CAddonBase because of a hen and egg problem. + */ +inline std::shared_ptr ATTRIBUTE_HIDDEN GetRenderHelper() +{ + using namespace ::kodi::addon; + if (static_cast(CAddonBase::m_interface->addonBase)->m_renderHelper) + return static_cast(CAddonBase::m_interface->addonBase)->m_renderHelper; + + const std::shared_ptr renderHelper(new CRenderHelper()); + if (!renderHelper->Init()) + return nullptr; + + static_cast(CAddonBase::m_interface->addonBase)->m_renderHelper = + renderHelper; // Hold on base for other types + return renderHelper; +} + +} /* namespace gui */ +} /* namespace kodi */ -- cgit v1.2.3