aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenen92 <92enen@gmail.com>2020-10-04 19:20:51 +0100
committerenen92 <92enen@gmail.com>2020-10-04 19:20:51 +0100
commit5caf963d2cbae9081f1e823ad45f5cb8acef76c3 (patch)
treea7f514cbcbe400a530b7db2cf839ddaaed2193a3
parent1d8c418e55a5c28d4c243c766756faf418ff23f9 (diff)
[python][xbmcgui] Allow visibility to be set before creating the control
-rw-r--r--xbmc/interfaces/legacy/Control.cpp19
-rw-r--r--xbmc/interfaces/legacy/Control.h11
2 files changed, 27 insertions, 3 deletions
diff --git a/xbmc/interfaces/legacy/Control.cpp b/xbmc/interfaces/legacy/Control.cpp
index 4017acf625..0b84900732 100644
--- a/xbmc/interfaces/legacy/Control.cpp
+++ b/xbmc/interfaces/legacy/Control.cpp
@@ -95,6 +95,7 @@ namespace XBMCAddon
0,
true,
false);
+ pGUIControl->SetVisible(m_visible);
CGUIMessage msg(GUI_MSG_LABEL_RESET, iParentId, iControlId);
pGUIControl->OnMessage(msg);
@@ -186,6 +187,7 @@ namespace XBMCAddon
pGUIControl = new CGUITextBox(iParentId, iControlId,
(float)dwPosX, (float)dwPosY, (float)dwWidth, (float)dwHeight,
label);
+ pGUIControl->SetVisible(m_visible);
// set label
CGUIMessage msg(GUI_MSG_LABEL_SET, iParentId, iControlId);
@@ -305,6 +307,7 @@ namespace XBMCAddon
CTextureInfo(strTextureFocus),
CTextureInfo(strTextureNoFocus),
label);
+ pGUIControl->SetVisible(m_visible);
CGUIButtonControl* pGuiButtonControl =
static_cast<CGUIButtonControl*>(pGUIControl);
@@ -359,6 +362,7 @@ namespace XBMCAddon
pGUIControl = new CGUIImage(iParentId, iControlId,
(float)dwPosX, (float)dwPosY, (float)dwWidth, (float)dwHeight,
CTextureInfo(strFileName));
+ pGUIControl->SetVisible(m_visible);
if (pGUIControl && aspectRatio <= CAspectRatio::AR_KEEP)
static_cast<CGUIImage*>(pGUIControl)->SetAspectRatio((CAspectRatio::ASPECT_RATIO)aspectRatio);
@@ -417,6 +421,7 @@ namespace XBMCAddon
CTextureInfo(strTextureBg), CTextureInfo(strTextureLeft),
CTextureInfo(strTextureMid), CTextureInfo(strTextureRight),
CTextureInfo(strTextureOverlay));
+ pGUIControl->SetVisible(m_visible);
if (pGUIControl && colorDiffuse)
static_cast<CGUIProgressControl*>(pGUIControl)->SetColorDiffuse(GUILIB::GUIINFO::CGUIInfoColor(colorDiffuse));
@@ -521,6 +526,7 @@ namespace XBMCAddon
(float) dwPosY,
(float) dwWidth,
(float) dwHeight);
+ pGUIControl->SetVisible(m_visible);
return pGUIControl;
}
@@ -666,6 +672,7 @@ namespace XBMCAddon
CTextureInfo(strTextureRadioOffNoFocus),
CTextureInfo(strTextureRadioOnDisabled),
CTextureInfo(strTextureRadioOffDisabled));
+ pGUIControl->SetVisible(m_visible);
CGUIRadioButtonControl* pGuiButtonControl =
static_cast<CGUIRadioButtonControl*>(pGUIControl);
@@ -706,8 +713,14 @@ namespace XBMCAddon
{
DelayedCallGuard dcguard(languageHook);
XBMCAddonUtils::GuiLock lock(languageHook, false);
- if (pGUIControl)
+ if (pGUIControl != nullptr)
+ {
pGUIControl->SetVisible(visible);
+ }
+ else
+ {
+ m_visible = visible;
+ }
}
bool Control::isVisible()
@@ -969,6 +982,7 @@ namespace XBMCAddon
label,
false,
bHasPath);
+ pGUIControl->SetVisible(m_visible);
static_cast<CGUILabelControl*>(pGUIControl)->SetLabel(strText);
return pGUIControl;
}
@@ -1035,6 +1049,7 @@ namespace XBMCAddon
CTextureInfo(strTextureNoFocus),
label,
strText);
+ pGUIControl->SetVisible(m_visible);
// set label
CGUIMessage msg(GUI_MSG_LABEL_SET, iParentId, iControlId);
@@ -1163,7 +1178,7 @@ namespace XBMCAddon
(float)itemHeight,
(float)imageWidth, (float)imageHeight,
(float)space);
-
+ pGUIControl->SetVisible(m_visible);
return pGUIControl;
}
diff --git a/xbmc/interfaces/legacy/Control.h b/xbmc/interfaces/legacy/Control.h
index 94dc18c02a..a80ff37065 100644
--- a/xbmc/interfaces/legacy/Control.h
+++ b/xbmc/interfaces/legacy/Control.h
@@ -239,11 +239,15 @@ namespace XBMCAddon
/// \ingroup python_xbmcgui_control
/// @brief \python_func{ setVisible(visible) }
/// Set's the control's visible/hidden state.
+ /// \anchor python_xbmcgui_control_setVisible
///
/// @param visible bool - True=visible / False=hidden.
///
///
///-----------------------------------------------------------------------
+ /// @python_v19 You can now define the visible state of a control before it being
+ /// added to a window. This value will be taken into account when the control is later
+ /// added.
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
@@ -261,7 +265,11 @@ namespace XBMCAddon
#ifdef DOXYGEN_SHOULD_USE_THIS
/// \ingroup python_xbmcgui_control
/// @brief \python_func{ isVisible() }
- /// Get the control's visible/hidden state.
+ /// Get the control's visible/hidden state with respect to the container/window
+ ///
+ /// @note If a given control is set visible (c.f. \ref python_xbmcgui_control_setVisible "setVisible()"
+ /// but was not yet added to a window, this method will return `False` (the control is not visible yet since
+ /// it was not added to the window).
///
///-----------------------------------------------------------------------
/// @python_v18 New function added.
@@ -605,6 +613,7 @@ namespace XBMCAddon
int iControlLeft = 0;
int iControlRight = 0;
std::string m_label{};
+ bool m_visible{true};
CGUIControl* pGUIControl = nullptr;
#endif