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 Aug 1, 2020
1 parent db40b2a commit d2ab2a1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 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
49 changes: 47 additions & 2 deletions xbmc/dialogs/GUIDialogSelect.cpp
Expand Up @@ -19,15 +19,17 @@
#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) {}

CGUIDialogSelect::CGUIDialogSelect(int windowId)
: CGUIDialogBoxBase(windowId, "DialogSelect.xml"),
m_bButtonEnabled(false),
m_bButton2Enabled(false),
m_bButtonPressed(false),
m_buttonLabel(-1),
m_bButton2Pressed(false),
m_selectedItem(nullptr),
m_useDetails(false),
m_multiSelection(false),
Expand All @@ -49,6 +51,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 +76,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 +108,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 +177,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 @@ -214,16 +228,39 @@ const std::vector<int>& CGUIDialogSelect::GetSelectedItems() const
}

void CGUIDialogSelect::EnableButton(bool enable, int label)
{
m_bButtonEnabled = enable;
m_buttonLabel = g_localizeStrings.Get(label);
}

void CGUIDialogSelect::EnableButton(bool enable, const std::string& label)
{
m_bButtonEnabled = enable;
m_buttonLabel = label;
}

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

void CGUIDialogSelect::EnableButton2(bool enable, const std::string& 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 @@ -325,12 +362,20 @@ void CGUIDialogSelect::OnInitWindow()

if (m_bButtonEnabled)
{
SET_CONTROL_LABEL(CONTROL_EXTRA_BUTTON, g_localizeStrings.Get(m_buttonLabel));
SET_CONTROL_LABEL(CONTROL_EXTRA_BUTTON, m_buttonLabel);
SET_CONTROL_VISIBLE(CONTROL_EXTRA_BUTTON);
}
else
SET_CONTROL_HIDDEN(CONTROL_EXTRA_BUTTON);

if (m_bButton2Enabled)
{
SET_CONTROL_LABEL(CONTROL_EXTRA_BUTTON2, 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
9 changes: 8 additions & 1 deletion xbmc/dialogs/GUIDialogSelect.h
Expand Up @@ -33,7 +33,11 @@ class CGUIDialogSelect : public CGUIDialogBoxBase
int GetSelectedItem() const;
const std::vector<int>& GetSelectedItems() const;
void EnableButton(bool enable, int label);
void EnableButton(bool enable, const std::string& label);
void EnableButton2(bool enable, int label);
void EnableButton2(bool enable, const std::string& label);
bool IsButtonPressed();
bool IsButton2Pressed();
void Sort(bool bSortOrder = true);
void SetSelected(int iSelected);
void SetSelected(const std::string &strSelectedLabel);
Expand All @@ -55,8 +59,11 @@ class CGUIDialogSelect : public CGUIDialogBoxBase

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

0 comments on commit d2ab2a1

Please sign in to comment.