11#include "../AddonBase.h"
12#include "../c-api/gui/window.h"
14#include "input/ActionIDs.h"
127 const std::string& defaultSkin,
129 bool isMedia =
false)
132 m_controlHandle = m_interface->kodi_gui->window->create(
133 m_interface->kodiBase, xmlFilename.c_str(), defaultSkin.c_str(), asDialog, isMedia);
134 if (!m_controlHandle)
136 m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle,
this,
137 CBOnInit, CBOnFocus, CBOnClick, CBOnAction,
138 CBGetContextButtons, CBOnContextButton);
149 m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle);
172 return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle);
183 void Close() { m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); }
192 m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle);
206 return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle,
219 return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle);
232 m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle,
233 controlId, label.c_str());
246 m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle,
260 m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle,
261 controlId, selected);
278 void SetProperty(
const std::string& key,
const std::string& value)
280 m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(),
301 char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle,
305 if (std::strlen(ret))
307 m_interface->free_string(m_interface->kodiBase, ret);
322 m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle,
336 return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle,
350 m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle,
364 return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle,
378 m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle,
392 return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase,
393 m_controlHandle, key.c_str());
403 m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle);
431 m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle,
443 m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle);
454 void AddListItem(
const std::shared_ptr<CListItem>& item,
int itemPosition = -1)
456 m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle,
457 item->m_controlHandle, itemPosition);
470 m_interface->kodi_gui->window->add_list_item(
471 m_interface->kodiBase, m_controlHandle,
472 std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition);
484 m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase,
485 m_controlHandle, itemPosition);
497 m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle,
498 item->m_controlHandle);
513 KODI_GUI_LISTITEM_HANDLE handle = m_interface->kodi_gui->window->get_list_item(
514 m_interface->kodiBase, m_controlHandle, listPos);
516 return std::shared_ptr<CListItem>();
518 return std::make_shared<kodi::gui::CListItem>(handle);
530 m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle,
543 return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase,
556 return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle);
574 m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle,
575 key.c_str(), value.c_str());
613 m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle,
626 return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase,
638 return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle);
673 virtual bool OnFocus(
int controlId) {
return false; }
685 virtual bool OnClick(
int controlId) {
return false; }
764 std::vector<std::pair<unsigned int, std::string>>& buttons)
844 unsigned int* size) =
nullptr,
847 unsigned int button) =
nullptr)
849 if (!cbhdl || !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction)
855 m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl,
856 CBOnInit, CBOnFocus, CBOnClick, CBOnAction,
857 CBGetContextButtons, CBOnContextButton);
863 static bool CBOnInit(KODI_GUI_CLIENT_HANDLE cbhdl)
865 return static_cast<CWindow*
>(cbhdl)->OnInit();
868 static bool CBOnFocus(KODI_GUI_CLIENT_HANDLE cbhdl,
int controlId)
870 return static_cast<CWindow*
>(cbhdl)->OnFocus(controlId);
873 static bool CBOnClick(KODI_GUI_CLIENT_HANDLE cbhdl,
int controlId)
875 return static_cast<CWindow*
>(cbhdl)->OnClick(controlId);
878 static bool CBOnAction(KODI_GUI_CLIENT_HANDLE cbhdl,
ADDON_ACTION actionId)
880 return static_cast<CWindow*
>(cbhdl)->OnAction(actionId);
883 static void CBGetContextButtons(KODI_GUI_CLIENT_HANDLE cbhdl,
888 std::vector<std::pair<unsigned int, std::string>> buttonList;
889 static_cast<CWindow*
>(cbhdl)->GetContextButtons(itemNumber, buttonList);
890 if (!buttonList.empty())
892 unsigned int presentSize =
static_cast<unsigned int>(buttonList.size());
893 if (presentSize > *size)
898 for (
unsigned int i = 0; i < *size; ++i)
900 buttons[i].id = buttonList[i].first;
901 strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH);
906 static bool CBOnContextButton(KODI_GUI_CLIENT_HANDLE cbhdl,
int itemNumber,
unsigned int button)
908 return static_cast<CWindow*
>(cbhdl)->OnContextButton(itemNumber, button);
~CWindow() override
Class destructor.
Definition Window.h:146
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
@ ADDON_LOG_WARNING
2 : To write warnings in the log file.
Definition addon_base.h:190
ADDON_ACTION
Definition action_ids.h:19
@ ADDON_ACTION_PREVIOUS_MENU
10: Previous menu.
Definition action_ids.h:54
@ ADDON_ACTION_NAV_BACK
90: Nav back.
Definition action_ids.h:286
KODI_GUI_CLIENT_HANDLE ClientHandle
Handler for addon-sided processing class If the callback functions used by the window are not used di...
Definition Window.h:43
virtual bool OnContextButton(int itemNumber, unsigned int button)
Called after selection in context menu.
Definition Window.h:777
virtual void GetContextButtons(int itemNumber, std::vector< std::pair< unsigned int, std::string > > &buttons)
Get context menu buttons for list entry.
Definition Window.h:763
virtual bool OnAction(ADDON_ACTION actionId)
OnAction method.
Definition Window.h:740
virtual bool OnInit()
OnInit method.
Definition Window.h:661
virtual bool OnFocus(int controlId)
OnFocus method.
Definition Window.h:673
void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl, bool(*CBOnInit)(kodi::gui::ClientHandle cbhdl), bool(*CBOnFocus)(kodi::gui::ClientHandle cbhdl, int controlId), bool(*CBOnClick)(kodi::gui::ClientHandle cbhdl, int controlId), bool(*CBOnAction)(kodi::gui::ClientHandle cbhdl, ADDON_ACTION actionId), void(*CBGetContextButtons)(kodi::gui::ClientHandle cbhdl, int itemNumber, gui_context_menu_pair *buttons, unsigned int *size)=nullptr, bool(*CBOnContextButton)(kodi::gui::ClientHandle cbhdl, int itemNumber, unsigned int button)=nullptr)
Set independent callbacks
Definition Window.h:835
virtual bool OnClick(int controlId)
OnClick method.
Definition Window.h:685
bool SetFocusId(int controlId)
Gives the control with the supplied focus.
Definition Window.h:204
void RemoveListItem(const std::shared_ptr< CListItem > &item)
Remove item with given control class from list.
Definition Window.h:495
int GetListSize()
To get the amount of entries in the list.
Definition Window.h:554
CWindow(const std::string &xmlFilename, const std::string &defaultSkin, bool asDialog, bool isMedia=false)
Class constructor with needed values for window / dialog.
Definition Window.h:126
void ClearList()
Function delete all entries in integrated list.
Definition Window.h:441
void SetContainerContent(const std::string &value)
Sets the content type of the container.
Definition Window.h:611
void SetPropertyDouble(const std::string &key, double value)
Sets a window property with double value.
Definition Window.h:376
void SetPropertyInt(const std::string &key, int value)
Sets a window property with integer value.
Definition Window.h:320
std::shared_ptr< CListItem > GetListItem(int listPos)
To get list item control class on wanted position.
Definition Window.h:511
void SetControlLabel(int controlId, const std::string &label)
To set the used label on given control id.
Definition Window.h:230
void MarkDirtyRegion()
To inform Kodi that it need to render region new.
Definition Window.h:636
void SetControlVisible(int controlId, bool visible)
To set the visibility on given control id.
Definition Window.h:244
void SetControlSelected(int controlId, bool selected)
To set the selection on given control id.
Definition Window.h:258
void SetProperty(const std::string &key, const std::string &value)
Sets a window property, similar to an infolabel.
Definition Window.h:278
void Close()
Closes this window.
Definition Window.h:183
int GetCurrentListPosition()
To get current selected position in list.
Definition Window.h:541
void DoModal()
Display this window until close() is called.
Definition Window.h:190
void ClearProperty(const std::string &key)
Clears the specific window property.
Definition Window.h:429
void SetPropertyBool(const std::string &key, bool value)
Sets a window property with boolean value.
Definition Window.h:348
std::string GetProperty(const std::string &key) const
Returns a window property as a string, similar to an infolabel.
Definition Window.h:298
bool GetPropertyBool(const std::string &key) const
Returns a window property with boolean value.
Definition Window.h:362
bool Show()
Show this window.
Definition Window.h:170
void SetContainerProperty(const std::string &key, const std::string &value)
Sets a container property, similar to an infolabel.
Definition Window.h:572
int GetPropertyInt(const std::string &key) const
Returns a window property with integer value.
Definition Window.h:334
void SetCurrentListPosition(int listPos)
To set position of selected part in list.
Definition Window.h:528
void AddListItem(const std::shared_ptr< CListItem > &item, int itemPosition=-1)
To add a list item in the on window integrated list.
Definition Window.h:454
void ClearProperties()
Remove all present properties from window.
Definition Window.h:401
void RemoveListItem(int itemPosition)
Remove list item on position.
Definition Window.h:482
int GetCurrentContainerId()
Get the id of the currently visible container.
Definition Window.h:624
void AddListItem(const std::string &item, int itemPosition=-1)
To add a list item based upon string in the on window integrated list.
Definition Window.h:468
double GetPropertyDouble(const std::string &key) const
Returns a window property with double value.
Definition Window.h:390
int GetFocusId()
Returns the id of the control which is focused.
Definition Window.h:217
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938