Permalink
Browse files

WIP: add SetLimit()

  • Loading branch information...
Montellese committed Mar 27, 2013
1 parent a6cd4a3 commit decca1e0d7e449d67c0e77f13c507cdf9a5ee3e1
@@ -1,5 +1,5 @@
<window type="dialog">
- <defaultcontrol always="true">2</defaultcontrol>
+ <defaultcontrol>2</defaultcontrol>
<coordinates>
<system>1</system>
<posx>190</posx>
@@ -70,7 +70,7 @@
<height>466</height>
<onup>2</onup>
<ondown>2</ondown>
- <onleft>4</onleft>
+ <onleft>5</onleft>
<onright>61</onright>
<pagecontrol>61</pagecontrol>
<scrolltime>200</scrolltime>
@@ -146,7 +146,7 @@
<showonepage>false</showonepage>
<orientation>vertical</orientation>
</control>
- <control type="label">
+ <!--<control type="label">
<description>number of files/pages in list text label</description>
<posx>430</posx>
<posy>545</posy>
@@ -159,7 +159,7 @@
<textcolor>grey</textcolor>
<label>([COLOR=blue]$INFO[Container(2).NumItems][/COLOR]) $LOCALIZE[31025] - $LOCALIZE[31024] ([COLOR=blue]$INFO[Container(2).CurrentPage]/$INFO[Container(2).NumPages][/COLOR])</label>
<visible>Control.IsVisible(2)</visible>
- </control>
+ </control>-->
<control type="list" id="3">
<posx>460</posx>
<posy>67</posy>
@@ -237,13 +237,13 @@
<textureslidernib>ScrollBarNib.png</textureslidernib>
<textureslidernibfocus>ScrollBarNib.png</textureslidernibfocus>
<onleft>3</onleft>
- <onright>4</onright>
+ <onright>5</onright>
<ondown>62</ondown>
<onup>62</onup>
<showonepage>false</showonepage>
<orientation>vertical</orientation>
</control>
- <control type="label">
+ <!--<control type="label">
<description>number of files/pages in list text label</description>
<posx>870</posx>
<posy>545</posy>
@@ -256,10 +256,10 @@
<textcolor>grey</textcolor>
<label>([COLOR=blue]$INFO[Container(3).NumItems][/COLOR]) $LOCALIZE[31025] - $LOCALIZE[31024] ([COLOR=blue]$INFO[Container(3).CurrentPage]/$INFO[Container(3).NumPages][/COLOR])</label>
<visible>Control.IsVisible(3)</visible>
- </control>
- <control type="button" id="4">
+ </control>-->
+ <control type="button" id="5">
<description>Manual button</description>
- <posx>20</posx>
+ <posx>350</posx>
<posy>585</posy>
<width>200</width>
<height>40</height>
@@ -26,7 +26,7 @@
#define CONTROL_HEADING 1
#define CONTROL_LIST 2
#define CONTROL_LIST_ASSIGNED 3
-#define CONTROL_BUTTON 4
+#define CONTROL_BUTTON 5
static CFileItemList EmtpyItemList;
@@ -35,6 +35,7 @@ CGUIDialogMultiPropertyEditor::CGUIDialogMultiPropertyEditor()
{
m_aborted = false;
m_sorting.sortBy = SortByLabel;
+ m_limit = 0;
m_items = new CFileItemList;
m_assignedItems = new CFileItemList;
}
@@ -60,7 +61,6 @@ bool CGUIDialogMultiPropertyEditor::OnMessage(CGUIMessage& message)
m_viewControlAssignedItems.Clear();
m_items->Clear();
- SET_CONTROL_LABEL(CONTROL_BUTTON, "");
return true;
case GUI_MSG_CLICKED:
@@ -78,6 +78,10 @@ bool CGUIDialogMultiPropertyEditor::OnMessage(CGUIMessage& message)
int iAction = message.GetParam1();
if (iAction == ACTION_SELECT_ITEM || ACTION_MOUSE_LEFT_CLICK == iAction)
{
+ // check if more items can be assigned
+ if (iControl == CONTROL_LIST && m_limit > 0 && m_limit <= (unsigned int)m_assignedItems->Size())
+ break;
+
CFileItemList *itemsFrom = iControl == CONTROL_LIST ? m_items : m_assignedItems;
CFileItemList *itemsTo = iControl == CONTROL_LIST ? m_assignedItems : m_items;
CGUIViewControl *viewControlFrom = iControl == CONTROL_LIST ? &m_viewControlItems : &m_viewControlAssignedItems;
@@ -119,6 +123,8 @@ bool CGUIDialogMultiPropertyEditor::OnMessage(CGUIMessage& message)
if (iSelected >= 0)
viewControlTo->SetSelectedItem(iSelected);
}
+
+ UpdateControls();
}
}
}
@@ -156,6 +162,7 @@ void CGUIDialogMultiPropertyEditor::Reset()
m_aborted = false;
m_sorting = SortDescription();
m_sorting.sortBy = SortByLabel;
+ m_limit = 0;
m_items->Clear();
m_assignedItems->Clear();
@@ -208,6 +215,11 @@ void CGUIDialogMultiPropertyEditor::SetSorting(const SortDescription &sorting)
m_sorting = sorting;
}
+void CGUIDialogMultiPropertyEditor::SetLimit(unsigned int limit)
+{
+ m_limit = limit;
+}
+
const CFileItemList& CGUIDialogMultiPropertyEditor::GetAssignedItems() const
{
if (m_aborted)
@@ -218,7 +230,7 @@ const CFileItemList& CGUIDialogMultiPropertyEditor::GetAssignedItems() const
CGUIControl* CGUIDialogMultiPropertyEditor::GetFirstFocusableControl(int id)
{
- if (m_viewControlItems.HasControl(id))
+ if (m_viewControlItems.HasControl(id) && (m_limit <= 0 || m_limit > (unsigned int)m_assignedItems->Size()))
id = m_viewControlItems.GetCurrentControl();
else if (m_viewControlAssignedItems.HasControl(id))
id = m_viewControlAssignedItems.GetCurrentControl();
@@ -245,6 +257,7 @@ void CGUIDialogMultiPropertyEditor::OnInitWindow()
m_viewControlAssignedItems.SetCurrentView(CONTROL_LIST_ASSIGNED);
SetupButton();
+ UpdateControls();
CGUIDialogBoxBase::OnInitWindow();
m_viewControlItems.SetSelectedItem(0);
@@ -262,3 +275,8 @@ void CGUIDialogMultiPropertyEditor::SetupButton()
{
SET_CONTROL_LABEL(CONTROL_BUTTON, g_localizeStrings.Get(186));
}
+
+void CGUIDialogMultiPropertyEditor::UpdateControls()
+{
+ CONTROL_ENABLE_ON_CONDITION(CONTROL_LIST, m_limit <= 0 || m_limit > (unsigned int)m_assignedItems->Size());
+}
@@ -45,6 +45,7 @@ class CGUIDialogMultiPropertyEditor : public CGUIDialogBoxBase
void AddAssignedItem(const std::string &item);
void AddAssignedItem(const CFileItem *item);
void SetSorting(const SortDescription &sorting);
+ void SetLimit(unsigned int limit);
const CFileItemList& GetAssignedItems() const;
@@ -55,9 +56,11 @@ class CGUIDialogMultiPropertyEditor : public CGUIDialogBoxBase
virtual void OnWindowUnload();
void SetupButton();
+ void UpdateControls();
bool m_aborted;
SortDescription m_sorting;
+ unsigned int m_limit;
CFileItemList* m_items;
CFileItemList* m_assignedItems;
@@ -1778,6 +1778,7 @@ bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std:
dialog->SetHeading(strHeading);
dialog->SetItems(listItems);
dialog->SetAssignedItems(assignedItems);
+ dialog->SetLimit(5);
dialog->DoModal();
items.Copy(dialog->GetAssignedItems());

0 comments on commit decca1e

Please sign in to comment.