Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[addons] add gui control classes to new addon interface #12259
Conversation
5000+ lines of code to review. That was hard candy. You ow me a beer at next Devcon, @AlwinEsch :-) |
return nullptr; | ||
} | ||
|
||
return pAddonWindow->GetAddonControl(control_id, CGUIControl::GUICONTROL_TEXTBOX, "textbox"); |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
Most of the method implementations in this source file are almost identical. May I suggest to factor out the common functionality. Something like the following would do the trick and significantly reduce the size of this source file:
void* Interface_GUIWindow::get_control(void* kodiBase, void* handle, int control_id, const char* function, CGUIControl::GUICONTROLTYPES type, std::string typeName) { CAddonDll* addon = static_cast(kodiBase); CGUIAddonWindow* pAddonWindow = static_cast(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, type, typeName); }
And change the implementations like this (example):
void* Interface_GUIWindow::get_control_text_box(void* kodiBase, void* handle, int control_id) { return get_control(kodiBase, handle, control_id, __FUNCTION__, CGUIControl::GUICONTROL_TEXTBOX, "textbox"); }
This comment has been minimized.
This comment has been minimized.
AlwinEsch
Jun 7, 2017
Author
Member
If this is not problematic with a static_cast, looks it really better.
This comment has been minimized.
This comment has been minimized.
static char* get_text(void* kodiBase, void* handle); | ||
|
||
static unsigned int get_cursor_position(void* kodiBase, void* handle); | ||
static void set_cursor_position(void* kodiBase, void* handle, unsigned int position); |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
cosmetics: swap the above two lines, for consistency reasons (first the setter, then the getter). At least you used this order for the other read-write properties in this header.
static void set_enabled(void* kodiBase, void* handle, bool enabled); | ||
static void set_selected(void* kodiBase, void* handle, bool selected); | ||
|
||
static void add_label(void* kodiBase, void* handle, const char* label); |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
•
Member
Question: Why "add", not "set"? Can this control have multiple labels and this functions adds another one? If it can only have max. one label, I suggest to name this function "set_label".
In this PR, you introduce other methods/functions having "add" in it's name. Same question applies to all this cases.
This comment has been minimized.
This comment has been minimized.
AlwinEsch
Jun 7, 2017
Author
Member
It can have more strings in a list, for them is the set_scrolling and reset also used.
This comment has been minimized.
This comment has been minimized.
control->SetVisible(visible); | ||
} | ||
|
||
void Interface_GUIControlImage::set_filename(void* kodiBase, void* handle, const char* filename, const bool use_Cache) |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
"const bool" makes no real sense. remove the "const" before "bool", please.
Also, the naming scheme used for the last parameter (the underscore in the middle of the name) is quite unusual. I would just name it "useCache".
This comment has been minimized.
This comment has been minimized.
AlwinEsch
Jun 7, 2017
Author
Member
Thought to have all removed, thank you. It flies out.
With the "use_cache" has I used to have more equal to "C" name style (has wrongly set one character as uppercase).
Only leaved everywhere the "kodiBase" as sign for me that a C++ base is behind.
return; | ||
} | ||
|
||
// create message |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
•
Member
Remove this comment, please. If somebody needs this comment to understand the following lines of code, he's just, well ..., hmpf ;-)
There are other occurrences of exactly this useless comment in this PR. Fix all of it, please.
{ | ||
CLog::Log(LOGERROR, "Interface_GUIControlSlider::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'", | ||
__FUNCTION__, addon, control, addon ? addon->ID().c_str() : "unknown"); | ||
return 0; |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
"return -1;" to indicate error, like done in all (?) other methods returning int?
{ | ||
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); | ||
CGUISpinControlEx* control = static_cast<CGUISpinControlEx*>(handle); | ||
if (!addon || !control) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
{ | ||
CLog::Log(LOGERROR, "Interface_GUIControlSpin::%s - invalid handler data (kodiBase='%p', handle='%p') on addon '%s'", | ||
__FUNCTION__, addon, control, addon ? addon->ID().c_str() : "unknown"); | ||
return 0; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
AlwinEsch
Jun 7, 2017
Author
Member
Not sure what's the best, has set it as 0 to have equal with float error return and is normally the default value if nothing becomes set before.
/// | ||
virtual ~CEdit() | ||
{ | ||
} |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
One of my favorites (as you know): "virtual ~CEdit() = default;" ? Here and everywhere in this PR. ;-)
This comment has been minimized.
This comment has been minimized.
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::CRendering can't create control class from Kodi !!!"); |
This comment has been minimized.
This comment has been minimized.
ksooo
Jun 7, 2017
Member
Use FUNCTION here and at the other places where you hard coded the funtion name for logging?
This comment has been minimized.
This comment has been minimized.
Thanks a lot and the beer is ready. |
Just another small nitpick, the rest is looking very good now. |
} | ||
//@} | ||
|
||
void* Interface_GUIWindow::GetControl(void* kodiBase, void* handle, int control_id, const char* function, CGUIControl::GUICONTROLTYPES type, std::string typeName) |
This comment has been minimized.
This comment has been minimized.
static void set_enabled(void* kodiBase, void* handle, bool enabled); | ||
static void set_selected(void* kodiBase, void* handle, bool selected); | ||
|
||
static void add_label(void* kodiBase, void* handle, const char* label); |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
jenkins build this please |
Good to go. |
AlwinEsch commentedJun 7, 2017
•
edited
Description
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.
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of change
Checklist: