From f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 4 Jun 2017 16:57:49 +0200 Subject: sync with upstream --- .../include/kodi/libKODI_guilib.h | 1393 +++++++++++++------- 1 file changed, 882 insertions(+), 511 deletions(-) (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h index b699fa0..d6f0f4f 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h @@ -28,416 +28,1068 @@ typedef void* GUIHANDLE; -#define GUI_HELPER_DLL KODI_DLL("guilib") -#define GUI_HELPER_DLL_NAME KODI_DLL_NAME("guilib") +namespace KodiAPI +{ +namespace GUI +{ -/* current ADDONGUI API version */ -#define KODI_GUILIB_API_VERSION "5.11.0" +typedef struct CB_GUILib +{ + void (*Lock)(); + void (*Unlock)(); + int (*GetScreenHeight)(); + int (*GetScreenWidth)(); + int (*GetVideoResolution)(); + GUIHANDLE (*Window_New)(void *addonData, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); + void (*Window_Delete)(void *addonData, GUIHANDLE handle); + void (*Window_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*)(GUIHANDLE handle), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int), bool (*)(GUIHANDLE handle, int)); + bool (*Window_Show)(void *addonData, GUIHANDLE handle); + bool (*Window_Close)(void *addonData, GUIHANDLE handle); + bool (*Window_DoModal)(void *addonData, GUIHANDLE handle); + bool (*Window_SetFocusId)(void *addonData, GUIHANDLE handle, int iControlId); + int (*Window_GetFocusId)(void *addonData, GUIHANDLE handle); + bool (*Window_SetCoordinateResolution)(void *addonData, GUIHANDLE handle, int res); + void (*Window_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); + void (*Window_SetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key, int value); + void (*Window_SetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key, bool value); + void (*Window_SetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key, double value); + const char* (*Window_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); + int (*Window_GetPropertyInt)(void *addonData, GUIHANDLE handle, const char *key); + bool (*Window_GetPropertyBool)(void *addonData, GUIHANDLE handle, const char *key); + double (*Window_GetPropertyDouble)(void *addonData, GUIHANDLE handle, const char *key); + void (*Window_ClearProperties)(void *addonData, GUIHANDLE handle); + int (*Window_GetListSize)(void *addonData, GUIHANDLE handle); + void (*Window_ClearList)(void *addonData, GUIHANDLE handle); + GUIHANDLE (*Window_AddItem)(void *addonData, GUIHANDLE handle, GUIHANDLE item, int itemPosition); + GUIHANDLE (*Window_AddStringItem)(void *addonData, GUIHANDLE handle, const char *itemName, int itemPosition); + void (*Window_RemoveItem)(void *addonData, GUIHANDLE handle, int itemPosition); + GUIHANDLE (*Window_GetListItem)(void *addonData, GUIHANDLE handle, int listPos); + void (*Window_SetCurrentListPosition)(void *addonData, GUIHANDLE handle, int listPos); + int (*Window_GetCurrentListPosition)(void *addonData, GUIHANDLE handle); + GUIHANDLE (*Window_GetControl_Spin)(void *addonData, GUIHANDLE handle, int controlId); + GUIHANDLE (*Window_GetControl_Button)(void *addonData, GUIHANDLE handle, int controlId); + GUIHANDLE (*Window_GetControl_RadioButton)(void *addonData, GUIHANDLE handle, int controlId); + GUIHANDLE (*Window_GetControl_Edit)(void *addonData, GUIHANDLE handle, int controlId); + GUIHANDLE (*Window_GetControl_Progress)(void *addonData, GUIHANDLE handle, int controlId); + GUIHANDLE (*Window_GetControl_RenderAddon)(void *addonData, GUIHANDLE handle, int controlId); + void (*Window_SetControlLabel)(void *addonData, GUIHANDLE handle, int controlId, const char *label); + void (*Window_MarkDirtyRegion)(void *addonData, GUIHANDLE handle); + void (*Control_Spin_SetVisible)(void *addonData, GUIHANDLE spinhandle, bool yesNo); + void (*Control_Spin_SetText)(void *addonData, GUIHANDLE spinhandle, const char *label); + void (*Control_Spin_Clear)(void *addonData, GUIHANDLE spinhandle); + void (*Control_Spin_AddLabel)(void *addonData, GUIHANDLE spinhandle, const char *label, int iValue); + int (*Control_Spin_GetValue)(void *addonData, GUIHANDLE spinhandle); + void (*Control_Spin_SetValue)(void *addonData, GUIHANDLE spinhandle, int iValue); + void (*Control_RadioButton_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); + void (*Control_RadioButton_SetText)(void *addonData, GUIHANDLE handle, const char *label); + void (*Control_RadioButton_SetSelected)(void *addonData, GUIHANDLE handle, bool yesNo); + bool (*Control_RadioButton_IsSelected)(void *addonData, GUIHANDLE handle); + void (*Control_Progress_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); + float (*Control_Progress_GetPercentage)(void *addonData, GUIHANDLE handle); + void (*Control_Progress_SetInfo)(void *addonData, GUIHANDLE handle, int iInfo); + int (*Control_Progress_GetInfo)(void *addonData, GUIHANDLE handle); + const char* (*Control_Progress_GetDescription)(void *addonData, GUIHANDLE handle); + GUIHANDLE (*Window_GetControl_Slider)(void *addonData, GUIHANDLE handle, int controlId); + void (*Control_Slider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); + const char *(*Control_Slider_GetDescription)(void *addonData, GUIHANDLE handle); + void (*Control_Slider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); + void (*Control_Slider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); + int (*Control_Slider_GetIntValue)(void *addonData, GUIHANDLE handle); + void (*Control_Slider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); + void (*Control_Slider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); + float (*Control_Slider_GetPercentage)(void *addonData, GUIHANDLE handle); + void (*Control_Slider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); + void (*Control_Slider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); + float (*Control_Slider_GetFloatValue)(void *addonData, GUIHANDLE handle); + void (*Control_Slider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); + GUIHANDLE (*Window_GetControl_SettingsSlider)(void *addonData, GUIHANDLE handle, int controlId); + void (*Control_SettingsSlider_SetVisible)(void *addonData, GUIHANDLE handle, bool yesNo); + void (*Control_SettingsSlider_SetText)(void *addonData, GUIHANDLE handle, const char *label); + const char *(*Control_SettingsSlider_GetDescription)(void *addonData, GUIHANDLE handle); + void (*Control_SettingsSlider_SetIntRange)(void *addonData, GUIHANDLE handle, int iStart, int iEnd); + void (*Control_SettingsSlider_SetIntValue)(void *addonData, GUIHANDLE handle, int iValue); + int (*Control_SettingsSlider_GetIntValue)(void *addonData, GUIHANDLE handle); + void (*Control_SettingsSlider_SetIntInterval)(void *addonData, GUIHANDLE handle, int iInterval); + void (*Control_SettingsSlider_SetPercentage)(void *addonData, GUIHANDLE handle, float fPercent); + float (*Control_SettingsSlider_GetPercentage)(void *addonData, GUIHANDLE handle); + void (*Control_SettingsSlider_SetFloatRange)(void *addonData, GUIHANDLE handle, float fStart, float fEnd); + void (*Control_SettingsSlider_SetFloatValue)(void *addonData, GUIHANDLE handle, float fValue); + float (*Control_SettingsSlider_GetFloatValue)(void *addonData, GUIHANDLE handle); + void (*Control_SettingsSlider_SetFloatInterval)(void *addonData, GUIHANDLE handle, float fInterval); + GUIHANDLE (*ListItem_Create)(void *addonData, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); + const char* (*ListItem_GetLabel)(void *addonData, GUIHANDLE handle); + void (*ListItem_SetLabel)(void *addonData, GUIHANDLE handle, const char *label); + const char* (*ListItem_GetLabel2)(void *addonData, GUIHANDLE handle); + void (*ListItem_SetLabel2)(void *addonData, GUIHANDLE handle, const char *label); + void (*ListItem_SetIconImage)(void *addonData, GUIHANDLE handle, const char *image); + void (*ListItem_SetThumbnailImage)(void *addonData, GUIHANDLE handle, const char *image); + void (*ListItem_SetInfo)(void *addonData, GUIHANDLE handle, const char *info); + void (*ListItem_SetProperty)(void *addonData, GUIHANDLE handle, const char *key, const char *value); + const char* (*ListItem_GetProperty)(void *addonData, GUIHANDLE handle, const char *key); + void (*ListItem_SetPath)(void *addonData, GUIHANDLE handle, const char *path); + void (*RenderAddon_SetCallbacks)(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*createCB)(GUIHANDLE,int,int,int,int,void*), void (*renderCB)(GUIHANDLE), void (*stopCB)(GUIHANDLE), bool (*dirtyCB)(GUIHANDLE)); + void (*RenderAddon_Delete)(void *addonData, GUIHANDLE handle); + void (*RenderAddon_MarkDirty)(void *addonData, GUIHANDLE handle); + + bool (*Dialog_Keyboard_ShowAndGetInputWithHead)(char &strTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndGetInput)(char &strTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndGetNewPasswordWithHead)(char &newPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndGetNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead)(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmpty, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); + int (*Dialog_Keyboard_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_ShowAndGetFilter)(char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); + bool (*Dialog_Keyboard_SendTextToActiveKeyboard)(const char *aTextString, bool closeKeyboard); + bool (*Dialog_Keyboard_isKeyboardActivated)(); + + bool (*Dialog_Numeric_ShowAndVerifyNewPassword)(char &strNewPassword, unsigned int iMaxStringSize); + int (*Dialog_Numeric_ShowAndVerifyPassword)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); + bool (*Dialog_Numeric_ShowAndVerifyInput)(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); + bool (*Dialog_Numeric_ShowAndGetTime)(tm &time, const char *strHeading); + bool (*Dialog_Numeric_ShowAndGetDate)(tm &date, const char *strHeading); + bool (*Dialog_Numeric_ShowAndGetIPAddress)(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading); + bool (*Dialog_Numeric_ShowAndGetNumber)(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); + bool (*Dialog_Numeric_ShowAndGetSeconds)(char &timeString, unsigned int iMaxStringSize, const char *strHeading); + + bool (*Dialog_FileBrowser_ShowAndGetFile)(const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); + + void (*Dialog_OK_ShowAndGetInputSingleText)(const char *heading, const char *text); + void (*Dialog_OK_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2); + + bool (*Dialog_YesNo_ShowAndGetInputSingleText)(const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); + bool (*Dialog_YesNo_ShowAndGetInputLineText)(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); + bool (*Dialog_YesNo_ShowAndGetInputLineButtonText)(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); + + void (*Dialog_TextViewer)(const char *heading, const char *text); + + int (*Dialog_Select)(const char *heading, const char *entries[], unsigned int size, int selected); +} CB_GUILib; + +} /* namespace GUI */ +} /* namespace KodiAPI */ -/* min. ADDONGUI API version */ -#define KODI_GUILIB_MIN_API_VERSION "5.10.0" #define ADDON_ACTION_PREVIOUS_MENU 10 #define ADDON_ACTION_CLOSE_DIALOG 51 #define ADDON_ACTION_NAV_BACK 92 -class CAddonGUIWindow; -class CAddonGUISpinControl; -class CAddonGUIRadioButton; -class CAddonGUIProgressControl; -class CAddonListItem; -class CAddonGUIRenderingControl; -class CAddonGUISliderControl; -class CAddonGUISettingsSliderControl; +class CAddonGUIControlBase +{ +public: + GUIHANDLE GetControlHandle() const { return m_controlHandle; } -class CHelper_libKODI_guilib +protected: + CAddonGUIControlBase(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIControlBase* window) + : m_controlHandle(nullptr), m_Handle(hdl), m_cb(cb), m_Window(window) {} + virtual ~CAddonGUIControlBase() = default; + + GUIHANDLE m_controlHandle; + AddonCB* m_Handle; + KodiAPI::GUI::CB_GUILib* m_cb; + CAddonGUIControlBase* m_Window; + +private: + CAddonGUIControlBase() = delete; + CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; + CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; +}; + +class CAddonListItem : public CAddonGUIControlBase { public: - CHelper_libKODI_guilib() + CAddonListItem(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) + : CAddonGUIControlBase(hdl, cb, nullptr) { - m_libKODI_guilib = NULL; - m_Handle = NULL; + m_controlHandle = m_cb->ListItem_Create(m_Handle->addonData, label, label2, iconImage, thumbnailImage, path); } - ~CHelper_libKODI_guilib() + virtual ~CAddonListItem() = default; + + const char *GetLabel() + { + if (!m_controlHandle) + return ""; + + return m_cb->ListItem_GetLabel(m_Handle->addonData, m_controlHandle); + } + + void SetLabel(const char *label) + { + if (m_controlHandle) + m_cb->ListItem_SetLabel(m_Handle->addonData, m_controlHandle, label); + } + + const char *GetLabel2() + { + if (!m_controlHandle) + return ""; + + return m_cb->ListItem_GetLabel2(m_Handle->addonData, m_controlHandle); + } + + void SetLabel2(const char *label) + { + if (m_controlHandle) + m_cb->ListItem_SetLabel2(m_Handle->addonData, m_controlHandle, label); + } + + void SetIconImage(const char *image) + { + if (m_controlHandle) + m_cb->ListItem_SetIconImage(m_Handle->addonData, m_controlHandle, image); + } + + void SetThumbnailImage(const char *image) + { + if (m_controlHandle) + m_cb->ListItem_SetThumbnailImage(m_Handle->addonData, m_controlHandle, image); + } + + void SetInfo(const char *Info) + { + if (m_controlHandle) + m_cb->ListItem_SetInfo(m_Handle->addonData, m_controlHandle, Info); + } + + void SetProperty(const char *key, const char *value) + { + if (m_controlHandle) + m_cb->ListItem_SetProperty(m_Handle->addonData, m_controlHandle, key, value); + } + + const char *GetProperty(const char *key) const + { + if (!m_controlHandle) + return ""; + + return m_cb->ListItem_GetProperty(m_Handle->addonData, m_controlHandle, key); + } + + void SetPath(const char *Path) + { + if (m_controlHandle) + m_cb->ListItem_SetPath(m_Handle->addonData, m_controlHandle, Path); + } +}; + +class CAddonGUIWindow : public CAddonGUIControlBase +{ +public: + CAddonGUIWindow(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) + : CAddonGUIControlBase(hdl, cb, nullptr) + , m_cbhdl(nullptr) + , CBOnInit(nullptr) + , CBOnFocus(nullptr) + , CBOnClick(nullptr) + , CBOnAction(nullptr) + { + if (hdl && cb) + { + m_controlHandle = m_cb->Window_New(m_Handle->addonData, xmlFilename, defaultSkin, forceFallback, asDialog); + if (!m_controlHandle) + fprintf(stderr, "libKODI_guilib: ERROR: Can't create window class !!!\n"); + + m_cb->Window_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnInitCB, OnClickCB, OnFocusCB, OnActionCB); + } + } + + virtual ~CAddonGUIWindow() { - if (m_libKODI_guilib) + if (m_Handle && m_cb && m_controlHandle) { - GUI_unregister_me(m_Handle, m_Callbacks); - dlclose(m_libKODI_guilib); + m_cb->Window_Delete(m_Handle->addonData, m_controlHandle); + m_controlHandle = nullptr; } } - bool RegisterMe(void *Handle) + bool Show() { - m_Handle = Handle; + return m_cb->Window_Show(m_Handle->addonData, m_controlHandle); + } - std::string libBasePath; - libBasePath = ((cb_array*)m_Handle)->libPath; - libBasePath += GUI_HELPER_DLL; + void Close() + { + m_cb->Window_Close(m_Handle->addonData, m_controlHandle); + } - m_libKODI_guilib = dlopen(libBasePath.c_str(), RTLD_LAZY); - if (m_libKODI_guilib == NULL) - { - fprintf(stderr, "Unable to load %s\n", dlerror()); + void DoModal() + { + m_cb->Window_DoModal(m_Handle->addonData, m_controlHandle); + } + + bool SetFocusId(int iControlId) + { + return m_cb->Window_SetFocusId(m_Handle->addonData, m_controlHandle, iControlId); + } + + int GetFocusId() + { + return m_cb->Window_GetFocusId(m_Handle->addonData, m_controlHandle); + } + + bool SetCoordinateResolution(int res) + { + return m_cb->Window_SetCoordinateResolution(m_Handle->addonData, m_controlHandle, res); + } + + void SetProperty(const char *key, const char *value) + { + m_cb->Window_SetProperty(m_Handle->addonData, m_controlHandle, key, value); + } + + void SetPropertyInt(const char *key, int value) + { + m_cb->Window_SetPropertyInt(m_Handle->addonData, m_controlHandle, key, value); + } + + void SetPropertyBool(const char *key, bool value) + { + m_cb->Window_SetPropertyBool(m_Handle->addonData, m_controlHandle, key, value); + } + + void SetPropertyDouble(const char *key, double value) + { + m_cb->Window_SetPropertyDouble(m_Handle->addonData, m_controlHandle, key, value); + } + + const char *GetProperty(const char *key) const + { + return m_cb->Window_GetProperty(m_Handle->addonData, m_controlHandle, key); + } + + int GetPropertyInt(const char *key) const + { + return m_cb->Window_GetPropertyInt(m_Handle->addonData, m_controlHandle, key); + } + + bool GetPropertyBool(const char *key) const + { + return m_cb->Window_GetPropertyBool(m_Handle->addonData, m_controlHandle, key); + } + + double GetPropertyDouble(const char *key) const + { + return m_cb->Window_GetPropertyDouble(m_Handle->addonData, m_controlHandle, key); + } + + void ClearProperties() + { + m_cb->Window_ClearProperties(m_Handle->addonData, m_controlHandle); + } + + int GetListSize() + { + return m_cb->Window_GetListSize(m_Handle->addonData, m_controlHandle); + } + + void ClearList() + { + m_cb->Window_ClearList(m_Handle->addonData, m_controlHandle); + } + + GUIHANDLE AddStringItem(const char *name, int itemPosition = -1) + { + return m_cb->Window_AddStringItem(m_Handle->addonData, m_controlHandle, name, itemPosition); + } + + void AddItem(GUIHANDLE item, int itemPosition = -1) + { + m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item, itemPosition); + } + + void AddItem(CAddonListItem *item, int itemPosition = -1) + { + m_cb->Window_AddItem(m_Handle->addonData, m_controlHandle, item->GetControlHandle(), itemPosition); + } + + void RemoveItem(int itemPosition) + { + m_cb->Window_RemoveItem(m_Handle->addonData, m_controlHandle, itemPosition); + } + + GUIHANDLE GetListItem(int listPos) + { + return m_cb->Window_GetListItem(m_Handle->addonData, m_controlHandle, listPos); + } + + void SetCurrentListPosition(int listPos) + { + m_cb->Window_SetCurrentListPosition(m_Handle->addonData, m_controlHandle, listPos); + } + + int GetCurrentListPosition() + { + return m_cb->Window_GetCurrentListPosition(m_Handle->addonData, m_controlHandle); + } + + void SetControlLabel(int controlId, const char *label) + { + m_cb->Window_SetControlLabel(m_Handle->addonData, m_controlHandle, controlId, label); + } + + void MarkDirtyRegion() + { + m_cb->Window_MarkDirtyRegion(m_Handle->addonData, m_controlHandle); + } + + bool OnClick(int controlId) + { + if (!CBOnClick) return false; - } - GUI_register_me = (void* (*)(void *HANDLE)) - dlsym(m_libKODI_guilib, "GUI_register_me"); - if (GUI_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return CBOnClick(m_cbhdl, controlId); + } + + bool OnFocus(int controlId) + { + if (!CBOnFocus) + return false; + + return CBOnFocus(m_cbhdl, controlId); + } + + bool OnInit() + { + if (!CBOnInit) + return false; + + return CBOnInit(m_cbhdl); + } + + bool OnAction(int actionId) + { + if (!CBOnAction) + return false; + + return CBOnAction(m_cbhdl, actionId); + } + + GUIHANDLE m_cbhdl; + bool (*CBOnInit)(GUIHANDLE cbhdl); + bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); + bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); + bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); + +protected: + static bool OnInitCB(GUIHANDLE cbhdl); + static bool OnFocusCB(GUIHANDLE cbhdl, int controlId); + static bool OnClickCB(GUIHANDLE cbhdl, int controlId); + static bool OnActionCB(GUIHANDLE cbhdl, int actionId); +}; + + +inline bool CAddonGUIWindow::OnInitCB(GUIHANDLE cbhdl) +{ + return static_cast(cbhdl)->OnInit(); +} + +inline bool CAddonGUIWindow::OnClickCB(GUIHANDLE cbhdl, int controlId) +{ + return static_cast(cbhdl)->OnClick(controlId); +} + +inline bool CAddonGUIWindow::OnFocusCB(GUIHANDLE cbhdl, int controlId) +{ + return static_cast(cbhdl)->OnFocus(controlId); +} + +inline bool CAddonGUIWindow::OnActionCB(GUIHANDLE cbhdl, int actionId) +{ + return static_cast(cbhdl)->OnAction(actionId); +} + +class CAddonGUISpinControl: public CAddonGUIControlBase +{ +public: + CAddonGUISpinControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + { + m_controlHandle = m_cb->Window_GetControl_Spin(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } + ~CAddonGUISpinControl(void) {} + + void SetVisible(bool yesNo) + { + if (m_controlHandle) + m_cb->Control_Spin_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); + } + + void SetText(const char *label) + { + if (m_controlHandle) + m_cb->Control_Spin_SetText(m_Handle->addonData, m_controlHandle, label); + } + + void Clear() + { + if (m_controlHandle) + m_cb->Control_Spin_Clear(m_Handle->addonData, m_controlHandle); + } + + void AddLabel(const char *label, int iValue) + { + if (m_controlHandle) + m_cb->Control_Spin_AddLabel(m_Handle->addonData, m_controlHandle, label, iValue); + } + + int GetValue() + { + if (!m_controlHandle) + return -1; + + return m_cb->Control_Spin_GetValue(m_Handle->addonData, m_controlHandle); + } + + void SetValue(int iValue) + { + if (m_controlHandle) + m_cb->Control_Spin_SetValue(m_Handle->addonData, m_controlHandle, iValue); + } +}; + +class CAddonGUIRadioButton : public CAddonGUIControlBase +{ +public: + CAddonGUIRadioButton(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + { + m_controlHandle = m_cb->Window_GetControl_RadioButton(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } + ~CAddonGUIRadioButton() {} + + void SetVisible(bool yesNo) + { + if (m_controlHandle) + m_cb->Control_RadioButton_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); + } + + void SetText(const char *label) + { + if (m_controlHandle) + m_cb->Control_RadioButton_SetText(m_Handle->addonData, m_controlHandle, label); + } + + void SetSelected(bool yesNo) + { + if (m_controlHandle) + m_cb->Control_RadioButton_SetSelected(m_Handle->addonData, m_controlHandle, yesNo); + } + + bool IsSelected() + { + if (!m_controlHandle) + return false; + + return m_cb->Control_RadioButton_IsSelected(m_Handle->addonData, m_controlHandle); + } +}; + +class CAddonGUIProgressControl : public CAddonGUIControlBase +{ +public: + CAddonGUIProgressControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + { + m_controlHandle = m_cb->Window_GetControl_Progress(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } + + ~CAddonGUIProgressControl(void) {} + + void SetPercentage(float fPercent) + { + if (m_controlHandle) + m_cb->Control_Progress_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); + } + + float GetPercentage() const + { + if (!m_controlHandle) + return 0.0f; + + return m_cb->Control_Progress_GetPercentage(m_Handle->addonData, m_controlHandle); + } + + void SetInfo(int iInfo) + { + if (m_controlHandle) + m_cb->Control_Progress_SetInfo(m_Handle->addonData, m_controlHandle, iInfo); + } + + int GetInfo() const + { + if (!m_controlHandle) + return -1; + + return m_cb->Control_Progress_GetInfo(m_Handle->addonData, m_controlHandle); + } + + std::string GetDescription() const + { + if (!m_controlHandle) + return ""; - GUI_unregister_me = (void (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_unregister_me"); - if (GUI_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return m_cb->Control_Progress_GetDescription(m_Handle->addonData, m_controlHandle); + } +}; - GUI_lock = (void (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_lock"); - if (GUI_lock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +class CAddonGUISliderControl : public CAddonGUIControlBase +{ +public: + CAddonGUISliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + { + m_controlHandle = m_cb->Window_GetControl_Slider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } + + ~CAddonGUISliderControl(void) {} + + void SetVisible(bool yesNo) + { + if (m_controlHandle) + m_cb->Control_Slider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); + } + + std::string GetDescription() const + { + if (!m_controlHandle) + return ""; - GUI_unlock = (void (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_unlock"); - if (GUI_unlock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return m_cb->Control_Slider_GetDescription(m_Handle->addonData, m_controlHandle); + } - GUI_get_screen_height = (int (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_get_screen_height"); - if (GUI_get_screen_height == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntRange(int iStart, int iEnd) + { + if (m_controlHandle) + m_cb->Control_Slider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); + } - GUI_get_screen_width = (int (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_get_screen_width"); - if (GUI_get_screen_width == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntValue(int iValue) + { + if (m_controlHandle) + m_cb->Control_Slider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); + } - GUI_get_video_resolution = (int (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_get_video_resolution"); - if (GUI_get_video_resolution == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + int GetIntValue() const + { + if (!m_controlHandle) + return 0; + return m_cb->Control_Slider_GetIntValue(m_Handle->addonData, m_controlHandle); + } - GUI_Window_create = (CAddonGUIWindow* (*)(void *HANDLE, void *CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog)) - dlsym(m_libKODI_guilib, "GUI_Window_create"); - if (GUI_Window_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntInterval(int iInterval) + { + if (m_controlHandle) + m_cb->Control_Slider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); + } - GUI_Window_destroy = (void (*)(CAddonGUIWindow* p)) - dlsym(m_libKODI_guilib, "GUI_Window_destroy"); - if (GUI_Window_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetPercentage(float fPercent) + { + if (m_controlHandle) + m_cb->Control_Slider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); + } - GUI_control_get_spin = (CAddonGUISpinControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_spin"); - if (GUI_control_get_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + float GetPercentage() const + { + if (!m_controlHandle) + return 0.0f; - GUI_control_release_spin = (void (*)(CAddonGUISpinControl* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_spin"); - if (GUI_control_release_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return m_cb->Control_Slider_GetPercentage(m_Handle->addonData, m_controlHandle); + } - GUI_control_get_radiobutton = (CAddonGUIRadioButton* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_radiobutton"); - if (GUI_control_get_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatRange(float fStart, float fEnd) + { + if (m_controlHandle) + m_cb->Control_Slider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); + } - GUI_control_release_radiobutton = (void (*)(CAddonGUIRadioButton* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_radiobutton"); - if (GUI_control_release_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatValue(float fValue) + { + if (m_controlHandle) + m_cb->Control_Slider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); + } - GUI_control_get_progress = (CAddonGUIProgressControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_progress"); - if (GUI_control_get_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + float GetFloatValue() const + { + if (!m_controlHandle) + return 0.0f; + return m_cb->Control_Slider_GetFloatValue(m_Handle->addonData, m_controlHandle); + } - GUI_control_release_progress = (void (*)(CAddonGUIProgressControl* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_progress"); - if (GUI_control_release_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatInterval(float fInterval) + { + if (m_controlHandle) + m_cb->Control_Slider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); + } +}; - GUI_ListItem_create = (CAddonListItem* (*)(void *HANDLE, void *CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path)) - dlsym(m_libKODI_guilib, "GUI_ListItem_create"); - if (GUI_ListItem_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +class CAddonGUISettingsSliderControl : public CAddonGUIControlBase +{ +public: + CAddonGUISettingsSliderControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + { + m_controlHandle = m_cb->Window_GetControl_SettingsSlider(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } + + ~CAddonGUISettingsSliderControl(void) {} - GUI_ListItem_destroy = (void (*)(CAddonListItem* p)) - dlsym(m_libKODI_guilib, "GUI_ListItem_destroy"); - if (GUI_ListItem_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetVisible(bool yesNo) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetVisible(m_Handle->addonData, m_controlHandle, yesNo); + } - GUI_control_get_rendering = (CAddonGUIRenderingControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_rendering"); - if (GUI_control_get_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetText(const char *label) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetText(m_Handle->addonData, m_controlHandle, label); + } - GUI_control_release_rendering = (void (*)(CAddonGUIRenderingControl* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_rendering"); - if (GUI_control_release_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + std::string GetDescription() const + { + if (!m_controlHandle) + return ""; - GUI_control_get_slider = (CAddonGUISliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_slider"); - if (GUI_control_get_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return m_cb->Control_SettingsSlider_GetDescription(m_Handle->addonData, m_controlHandle); + } - GUI_control_release_slider = (void (*)(CAddonGUISliderControl* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_slider"); - if (GUI_control_release_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntRange(int iStart, int iEnd) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetIntRange(m_Handle->addonData, m_controlHandle, iStart, iEnd); + } - GUI_control_get_settings_slider = (CAddonGUISettingsSliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) - dlsym(m_libKODI_guilib, "GUI_control_get_settings_slider"); - if (GUI_control_get_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntValue(int iValue) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetIntValue(m_Handle->addonData, m_controlHandle, iValue); + } - GUI_control_release_settings_slider = (void (*)(CAddonGUISettingsSliderControl* p)) - dlsym(m_libKODI_guilib, "GUI_control_release_settings_slider"); - if (GUI_control_release_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + int GetIntValue() const + { + if (!m_controlHandle) + return 0; + return m_cb->Control_SettingsSlider_GetIntValue(m_Handle->addonData, m_controlHandle); + } - GUI_dialog_keyboard_show_and_get_input_with_head = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input_with_head"); - if (GUI_dialog_keyboard_show_and_get_input_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetIntInterval(int iInterval) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetIntInterval(m_Handle->addonData, m_controlHandle, iInterval); + } - GUI_dialog_keyboard_show_and_get_input = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input"); - if (GUI_dialog_keyboard_show_and_get_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetPercentage(float fPercent) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetPercentage(m_Handle->addonData, m_controlHandle, fPercent); + } - GUI_dialog_keyboard_show_and_get_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password_with_head"); - if (GUI_dialog_keyboard_show_and_get_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + float GetPercentage() const + { + if (!m_controlHandle) + return 0.0f; - GUI_dialog_keyboard_show_and_get_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password"); - if (GUI_dialog_keyboard_show_and_get_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return m_cb->Control_SettingsSlider_GetPercentage(m_Handle->addonData, m_controlHandle); + } - GUI_dialog_keyboard_show_and_verify_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password_with_head"); - if (GUI_dialog_keyboard_show_and_verify_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatRange(float fStart, float fEnd) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetFloatRange(m_Handle->addonData, m_controlHandle, fStart, fEnd); + } - GUI_dialog_keyboard_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password"); - if (GUI_dialog_keyboard_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatValue(float fValue) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetFloatValue(m_Handle->addonData, m_controlHandle, fValue); + } - GUI_dialog_keyboard_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_password"); - if (GUI_dialog_keyboard_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + float GetFloatValue() const + { + if (!m_controlHandle) + return 0.0f; + return m_cb->Control_SettingsSlider_GetFloatValue(m_Handle->addonData, m_controlHandle); + } - GUI_dialog_keyboard_show_and_get_filter = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_filter"); - if (GUI_dialog_keyboard_show_and_get_filter == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void SetFloatInterval(float fInterval) + { + if (m_controlHandle) + m_cb->Control_SettingsSlider_SetFloatInterval(m_Handle->addonData, m_controlHandle, fInterval); + } +}; - GUI_dialog_keyboard_send_text_to_active_keyboard = (bool (*)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_send_text_to_active_keyboard"); - if (GUI_dialog_keyboard_send_text_to_active_keyboard == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +class CAddonGUIRenderingControl : public CAddonGUIControlBase +{ +public: + CAddonGUIRenderingControl(AddonCB* hdl, KodiAPI::GUI::CB_GUILib* cb, CAddonGUIWindow *window, int controlId) + : CAddonGUIControlBase(hdl, cb, window) + , m_cbhdl(nullptr) + , CBCreate(nullptr) + , CBRender(nullptr) + , CBStop(nullptr) + , CBDirty(nullptr) + { + m_controlHandle = m_cb->Window_GetControl_RenderAddon(m_Handle->addonData, m_Window->GetControlHandle(), controlId); + } - GUI_dialog_keyboard_is_activated = (bool (*)(void *HANDLE, void *CB)) - dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_is_activated"); - if (GUI_dialog_keyboard_is_activated == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + virtual ~CAddonGUIRenderingControl() + { + m_cb->RenderAddon_Delete(m_Handle->addonData, m_controlHandle); + } - GUI_dialog_numeric_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_new_password"); - if (GUI_dialog_numeric_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void Init() + { + m_cb->RenderAddon_SetCallbacks(m_Handle->addonData, m_controlHandle, this, OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); + } - GUI_dialog_numeric_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_password"); - if (GUI_dialog_numeric_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + bool Create(int x, int y, int w, int h, void *device) + { + if (!CBCreate) + return false; - GUI_dialog_numeric_show_and_verify_input = (bool (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_input"); - if (GUI_dialog_numeric_show_and_verify_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return CBCreate(m_cbhdl, x, y, w, h, device); + } - GUI_dialog_numeric_show_and_get_time = (bool (*)(void *HANDLE, void *CB, tm &time, const char *strHeading)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_time"); - if (GUI_dialog_numeric_show_and_get_time == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void Render() + { + if (!CBRender) + return; - GUI_dialog_numeric_show_and_get_date = (bool (*)(void *HANDLE, void *CB, tm &date, const char *strHeading)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_date"); - if (GUI_dialog_numeric_show_and_get_date == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + CBRender(m_cbhdl); + } - GUI_dialog_numeric_show_and_get_ipaddress = (bool (*)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_ipaddress"); - if (GUI_dialog_numeric_show_and_get_ipaddress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + void Stop() + { + if (!CBStop) + return; - GUI_dialog_numeric_show_and_get_number = (bool (*)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_number"); - if (GUI_dialog_numeric_show_and_get_number == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + CBStop(m_cbhdl); + } - GUI_dialog_numeric_show_and_get_seconds = (bool (*)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading)) - dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_seconds"); - if (GUI_dialog_numeric_show_and_get_seconds == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + bool Dirty() + { + if (!CBDirty) + return true; - GUI_dialog_filebrowser_show_and_get_file = (bool (*)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList)) - dlsym(m_libKODI_guilib, "GUI_dialog_filebrowser_show_and_get_file"); - if (GUI_dialog_filebrowser_show_and_get_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + return CBDirty(m_cbhdl); + } - GUI_dialog_ok_show_and_get_input_single_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *text)) - dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_single_text"); - if (GUI_dialog_ok_show_and_get_input_single_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + GUIHANDLE m_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); - GUI_dialog_ok_show_and_get_input_line_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2)) - dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_line_text"); - if (GUI_dialog_ok_show_and_get_input_line_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +private: + static bool OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device); + static void OnRenderCB(GUIHANDLE cbhdl); + static void OnStopCB(GUIHANDLE cbhdl); + static bool OnDirtyCB(GUIHANDLE cbhdl); +}; - GUI_dialog_yesno_show_and_get_input_singletext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel)) - dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_singletext"); - if (GUI_dialog_yesno_show_and_get_input_singletext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +inline bool CAddonGUIRenderingControl::OnCreateCB(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device) +{ + return static_cast(cbhdl)->Create(x, y, w, h, device); +} - GUI_dialog_yesno_show_and_get_input_linetext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel)) - dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linetext"); - if (GUI_dialog_yesno_show_and_get_input_linetext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +inline void CAddonGUIRenderingControl::OnRenderCB(GUIHANDLE cbhdl) +{ + static_cast(cbhdl)->Render(); +} - GUI_dialog_yesno_show_and_get_input_linebuttontext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel)) - dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linebuttontext"); - if (GUI_dialog_yesno_show_and_get_input_linebuttontext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +inline void CAddonGUIRenderingControl::OnStopCB(GUIHANDLE cbhdl) +{ + static_cast(cbhdl)->Stop(); +} - GUI_dialog_text_viewer = (void (*)(void *hdl, void *cb, const char *heading, const char *text)) - dlsym(m_libKODI_guilib, "GUI_dialog_text_viewer"); - if (GUI_dialog_text_viewer == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +inline bool CAddonGUIRenderingControl::OnDirtyCB(GUIHANDLE cbhdl) +{ + return static_cast(cbhdl)->Dirty(); +} + +class CHelper_libKODI_guilib +{ +public: + CHelper_libKODI_guilib() + { + m_Handle = nullptr; + m_Callbacks = nullptr; + } - GUI_dialog_select = (int (*)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected)) - dlsym(m_libKODI_guilib, "GUI_dialog_select"); - if (GUI_dialog_select == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + ~CHelper_libKODI_guilib() + { + if (m_Handle && m_Callbacks) + { + m_Handle->GUILib_UnRegisterMe(m_Handle->addonData, m_Callbacks); + } + } - m_Callbacks = GUI_register_me(m_Handle); - return m_Callbacks != NULL; + bool RegisterMe(void *handle) + { + m_Handle = static_cast(handle); + if (m_Handle) + m_Callbacks = (KodiAPI::GUI::CB_GUILib*)m_Handle->GUILib_RegisterMe(m_Handle->addonData); + if (!m_Callbacks) + fprintf(stderr, "libKODI_guilib-ERROR: GUILib_RegisterMe can't get callback table from Kodi !!!\n"); + + return m_Callbacks != nullptr; } void Lock() { - return GUI_lock(m_Handle, m_Callbacks); + m_Callbacks->Lock(); } void Unlock() { - return GUI_unlock(m_Handle, m_Callbacks); + m_Callbacks->Unlock(); } int GetScreenHeight() { - return GUI_get_screen_height(m_Handle, m_Callbacks); + return m_Callbacks->GetScreenHeight(); } int GetScreenWidth() { - return GUI_get_screen_width(m_Handle, m_Callbacks); + return m_Callbacks->GetScreenWidth(); } int GetVideoResolution() { - return GUI_get_video_resolution(m_Handle, m_Callbacks); + return m_Callbacks->GetVideoResolution(); } CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) { - return GUI_Window_create(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); + return new CAddonGUIWindow(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); } void Window_destroy(CAddonGUIWindow* p) { - return GUI_Window_destroy(p); + delete p; } CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_spin(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUISpinControl(m_Handle, m_Callbacks, window, controlId); } void Control_releaseSpin(CAddonGUISpinControl* p) { - return GUI_control_release_spin(p); + delete p; } CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_radiobutton(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUIRadioButton(m_Handle, m_Callbacks, window, controlId); } void Control_releaseRadioButton(CAddonGUIRadioButton* p) { - return GUI_control_release_radiobutton(p); + delete p; } CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_progress(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUIProgressControl(m_Handle, m_Callbacks, window, controlId); } void Control_releaseProgress(CAddonGUIProgressControl* p) { - return GUI_control_release_progress(p); + delete p; } CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) { - return GUI_ListItem_create(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); + return new CAddonListItem(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); } void ListItem_destroy(CAddonListItem* p) { - return GUI_ListItem_destroy(p); + delete p; } CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_rendering(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUIRenderingControl(m_Handle, m_Callbacks, window, controlId); } void Control_releaseRendering(CAddonGUIRenderingControl* p) { - return GUI_control_release_rendering(p); + delete p; } CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_slider(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUISliderControl(m_Handle, m_Callbacks, window, controlId); } void Control_releaseSlider(CAddonGUISliderControl* p) { - return GUI_control_release_slider(p); + delete p; } CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId) { - return GUI_control_get_settings_slider(m_Handle, m_Callbacks, window, controlId); + return new CAddonGUISettingsSliderControl(m_Handle, m_Callbacks, window, controlId); } void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p) { - return GUI_control_release_settings_slider(p); + delete p; } /*! @name GUI Keyboard functions */ //@{ bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_get_input_with_head(m_Handle, m_Callbacks, strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndGetInputWithHead(strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); } bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_get_input(m_Handle, m_Callbacks, strText, iMaxStringSize, allowEmptyResult, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndGetInput(strText, iMaxStringSize, allowEmptyResult, autoCloseMs); } bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_get_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); } bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_get_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndGetNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); } bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_verify_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead(strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); } bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize, autoCloseMs); } int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); } bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0) { - return GUI_dialog_keyboard_show_and_get_filter(m_Handle, m_Callbacks, strText, iMaxStringSize, searching, autoCloseMs); + return m_Callbacks->Dialog_Keyboard_ShowAndGetFilter(strText, iMaxStringSize, searching, autoCloseMs); } bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false) { - return GUI_dialog_keyboard_send_text_to_active_keyboard(m_Handle, m_Callbacks, aTextString, closeKeyboard); + return m_Callbacks->Dialog_Keyboard_SendTextToActiveKeyboard(aTextString, closeKeyboard); } bool Dialog_Keyboard_isKeyboardActivated() { - return GUI_dialog_keyboard_is_activated(m_Handle, m_Callbacks); + return m_Callbacks->Dialog_Keyboard_isKeyboardActivated(); } //@} @@ -445,42 +1097,42 @@ public: //@{ bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize) { - return GUI_dialog_numeric_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize); + return m_Callbacks->Dialog_Numeric_ShowAndVerifyNewPassword(strNewPassword, iMaxStringSize); } int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries) { - return GUI_dialog_numeric_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries); + return m_Callbacks->Dialog_Numeric_ShowAndVerifyPassword(strPassword, iMaxStringSize, strHeading, iRetries); } bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput) { - return GUI_dialog_numeric_show_and_verify_input(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, bGetUserInput); + return m_Callbacks->Dialog_Numeric_ShowAndVerifyInput(strPassword, iMaxStringSize, strHeading, bGetUserInput); } bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading) { - return GUI_dialog_numeric_show_and_get_time(m_Handle, m_Callbacks, time, strHeading); + return m_Callbacks->Dialog_Numeric_ShowAndGetTime(time, strHeading); } bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading) { - return GUI_dialog_numeric_show_and_get_date(m_Handle, m_Callbacks, date, strHeading); + return m_Callbacks->Dialog_Numeric_ShowAndGetDate(date, strHeading); } bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading) { - return GUI_dialog_numeric_show_and_get_ipaddress(m_Handle, m_Callbacks, strIPAddress, iMaxStringSize, strHeading); + return m_Callbacks->Dialog_Numeric_ShowAndGetIPAddress(strIPAddress, iMaxStringSize, strHeading); } bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0) { - return GUI_dialog_numeric_show_and_get_number(m_Handle, m_Callbacks, strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); + return m_Callbacks->Dialog_Numeric_ShowAndGetNumber(strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); } bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading) { - return GUI_dialog_numeric_show_and_get_seconds(m_Handle, m_Callbacks, strTime, iMaxStringSize, strHeading); + return m_Callbacks->Dialog_Numeric_ShowAndGetSeconds(strTime, iMaxStringSize, strHeading); } //@} @@ -488,7 +1140,7 @@ public: //@{ bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) { - return GUI_dialog_filebrowser_show_and_get_file(m_Handle, m_Callbacks, directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); + return m_Callbacks->Dialog_FileBrowser_ShowAndGetFile(directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); } //@} @@ -496,12 +1148,12 @@ public: //@{ void Dialog_OK_ShowAndGetInput(const char *heading, const char *text) { - GUI_dialog_ok_show_and_get_input_single_text(m_Handle, m_Callbacks, heading, text); + return m_Callbacks->Dialog_OK_ShowAndGetInputSingleText(heading, text); } void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2) { - GUI_dialog_ok_show_and_get_input_line_text(m_Handle, m_Callbacks, heading, line0, line1, line2); + return m_Callbacks->Dialog_OK_ShowAndGetInputLineText(heading, line0, line1, line2); } //@} @@ -509,17 +1161,17 @@ public: //@{ bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "") { - return GUI_dialog_yesno_show_and_get_input_singletext(m_Handle, m_Callbacks, heading, text, bCanceled, noLabel, yesLabel); + return m_Callbacks->Dialog_YesNo_ShowAndGetInputSingleText(heading, text, bCanceled, noLabel, yesLabel); } bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "") { - return GUI_dialog_yesno_show_and_get_input_linetext(m_Handle, m_Callbacks, heading, line0, line1, line2, noLabel, yesLabel); + return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineText(heading, line0, line1, line2, noLabel, yesLabel); } bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "") { - return GUI_dialog_yesno_show_and_get_input_linebuttontext(m_Handle, m_Callbacks, heading, line0, line1, line2, bCanceled, noLabel, yesLabel); + return m_Callbacks->Dialog_YesNo_ShowAndGetInputLineButtonText(heading, line0, line1, line2, bCanceled, noLabel, yesLabel); } //@} @@ -527,7 +1179,7 @@ public: //@{ void Dialog_TextViewer(const char *heading, const char *text) { - return GUI_dialog_text_viewer(m_Handle, m_Callbacks, heading, text); + return m_Callbacks->Dialog_TextViewer(heading, text); } //@} @@ -535,292 +1187,11 @@ public: //@{ int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1) { - return GUI_dialog_select(m_Handle, m_Callbacks, heading, entries, size, selected); + return m_Callbacks->Dialog_Select(heading, entries, size, selected); } //@} -protected: - void* (*GUI_register_me)(void *HANDLE); - void (*GUI_unregister_me)(void *HANDLE, void* CB); - void (*GUI_lock)(void *HANDLE, void* CB); - void (*GUI_unlock)(void *HANDLE, void* CB); - int (*GUI_get_screen_height)(void *HANDLE, void* CB); - int (*GUI_get_screen_width)(void *HANDLE, void* CB); - int (*GUI_get_video_resolution)(void *HANDLE, void* CB); - CAddonGUIWindow* (*GUI_Window_create)(void *HANDLE, void* CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); - void (*GUI_Window_destroy)(CAddonGUIWindow* p); - CAddonGUISpinControl* (*GUI_control_get_spin)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_spin)(CAddonGUISpinControl* p); - CAddonGUIRadioButton* (*GUI_control_get_radiobutton)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_radiobutton)(CAddonGUIRadioButton* p); - CAddonGUIProgressControl* (*GUI_control_get_progress)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_progress)(CAddonGUIProgressControl* p); - CAddonListItem* (*GUI_ListItem_create)(void *HANDLE, void* CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); - void (*GUI_ListItem_destroy)(CAddonListItem* p); - CAddonGUIRenderingControl* (*GUI_control_get_rendering)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_rendering)(CAddonGUIRenderingControl* p); - CAddonGUISliderControl* (*GUI_control_get_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_slider)(CAddonGUISliderControl* p); - CAddonGUISettingsSliderControl* (*GUI_control_get_settings_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); - void (*GUI_control_release_settings_slider)(CAddonGUISettingsSliderControl* p); - bool (*GUI_dialog_keyboard_show_and_get_input_with_head)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_get_input)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_get_new_password_with_head)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_get_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_verify_new_password_with_head)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); - int (*GUI_dialog_keyboard_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_show_and_get_filter)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); - bool (*GUI_dialog_keyboard_send_text_to_active_keyboard)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard); - bool (*GUI_dialog_keyboard_is_activated)(void *HANDLE, void *CB); - bool (*GUI_dialog_numeric_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize); - int (*GUI_dialog_numeric_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); - bool (*GUI_dialog_numeric_show_and_verify_input)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); - bool (*GUI_dialog_numeric_show_and_get_time)(void *HANDLE, void *CB, tm &time, const char *strHeading); - bool (*GUI_dialog_numeric_show_and_get_date)(void *HANDLE, void *CB, tm &date, const char *strHeading); - bool (*GUI_dialog_numeric_show_and_get_ipaddress)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading); - bool (*GUI_dialog_numeric_show_and_get_number)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); - bool (*GUI_dialog_numeric_show_and_get_seconds)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading); - bool (*GUI_dialog_filebrowser_show_and_get_file)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); - void (*GUI_dialog_ok_show_and_get_input_single_text)(void *HANDLE, void *CB, const char *heading, const char *text); - void (*GUI_dialog_ok_show_and_get_input_line_text)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2); - bool (*GUI_dialog_yesno_show_and_get_input_singletext)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); - bool (*GUI_dialog_yesno_show_and_get_input_linetext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); - bool (*GUI_dialog_yesno_show_and_get_input_linebuttontext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); - void (*GUI_dialog_text_viewer)(void *hdl, void *cb, const char *heading, const char *text); - int (*GUI_dialog_select)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected); - -private: - void *m_libKODI_guilib; - void *m_Handle; - void *m_Callbacks; - struct cb_array - { - const char* libPath; - }; -}; - -class CAddonGUISpinControl -{ -public: - CAddonGUISpinControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUISpinControl(void) {} - - virtual void SetVisible(bool yesNo); - virtual void SetText(const char *label); - virtual void Clear(); - virtual void AddLabel(const char *label, int iValue); - virtual int GetValue(); - virtual void SetValue(int iValue); - -private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_SpinHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUIRadioButton -{ -public: - CAddonGUIRadioButton(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUIRadioButton() {} - - virtual void SetVisible(bool yesNo); - virtual void SetText(const char *label); - virtual void SetSelected(bool yesNo); - virtual bool IsSelected(); - -private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_ButtonHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUIProgressControl -{ -public: - CAddonGUIProgressControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUIProgressControl(void) {} - - virtual void SetPercentage(float fPercent); - virtual float GetPercentage() const; - virtual void SetInfo(int iInfo); - virtual int GetInfo() const; - virtual std::string GetDescription() const; - -private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_ProgressHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUISliderControl -{ -public: - CAddonGUISliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUISliderControl(void) {} - - virtual void SetVisible(bool yesNo); - virtual std::string GetDescription() const; - - virtual void SetIntRange(int iStart, int iEnd); - virtual void SetIntValue(int iValue); - virtual int GetIntValue() const; - virtual void SetIntInterval(int iInterval); - - virtual void SetPercentage(float fPercent); - virtual float GetPercentage() const; - - virtual void SetFloatRange(float fStart, float fEnd); - virtual void SetFloatValue(float fValue); - virtual float GetFloatValue() const; - virtual void SetFloatInterval(float fInterval); - -private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_SliderHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUISettingsSliderControl -{ -public: - CAddonGUISettingsSliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUISettingsSliderControl(void) {} - - virtual void SetVisible(bool yesNo); - virtual void SetText(const char *label); - virtual std::string GetDescription() const; - - virtual void SetIntRange(int iStart, int iEnd); - virtual void SetIntValue(int iValue); - virtual int GetIntValue() const; - virtual void SetIntInterval(int iInterval); - - virtual void SetPercentage(float fPercent); - virtual float GetPercentage() const; - - virtual void SetFloatRange(float fStart, float fEnd); - virtual void SetFloatValue(float fValue); - virtual float GetFloatValue() const; - virtual void SetFloatInterval(float fInterval); - -private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_SettingsSliderHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonListItem -{ -friend class CAddonGUIWindow; - -public: - CAddonListItem(void *hdl, void *cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); - virtual ~CAddonListItem(void) {} - - virtual const char *GetLabel(); - virtual void SetLabel(const char *label); - virtual const char *GetLabel2(); - virtual void SetLabel2(const char *label); - virtual void SetIconImage(const char *image); - virtual void SetThumbnailImage(const char *image); - virtual void SetInfo(const char *Info); - virtual void SetProperty(const char *key, const char *value); - virtual const char *GetProperty(const char *key) const; - virtual void SetPath(const char *Path); - -// {(char*)"select(); -// {(char*)"isSelected(); -protected: - GUIHANDLE m_ListItemHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUIWindow -{ -friend class CAddonGUISpinControl; -friend class CAddonGUIRadioButton; -friend class CAddonGUIProgressControl; -friend class CAddonGUIRenderingControl; -friend class CAddonGUISliderControl; -friend class CAddonGUISettingsSliderControl; - -public: - CAddonGUIWindow(void *hdl, void *cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); - virtual ~CAddonGUIWindow(); - - virtual bool Show(); - virtual void Close(); - virtual void DoModal(); - virtual bool SetFocusId(int iControlId); - virtual int GetFocusId(); - virtual bool SetCoordinateResolution(int res); - virtual void SetProperty(const char *key, const char *value); - virtual void SetPropertyInt(const char *key, int value); - virtual void SetPropertyBool(const char *key, bool value); - virtual void SetPropertyDouble(const char *key, double value); - virtual const char *GetProperty(const char *key) const; - virtual int GetPropertyInt(const char *key) const; - virtual bool GetPropertyBool(const char *key) const; - virtual double GetPropertyDouble(const char *key) const; - virtual void ClearProperties(); - virtual int GetListSize(); - virtual void ClearList(); - virtual GUIHANDLE AddStringItem(const char *name, int itemPosition = -1); - virtual void AddItem(GUIHANDLE item, int itemPosition = -1); - virtual void AddItem(CAddonListItem *item, int itemPosition = -1); - virtual void RemoveItem(int itemPosition); - virtual GUIHANDLE GetListItem(int listPos); - virtual void SetCurrentListPosition(int listPos); - virtual int GetCurrentListPosition(); - virtual void SetControlLabel(int controlId, const char *label); - virtual void MarkDirtyRegion(); - - virtual bool OnClick(int controlId); - virtual bool OnFocus(int controlId); - virtual bool OnInit(); - virtual bool OnAction(int actionId); - - GUIHANDLE m_cbhdl; - bool (*CBOnInit)(GUIHANDLE cbhdl); - bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); - bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); - bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); - -protected: - GUIHANDLE m_WindowHandle; - void *m_Handle; - void *m_cb; -}; - -class CAddonGUIRenderingControl -{ -public: - CAddonGUIRenderingControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); - virtual ~CAddonGUIRenderingControl(); - virtual void Init(); - - virtual bool Create(int x, int y, int w, int h, void *device); - virtual void Render(); - virtual void Stop(); - virtual bool Dirty(); - - GUIHANDLE m_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); - private: - CAddonGUIWindow *m_Window; - GUIHANDLE m_RenderingHandle; - void *m_Handle; - void *m_cb; + AddonCB* m_Handle; + KodiAPI::GUI::CB_GUILib* m_Callbacks; }; -- cgit v1.2.3