Skip to content

Commit

Permalink
Add 3rd optional button to GUIDialogSelect
Browse files Browse the repository at this point in the history
Update both Estuary and Estouchy skins to show this button (id=8)
  • Loading branch information
DaveTBlake committed Jul 31, 2020
1 parent db40b2a commit c52334a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addons/skin.estouchy/xml/DialogSelect.xml
Expand Up @@ -226,6 +226,12 @@
<include>ButtonInfoDialogsCommonValues</include>
<label>186</label>
</control>
<control type="button" id="8">
<description>Add button</description>
<width>200</width>
<include>ButtonInfoDialogsCommonValues</include>
<label></label>
</control>
<control type="button" id="7">
<description>Cancel button</description>
<width>200</width>
Expand Down
4 changes: 4 additions & 0 deletions addons/skin.estuary/xml/Includes_DialogSelect.xml
Expand Up @@ -141,6 +141,10 @@
<param name="id" value="5" />
<param name="label" value="" />
</include>
<include content="DefaultDialogButton">
<param name="id" value="8" />
<param name="label" value="" />
</include>
<include content="DefaultDialogButton">
<param name="id" value="7" />
<param name="label" value="$LOCALIZE[222]" />
Expand Down
35 changes: 35 additions & 0 deletions xbmc/dialogs/GUIDialogSelect.cpp
Expand Up @@ -19,6 +19,7 @@
#define CONTROL_SIMPLE_LIST 3
#define CONTROL_DETAILED_LIST 6
#define CONTROL_EXTRA_BUTTON 5
#define CONTROL_EXTRA_BUTTON2 8
#define CONTROL_CANCEL_BUTTON 7

CGUIDialogSelect::CGUIDialogSelect() : CGUIDialogSelect(WINDOW_DIALOG_SELECT) {}
Expand All @@ -28,6 +29,9 @@ CGUIDialogSelect::CGUIDialogSelect(int windowId)
m_bButtonEnabled(false),
m_bButtonPressed(false),
m_buttonLabel(-1),
m_bButton2Enabled(false),
m_bButton2Pressed(false),
m_button2Label(-1),
m_selectedItem(nullptr),
m_useDetails(false),
m_multiSelection(false),
Expand All @@ -49,6 +53,7 @@ bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
CGUIDialogBoxBase::OnMessage(message);

m_bButtonEnabled = false;
m_bButton2Enabled = false;
m_useDetails = false;
m_multiSelection = false;

Expand All @@ -73,6 +78,7 @@ bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
case GUI_MSG_WINDOW_INIT:
{
m_bButtonPressed = false;
m_bButton2Pressed = false;
m_bConfirmed = false;
CGUIDialogBoxBase::OnMessage(message);
return true;
Expand Down Expand Up @@ -104,6 +110,13 @@ bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
}
}
}
if (iControl == CONTROL_EXTRA_BUTTON2)
{
m_bButton2Pressed = true;
if (m_multiSelection)
m_bConfirmed = true;
Close();
}
if (iControl == CONTROL_EXTRA_BUTTON)
{
m_selectedItem = nullptr;
Expand Down Expand Up @@ -166,6 +179,9 @@ void CGUIDialogSelect::Reset()
{
m_bButtonEnabled = false;
m_bButtonPressed = false;
m_bButton2Enabled = false;
m_bButton2Pressed = false;

m_useDetails = false;
m_multiSelection = false;
m_focusToButton = false;
Expand Down Expand Up @@ -219,11 +235,22 @@ void CGUIDialogSelect::EnableButton(bool enable, int label)
m_buttonLabel = label;
}

void CGUIDialogSelect::EnableButton2(bool enable, int label)
{
m_bButton2Enabled = enable;
m_button2Label = label;
}

bool CGUIDialogSelect::IsButtonPressed()
{
return m_bButtonPressed;
}

bool CGUIDialogSelect::IsButton2Pressed()
{
return m_bButton2Pressed;
}

void CGUIDialogSelect::Sort(bool bSortOrder /*=true*/)
{
m_vecList->Sort(SortByLabel, bSortOrder ? SortOrderAscending : SortOrderDescending);
Expand Down Expand Up @@ -331,6 +358,14 @@ void CGUIDialogSelect::OnInitWindow()
else
SET_CONTROL_HIDDEN(CONTROL_EXTRA_BUTTON);

if (m_bButton2Enabled)
{
SET_CONTROL_LABEL(CONTROL_EXTRA_BUTTON2, g_localizeStrings.Get(m_button2Label));
SET_CONTROL_VISIBLE(CONTROL_EXTRA_BUTTON2);
}
else
SET_CONTROL_HIDDEN(CONTROL_EXTRA_BUTTON2);

SET_CONTROL_LABEL(CONTROL_CANCEL_BUTTON, g_localizeStrings.Get(222));

CGUIDialogBoxBase::OnInitWindow();
Expand Down
5 changes: 5 additions & 0 deletions xbmc/dialogs/GUIDialogSelect.h
Expand Up @@ -33,7 +33,9 @@ class CGUIDialogSelect : public CGUIDialogBoxBase
int GetSelectedItem() const;
const std::vector<int>& GetSelectedItems() const;
void EnableButton(bool enable, int label);
void EnableButton2(bool enable, int label);
bool IsButtonPressed();
bool IsButton2Pressed();
void Sort(bool bSortOrder = true);
void SetSelected(int iSelected);
void SetSelected(const std::string &strSelectedLabel);
Expand All @@ -55,8 +57,11 @@ class CGUIDialogSelect : public CGUIDialogBoxBase

private:
bool m_bButtonEnabled;
bool m_bButton2Enabled;
bool m_bButtonPressed;
bool m_bButton2Pressed;
int m_buttonLabel;
int m_button2Label;
CFileItemPtr m_selectedItem;
bool m_useDetails;
bool m_multiSelection;
Expand Down

0 comments on commit c52334a

Please sign in to comment.