Skip to content

Commit

Permalink
[addons] add gui control classes to new addon interface
Browse files Browse the repository at this point in the history
This change alow addons to edit all used controls on his processed window.

For the moment is this mostly the last request to create the global addon
interface function.

Most further requests are to change addon types iself to new style.
  • Loading branch information
AlwinEsch committed Jun 7, 2017
1 parent b196817 commit 1693350
Show file tree
Hide file tree
Showing 38 changed files with 5,507 additions and 2 deletions.
33 changes: 33 additions & 0 deletions xbmc/addons/interfaces/GUI/General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@

#include "General.h"
#include "controls/Button.h"
#include "controls/Edit.h"
#include "controls/FadeLabel.h"
#include "controls/Image.h"
#include "controls/Label.h"
#include "controls/Progress.h"
#include "controls/RadioButton.h"
#include "controls/Rendering.h"
#include "controls/SettingsSlider.h"
#include "controls/Slider.h"
#include "controls/Spin.h"
#include "controls/TextBox.h"
#include "dialogs/ContextMenu.h"
#include "dialogs/ExtendedProgressBar.h"
#include "dialogs/FileBrowser.h"
Expand Down Expand Up @@ -58,6 +69,17 @@ void Interface_GUIGeneral::Init(AddonGlobalInterface* addonInterface)
addonInterface->toKodi->kodi_gui = static_cast<AddonToKodiFuncTable_kodi_gui*>(malloc(sizeof(AddonToKodiFuncTable_kodi_gui)));

Interface_GUIControlButton::Init(addonInterface);
Interface_GUIControlEdit::Init(addonInterface);
Interface_GUIControlFadeLabel::Init(addonInterface);
Interface_GUIControlImage::Init(addonInterface);
Interface_GUIControlLabel::Init(addonInterface);
Interface_GUIControlProgress::Init(addonInterface);
Interface_GUIControlRadioButton::Init(addonInterface);
Interface_GUIControlAddonRendering::Init(addonInterface);
Interface_GUIControlSettingsSlider::Init(addonInterface);
Interface_GUIControlSlider::Init(addonInterface);
Interface_GUIControlSpin::Init(addonInterface);
Interface_GUIControlTextBox::Init(addonInterface);
Interface_GUIDialogContextMenu::Init(addonInterface);
Interface_GUIDialogExtendedProgress::Init(addonInterface);
Interface_GUIDialogFileBrowser::Init(addonInterface);
Expand Down Expand Up @@ -88,6 +110,17 @@ void Interface_GUIGeneral::DeInit(AddonGlobalInterface* addonInterface)
addonInterface->toKodi->kodi_gui)
{
Interface_GUIControlButton::DeInit(addonInterface);
Interface_GUIControlEdit::DeInit(addonInterface);
Interface_GUIControlFadeLabel::DeInit(addonInterface);
Interface_GUIControlImage::DeInit(addonInterface);
Interface_GUIControlLabel::DeInit(addonInterface);
Interface_GUIControlProgress::DeInit(addonInterface);
Interface_GUIControlRadioButton::DeInit(addonInterface);
Interface_GUIControlAddonRendering::DeInit(addonInterface);
Interface_GUIControlSettingsSlider::DeInit(addonInterface);
Interface_GUIControlSlider::DeInit(addonInterface);
Interface_GUIControlSpin::DeInit(addonInterface);
Interface_GUIControlTextBox::DeInit(addonInterface);
Interface_GUIDialogContextMenu::DeInit(addonInterface);
Interface_GUIDialogExtendedProgress::DeInit(addonInterface);
Interface_GUIDialogFileBrowser::DeInit(addonInterface);
Expand Down
171 changes: 171 additions & 0 deletions xbmc/addons/interfaces/GUI/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

#include "Window.h"
#include "General.h"
#include "controls/Rendering.h"

#include "Application.h"
#include "FileItem.h"
#include "addons/AddonDll.h"
#include "addons/Skin.h"
#include "filesystem/File.h"
#include "guilib/GUIRenderingControl.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/TextureManager.h"
#include "input/Key.h"
Expand Down Expand Up @@ -95,6 +97,17 @@ void Interface_GUIWindow::Init(AddonGlobalInterface* addonInterface)

/* GUI control access functions */
addonInterface->toKodi->kodi_gui->window->get_control_button = get_control_button;
addonInterface->toKodi->kodi_gui->window->get_control_edit = get_control_edit;
addonInterface->toKodi->kodi_gui->window->get_control_fade_label = get_control_fade_label;
addonInterface->toKodi->kodi_gui->window->get_control_image = get_control_image;
addonInterface->toKodi->kodi_gui->window->get_control_label = get_control_label;
addonInterface->toKodi->kodi_gui->window->get_control_progress = get_control_progress;
addonInterface->toKodi->kodi_gui->window->get_control_radio_button = get_control_radio_button;
addonInterface->toKodi->kodi_gui->window->get_control_render_addon = get_control_render_addon;
addonInterface->toKodi->kodi_gui->window->get_control_settings_slider = get_control_settings_slider;
addonInterface->toKodi->kodi_gui->window->get_control_slider = get_control_slider;
addonInterface->toKodi->kodi_gui->window->get_control_spin = get_control_spin;
addonInterface->toKodi->kodi_gui->window->get_control_text_box = get_control_text_box;
}

void Interface_GUIWindow::DeInit(AddonGlobalInterface* addonInterface)
Expand Down Expand Up @@ -840,6 +853,164 @@ void* Interface_GUIWindow::get_control_button(void* kodiBase, void* handle, int

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_BUTTON, "button");
}

void* Interface_GUIWindow::get_control_edit(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_EDIT, "edit");
}

void* Interface_GUIWindow::get_control_fade_label(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_FADELABEL, "fade label");
}

void* Interface_GUIWindow::get_control_image(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_IMAGE, "image");
}

void* Interface_GUIWindow::get_control_label(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_LABEL, "label");
}
void* Interface_GUIWindow::get_control_progress(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_PROGRESS, "progress");
}

void* Interface_GUIWindow::get_control_radio_button(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_RADIO, "radio button");
}

void* Interface_GUIWindow::get_control_render_addon(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

CGUIControl* pGUIControl = static_cast<CGUIAddonWindow*>(handle)->GetAddonControl(control_id, CGUIControl::GUICONTROL_RENDERADDON, "renderaddon");
if (!pGUIControl)
return nullptr;

CGUIAddonRenderingControl *pRenderControl = new CGUIAddonRenderingControl(dynamic_cast<CGUIRenderingControl*>(pGUIControl));
return pRenderControl;
}

void* Interface_GUIWindow::get_control_settings_slider(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_SETTINGS_SLIDER, "settings slider");
}

void* Interface_GUIWindow::get_control_slider(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_SLIDER, "slider");
}

void* Interface_GUIWindow::get_control_spin(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_SPINEX, "spin");
}

void* Interface_GUIWindow::get_control_text_box(void* kodiBase, void* handle, int control_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
CGUIAddonWindow* pAddonWindow = static_cast<CGUIAddonWindow*>(handle);
if (!addon || !pAddonWindow)
{
CLog::Log(LOGERROR, "Interface_GUIWindow::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'",
__FUNCTION__, addon, handle, addon ? addon->ID().c_str() : "unknown");
return nullptr;
}

return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_TEXTBOX, "textbox");
}
//@}

int Interface_GUIWindow::GetNextAvailableWindowId()
Expand Down
11 changes: 11 additions & 0 deletions xbmc/addons/interfaces/GUI/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ namespace ADDON

/* GUI control access functions */
static void* get_control_button(void* kodiBase, void* handle, int control_id);
static void* get_control_edit(void* kodiBase, void* handle, int control_id);
static void* get_control_fade_label(void* kodiBase, void* handle, int control_id);
static void* get_control_image(void* kodiBase, void* handle, int control_id);
static void* get_control_label(void* kodiBase, void* handle, int control_id);
static void* get_control_radio_button(void* kodiBase, void* handle, int control_id);
static void* get_control_progress(void* kodiBase, void* handle, int control_id);
static void* get_control_render_addon(void* kodiBase, void* handle, int control_id);
static void* get_control_settings_slider(void* kodiBase, void* handle, int control_id);
static void* get_control_slider(void* kodiBase, void* handle, int control_id);
static void* get_control_spin(void* kodiBase, void* handle, int control_id);
static void* get_control_text_box(void* kodiBase, void* handle, int control_id);
//@}

private:
Expand Down
26 changes: 24 additions & 2 deletions xbmc/addons/interfaces/GUI/controls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
set(SOURCES Button.cpp)
set(SOURCES Button.cpp
Edit.cpp
FadeLabel.cpp
Image.cpp
Label.cpp
Progress.cpp
RadioButton.cpp
Rendering.cpp
SettingsSlider.cpp
Slider.cpp
Spin.cpp
TextBox.cpp)

set(HEADERS Button.h)
set(HEADERS Button.h
Edit.h
FadeLabel.h
Image.h
Label.h
Progress.h
RadioButton.h
Rendering.h
SettingsSlider.h
Slider.h
Spin.h
TextBox.h)

core_add_library(addons_interfaces_gui_controls)
Loading

0 comments on commit 1693350

Please sign in to comment.