From 4c3251ec645c8b71820dab7e51e612e5919d4e75 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 23 Jul 2017 16:59:43 +0200 Subject: sync with upstream --- .../include/kodi/gui/DialogContextMenu.h | 95 ----- .../include/kodi/gui/DialogExtendedProgress.h | 244 ------------ .../include/kodi/gui/DialogFileBrowser.h | 293 -------------- .../include/kodi/gui/DialogKeyboard.h | 416 -------------------- .../include/kodi/gui/DialogNumeric.h | 366 ------------------ .../kodi-addon-dev-kit/include/kodi/gui/DialogOK.h | 104 ----- .../include/kodi/gui/DialogProgress.h | 249 ------------ .../include/kodi/gui/DialogSelect.h | 101 ----- .../include/kodi/gui/DialogTextViewer.h | 115 ------ .../include/kodi/gui/DialogYesNo.h | 187 --------- .../kodi-addon-dev-kit/include/kodi/gui/ListItem.h | 86 ++++- .../kodi-addon-dev-kit/include/kodi/gui/Window.h | 385 ++++++++++++++++++- .../include/kodi/gui/controls/Button.h | 176 +++++++++ .../include/kodi/gui/controls/Edit.h | 276 ++++++++++++++ .../include/kodi/gui/controls/FadeLabel.h | 159 ++++++++ .../include/kodi/gui/controls/Image.h | 123 ++++++ .../include/kodi/gui/controls/Label.h | 128 +++++++ .../include/kodi/gui/controls/Progress.h | 121 ++++++ .../include/kodi/gui/controls/RadioButton.h | 171 +++++++++ .../include/kodi/gui/controls/Rendering.h | 215 +++++++++++ .../include/kodi/gui/controls/SettingsSlider.h | 323 ++++++++++++++++ .../include/kodi/gui/controls/Slider.h | 336 +++++++++++++++++ .../include/kodi/gui/controls/Spin.h | 376 ++++++++++++++++++ .../include/kodi/gui/controls/TextBox.h | 176 +++++++++ .../include/kodi/gui/definitions.h | 240 +++++++++++- .../include/kodi/gui/dialogs/ContextMenu.h | 98 +++++ .../include/kodi/gui/dialogs/ExtendedProgress.h | 247 ++++++++++++ .../include/kodi/gui/dialogs/FileBrowser.h | 296 +++++++++++++++ .../include/kodi/gui/dialogs/Keyboard.h | 419 +++++++++++++++++++++ .../include/kodi/gui/dialogs/Numeric.h | 369 ++++++++++++++++++ .../include/kodi/gui/dialogs/OK.h | 107 ++++++ .../include/kodi/gui/dialogs/Progress.h | 252 +++++++++++++ .../include/kodi/gui/dialogs/Select.h | 105 ++++++ .../include/kodi/gui/dialogs/TextViewer.h | 118 ++++++ .../include/kodi/gui/dialogs/YesNo.h | 190 ++++++++++ 35 files changed, 5482 insertions(+), 2180 deletions(-) delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h deleted file mode 100644 index 66a1c90..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogContextMenu Dialog Context Menu - /// \ingroup cpp_kodi_gui - /// @brief \cpp_namespace{ kodi::gui::DialogContextMenu } - /// **Context menu dialog** - /// - /// The function listed below permits the call of a dialogue as context menu to - /// select of an entry as a key - /// - /// It has the header \ref DialogContextMenu.h "#include " - /// be included to enjoy it. - /// - /// - namespace DialogContextMenu - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogContextMenu - /// @brief Show a context menu dialog about given parts. - /// - /// @param[in] heading Dialog heading name - /// @param[in] entries String list about entries - /// @return The selected entry, if return -1 was nothing selected or canceled - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// const std::vector entries - /// { - /// "Test 1", - /// "Test 2", - /// "Test 3", - /// "Test 4", - /// "Test 5" - /// }; - /// - /// int selected = kodi::gui::DialogContextMenu::Show("Test selection", entries); - /// if (selected < 0) - /// fprintf(stderr, "Item selection canceled\n"); - /// else - /// fprintf(stderr, "Selected item is: %i\n", selected); - /// ~~~~~~~~~~~~~ - /// - inline int 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**))); - 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); - free(cEntries); - return ret; - } - //-------------------------------------------------------------------------- - }; - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h deleted file mode 100644 index b6f2deb..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h +++ /dev/null @@ -1,244 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_CDialogExtendedProgress Dialog Extended Progress - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::CDialogExtendedProgress } - /// **Progress dialog shown for background work** - /// - /// The with \ref DialogExtendedProgress.h "#include " - /// given class are basically used to create Kodi's extended progress. - /// - /// - /// -------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// kodi::gui::CDialogExtendedProgress *ext_progress = new kodi::gui::CDialogExtendedProgress("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 CDialogExtendedProgress - { - public: - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_CDialogExtendedProgress - /// Construct a new dialog - /// - /// @param[in] title Title string - /// - CDialogExtendedProgress(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_CDialogExtendedProgress - /// Destructor - /// - ~CDialogExtendedProgress() - { - 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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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_CDialogExtendedProgress - /// @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 gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h deleted file mode 100644 index e348125..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h +++ /dev/null @@ -1,293 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogFileBrowser Dialog File Browser - /// \ingroup cpp_kodi_gui - /// @brief \cpp_namespace{ kodi::gui::DialogFileBrowser } - /// **File browser dialog** - /// - /// The functions listed below of the class "DialogFileBrowser" offer - /// the possibility to select to a file by the user of the add-on. - /// - /// It allows all the options that are possible in Kodi itself and offers all - /// support file types. - /// - /// It has the header \ref DialogFileBrowser.h "#include " - /// be included to enjoy it. - /// - namespace DialogFileBrowser - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief Directory selection dialog - /// - /// @param[in] shares With Shares becomes the available start folders - /// be set. - /// @param[in] heading Dialog header name - /// @param[in,out] path As in the path to start and return value about - /// selected directory - /// @param[in] writeOnly If set only writeable folders are shown. - /// @return False if selection becomes canceled. - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// /* - /// * Example show directory selection dialog with on 'share' (first value) - /// * defined directory types. - /// * - /// * If this becomes leaved empty and 'directory' is empty goes it to the - /// * base path of the hard disk. - /// * - /// * Also can be with path written to 'directory' before the dialog forced - /// * to a start place. - /// */ - /// std::string directory; - /// bool ret = kodi::gui::DialogFileBrowser::ShowAndGetDirectory("local|network|removable", - /// "Test directory selection", - /// directory, - /// false); - /// 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) - { - 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); - if (retString != nullptr) - { - if (std::strlen(retString)) - path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief File selection dialog - /// - /// @param[in] shares With Shares becomes the available start - /// folders be set. - /// @param[in] mask The mask to filter visible files, e.g. - /// ".m3u|.pls|.b4s|.wpl". - /// @param[in] heading Dialog header name - /// @param[in,out] path As in the path to start and Return value - /// about selected file - /// @param[in] useThumbs If set show thumbs if possible on dialog. - /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are - /// 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) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, - shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, - useThumbs, useFileDirectories); - if (retString != nullptr) - { - if (std::strlen(retString)) - path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief File selection from a directory - /// - /// @param[in] directory The directory name where the dialog - /// start, possible are normal names and - /// kodi's special names. - /// @param[in] mask The mask to filter visible files, e.g. - /// ".m3u|.pls|.b4s|.wpl". - /// @param[in] heading Dialog header name - /// @param[in,out] path As in the path to start and Return value - /// about selected file - /// @param[in] useThumbs If set show thumbs if possible on dialog. - /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are - /// handled as directories. - /// @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) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, - directory.c_str(), mask.c_str(), heading.c_str(), - path.c_str(), &retString, useThumbs, - useFileDirectories, singleList); - if (retString != nullptr) - { - if (std::strlen(retString)) - path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief File selection dialog to get several in to a list - /// - /// @param[in] shares With Shares becomes the available start - /// folders be set. - /// @param[in] mask The mask to filter visible files, e.g. - /// ".m3u|.pls|.b4s|.wpl". - /// @param[in] heading Dialog header name - /// @param[out] fileList Return value about selected files - /// @param[in] useThumbs If set show thumbs if possible on dialog. - /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are - /// 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) - { - using namespace ::kodi::addon; - char** list = nullptr; - unsigned int listSize = 0; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, - shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, - useThumbs, useFileDirectories); - if (ret) - { - for (unsigned int i = 0; i < listSize; ++i) - fileList.push_back(list[i]); - CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief Source selection dialog - /// - /// @param[in,out] path As in the path to start and Return value - /// about selected source - /// @param[in] allowNetworkShares Allow also access to network - /// @param[in] additionalShare With additionalShare becomes the available - /// start folders be set (optional). - /// @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 = "") - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, - allowNetworkShares, additionalShare.c_str(), type.c_str()); - if (retString != nullptr) - { - if (std::strlen(retString)) - path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief Image selection dialog - /// - /// @param[in] shares With Shares becomes the available start folders be - /// set. - /// @param[in] heading Dialog header name - /// @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) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, - shares.c_str(), heading.c_str(), path.c_str(), &retString); - if (retString != nullptr) - { - if (std::strlen(retString)) - path = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogFileBrowser - /// @brief Image selection dialog to get several in to a list - /// - /// @param[in] shares With Shares becomes the available start folders - /// be set. - /// @param[in] heading Dialog header name - /// @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) - { - using namespace ::kodi::addon; - char** list = nullptr; - unsigned int listSize = 0; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, - shares.c_str(), heading.c_str(), &list, &listSize); - if (ret) - { - for (unsigned int i = 0; i < listSize; ++i) - file_list.push_back(list[i]); - CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); - } - return ret; - } - //-------------------------------------------------------------------------- - }; - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h deleted file mode 100644 index 9261972..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h +++ /dev/null @@ -1,416 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogKeyboard Dialog Keyboard - /// \ingroup cpp_kodi_gui - /// @brief \cpp_namespace{ kodi::gui::DialogKeyboard } - /// **Keyboard dialogs** - /// - /// The functions listed below have to be permitted by the user for the - /// representation of a keyboard around an input. - /// - /// The class supports several kinds, from an easy text choice up to the - /// passport Word production and their confirmation for add-on. - /// - /// It has the header \ref DialogKeyboard.h "#include " - /// be included to enjoy it. - /// - namespace DialogKeyboard - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Show keyboard with initial value `text` and replace with result - /// string. - /// - /// @param[in,out] text Overwritten with user input if return=true. - /// @param[in] heading String shown on dialog title. - /// @param[in] allowEmptyResult Whether a blank password is valid or not. - /// @param[in] hiddenInput The inserted input is not shown as text. - /// @param[in] autoCloseMs To close the dialog after a specified - /// time, in milliseconds, default is 0 which - /// keeps the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// /* - /// * The example shows the display of keyboard call dialog at Kodi from the add-on. - /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) - /// * to be released if not needed. - /// */ - /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a - /// entry text added */ - /// bool bRet = ::kodi::gui::DialogKeyboard::ShowAndGetInput(text, - /// "Demonstration text entry", - /// true, - /// false, - /// 0); - /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", - /// 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) - { - 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); - if (retString != nullptr) - { - if (std::strlen(retString)) - text = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief The example shows the display of keyboard call dialog at Kodi - /// from the add-on. - /// - /// @param[out] text Overwritten with user input if return=true. - /// @param[in] allowEmptyResult If set to true keyboard can also exited - /// without entered text. - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, - text.c_str(), &retString, - allowEmptyResult, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - text = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Shows keyboard and prompts for a password. Differs from - /// `ShowAndVerifyNewPassword()` in that no second verification - /// - /// @param[in,out] newPassword Overwritten with user input if return=true. - /// @param[in] heading String shown on dialog title. - /// @param[in] allowEmptyResult Whether a blank password is valid or not. - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// 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) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, - newPassword.c_str(), &retString, heading.c_str(), - allowEmptyResult, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - newPassword = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Shows keyboard and prompts for a password. Differs from - /// `ShowAndVerifyNewPassword()` in that no second verification - /// - /// @param[in,out] newPassword Overwritten with user input if return=true. - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, - newPassword.c_str(), &retString, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - newPassword = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Show keyboard twice to get and confirm a user-entered password - /// string. - /// - /// @param[out] newPassword Overwritten with user input if return=true. - /// @param[in] heading String shown on dialog title. - /// @param[in] allowEmptyResult - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// #include - /// - /// /* - /// * The example below shows the complete use of keyboard dialog for password - /// * check. If only one check from add-on needed can be function with retries - /// * set to '0' called alone. - /// * - /// * The use of MD5 translated password is always required for the check on Kodi! - /// */ - /// - /// int maxretries = 3; - /// /* - /// * Password names need to be send as md5 sum to kodi. - /// */ - /// std::string password; - /// kodi::GetMD5("kodi", password); - /// - /// /* - /// * To the loop about password checks. - /// */ - /// int ret; - /// for (unsigned int i = 0; i < maxretries; i++) - /// { - /// /* - /// * Ask the user about the password. - /// */ - /// ret = ::kodi::gui::DialogKeyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); - /// if (ret == 0) - /// { - /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); - /// break; - /// } - /// else if (ret < 0) - /// { - /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); - /// break; - /// } - /// else /* if (ret > 0) */ - /// { - /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); - /// } - /// } - /// ~~~~~~~~~~~~~ - /// - inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, - &retString, heading.c_str(), allowEmptyResult, - autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - newPassword = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Show keyboard twice to get and confirm a user-entered password - /// string. - /// - /// @param[out] newPassword Overwritten with user input if return=true. - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, - &retString, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - newPassword = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Show keyboard and verify user input against `password`. - /// - /// @param[in,out] password Value to compare against user input. - /// @param[in] heading String shown on dialog title. - /// @param[in] retries If greater than 0, shows "Incorrect - /// password, %d retries left" on dialog line 2, - /// else line 2 is blank. - /// @param[in] autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return 0 if successful display and user input. 1 if - /// 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) - { - using namespace ::kodi::addon; - char* retString = nullptr; - int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, - password.c_str(), &retString, heading.c_str(), - retries, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - password = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Shows a filter related keyboard - /// - /// @param[in,out] text Overwritten with user input if return=true. - /// @param[in] searching Use dialog for search and send our search - /// message in safe way (only the active window - /// needs it) - /// - header name if true is "Enter search string" - /// - header name if false is "Enter value" - /// @param autoCloseMs To close the dialog after a specified time, - /// in milliseconds, default is 0 which keeps - /// the dialog open indefinitely. - /// @return true if successful display and user input. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, - text.c_str(), &retString, searching, autoCloseMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - text = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Send a text to a visible keyboard - /// - /// @param[in] text Overwritten with user input if return=true. - /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. - /// @return true if successful done, false if - /// unsuccessful or keyboard not present. - /// - inline bool 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, - text.c_str(), closeKeyboard); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogKeyboard - /// @brief Check for visible keyboard on GUI - /// - /// @return true if keyboard present, false if not present - /// - inline bool IsKeyboardActivated() - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); - } - //-------------------------------------------------------------------------- - }; - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h deleted file mode 100644 index 8b5c592..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h +++ /dev/null @@ -1,366 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogNumeric Dialog Numeric - /// \ingroup cpp_kodi_gui - /// @{ - /// @brief \cpp_namespace{ kodi::gui::DialogNumeric } - /// **Numeric dialogs** - /// - /// The functions listed below have to be permitted by the user for the - /// representation of a numeric keyboard around an input. - /// - /// The class supports several kinds, from an easy number choice up to the - /// passport Word production and their confirmation for add-on. - /// - /// It has the header \ref DialogNumeric.h "#include " - /// be included to enjoy it. - /// - namespace DialogNumeric - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to get numeric new password - /// - /// @param[out] newPassword String to preload into the keyboard - /// accumulator. Overwritten with user input - /// if return=true. Returned in MD5 format. - /// @return true if successful display and user - /// input entry/re-entry. - /// false if unsuccessful display, no user - /// input, or canceled editing. - /// - inline bool 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); - if (pw != nullptr) - { - if (std::strlen(pw)) - newPassword = pw; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to verify numeric password. - /// - /// @param[in] password Password to compare with user input, need - /// in MD5 format. - /// @param[in] heading Heading to display - /// @param[in] retries If greater than 0, shows "Incorrect - /// password, %d retries left" on dialog - /// line 2, else line 2 is blank. - /// @return Possible values: - /// - 0 if successful display and user input. - /// - 1 if unsuccessful input. - /// - -1 if no user input or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include /* fprintf */ - /// #include - /// #include - /// - /// /* - /// * The example below shows the complete use of keyboard dialog for password - /// * check. If only one check from add-on needed can be function with retries - /// * set to '0' called alone. - /// * - /// * The use of MD5 translated password is always required for the check on Kodi! - /// */ - /// - /// int maxretries = 3; - /// - /// /* - /// * Password names need to be send as md5 sum to kodi. - /// */ - /// std::string password = kodi::GetMD5("1234"); - /// - /// /* - /// * To the loop about password checks. - /// */ - /// int ret; - /// for (unsigned int i = 0; i < maxretries; i++) - /// { - /// /* - /// * Ask the user about the password. - /// */ - /// ret = kodi::gui::DialogNumeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); - /// if (ret == 0) - /// { - /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); - /// break; - /// } - /// else if (ret < 0) - /// { - /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); - /// break; - /// } - /// else /* if (ret > 0) */ - /// { - /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); - /// } - /// } - /// ~~~~~~~~~~~~~ - /// - inline int 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, - password.c_str(), heading.c_str(), retries); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to verify numeric password - /// - /// @param[in,out] toVerify Value to compare against user input. - /// @param[in] heading Heading to display - /// @param[in] verifyInput If set as true we verify the users input - /// versus toVerify. - /// @return true if successful display and user - /// input. false if unsuccessful display, no - /// user input, or canceled editing. - /// - inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, - toVerify.c_str(), &retString, heading.c_str(), verifyInput); - if (retString != nullptr) - { - if (std::strlen(retString)) - toVerify = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to get time value. - /// - /// @param[out] time Overwritten with user input if - /// return=true and time inserted. - /// @param[in] heading Heading to display. - /// @return true if successful display and user - /// input. false if unsuccessful display, no - /// user input, or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include /* printf */ - /// #include /* time_t, struct tm, time, localtime, strftime */ - /// #include - /// - /// time_t rawtime; - /// struct tm * timeinfo; - /// char buffer [10]; - /// - /// time (&rawtime); - /// timeinfo = localtime(&rawtime); - /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetTime(*timeinfo, "Selected time test call"); - /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); - /// 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) - { - 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()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to get date value. - /// - /// @param[in,out] date Overwritten with user input if - /// return=true and date inserted. - /// @param[in] heading Heading to display - /// @return true if successful display and user - /// input. false if unsuccessful display, no - /// user input, or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include /* printf */ - /// #include /* time_t, struct tm, time, localtime, strftime */ - /// #include - /// - /// time_t rawtime; - /// struct tm * timeinfo; - /// char buffer [20]; - /// - /// time (&rawtime); - /// timeinfo = localtime(&rawtime); - /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetDate(*timeinfo, "Selected date test call"); - /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); - /// 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) - { - 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()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to get a IP - /// - /// @param[in,out] ipAddress Overwritten with user input if - /// return=true and IP address inserted. - /// @param[in] heading Heading to display. - /// @return true if successful display and - /// user input. false if unsuccessful - /// display, no user input, or canceled - /// editing. - /// - inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, - ipAddress.c_str(), &retString, heading.c_str()); - if (retString != nullptr) - { - if (std::strlen(retString)) - ipAddress = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Use dialog to get normal number. - /// - /// @param[in,out] input Overwritten with user input if - /// return=true and time in seconds inserted - /// @param[in] heading Heading to display - /// @param[in] autoCloseTimeoutMs To close the dialog after a specified - /// time, in milliseconds, default is 0 - /// which keeps the dialog open - /// indefinitely. - /// @return true if successful display and user - /// input. false if unsuccessful display, no - /// user input, or canceled editing. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include /* printf */ - /// #include /* strtoull (C++11) */ - /// #include - /// - /// std::string number; - /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetNumber(number, "Number test call"); - /// printf("Written number input is : %llu and was %s\n", - /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); - /// ~~~~~~~~~~~~~ - /// - inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, - input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); - if (retString != nullptr) - { - if (std::strlen(retString)) - input = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogNumeric - /// @brief Show numeric keypad to get seconds. - /// - /// @param[in,out] time Overwritten with user input if return=true and - /// time in seconds inserted. - /// @param[in] heading Heading to display - /// @return true if successful display and user input. false - /// if unsuccessful display, no user input, or - /// canceled editing. - /// - inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) - { - using namespace ::kodi::addon; - char* retString = nullptr; - bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, - time.c_str(), &retString, heading.c_str()); - if (retString != nullptr) - { - if (std::strlen(retString)) - time = retString; - CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); - } - return ret; - } - //-------------------------------------------------------------------------- - }; - /// @} - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h deleted file mode 100644 index fa98241..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h +++ /dev/null @@ -1,104 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "../AddonBase.h" -#include "definitions.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogOK Dialog OK - /// \ingroup cpp_kodi_gui - /// @{ - /// @brief \cpp_namespace{ kodi::gui::DialogOK } - /// **OK dialog** - /// - /// The functions listed below permit the call of a dialogue of information, a - /// confirmation of the user by press from OK required. - /// - /// It has the header \ref DialogOK.h "#include " - /// be included to enjoy it. - /// - namespace DialogOK - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogOK - /// @brief Use dialog to inform user with text and confirmation with OK with continued string. - /// - /// @param[in] heading Dialog heading. - /// @param[in] text Multi-line text. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// ... - /// kodi::gui::DialogOK::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) - { - 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()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogOK - /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. - /// - /// @param[in] heading Dialog heading. - /// @param[in] line0 Line #1 text. - /// @param[in] line1 Line #2 text. - /// @param[in] line2 Line #3 text. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// ... - /// kodi::gui::DialogOK::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) - { - using namespace ::kodi::addon; - CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, - heading.c_str(), line0.c_str(), line1.c_str(), - line2.c_str()); - } - //-------------------------------------------------------------------------- - } - /// @} - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h deleted file mode 100644 index e652644..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h +++ /dev/null @@ -1,249 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_CDialogProgress Dialog Progress - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::CDialogProgress } - /// **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::CDialogProgress *progress = new kodi::gui::CDialogProgress; - /// 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 CDialogProgress - { - public: - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_CDialogProgress - /// @brief Construct a new dialog - /// - CDialogProgress() - { - 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::CDialogProgress can't create window class from Kodi !!!"); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_CDialogProgress - /// @brief Destructor - /// - ~CDialogProgress() - { - 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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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_CDialogProgress - /// @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; - }; - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h deleted file mode 100644 index 36433db..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h +++ /dev/null @@ -1,101 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogSelect Dialog Select - /// \ingroup cpp_kodi_gui - /// @{ - /// @brief \cpp_namespace{ kodi::gui::DialogSelect } - /// **Selection dialog** - /// - /// The function listed below permits the call of a dialogue to select of an - /// entry as a key - /// - /// It has the header \ref DialogSelect.h "#include " - /// be included to enjoy it. - /// - /// - namespace DialogSelect - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogSelect - /// @brief Show a selection dialog about given parts. - /// - /// @param[in] heading Dialog heading name - /// @param[in] entries String list about entries - /// @param[in] selected [opt] Predefined selection (default is - /// -1 for the first) - /// @param[in] autoclose [opt] To close dialog automatic after a time - /// @return The selected entry, if return -1 was - /// nothing selected or canceled - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// const std::vector entries - /// { - /// "Test 1", - /// "Test 2", - /// "Test 3", - /// "Test 4", - /// "Test 5" - /// }; - /// - /// int selected = kodi::gui::DialogSelect::Show("Test selection", entries, -1); - /// if (selected < 0) - /// fprintf(stderr, "Item selection canceled\n"); - /// else - /// fprintf(stderr, "Selected item is: %i\n", selected); - /// ~~~~~~~~~~~~~ - /// - inline int Show(const std::string& heading, const std::vector& entries, int selected = -1, bool autoclose = false) - { - using namespace ::kodi::addon; - unsigned int size = 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); - free(cEntries); - return ret; - } - //-------------------------------------------------------------------------- - }; - /// @} - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h deleted file mode 100644 index 09c81bd..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h +++ /dev/null @@ -1,115 +0,0 @@ -#pragma once -/* - * Copyright (C) 2015-2016 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogTextViewer Dialog Text Viewer - /// \ingroup cpp_kodi_gui - /// @{ - /// @brief \cpp_namespace{ kodi::gui::DialogTextViewer } - /// **Text viewer dialog** - /// - /// The text viewer dialog can be used to display descriptions, help texts or - /// other larger texts. - /// - /// In order to achieve a line break is a \\n directly in the text or - /// in the "./resources/language/resource.language.??_??/strings.po" - /// to call with std::string kodi::general::GetLocalizedString(...);. - /// - /// It has the header \ref DialogTextViewer.h "#include " - /// be included to enjoy it. - /// - namespace DialogTextViewer - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogTextViewer - /// @brief Show info text dialog - /// - /// @param[in] heading Small heading text - /// @param[in] text Showed text on dialog - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// kodi::gui::DialogTextViewer::Show("The Wizard of Oz (1939 film)", - /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " - /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " - /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " - /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" - /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " - /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " - /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" - /// "\n" - /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " - /// "unusual characters, over the years it has become an icon of American popular " - /// "culture. It was nominated for six Academy Awards, including Best Picture but " - /// "lost to Gone with the Wind. It did win in two other categories including Best " - /// "Original Song for \"Over the Rainbow\". However, the film was a box office " - /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " - /// "budget, despite receiving largely positive reviews. It was MGM's most " - /// "expensive production at that time, and did not completely recoup the studio's " - /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" - /// "\n" - /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " - /// "film to the wider public and eventually made the presentation an annual " - /// "tradition, making it one of the most known films in cinema history. The " - /// "film was named the most-viewed motion picture on television syndication by " - /// "the Library of Congress who also included the film in its National Film " - /// "Registry in its inaugural year in 1989. Designation on the registry calls " - /// "for efforts to preserve it for being \"culturally, historically, and " - /// "aesthetically significant\". It is also one of the few films on UNESCO's " - /// "Memory of the World Register.\n" - /// "\n" - /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " - /// "polls. It is the source of many quotes referenced in modern popular culture. " - /// "It was directed primarily by Victor Fleming (who left production to take " - /// "over direction on the troubled Gone with the Wind production). Noel Langley, " - /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " - /// "but there were uncredited contributions by others. The songs were written " - /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " - /// "music, based largely on the songs, was composed by Herbert Stothart, with " - /// "interspersed renderings from classical composers.\n"); - /// ~~~~~~~~~~~~~ - /// - inline void 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()); - } - //-------------------------------------------------------------------------- - }; - /// @} - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h deleted file mode 100644 index 064bf8c..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h +++ /dev/null @@ -1,187 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2017 Team KODI - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with KODI; see the file COPYING. If not, see - * . - * - */ - -#include "definitions.h" -#include "../AddonBase.h" - -namespace kodi -{ -namespace gui -{ - - //============================================================================ - /// - /// \defgroup cpp_kodi_gui_DialogYesNo Dialog Yes/No - /// \ingroup cpp_kodi_gui - /// @{ - /// @brief \cpp_namespace{ kodi::gui::DialogYesNo } - /// **Yes / No dialog** - /// - /// The Yes / No dialog can be used to inform the user about questions and get - /// the answer. - /// - /// In order to achieve a line break is a \\n directly in the text or - /// in the "./resources/language/resource.language.??_??/strings.po" - /// to call with std::string kodi::general::GetLocalizedString(...);. - /// - /// It has the header \ref DialogYesNo.h "#include " - /// be included to enjoy it. - /// - /// - namespace DialogYesNo - { - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogYesNo - /// @brief Use dialog to get numeric new password with one text string shown - /// everywhere and cancel return field - /// - /// @param[in] heading Dialog heading - /// @param[in] text Multi-line text - /// @param[out] canceled Return value about cancel button - /// @param[in] noLabel [opt] label to put on the no button - /// @param[in] yesLabel [opt] label to put on the yes button - /// @return Returns True if 'Yes' was pressed, else False - /// - /// @note It is preferred to only use this as it is actually a multi-line text. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// bool canceled; - /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( - /// "Yes / No test call", /* The Header */ - /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", - /// canceled, /* return value about cancel button */ - /// "Not really", /* No label, is optional and if empty "No" */ - /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ - /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", - /// ret ? "yes" : "no", - /// 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 = "") - { - 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()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogYesNo - /// @brief Use dialog to get numeric new password with separated line strings - /// - /// @param[in] heading Dialog heading - /// @param[in] line0 Line #0 text - /// @param[in] line1 Line #1 text - /// @param[in] line2 Line #2 text - /// @param[in] noLabel [opt] label to put on the no button. - /// @param[in] yesLabel [opt] label to put on the yes button. - /// @return Returns True if 'Yes' was pressed, else False. - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( - /// "Yes / No test call", // The Header - /// "You has opened Yes / No dialog for test", - /// "", - /// "Is this OK for you?", - /// "Not really", // No label, is optional and if empty "No" - /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" - /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", - /// 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 = "") - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, - heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), - noLabel.c_str(), yesLabel.c_str()); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_DialogYesNo - /// @brief Use dialog to get numeric new password with separated line strings and cancel return field - /// - /// @param[in] heading Dialog heading - /// @param[in] line0 Line #0 text - /// @param[in] line1 Line #1 text - /// @param[in] line2 Line #2 text - /// @param[out] canceled Return value about cancel button - /// @param[in] noLabel [opt] label to put on the no button - /// @param[in] yesLabel [opt] label to put on the yes button - /// @return Returns True if 'Yes' was pressed, else False - /// - /// - ///------------------------------------------------------------------------- - /// - /// **Example:** - /// ~~~~~~~~~~~~~{.cpp} - /// #include - /// - /// bool canceled; - /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( - /// "Yes / No test call", // The Header - /// "You has opened Yes / No dialog for test", - /// "", - /// "Is this OK for you?", - /// canceled, // return value about cancel button - /// "Not really", // No label, is optional and if empty "No" - /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" - /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", - /// ret ? "yes" : "no", - /// 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 = "") - { - using namespace ::kodi::addon; - return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, - heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), - &canceled, noLabel.c_str(), yesLabel.c_str()); - } - //-------------------------------------------------------------------------- - }; - /// @} - -} /* namespace gui */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h index a473f28..944b1b9 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 @@ -91,20 +91,18 @@ namespace gui /// @param[in] label Item label /// @param[in] label2 Second Item label (if needed) /// @param[in] iconImage Item icon image (if needed) - /// @param[in] thumbnailImage Thumbnail Image of item (if needed) /// @param[in] path Path to where item is defined /// CListItem( const std::string& label = "", const std::string& label2 = "", const std::string& iconImage = "", - const std::string& thumbnailImage = "", const std::string& path = "") : CAddonGUIControlBase(nullptr) { m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), label2.c_str(), iconImage.c_str(), - thumbnailImage.c_str(), path.c_str()); + path.c_str()); } /* @@ -124,7 +122,7 @@ namespace gui /// \ingroup cpp_kodi_gui_CListItem /// @brief Class destructor /// - virtual ~CListItem() + ~CListItem() override { m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); } @@ -330,6 +328,86 @@ namespace gui } //-------------------------------------------------------------------------- + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets a listitem property, similar to an infolabel. + /// + /// @param[in] key string - property name. + /// @param[in] value string or unicode - value of property. + /// + /// @note Key is NOT case sensitive. + /// You can use the above as keywords for arguments and skip certain\n + /// optional arguments.\n + /// Once you use a keyword, all following arguments require the + /// keyword. + /// + /// Some of these are treated internally by Kodi, such as the + /// 'StartOffset' property, which is the offset in seconds at which to + /// start playback of an item. Others may be used in the skin to add + /// extra information, such as 'WatchedCount' for tvshow items + /// + void SetProperty(const std::string& key, const std::string& value) + { + m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Returns a listitem property as a string, similar to an infolabel. + /// + /// @param[in] key string - property name. + /// @return string - List item property + /// + /// @note Key is NOT case sensitive.\n + /// You can use the above as keywords for arguments and skip certain + /// optional arguments.\n + /// Once you use a keyword, all following arguments require the + /// keyword. + /// + std::string GetProperty(const std::string& key) + { + std::string label; + char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief To control selection of item in list (also multiple selection, + /// in list on serveral items possible). + /// + /// @param[in] selected if true becomes set as selected + /// + void Select(bool selected) + { + m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Returns the listitem's selected status. + /// + /// @return true if selected, otherwise false + /// + bool IsSelected() + { + return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + }; } /* namespace gui */ 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 7069e63..b78585f 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 @@ -110,7 +110,7 @@ namespace gui /// /// /// - virtual ~CWindow() + ~CWindow() override { if (m_controlHandle) m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); @@ -163,6 +163,232 @@ namespace gui } //-------------------------------------------------------------------------- + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Gives the control with the supplied focus. + /// + /// @param[in] iControlId On skin defined id of control + /// @return Return true if call and focus is successed, + /// if false was something failed to get needed + /// skin parts. + /// + /// + bool SetFocusId(int iControlId) + { + return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle, iControlId); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Returns the id of the control which is focused. + /// + /// @return Focused control id + /// + /// + int GetFocusId() + { + return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To set the used label on given control id + /// + /// @param[in] controlId Control id where label need to set + /// @param[in] label Label to use + /// + /// + void SetControlLabel(int controlId, const std::string& label) + { + m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle, controlId, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets a window property, similar to an infolabel. + /// + /// @param[in] key string - property name. + /// @param[in] value string or unicode - value of property. + /// + /// @note Key is NOT case sensitive. Setting value to an empty string is + /// equivalent to clearProperty(key).\n + /// You can use the above as keywords for arguments and skip certain + /// optional arguments.\n + /// Once you use a keyword, all following arguments require the keyword. + /// + void SetProperty(const std::string& key, const std::string& value) + { + m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Returns a window property as a string, similar to an infolabel. + /// + /// @param[in] key string - property name. + /// @return The property as strin (if present) + /// + /// @note Key is NOT case sensitive. Setting value to an empty string is + /// equivalent to clearProperty(key).\n + /// You can use the above as keywords for arguments and skip certain + /// optional arguments.\n + /// Once you use a keyword, all following arguments require the keyword. + /// + /// + std::string GetProperty(const std::string& key) const + { + std::string label; + char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle, key.c_str()); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets a window property with integer value + /// + /// @param[in] key string - property name. + /// @param[in] value integer value to set + /// + /// + void SetPropertyInt(const std::string& key, int value) + { + m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle, key.c_str(), value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Returns a window property with integer value + /// + /// @param[in] key string - property name. + /// @return integer value of property + /// + int GetPropertyInt(const std::string& key) const + { + return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle, key.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets a window property with boolean value + /// + /// @param[in] key string - property name. + /// @param[in] value boolean value to set + /// + /// + void SetPropertyBool(const std::string& key, bool value) + { + m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str(), value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Returns a window property with boolean value + /// + /// @param[in] key string - property name. + /// @return boolean value of property + /// + bool GetPropertyBool(const std::string& key) const + { + return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle, key.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets a window property with double value + /// + /// @param[in] key string - property name. + /// @param[in] value double value to set + /// + /// + void SetPropertyDouble(const std::string& key, double value) + { + m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle, key.c_str(), value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Returns a window property with double value + /// + /// @param[in] key string - property name. + /// @return double value of property + /// + /// + double GetPropertyDouble(const std::string& key) const + { + return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase, m_controlHandle, key.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Remove all present properties from window + /// + /// + /// + void ClearProperties() + { + m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Clears the specific window property. + /// + /// @param[in] key string - property name. + /// + /// @note Key is NOT case sensitive. Equivalent to SetProperty(key, "") + /// You can use the above as keywords for arguments and skip certain + /// optional arguments. + /// Once you use a keyword, all following arguments require the + /// keyword. + /// + /// + ///----------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// .. + /// ClearProperty('Category') + /// .. + /// ~~~~~~~~~~~~~ + /// + void ClearProperty(const std::string& key) + { + m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle, key.c_str()); + } + //-------------------------------------------------------------------------- + + //@{ //========================================================================== /// /// \ingroup cpp_kodi_gui_CWindow @@ -206,6 +432,34 @@ namespace gui } //-------------------------------------------------------------------------- + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Remove list item on position. + /// + /// @param[in] itemPosition List position to remove + /// + /// + void RemoveListItem(int itemPosition) + { + m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase, m_controlHandle, itemPosition); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Remove item with given control class from list. + /// + /// @param[in] item List item control class to remove + /// + /// + void RemoveListItem(ListItemPtr item) + { + m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle); + } + //-------------------------------------------------------------------------- + //========================================================================== /// /// \ingroup cpp_kodi_gui_CWindow @@ -226,6 +480,135 @@ namespace gui } //-------------------------------------------------------------------------- + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To set position of selected part in list. + /// + /// @param[in] listPos Position to use + /// + /// + void SetCurrentListPosition(int listPos) + { + m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle, listPos); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To get current selected position in list + /// + /// @return Current list position + /// + /// + int GetCurrentListPosition() + { + return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To get the amount of entries in the list. + /// + /// @return Size of in window integrated control class + /// + /// + int GetListSize() + { + return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets a container property, similar to an infolabel. + /// + /// @param[in] key string - property name. + /// @param[in] value string or unicode - value of property. + /// + /// @note Key is NOT case sensitive.\n + /// You can use the above as keywords for arguments and skip certain + /// optional arguments.\n + /// Once you use a keyword, all following arguments require the keyword. + /// + /// + void SetContainerProperty(const std::string& key, const std::string& value) + { + m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle, key.c_str(), value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Sets the content type of the container. + /// + /// @param[in] value string or unicode - content value. + /// + /// __Available content types__ + /// | Name | Media | + /// |:-----------:|:-----------------------------------------| + /// | actors | Videos + /// | addons | Addons, Music, Pictures, Programs, Videos + /// | albums | Music, Videos + /// | artists | Music, Videos + /// | countries | Music, Videos + /// | directors | Videos + /// | files | Music, Videos + /// | games | Games + /// | genres | Music, Videos + /// | images | Pictures + /// | mixed | Music, Videos + /// | movies | Videos + /// | Musicvideos | Music, Videos + /// | playlists | Music, Videos + /// | seasons | Videos + /// | sets | Videos + /// | songs | Music + /// | studios | Music, Videos + /// | tags | Music, Videos + /// | tvshows | Videos + /// | videos | Videos + /// | years | Music, Videos + /// + /// + void SetContainerContent(const std::string& value) + { + m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle, value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Get the id of the currently visible container. + /// + /// @return currently visible container id + /// + /// + int GetCurrentContainerId() + { + return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + //@} + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To inform Kodi that it need to render region new. + /// + /// + void MarkDirtyRegion() + { + return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + //========================================================================== // /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h new file mode 100644 index 0000000..5892d24 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Button.h @@ -0,0 +1,176 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CButton Control Button + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CButton } + /// **Standard push button control for window** + /// + /// The button control is used for creating push buttons in Kodi. You can + /// choose the position, size, and look of the button, as well as choosing + /// what action(s) should be performed when pushed. + /// + /// It has the header \ref Button.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref skin_Button_control "button control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CButton : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CButton(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_button(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Destructor + /// + ~CButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief To set the text string on button + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Get the used text from button + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief If two labels are used for button becomes it set with them + /// + /// @param[in] label Text for second label + /// + void SetLabel2(const std::string& label) + { + m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// @ingroup cpp_kodi_gui_control_CButton + /// @brief Get the second label if present + /// + /// @return Second label + /// + std::string GetLabel2() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h new file mode 100644 index 0000000..83eeede --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Edit.h @@ -0,0 +1,276 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CEdit Control Edit + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CEdit } + /// **Editable window text control used as an input control for the osd keyboard + /// and other input fields** + /// + /// The edit control allows a user to input text in Kodi. You can choose the + /// font, size, colour, location and header of the text to be displayed. + /// + /// It has the header \ref Edit.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref skin_Edit_control + /// "edit control". + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + + //============================================================================ + // see gui/definition.h for use of group "cpp_kodi_gui_controls_CEdit_Defs" + /// + /// \defgroup cpp_kodi_gui_controls_CEdit_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief **Library definition values** + /// + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ + +//============================================================================ +/// +/// \ingroup cpp_kodi_gui_controls_CEdit_Defs +/// @{ +/// @anchor AddonGUIInputType +/// @brief Text input types used on kodi::gui::controls::CEdit +enum AddonGUIInputType +{ + /// Text inside edit control only readable + ADDON_INPUT_TYPE_READONLY = -1, + /// Normal text entries + ADDON_INPUT_TYPE_TEXT = 0, + /// To use on edit control only numeric numbers + ADDON_INPUT_TYPE_NUMBER, + /// To insert seconds + ADDON_INPUT_TYPE_SECONDS, + /// To insert time + ADDON_INPUT_TYPE_TIME, + /// To insert a date + ADDON_INPUT_TYPE_DATE, + /// Used for write in IP addresses + ADDON_INPUT_TYPE_IPADDRESS, + /// Text field used as password entry field with not visible text + ADDON_INPUT_TYPE_PASSWORD, + /// Text field used as password entry field with not visible text but + /// returned as MD5 value + ADDON_INPUT_TYPE_PASSWORD_MD5, + /// Use text field for search purpose + ADDON_INPUT_TYPE_SEARCH, + /// Text field as filter + ADDON_INPUT_TYPE_FILTER, + /// + ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW +}; +/// @} +//---------------------------------------------------------------------------- + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + class CEdit : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CEdit(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_edit(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::control::CEdit can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Destructor + /// + ~CEdit() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief To set the text string on edit control + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Returns the text heading for this edit control. + /// + /// @return Heading text + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Set's text heading for this edit control. + /// + /// @param[in] text string or unicode - text string. + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Returns the text value for this edit control. + /// + /// @return Text value of control + /// + std::string GetText() const + { + std::string text; + char* ret = m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief Set the cursor position on text. + /// + /// @param[in] iPosition The position to set + /// + void SetCursorPosition(unsigned int iPosition) + { + m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle, iPosition); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief To get current cursor position on text field + /// + /// @return The current cursor position + /// + unsigned int GetCursorPosition() + { + return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CEdit + /// @brief To set field input type which are defined on \ref AddonGUIInputType + /// + /// @param[in] type The \ref AddonGUIInputType "Add-on input type" + /// to use + /// @param[in] heading The heading text for related keyboard + /// dialog + /// + void SetInputType(AddonGUIInputType type, const std::string& heading) + { + m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle, static_cast(type), heading.c_str()); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h new file mode 100644 index 0000000..82d17ff --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/FadeLabel.h @@ -0,0 +1,159 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CFadeLabel Control Fade Label + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CFadeLabel } + /// **Window control used to show multiple pieces of text in the same position, + /// by fading from one to the other** + /// + /// The fade label control is used for displaying multiple pieces of text in + /// the same space in Kodi. You can choose the font, size, colour, location + /// and contents of the text to be displayed. The first piece of information + /// to display fades in over 50 frames, then scrolls off to the left. Once it + /// is finished scrolling off screen, the second piece of information fades + /// in and the process repeats. A fade label control is not supported in a + /// list container. + /// + /// It has the header \ref FadeLabel.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Fade_Label_Control "fade label control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CFadeLabel : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Construct a new control. + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CFadeLabel(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Destructor. + /// + ~CFadeLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Set the control on window to visible. + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief To add additional text string on fade label. + /// + /// @param[in] label Text to show + /// + void AddLabel(const std::string& label) + { + m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief Get the used text from button + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief To enable or disable scrolling on fade label + /// + /// @param[in] scroll To enable scrolling set to true, otherwise is + /// disabled + /// + void SetScrolling(bool scroll) + { + m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle, scroll); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CFadeLabel + /// @brief To reset al inserted labels. + /// + void Reset() + { + m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h new file mode 100644 index 0000000..1179fab --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Image.h @@ -0,0 +1,123 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CImage Control Image + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CImage } + /// **Window control used to show an image.** + /// + /// The image control is used for displaying images in Kodi. You can choose + /// the position, size, transparency and contents of the image to be displayed. + /// + /// It has the header \ref Image.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Image_Control "image control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CImage : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CImage(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_image(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CImage can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Destructor + /// + ~CImage() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief To set the filename used on image control. + /// + /// @param[in] filename Image file to use + /// @param[in] useCache To define storage of image, default is + /// in cache, if false becomes it loaded + /// always on changes again + /// + void SetFileName(const std::string& filename, bool useCache = true) + { + m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle, filename.c_str(), useCache); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CImage + /// @brief To set set the diffuse color on image. + /// + /// @param[in] colorDiffuse Color to use for diffuse + /// + void SetColorDiffuse(uint32_t colorDiffuse) + { + m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle, colorDiffuse); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h new file mode 100644 index 0000000..f74ac03 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h @@ -0,0 +1,128 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CLabel Control Label + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CLabel } + /// **Window control used to show some lines of text.** + /// + /// The label control is used for displaying text in Kodi. You can choose + /// the font, size, colour, location and contents of the text to be displayed. + /// + /// It has the header \ref Label.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Label_Control "label control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CLabel : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CLabel(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_label(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Destructor + /// + ~CLabel() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief To set the text string on label + /// + /// @param[in] text Text to show + /// + void SetLabel(const std::string& text) + { + m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CLabel + /// @brief Get the used text from control + /// + /// @return Used text on label control + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h new file mode 100644 index 0000000..44310ed --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Progress.h @@ -0,0 +1,121 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CProgress Control Progress + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CProgress } + /// **Window control to show the progress of a particular operation** + /// + /// The progress control is used to show the progress of an item that may take + /// a long time, or to show how far through a movie you are. You can choose + /// the position, size, and look of the progress control. + /// + /// It has the header \ref Progress.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Progress_Control "progress control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CProgress : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CProgress(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_progress(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CProgress can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Destructor + /// + ~CProgress() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief To set Percent position of control + /// + /// @param[in] percent The percent position to use + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle, percent); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CProgress + /// @brief Get the active percent position of progress bar + /// + /// @return Progress position as percent + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h new file mode 100644 index 0000000..b87920d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h @@ -0,0 +1,171 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CRadioButton } + /// **Window control for a radio button (as used for on/off settings)** + /// + /// The radio button control is used for creating push button on/off settings + /// in Kodi. You can choose the position, size, and look of the button. When + /// the user clicks on the radio button, the state will change, toggling the + /// extra textures (textureradioon and textureradiooff). Used for settings + /// controls. + /// + /// It has the header \ref RadioButton.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Radio_button_control "radio button control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CRadioButton : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CRadioButton(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Destructor + /// + ~CRadioButton() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief To set the text string on radio button + /// + /// @param[in] label Text to show + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Get the used text from control + /// + /// @return Text shown + /// + std::string GetLabel() const + { + std::string label; + char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief To set radio button condition to on or off + /// + /// @param[in] selected true set radio button to selection on, otherwise + /// off + /// + void SetSelected(bool selected) + { + m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, m_controlHandle, selected); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRadioButton + /// @brief Get the current selected condition of radio button + /// + /// @return Selected condition + /// + bool IsSelected() const + { + return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h new file mode 100644 index 0000000..f80fcfa --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h @@ -0,0 +1,215 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CRendering } + /// **Window control for rendering own parts** + /// + /// This rendering control is used when own parts are needed. You have the + /// control over them to render direct OpenGL or DirectX content to the + /// screen set by the size of them. + /// + /// Alternative can be the virtual functions from t his been ignored if the + /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and + /// class is used as single and not as a parent class. + /// + /// It has the header \ref Rendering.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief **Library definition values** + /// + + class CRendering : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CRendering(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (m_controlHandle) + m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, this, + OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); + else + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", __FUNCTION__); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Destructor + /// + ~CRendering() override + { + m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief To create rendering control on Add-on + /// + /// Function creates the needed rendering control for Kodi which becomes + /// handled and processed from Add-on + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + /// @param[in] x Horizontal position + /// @param[in] y Vertical position + /// @param[in] w Width of control + /// @param[in] h Height of control + /// @param[in] device The device to use. For OpenGL is empty + /// on Direct X is the needed device send. + /// @return Add-on needs to return true if successed, + /// otherwise false. + /// + virtual bool Create(int x, int y, int w, int h, void* device) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Render process call from Kodi + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual void Render() { } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Call from Kodi to stop rendering process + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual void Stop() { } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Call from Kodi where add-on becomes asked about dirty rendering + /// region. + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual bool Dirty() { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// \anchor CRendering_SetIndependentCallbacks + /// @brief If the class is used independent (with "new CRendering") + /// and not as parent (with "cCLASS_own : CRendering") from own must + /// be the callback from Kodi to add-on overdriven with own functions! + /// + void SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBCreate)(GUIHANDLE cbhdl, + int x, + int y, + int w, + int h, + void* device), + void (*CBRender)(GUIHANDLE cbhdl), + void (*CBStop) (GUIHANDLE cbhdl), + bool (*CBDirty) (GUIHANDLE cbhdl)) + { + if (!cbhdl || + !CBCreate || !CBRender || !CBStop || !CBDirty) + { + kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); + return; + } + + m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, + CBCreate, CBRender, CBStop, CBDirty); + } + //-------------------------------------------------------------------------- + + private: + /* + * Defined callback functions from Kodi to add-on, for use in parent / child system + * (is private)! + */ + static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) + { + return static_cast(cbhdl)->Create(x, y, w, h, device); + } + + static void OnRenderCB(void* cbhdl) + { + static_cast(cbhdl)->Render(); + } + + static void OnStopCB(void* cbhdl) + { + static_cast(cbhdl)->Stop(); + } + + static bool OnDirtyCB(void* cbhdl) + { + return static_cast(cbhdl)->Dirty(); + } + + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h new file mode 100644 index 0000000..e51433a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/SettingsSlider.h @@ -0,0 +1,323 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSettingsSlider Control Settings Slider + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSettingsSlider } + /// **Window control for moveable slider with text name** + /// + /// The settings slider control is used in the settings screens for when an + /// option is best specified on a sliding scale. You can choose the position, + /// size, and look of the slider control. It is basically a cross between the + /// button control and a slider control. It has a label and focus and non + /// focus textures, as well as a slider control on the right. + /// + /// It has the header \ref SettingsSlider.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Settings_Slider_Control "settings slider control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CSettingsSlider : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CSettingsSlider(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Destructor + /// + ~CSettingsSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To set the text string on settings slider + /// + /// @param[in] text Text to show + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To reset slider on defaults + /// + void Reset() + { + m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// The integer interval is as default 1 and can be changed with + /// @ref SetIntInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from \ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To set the interval steps of slider, as default is it 1. If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + void SetIntInterval(int interval) + { + m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, interval); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Sets the percent of the slider. + /// + /// @param[in] percent float - Percent value of slide + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase, m_controlHandle, percent); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Returns a float of the percent of the slider. + /// + /// @return float - Percent of slider + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To set the the range as float of slider, e.g. -25.0 is the slider + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​ can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief Set the slider position with the given float value. The Range + /// can be defined with a call from \ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSettingsSlider + /// @brief To set the interval steps of slider, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values ​​can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h new file mode 100644 index 0000000..cbb9b8f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Slider.h @@ -0,0 +1,336 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSlider Control Slider + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSlider } + /// **Window control for moveable slider** + /// + /// The slider control is used for things where a sliding bar best represents + /// the operation at hand (such as a volume control or seek control). You can + /// choose the position, size, and look of the slider control. + /// + /// It has the header \ref Slider.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Slider_Control "slider control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CSlider : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CSlider(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_slider(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Destructor + /// + ~CSlider() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To reset slider on defaults + /// + void Reset() + { + m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief With GetDescription becomes a string value of position returned. + /// + /// @return Text string about current slider position + /// + /// The following are the text definition returned from this: + /// | Value | Without range selection | With range selection | + /// |:---------:|:------------------------|:-------------------------------| + /// | float | %2.2f | [%2.2f, %2.2f] | + /// | integer | %i | [%i, %i] | + /// | percent | %i%% | [%i%%, %i%%] | + /// + std::string GetDescription() const + { + std::string text; + char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// The integer interval is as default 1 and can be changed with + /// @ref SetIntInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup CSlider + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from \ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To set the interval steps of slider, as default is it 1. If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetIntInterval(int interval) + { + m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, interval); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Sets the percent of the slider. + /// + /// @param[in] percent float - Percent value of slide + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetPercentage(float percent) + { + m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, percent); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Returns a float of the percent of the slider. + /// + /// @return float - Percent of slider + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + float GetPercentage() const + { + return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To set the the range as float of slider, e.g. -25.0 is the slider + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief Set the slider position with the given float value. The Range + /// can be defined with a call from \ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only one + /// each can be used. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSlider + /// @brief To set the interval steps of slider, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..b39cd06 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h @@ -0,0 +1,376 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CSpin Control Spin + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CSpin } + /// **Window control used for cycling up/down controls** + /// + /// The settings spin control is used in the settings screens for when a list + /// of options can be chosen from using up/down arrows. You can choose the + /// position, size, and look of the spin control. It is basically a cross + /// between the button control and a spin control. It has a label and focus + /// and non focus textures, as well as a spin control on the right. + /// + /// It has the header \ref Spin.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Spin_Control "spin control" + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + + + //============================================================================ + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @anchor AddonGUISpinControlType + /// @brief The values here defines the used value format for steps on + /// spin control. + /// + typedef enum AddonGUISpinControlType + { + /// One spin step interpreted as integer + ADDON_SPIN_CONTROL_TYPE_INT = 1, + /// One spin step interpreted as floating point value + ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, + /// One spin step interpreted as text string + ADDON_SPIN_CONTROL_TYPE_TEXT = 3, + /// One spin step interpreted as a page change value + ADDON_SPIN_CONTROL_TYPE_PAGE = 4 + } AddonGUISpinControlType; + //---------------------------------------------------------------------------- + + class CSpin : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CSpin(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_spin(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Destructor + /// + ~CSpin() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Set's the control's enabled/disabled state + /// + /// @param[in] enabled If true enabled, otherwise disabled + /// + void SetEnabled(bool enabled) + { + m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To set the text string on spin control + /// + /// @param[in] text Text to show as name for spin + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To reset spin control to defaults + /// + void Reset() + { + m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To set the with SpinControlType defined types of spin. + /// + /// @param[in] type The type to use + /// + /// @note See description of \ref AddonGUISpinControlType for available types. + /// + void SetType(AddonGUISpinControlType type) + { + m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, (int)type); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To add a label entry in spin defined with a value as string. + /// + /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @param[in] label Label string to view on skin + /// @param[in] value String value to use for selection + /// of them. + /// + void AddLabel(const std::string& label, const std::string& value) + { + m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To add a label entry in spin defined with a value as integer. + /// + /// Format must be set to ADDON_SPIN_CONTROL_TYPE_INT to use this function. + /// + /// @param[in] label Label string to view on skin + /// @param[in] value Integer value to use for selection + /// of them. + /// + void AddLabel(const std::string& label, int value) + { + m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To change the spin to position with them string as value. + /// + /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @param[in] value String value to change to + /// + void SetStringValue(const std::string& value) + { + m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, value.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To get the current spin control position with text string value. + /// + /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. + /// + /// @return Currently selected string value + /// + std::string GetStringValue() const + { + std::string value; + char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + value = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return value; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To set the the range as integer of slider, e.g. -10 is the slider + /// start and e.g. +10 is the from here defined position where it reach the + /// end. + /// + /// Ad default is the range from 0 to 100. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + void SetIntRange(int start, int end) + { + m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Set the slider position with the given integer value. The Range + /// must be defined with a call from \ref SetIntRange before. + /// + /// @param[in] value Position in range to set with integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + void SetIntValue(int value) + { + m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To get the current position as integer value. + /// + /// @return The position as integer + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + int GetIntValue() const + { + return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To set the the range as float of spin, e.g. -25.0 is the spin + /// start and e.g. +25.0 is the from here defined position where it reach + /// the end. + /// + /// As default is the range 0.0 to 1.0. + /// + /// The float interval is as default 0.1 and can be changed with + /// @ref SetFloatInterval. + /// + /// @param[in] start Integer start value + /// @param[in] end Integer end value + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + void SetFloatRange(float start, float end) + { + m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief Set the spin position with the given float value. The Range + /// can be defined with a call from \ref SetIntRange before, as default it + /// is 0.0 to 1.0. + /// + /// @param[in] value Position in range to set with float + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + void SetFloatValue(float value) + { + m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, value); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To get the current position as float value. + /// + /// @return The position as float + /// + float GetFloatValue() const + { + return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CSpin + /// @brief To set the interval steps of spin, as default is it 0.1 If it + /// becomes changed with this function will a step of the user with the + /// value fixed here be executed. + /// + /// @param[in] interval Intervall step to set. + /// + /// @note Percent, floating point or integer are alone possible. Combining + /// these different values can be not together and can, therefore, only + /// one each can be used and must be defined with \ref SetType before. + /// + void SetFloatInterval(float interval) + { + m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h new file mode 100644 index 0000000..9d8976e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/TextBox.h @@ -0,0 +1,176 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../Window.h" + +namespace kodi +{ +namespace gui +{ +namespace controls +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_controls_CTextBox Control Text Box + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::controls::CTextBox } + /// **Used to show a multi-page piece of text** + /// + /// The text box control can be used to display descriptions, help texts or + /// other larger texts. It corresponds to the representation which is also to + /// be seen on the CDialogTextViewer. + /// + /// It has the header \ref TextBox.h "#include " + /// be included to enjoy it. + /// + /// Here you find the needed skin part for a \ref Text_Box "textbox control". + /// + /// @note The call of the control is only possible from the corresponding + /// window as its class and identification number is required. + /// + class CTextBox : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CTextBox(CWindow* window, int controlId) + : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_text_box(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CTextBox can't create control class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Destructor + /// + ~CTextBox() override = default; + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Set the control on window to visible + /// + /// @param[in] visible If true visible, otherwise hidden + /// + void SetVisible(bool visible) + { + m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle, visible); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief To reset box an remove all the text + /// + void Reset() + { + m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief To set the text on box + /// + /// @param[in] text Text to show + /// + void SetText(const std::string& text) + { + m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief Get the used text from control + /// + /// @return Text shown + /// + std::string GetText() const + { + std::string text; + char* ret = m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + text = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief To scroll text on other position + /// + /// @param[in] position The line position to scroll to + /// + void Scroll(unsigned int position) + { + m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle, position); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CTextBox + /// @brief To set automatic scrolling of textbox + /// + /// Specifies the timing and conditions of any autoscrolling this textbox + /// should have. Times are in milliseconds. The content is delayed for the + /// given delay, then scrolls at a rate of one line per time interval until + /// the end. If the repeat tag is present, it then delays for the repeat + /// time, fades out over 1 second, and repeats. It does not wrap or reset + /// to the top at the end of the scroll. + /// + /// @param[in] delay Content delay + /// @param[in] time One line per time interval + /// @param[in] repeat Delays with given time, fades out over 1 + /// second, and repeats + /// + void SetAutoScrolling(int delay, int time, int repeat) + { + m_interface->kodi_gui->control_text_box->set_auto_scrolling(m_interface->kodiBase, m_controlHandle, delay, time, repeat); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace controls */ +} /* namespace gui */ +} /* namespace kodi */ 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 a4cf963..61af9fe 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 @@ -39,6 +39,145 @@ typedef struct AddonToKodiFuncTable_kodi_gui_general int (*get_current_window_id)(void* kodiBase); } AddonToKodiFuncTable_kodi_gui_general; +typedef struct AddonToKodiFuncTable_kodi_gui_control_button +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*set_label)(void* kodiBase, void* handle, const char* label); + char* (*get_label)(void* kodiBase, void* handle); + void (*set_label2)(void* kodiBase, void* handle, const char *label); + char* (*get_label2)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_button; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_edit +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*set_label)(void* kodiBase, void* handle, const char* label); + char* (*get_label)(void* kodiBase, void* handle); + void (*set_text)(void* kodiBase, void* handle, const char* text); + char* (*get_text)(void* kodiBase, void* handle); + void (*set_cursor_position)(void* kodiBase, void* handle, unsigned int position); + unsigned int (*get_cursor_position)(void* kodiBase, void* handle); + void (*set_input_type)(void* kodiBase, void* handle, int type, const char* heading); +} AddonToKodiFuncTable_kodi_gui_control_edit; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_fade_label +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*add_label)(void* kodiBase, void* handle, const char* text); + char* (*get_label)(void* kodiBase, void* handle); + void (*set_scrolling)(void* kodiBase, void* handle, bool scroll); + void (*reset)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_fade_label; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_image +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_filename)(void* kodiBase, void* handle, const char* filename, bool use_cache); + void (*set_color_diffuse)(void* kodiBase, void* handle, uint32_t color_diffuse); +} AddonToKodiFuncTable_kodi_gui_control_image; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_label +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_label)(void* kodiBase, void* handle, const char* text); + char* (*get_label)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_label; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_progress +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_percentage)(void* kodiBase, void* handle, float percent); + float (*get_percentage)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_progress; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_radio_button +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*set_label)(void* kodiBase, void* handle, const char* text); + char* (*get_label)(void* kodiBase, void* handle); + void (*set_selected)(void* kodiBase, void* handle, bool selected); + bool (*is_selected)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_radio_button; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_rendering +{ + void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, + bool (*createCB)(void*,int,int,int,int,void*), + void (*renderCB)(void*), + void (*stopCB)(void*), + bool (*dirtyCB)(void*)); + void (*destroy)(void *kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_control_rendering; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_settings_slider +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*set_text)(void* kodiBase, void* handle, const char* label); + void (*reset)(void* kodiBase, void* handle); + void (*set_int_range)(void* kodiBase, void* handle, int start, int end); + void (*set_int_value)(void* kodiBase, void* handle, int value); + int (*get_int_value)(void* kodiBase, void* handle); + void (*set_int_interval)(void* kodiBase, void* handle, int interval); + void (*set_percentage)(void* kodiBase, void* handle, float percent); + float (*get_percentage)(void* kodiBase, void* handle); + void (*set_float_range)(void* kodiBase, void* handle, float start, float end); + void (*set_float_value)(void* kodiBase, void* handle, float value); + float (*get_float_value)(void* kodiBase, void* handle); + void (*set_float_interval)(void* kodiBase, void* handle, float interval); +} AddonToKodiFuncTable_kodi_gui_control_settings_slider; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_slider +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*reset)(void* kodiBase, void* handle); + char* (*get_description)(void* kodiBase, void* handle); + void (*set_int_range)(void* kodiBase, void* handle, int start, int end); + void (*set_int_value)(void* kodiBase, void* handle, int value); + int (*get_int_value)(void* kodiBase, void* handle); + void (*set_int_interval)(void* kodiBase, void* handle, int interval); + void (*set_percentage)(void* kodiBase, void* handle, float percent); + float (*get_percentage)(void* kodiBase, void* handle); + void (*set_float_range)(void* kodiBase, void* handle, float start, float end); + void (*set_float_value)(void* kodiBase, void* handle, float value); + float (*get_float_value)(void* kodiBase, void* handle); + void (*set_float_interval)(void* kodiBase, void* handle, float interval); +} AddonToKodiFuncTable_kodi_gui_control_slider; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_spin +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*set_enabled)(void* kodiBase, void* handle, bool enabled); + void (*set_text)(void* kodiBase, void* handle, const char* text); + void (*reset)(void* kodiBase, void* handle); + void (*set_type)(void* kodiBase, void* handle, int type); + void (*add_string_label)(void* kodiBase, void* handle, const char* label, const char* value); + void (*set_string_value)(void* kodiBase, void* handle, const char* value); + char* (*get_string_value)(void* kodiBase, void* handle); + void (*add_int_label)(void* kodiBase, void* handle, const char* label, int value); + void (*set_int_range)(void* kodiBase, void* handle, int start, int end); + void (*set_int_value)(void* kodiBase, void* handle, int value); + int (*get_int_value)(void* kodiBase, void* handle); + void (*set_float_range)(void* kodiBase, void* handle, float start, float end); + void (*set_float_value)(void* kodiBase, void* handle, float value); + float (*get_float_value)(void* kodiBase, void* handle); + void (*set_float_interval)(void* kodiBase, void* handle, float interval); +} AddonToKodiFuncTable_kodi_gui_control_spin; + +typedef struct AddonToKodiFuncTable_kodi_gui_control_text_box +{ + void (*set_visible)(void* kodiBase, void* handle, bool visible); + void (*reset)(void* kodiBase, void* handle); + void (*set_text)(void* kodiBase, void* handle, const char* text); + char* (*get_text)(void* kodiBase, void* handle); + void (*scroll)(void* kodiBase, void* handle, unsigned int scroll); + void (*set_auto_scrolling)(void* kodiBase, void* handle, int delay, int time, int repeat); +} AddonToKodiFuncTable_kodi_gui_control_text_box; + typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu { int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); @@ -122,7 +261,7 @@ typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect { - int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, bool autoclose); + int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, unsigned int autoclose); } AddonToKodiFuncTable_kodi_gui_dialogSelect; typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer @@ -139,7 +278,7 @@ typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo typedef struct AddonToKodiFuncTable_kodi_gui_listItem { - void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* thumbnail_image, const char* path); + void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* path); void (*destroy)(void* kodiBase, void* handle); char* (*get_label)(void* kodiBase, void* handle); void (*set_label)(void* kodiBase, void* handle, const char* label); @@ -151,6 +290,10 @@ typedef struct AddonToKodiFuncTable_kodi_gui_listItem void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); char* (*get_path)(void* kodiBase, void* handle); void (*set_path)(void* kodiBase, void* handle, const char* path); + char* (*get_property)(void* kodiBase, void* handle, const char* key); + void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); + void (*select)(void* kodiBase, void* handle, bool select); + bool (*is_selected)(void* kodiBase, void* handle); } AddonToKodiFuncTable_kodi_gui_listItem; #define ADDON_MAX_CONTEXT_ENTRIES 20 @@ -160,9 +303,10 @@ typedef struct gui_context_menu_pair unsigned int id; char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; } gui_context_menu_pair; - + typedef struct AddonToKodiFuncTable_kodi_gui_window { + /* Window creation functions */ 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, @@ -175,14 +319,90 @@ typedef struct AddonToKodiFuncTable_kodi_gui_window bool (*show)(void* kodiBase, void* handle); bool (*close)(void* kodiBase, void* handle); bool (*do_modal)(void* kodiBase, void* handle); + + /* Window control functions */ + 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); + + /* Window property functions */ + void (*set_property)(void* kodiBase, void* handle, const char* key, const char* value); + void (*set_property_int)(void* kodiBase, void* handle, const char* key, int value); + void (*set_property_bool)(void* kodiBase, void* handle, const char* key, bool value); + void (*set_property_double)(void* kodiBase, void* handle, const char* key, double value); + char* (*get_property)(void* kodiBase, void* handle, const char* key); + int (*get_property_int)(void* kodiBase, void* handle, const char* key); + bool (*get_property_bool)(void* kodiBase, void* handle, const char* key); + double (*get_property_double)(void* kodiBase, void* handle, const char* key); + void (*clear_properties)(void* kodiBase, void* handle); + void (*clear_property)(void* kodiBase, void* handle, const char* key); + + /* List item functions */ void (*clear_item_list)(void* kodiBase, void* handle); - void (*add_list_item)(void* kodiBase, void* handle, void* item, int item_position); - void* (*get_list_item)(void* kodiBase, void* handle, int listPos); + void (*add_list_item)(void* kodiBase, void* handle, void* item, int list_position); + void (*remove_list_item_from_position)(void* kodiBase, void* handle, int list_position); + void (*remove_list_item)(void* kodiBase, void* handle, void* item); + void* (*get_list_item)(void* kodiBase, void* handle, int list_position); + void (*set_current_list_position)(void* kodiBase, void* handle, int list_position); + int (*get_current_list_position)(void* kodiBase, void* handle); + int (*get_list_size)(void* kodiBase, void* handle); + void (*set_container_property)(void* kodiBase, void* handle, const char* key, const char* value); + void (*set_container_content)(void* kodiBase, void* handle, const char* value); + int (*get_current_container_id)(void* kodiBase, void* handle); + + /* Various functions */ + void (*mark_dirty_region)(void* kodiBase, void* handle); + + /* GUI control access functions */ + void* (*get_control_button)(void* kodiBase, void* handle, int control_id); + void* (*get_control_edit)(void* kodiBase, void* handle, int control_id); + void* (*get_control_fade_label)(void* kodiBase, void* handle, int control_id); + void* (*get_control_image)(void* kodiBase, void* handle, int control_id); + void* (*get_control_label)(void* kodiBase, void* handle, int control_id); + void* (*get_control_progress)(void* kodiBase, void* handle, int control_id); + void* (*get_control_radio_button)(void* kodiBase, void* handle, int control_id); + void* (*get_control_render_addon)(void* kodiBase, void* handle, int control_id); + void* (*get_control_settings_slider)(void* kodiBase, void* handle, int control_id); + void* (*get_control_slider)(void* kodiBase, void* handle, int control_id); + void* (*get_control_spin)(void* kodiBase, void* handle, int control_id); + void* (*get_control_text_box)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy1)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy2)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy3)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy4)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy5)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy6)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy7)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy8)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy9)(void* kodiBase, void* handle, int control_id); + void* (*get_control_dummy10)(void* kodiBase, void* handle, int control_id); /* This and above used to add new get_control_* functions */ } AddonToKodiFuncTable_kodi_gui_window; typedef struct AddonToKodiFuncTable_kodi_gui { AddonToKodiFuncTable_kodi_gui_general* general; + AddonToKodiFuncTable_kodi_gui_control_button* control_button; + AddonToKodiFuncTable_kodi_gui_control_edit* control_edit; + AddonToKodiFuncTable_kodi_gui_control_fade_label* control_fade_label; + AddonToKodiFuncTable_kodi_gui_control_label* control_label; + AddonToKodiFuncTable_kodi_gui_control_image* control_image; + AddonToKodiFuncTable_kodi_gui_control_progress* control_progress; + AddonToKodiFuncTable_kodi_gui_control_radio_button* control_radio_button; + AddonToKodiFuncTable_kodi_gui_control_rendering* control_rendering; + AddonToKodiFuncTable_kodi_gui_control_settings_slider* control_settings_slider; + AddonToKodiFuncTable_kodi_gui_control_slider* control_slider; + AddonToKodiFuncTable_kodi_gui_control_spin* control_spin; + AddonToKodiFuncTable_kodi_gui_control_text_box* control_text_box; + void* control_dummy1; + void* control_dummy2; + void* control_dummy3; + void* control_dummy4; + void* control_dummy5; + void* control_dummy6; + void* control_dummy7; + void* control_dummy8; + void* control_dummy9; + void* control_dummy10; /* This and above used to add new controls */ AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; @@ -193,6 +413,16 @@ typedef struct AddonToKodiFuncTable_kodi_gui AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; + void* dialog_dummy1; + void* dialog_dummy2; + void* dialog_dummy3; + void* dialog_dummy4; + void* dialog_dummy5; + void* dialog_dummy6; + void* dialog_dummy7; + void* dialog_dummy8; + void* dialog_dummy9; + void* dialog_dummy10; /* This and above used to add new dialogs */ AddonToKodiFuncTable_kodi_gui_listItem* listItem; AddonToKodiFuncTable_kodi_gui_window* window; } AddonToKodiFuncTable_kodi_gui; 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 new file mode 100644 index 0000000..47afc23 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h @@ -0,0 +1,98 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu } + /// **Context menu dialog** + /// + /// The function listed below permits the call of a dialogue as context menu to + /// select of an entry as a key + /// + /// It has the header \ref ContextMenu.h "#include " + /// be included to enjoy it. + /// + /// + namespace ContextMenu + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_ContextMenu + /// @brief Show a context menu dialog about given parts. + /// + /// @param[in] heading Dialog heading name + /// @param[in] entries String list about entries + /// @return The selected entry, if return -1 was nothing selected or canceled + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// const std::vector entries + /// { + /// "Test 1", + /// "Test 2", + /// "Test 3", + /// "Test 4", + /// "Test 5" + /// }; + /// + /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); + /// if (selected < 0) + /// fprintf(stderr, "Item selection canceled\n"); + /// else + /// fprintf(stderr, "Selected item is: %i\n", selected); + /// ~~~~~~~~~~~~~ + /// + inline int 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**))); + 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); + free(cEntries); + return ret; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h new file mode 100644 index 0000000..e9c5a9d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h @@ -0,0 +1,247 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +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** + /// + /// 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 CExtendedProgress + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress + /// Construct a new dialog + /// + /// @param[in] title Title string + /// + 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; + 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 */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h new file mode 100644 index 0000000..401a78d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h @@ -0,0 +1,296 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::dialogs::FileBrowser } + /// **File browser dialog** + /// + /// The functions listed below of the class "FileBrowser" offer + /// the possibility to select to a file by the user of the add-on. + /// + /// It allows all the options that are possible in Kodi itself and offers all + /// support file types. + /// + /// It has the header \ref FileBrowser.h "#include " + /// be included to enjoy it. + /// + namespace FileBrowser + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief Directory selection dialog + /// + /// @param[in] shares With Shares becomes the available start folders + /// be set. + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and return value about + /// selected directory + /// @param[in] writeOnly If set only writeable folders are shown. + /// @return False if selection becomes canceled. + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// /* + /// * Example show directory selection dialog with on 'share' (first value) + /// * defined directory types. + /// * + /// * If this becomes leaved empty and 'directory' is empty goes it to the + /// * base path of the hard disk. + /// * + /// * Also can be with path written to 'directory' before the dialog forced + /// * to a start place. + /// */ + /// std::string directory; + /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable", + /// "Test directory selection", + /// directory, + /// false); + /// 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) + { + 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); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief File selection dialog + /// + /// @param[in] shares With Shares becomes the available start + /// folders be set. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and Return value + /// about selected file + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// 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) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, + useThumbs, useFileDirectories); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief File selection from a directory + /// + /// @param[in] directory The directory name where the dialog + /// start, possible are normal names and + /// kodi's special names. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and Return value + /// about selected file + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// handled as directories. + /// @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) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, + directory.c_str(), mask.c_str(), heading.c_str(), + path.c_str(), &retString, useThumbs, + useFileDirectories, singleList); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief File selection dialog to get several in to a list + /// + /// @param[in] shares With Shares becomes the available start + /// folders be set. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[out] fileList Return value about selected files + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// 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) + { + using namespace ::kodi::addon; + char** list = nullptr; + unsigned int listSize = 0; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, + useThumbs, useFileDirectories); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + fileList.push_back(list[i]); + CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief Source selection dialog + /// + /// @param[in,out] path As in the path to start and Return value + /// about selected source + /// @param[in] allowNetworkShares Allow also access to network + /// @param[in] additionalShare With additionalShare becomes the available + /// start folders be set (optional). + /// @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 = "") + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, + allowNetworkShares, additionalShare.c_str(), type.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief Image selection dialog + /// + /// @param[in] shares With Shares becomes the available start folders be + /// set. + /// @param[in] heading Dialog header name + /// @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) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), heading.c_str(), path.c_str(), &retString); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_FileBrowser + /// @brief Image selection dialog to get several in to a list + /// + /// @param[in] shares With Shares becomes the available start folders + /// be set. + /// @param[in] heading Dialog header name + /// @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) + { + using namespace ::kodi::addon; + char** list = nullptr; + unsigned int listSize = 0; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), heading.c_str(), &list, &listSize); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + file_list.push_back(list[i]); + CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); + } + return ret; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h new file mode 100644 index 0000000..cff30d8 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h @@ -0,0 +1,419 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::dialogs::Keyboard } + /// **Keyboard dialogs** + /// + /// The functions listed below have to be permitted by the user for the + /// representation of a keyboard around an input. + /// + /// The class supports several kinds, from an easy text choice up to the + /// passport Word production and their confirmation for add-on. + /// + /// It has the header \ref Keyboard.h "#include " + /// be included to enjoy it. + /// + namespace Keyboard + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Show keyboard with initial value `text` and replace with result + /// string. + /// + /// @param[in,out] text Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult Whether a blank password is valid or not. + /// @param[in] hiddenInput The inserted input is not shown as text. + /// @param[in] autoCloseMs To close the dialog after a specified + /// time, in milliseconds, default is 0 which + /// keeps the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// /* + /// * The example shows the display of keyboard call dialog at Kodi from the add-on. + /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) + /// * to be released if not needed. + /// */ + /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a + /// entry text added */ + /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text, + /// "Demonstration text entry", + /// true, + /// false, + /// 0); + /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", + /// 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) + { + 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); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief The example shows the display of keyboard call dialog at Kodi + /// from the add-on. + /// + /// @param[out] text Overwritten with user input if return=true. + /// @param[in] allowEmptyResult If set to true keyboard can also exited + /// without entered text. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), &retString, + allowEmptyResult, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Shows keyboard and prompts for a password. Differs from + /// `ShowAndVerifyNewPassword()` in that no second verification + /// + /// @param[in,out] newPassword Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult Whether a blank password is valid or not. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// 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) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, + newPassword.c_str(), &retString, heading.c_str(), + allowEmptyResult, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Shows keyboard and prompts for a password. Differs from + /// `ShowAndVerifyNewPassword()` in that no second verification + /// + /// @param[in,out] newPassword Overwritten with user input if return=true. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, + newPassword.c_str(), &retString, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Show keyboard twice to get and confirm a user-entered password + /// string. + /// + /// @param[out] newPassword Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// #include + /// + /// /* + /// * The example below shows the complete use of keyboard dialog for password + /// * check. If only one check from add-on needed can be function with retries + /// * set to '0' called alone. + /// * + /// * The use of MD5 translated password is always required for the check on Kodi! + /// */ + /// + /// int maxretries = 3; + /// /* + /// * Password names need to be send as md5 sum to kodi. + /// */ + /// std::string password; + /// kodi::GetMD5("kodi", password); + /// + /// /* + /// * To the loop about password checks. + /// */ + /// int ret; + /// for (unsigned int i = 0; i < maxretries; i++) + /// { + /// /* + /// * Ask the user about the password. + /// */ + /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); + /// if (ret == 0) + /// { + /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); + /// break; + /// } + /// else if (ret < 0) + /// { + /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); + /// break; + /// } + /// else /* if (ret > 0) */ + /// { + /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); + /// } + /// } + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, + &retString, heading.c_str(), allowEmptyResult, + autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Show keyboard twice to get and confirm a user-entered password + /// string. + /// + /// @param[out] newPassword Overwritten with user input if return=true. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, + &retString, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Show keyboard and verify user input against `password`. + /// + /// @param[in,out] password Value to compare against user input. + /// @param[in] heading String shown on dialog title. + /// @param[in] retries If greater than 0, shows "Incorrect + /// password, %d retries left" on dialog line 2, + /// else line 2 is blank. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return 0 if successful display and user input. 1 if + /// 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) + { + using namespace ::kodi::addon; + char* retString = nullptr; + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, + password.c_str(), &retString, heading.c_str(), + retries, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + password = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Shows a filter related keyboard + /// + /// @param[in,out] text Overwritten with user input if return=true. + /// @param[in] searching Use dialog for search and send our search + /// message in safe way (only the active window + /// needs it) + /// - header name if true is "Enter search string" + /// - header name if false is "Enter value" + /// @param autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), &retString, searching, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Send a text to a visible keyboard + /// + /// @param[in] text Overwritten with user input if return=true. + /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. + /// @return true if successful done, false if + /// unsuccessful or keyboard not present. + /// + inline bool 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, + text.c_str(), closeKeyboard); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Keyboard + /// @brief Check for visible keyboard on GUI + /// + /// @return true if keyboard present, false if not present + /// + inline bool IsKeyboardActivated() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h new file mode 100644 index 0000000..dddbf7e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h @@ -0,0 +1,369 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::dialogs::Numeric } + /// **Numeric dialogs** + /// + /// The functions listed below have to be permitted by the user for the + /// representation of a numeric keyboard around an input. + /// + /// The class supports several kinds, from an easy number choice up to the + /// passport Word production and their confirmation for add-on. + /// + /// It has the header \ref Numeric.h "#include " + /// be included to enjoy it. + /// + namespace Numeric + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to get numeric new password + /// + /// @param[out] newPassword String to preload into the keyboard + /// accumulator. Overwritten with user input + /// if return=true. Returned in MD5 format. + /// @return true if successful display and user + /// input entry/re-entry. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool 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); + if (pw != nullptr) + { + if (std::strlen(pw)) + newPassword = pw; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to verify numeric password. + /// + /// @param[in] password Password to compare with user input, need + /// in MD5 format. + /// @param[in] heading Heading to display + /// @param[in] retries If greater than 0, shows "Incorrect + /// password, %d retries left" on dialog + /// line 2, else line 2 is blank. + /// @return Possible values: + /// - 0 if successful display and user input. + /// - 1 if unsuccessful input. + /// - -1 if no user input or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* fprintf */ + /// #include + /// #include + /// + /// /* + /// * The example below shows the complete use of keyboard dialog for password + /// * check. If only one check from add-on needed can be function with retries + /// * set to '0' called alone. + /// * + /// * The use of MD5 translated password is always required for the check on Kodi! + /// */ + /// + /// int maxretries = 3; + /// + /// /* + /// * Password names need to be send as md5 sum to kodi. + /// */ + /// std::string password = kodi::GetMD5("1234"); + /// + /// /* + /// * To the loop about password checks. + /// */ + /// int ret; + /// for (unsigned int i = 0; i < maxretries; i++) + /// { + /// /* + /// * Ask the user about the password. + /// */ + /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); + /// if (ret == 0) + /// { + /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); + /// break; + /// } + /// else if (ret < 0) + /// { + /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); + /// break; + /// } + /// else /* if (ret > 0) */ + /// { + /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); + /// } + /// } + /// ~~~~~~~~~~~~~ + /// + inline int 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, + password.c_str(), heading.c_str(), retries); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to verify numeric password + /// + /// @param[in,out] toVerify Value to compare against user input. + /// @param[in] heading Heading to display + /// @param[in] verifyInput If set as true we verify the users input + /// versus toVerify. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, + toVerify.c_str(), &retString, heading.c_str(), verifyInput); + if (retString != nullptr) + { + if (std::strlen(retString)) + toVerify = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to get time value. + /// + /// @param[out] time Overwritten with user input if + /// return=true and time inserted. + /// @param[in] heading Heading to display. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* time_t, struct tm, time, localtime, strftime */ + /// #include + /// + /// time_t rawtime; + /// struct tm * timeinfo; + /// char buffer [10]; + /// + /// time (&rawtime); + /// timeinfo = localtime(&rawtime); + /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call"); + /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); + /// 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) + { + 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()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to get date value. + /// + /// @param[in,out] date Overwritten with user input if + /// return=true and date inserted. + /// @param[in] heading Heading to display + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* time_t, struct tm, time, localtime, strftime */ + /// #include + /// + /// time_t rawtime; + /// struct tm * timeinfo; + /// char buffer [20]; + /// + /// time (&rawtime); + /// timeinfo = localtime(&rawtime); + /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call"); + /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); + /// 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) + { + 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()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to get a IP + /// + /// @param[in,out] ipAddress Overwritten with user input if + /// return=true and IP address inserted. + /// @param[in] heading Heading to display. + /// @return true if successful display and + /// user input. false if unsuccessful + /// display, no user input, or canceled + /// editing. + /// + inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, + ipAddress.c_str(), &retString, heading.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + ipAddress = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Use dialog to get normal number. + /// + /// @param[in,out] input Overwritten with user input if + /// return=true and time in seconds inserted + /// @param[in] heading Heading to display + /// @param[in] autoCloseTimeoutMs To close the dialog after a specified + /// time, in milliseconds, default is 0 + /// which keeps the dialog open + /// indefinitely. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* strtoull (C++11) */ + /// #include + /// + /// std::string number; + /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call"); + /// printf("Written number input is : %llu and was %s\n", + /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, + input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + input = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Numeric + /// @brief Show numeric keypad to get seconds. + /// + /// @param[in,out] time Overwritten with user input if return=true and + /// time in seconds inserted. + /// @param[in] heading Heading to display + /// @return true if successful display and user input. false + /// if unsuccessful display, no user input, or + /// canceled editing. + /// + inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, + time.c_str(), &retString, heading.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + time = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h new file mode 100644 index 0000000..12799b7 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h @@ -0,0 +1,107 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../../AddonBase.h" +#include "../definitions.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_OK Dialog OK + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::dialogs::OK } + /// **OK dialog** + /// + /// The functions listed below permit the call of a dialogue of information, a + /// confirmation of the user by press from OK required. + /// + /// It has the header \ref OK.h "#include " + /// be included to enjoy it. + /// + namespace OK + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_OK + /// @brief Use dialog to inform user with text and confirmation with OK with continued string. + /// + /// @param[in] heading Dialog heading. + /// @param[in] text Multi-line text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// ... + /// 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) + { + 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()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_OK + /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. + /// + /// @param[in] heading Dialog heading. + /// @param[in] line0 Line #1 text. + /// @param[in] line1 Line #2 text. + /// @param[in] line2 Line #3 text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// ... + /// 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) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), + line2.c_str()); + } + //-------------------------------------------------------------------------- + } + /// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h new file mode 100644 index 0000000..3f18499 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h @@ -0,0 +1,252 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +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 + { + 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; + }; + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h new file mode 100644 index 0000000..963c84c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h @@ -0,0 +1,105 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_Select Dialog Select + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::dialogs::Select } + /// **Selection dialog** + /// + /// The function listed below permits the call of a dialogue to select of an + /// entry as a key + /// + /// It has the header \ref Select.h "#include " + /// be included to enjoy it. + /// + /// + namespace Select + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_Select + /// @brief Show a selection dialog about given parts. + /// + /// @param[in] heading Dialog heading name + /// @param[in] entries String list about entries + /// @param[in] selected [opt] Predefined selection (default is + /// -1 for the first) + /// @param[in] autoclose [opt] To close dialog automatic after the given + /// time in ms. As '0' it stays open. + /// @return The selected entry, if return -1 was + /// nothing selected or canceled + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// const std::vector entries + /// { + /// "Test 1", + /// "Test 2", + /// "Test 3", + /// "Test 4", + /// "Test 5" + /// }; + /// + /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); + /// if (selected < 0) + /// fprintf(stderr, "Item selection canceled\n"); + /// else + /// 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) + { + using namespace ::kodi::addon; + unsigned int size = 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); + free(cEntries); + return ret; + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h new file mode 100644 index 0000000..c64bc1e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h @@ -0,0 +1,118 @@ +#pragma once +/* + * Copyright (C) 2015-2016 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::dialogs::TextViewer } + /// **Text viewer dialog** + /// + /// The text viewer dialog can be used to display descriptions, help texts or + /// other larger texts. + /// + /// In order to achieve a line break is a \\n directly in the text or + /// in the "./resources/language/resource.language.??_??/strings.po" + /// to call with std::string kodi::general::GetLocalizedString(...);. + /// + /// It has the header \ref TextViewer.h "#include " + /// be included to enjoy it. + /// + namespace TextViewer + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_TextViewer + /// @brief Show info text dialog + /// + /// @param[in] heading Small heading text + /// @param[in] text Showed text on dialog + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)", + /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " + /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " + /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " + /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" + /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " + /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " + /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" + /// "\n" + /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " + /// "unusual characters, over the years it has become an icon of American popular " + /// "culture. It was nominated for six Academy Awards, including Best Picture but " + /// "lost to Gone with the Wind. It did win in two other categories including Best " + /// "Original Song for \"Over the Rainbow\". However, the film was a box office " + /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " + /// "budget, despite receiving largely positive reviews. It was MGM's most " + /// "expensive production at that time, and did not completely recoup the studio's " + /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" + /// "\n" + /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " + /// "film to the wider public and eventually made the presentation an annual " + /// "tradition, making it one of the most known films in cinema history. The " + /// "film was named the most-viewed motion picture on television syndication by " + /// "the Library of Congress who also included the film in its National Film " + /// "Registry in its inaugural year in 1989. Designation on the registry calls " + /// "for efforts to preserve it for being \"culturally, historically, and " + /// "aesthetically significant\". It is also one of the few films on UNESCO's " + /// "Memory of the World Register.\n" + /// "\n" + /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " + /// "polls. It is the source of many quotes referenced in modern popular culture. " + /// "It was directed primarily by Victor Fleming (who left production to take " + /// "over direction on the troubled Gone with the Wind production). Noel Langley, " + /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " + /// "but there were uncredited contributions by others. The songs were written " + /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " + /// "music, based largely on the songs, was composed by Herbert Stothart, with " + /// "interspersed renderings from classical composers.\n"); + /// ~~~~~~~~~~~~~ + /// + inline void 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()); + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h new file mode 100644 index 0000000..d9c34ff --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h @@ -0,0 +1,190 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../definitions.h" +#include "../../AddonBase.h" + +namespace kodi +{ +namespace gui +{ +namespace dialogs +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::dialogs::YesNo } + /// **Yes / No dialog** + /// + /// The Yes / No dialog can be used to inform the user about questions and get + /// the answer. + /// + /// In order to achieve a line break is a \\n directly in the text or + /// in the "./resources/language/resource.language.??_??/strings.po" + /// to call with std::string kodi::general::GetLocalizedString(...);. + /// + /// It has the header \ref YesNo.h "#include " + /// be included to enjoy it. + /// + /// + namespace YesNo + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_YesNo + /// @brief Use dialog to get numeric new password with one text string shown + /// everywhere and cancel return field + /// + /// @param[in] heading Dialog heading + /// @param[in] text Multi-line text + /// @param[out] canceled Return value about cancel button + /// @param[in] noLabel [opt] label to put on the no button + /// @param[in] yesLabel [opt] label to put on the yes button + /// @return Returns True if 'Yes' was pressed, else False + /// + /// @note It is preferred to only use this as it is actually a multi-line text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool canceled; + /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( + /// "Yes / No test call", /* The Header */ + /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", + /// canceled, /* return value about cancel button */ + /// "Not really", /* No label, is optional and if empty "No" */ + /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ + /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", + /// ret ? "yes" : "no", + /// 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 = "") + { + 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()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_YesNo + /// @brief Use dialog to get numeric new password with separated line strings + /// + /// @param[in] heading Dialog heading + /// @param[in] line0 Line #0 text + /// @param[in] line1 Line #1 text + /// @param[in] line2 Line #2 text + /// @param[in] noLabel [opt] label to put on the no button. + /// @param[in] yesLabel [opt] label to put on the yes button. + /// @return Returns True if 'Yes' was pressed, else False. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( + /// "Yes / No test call", // The Header + /// "You has opened Yes / No dialog for test", + /// "", + /// "Is this OK for you?", + /// "Not really", // No label, is optional and if empty "No" + /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" + /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", + /// 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 = "") + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), + noLabel.c_str(), yesLabel.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_dialogs_YesNo + /// @brief Use dialog to get numeric new password with separated line strings and cancel return field + /// + /// @param[in] heading Dialog heading + /// @param[in] line0 Line #0 text + /// @param[in] line1 Line #1 text + /// @param[in] line2 Line #2 text + /// @param[out] canceled Return value about cancel button + /// @param[in] noLabel [opt] label to put on the no button + /// @param[in] yesLabel [opt] label to put on the yes button + /// @return Returns True if 'Yes' was pressed, else False + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool canceled; + /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( + /// "Yes / No test call", // The Header + /// "You has opened Yes / No dialog for test", + /// "", + /// "Is this OK for you?", + /// canceled, // return value about cancel button + /// "Not really", // No label, is optional and if empty "No" + /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" + /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", + /// ret ? "yes" : "no", + /// 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 = "") + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), + &canceled, noLabel.c_str(), yesLabel.c_str()); + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace dialogs */ +} /* namespace gui */ +} /* namespace kodi */ -- cgit v1.2.3