aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/skin.confluence/720p/Home.xml11
-rw-r--r--addons/skin.confluence/720p/MyVideoNav.xml26
-rw-r--r--project/VS2010Express/XBMC.vcxproj3
-rw-r--r--project/VS2010Express/XBMC.vcxproj.filters9
-rw-r--r--xbmc/Application.cpp27
-rw-r--r--xbmc/Application.h1
-rw-r--r--xbmc/guilib/GUIAction.cpp112
-rw-r--r--xbmc/guilib/GUIAction.h72
-rw-r--r--xbmc/guilib/GUIActionDescriptor.h59
-rw-r--r--xbmc/guilib/GUIBaseContainer.cpp24
-rw-r--r--xbmc/guilib/GUIButtonControl.cpp24
-rw-r--r--xbmc/guilib/GUIButtonControl.h16
-rw-r--r--xbmc/guilib/GUIControl.cpp142
-rw-r--r--xbmc/guilib/GUIControl.h55
-rw-r--r--xbmc/guilib/GUIControlFactory.cpp112
-rw-r--r--xbmc/guilib/GUIControlFactory.h5
-rw-r--r--xbmc/guilib/GUIControlGroupList.cpp6
-rw-r--r--xbmc/guilib/GUIEditControl.cpp8
-rw-r--r--xbmc/guilib/GUIEditControl.h7
-rw-r--r--xbmc/guilib/GUIMessage.cpp11
-rw-r--r--xbmc/guilib/GUIMessage.h5
-rw-r--r--xbmc/guilib/GUIMultiSelectText.cpp4
-rw-r--r--xbmc/guilib/GUIPanelContainer.cpp8
-rw-r--r--xbmc/guilib/GUIStaticItem.cpp15
-rw-r--r--xbmc/guilib/GUIStaticItem.h4
-rw-r--r--xbmc/guilib/GUIToggleButtonControl.cpp2
-rw-r--r--xbmc/guilib/GUIToggleButtonControl.h2
-rw-r--r--xbmc/guilib/GUIWindow.cpp21
-rw-r--r--xbmc/guilib/GUIWindow.h6
-rw-r--r--xbmc/guilib/Makefile.in1
-rw-r--r--xbmc/interfaces/http-api/XBMChttp.cpp5
-rw-r--r--xbmc/utils/StringUtils.cpp8
-rw-r--r--xbmc/utils/StringUtils.h1
33 files changed, 344 insertions, 468 deletions
diff --git a/addons/skin.confluence/720p/Home.xml b/addons/skin.confluence/720p/Home.xml
index 7d4a52be3a..8313540223 100644
--- a/addons/skin.confluence/720p/Home.xml
+++ b/addons/skin.confluence/720p/Home.xml
@@ -600,18 +600,11 @@
</item>
<item id="2">
<label>3</label>
- <onclick>ActivateWindow(Videos)</onclick>
+ <onclick condition="!Skin.HasSetting(HomeVideostoFiles)">ActivateWindow(Videos)</onclick>
+ <onclick condition="Skin.HasSetting(HomeVideostoFiles)">ActivateWindow(Videos,Files,Return)</onclick>
<icon>special://skin/backgrounds/videos.jpg</icon>
<thumb>$INFO[Skin.String(Home_Custom_Back_Video_Folder)]</thumb>
<visible>!Skin.HasSetting(HomeMenuNoVideosButton)</visible>
- <visible>!Skin.HasSetting(HomeVideostoFiles)</visible>
- </item>
- <item id="2">
- <label>3</label>
- <onclick>ActivateWindow(Videos,Files,Return)</onclick>
- <icon>special://skin/backgrounds/videos.jpg</icon>
- <thumb>$INFO[Skin.String(Home_Custom_Back_Video_Folder)]</thumb>
- <visible>Skin.HasSetting(HomeVideostoFiles)</visible>
</item>
<item id="10">
<label>20342</label>
diff --git a/addons/skin.confluence/720p/MyVideoNav.xml b/addons/skin.confluence/720p/MyVideoNav.xml
index de024eb0a9..3a20cb6f7c 100644
--- a/addons/skin.confluence/720p/MyVideoNav.xml
+++ b/addons/skin.confluence/720p/MyVideoNav.xml
@@ -1,31 +1,9 @@
<window id="25">
- <defaultcontrol always="true">9999</defaultcontrol>
+ <defaultcontrol always="true">50</defaultcontrol>
<allowoverlay>no</allowoverlay>
<views>50,51,500,550,551,560,501,508,504,503,505,511</views>
+ <onload condition="Skin.HasSetting(ActivateTvTunes) + System.HasAddon(script.tvtunes)">XBMC.RunScript(script.tvtunes,backend=True&amp;loop=False)</onload>
<controls>
- <control type="button" id="9999">
- <description>TvTunes trigger</description>
- <posx>-10</posx>
- <posy>-10</posy>
- <width>1</width>
- <height>1</height>
- <onfocus>XBMC.RunScript(script.tvtunes,backend=True&amp;loop=False)</onfocus>
- <onfocus>SetFocus(50)</onfocus>
- <texturenofocus>-</texturenofocus>
- <texturefocus>-</texturefocus>
- <visible>Skin.HasSetting(ActivateTvTunes) + System.HasAddon(script.tvtunes)</visible>
- </control>
- <control type="button" id="9999">
- <description>Don't trigger TvTunes if its not installed or active (Saves log errors)</description>
- <posx>-10</posx>
- <posy>-10</posy>
- <width>1</width>
- <height>1</height>
- <onfocus>SetFocus(50)</onfocus>
- <texturenofocus>-</texturenofocus>
- <texturefocus>-</texturefocus>
- <visible>!Skin.HasSetting(ActivateTvTunes) | !System.HasAddon(script.tvtunes)</visible>
- </control>
<include>CommonVideoBackground</include>
<include>CommonMediaPlayingBackground</include>
<include>ContentPanelBackgrounds</include>
diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj
index a0d38b4c43..24f3ea6aee 100644
--- a/project/VS2010Express/XBMC.vcxproj
+++ b/project/VS2010Express/XBMC.vcxproj
@@ -360,6 +360,7 @@
<ClCompile Include="..\..\xbmc\guilib\DirtyRegionTracker.cpp" />
<ClCompile Include="..\..\xbmc\guilib\FrameBufferObject.cpp" />
<ClCompile Include="..\..\xbmc\guilib\GraphicContext.cpp" />
+ <ClCompile Include="..\..\xbmc\guilib\GUIAction.cpp" />
<ClCompile Include="..\..\xbmc\guilib\GUIAudioManager.cpp" />
<ClCompile Include="..\..\xbmc\guilib\GUIBaseContainer.cpp" />
<ClCompile Include="..\..\xbmc\guilib\GUIBorderedImage.cpp" />
@@ -1268,7 +1269,7 @@
<ClInclude Include="..\..\xbmc\guilib\Geometry.h" />
<ClInclude Include="..\..\xbmc\guilib\GraphicContext.h" />
<ClInclude Include="..\..\xbmc\guilib\gui3d.h" />
- <ClInclude Include="..\..\xbmc\guilib\GUIActionDescriptor.h" />
+ <ClInclude Include="..\..\xbmc\guilib\GUIAction.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIAudioManager.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIBaseContainer.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIBorderedImage.h" />
diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters
index c370592a28..3a377505f9 100644
--- a/project/VS2010Express/XBMC.vcxproj.filters
+++ b/project/VS2010Express/XBMC.vcxproj.filters
@@ -2490,6 +2490,9 @@
<ClCompile Include="..\..\xbmc\interfaces\info\InfoBool.cpp">
<Filter>interfaces\info</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\guilib\GUIAction.cpp">
+ <Filter>guilib</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
@@ -3631,9 +3634,6 @@
<ClInclude Include="..\..\xbmc\guilib\gui3d.h">
<Filter>guilib</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\guilib\GUIActionDescriptor.h">
- <Filter>guilib</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\guilib\GUIAudioManager.h">
<Filter>guilib</Filter>
</ClInclude>
@@ -5003,6 +5003,9 @@
<ClInclude Include="..\..\xbmc\interfaces\info\InfoBool.h">
<Filter>interfaces\info</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\guilib\GUIAction.h">
+ <Filter>guilib</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 8dbfe46ecc..17ebe6d4cf 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -4537,13 +4537,6 @@ bool CApplication::OnMessage(CGUIMessage& message)
case GUI_MSG_EXECUTE:
if (message.GetNumStringParams())
return ExecuteXBMCAction(message.GetStringParam());
- else
- {
- CGUIActionDescriptor action = message.GetAction();
- action.m_sourceWindowId = message.GetControlId(); // set source window id,
- return ExecuteAction(action);
- }
-
break;
}
return false;
@@ -4587,26 +4580,6 @@ bool CApplication::ExecuteXBMCAction(std::string actionStr)
return true;
}
-bool CApplication::ExecuteAction(CGUIActionDescriptor action)
-{
- if (action.m_lang == CGUIActionDescriptor::LANG_XBMC)
- {
- return ExecuteXBMCAction(action.m_action);
- }
- else if (action.m_lang == CGUIActionDescriptor::LANG_PYTHON)
- {
-#ifdef HAS_PYTHON
- // Determine the context of the action, if possible
- vector<CStdString> argv;
- g_pythonParser.evalString(action.m_action, argv);
- return true;
-#else
- return false;
-#endif
- }
- return false;
-}
-
void CApplication::Process()
{
MEASURE_FUNCTION;
diff --git a/xbmc/Application.h b/xbmc/Application.h
index 78e86072ee..d642f754fb 100644
--- a/xbmc/Application.h
+++ b/xbmc/Application.h
@@ -194,7 +194,6 @@ public:
void CheckMusicPlaylist();
bool ExecuteXBMCAction(std::string action);
- bool ExecuteAction(CGUIActionDescriptor action);
static bool OnEvent(XBMC_Event& newEvent);
diff --git a/xbmc/guilib/GUIAction.cpp b/xbmc/guilib/GUIAction.cpp
new file mode 100644
index 0000000000..da6345f53c
--- /dev/null
+++ b/xbmc/guilib/GUIAction.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "GUIAction.h"
+#include "utils/StringUtils.h"
+#include "GUIWindowManager.h"
+#include "GUIControl.h"
+#include "GUIInfoManager.h"
+
+using namespace std;
+
+CGUIAction::CGUIAction()
+{
+ m_sendThreadMessages = false;
+}
+
+bool CGUIAction::Execute(int controlID, int parentID, int direction /*= 0*/) const
+{
+ if (m_actions.size() == 0) return false;
+ bool retval = false;
+ CGUIAction copy(*this);
+ for (ciActions it = copy.m_actions.begin() ; it != copy.m_actions.end() ; it++)
+ {
+ if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
+ {
+ if (StringUtils::IsInteger(it->action))
+ {
+ CGUIMessage msg(GUI_MSG_MOVE, parentID, controlID, direction);
+ if (parentID)
+ {
+ CGUIWindow *pWindow = g_windowManager.GetWindow(parentID);
+ if (pWindow)
+ {
+ retval |= pWindow->OnMessage(msg);
+ continue;
+ }
+ }
+ retval |= g_windowManager.SendMessage(msg);
+ }
+ else
+ {
+ CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID);
+ msg.SetStringParam(it->action);
+ if (m_sendThreadMessages)
+ g_windowManager.SendThreadMessage(msg);
+ else
+ g_windowManager.SendMessage(msg);
+ retval |= true;
+ }
+ }
+ }
+ return retval;
+}
+
+int CGUIAction::GetNavigation() const
+{
+ for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ {
+ if (StringUtils::IsInteger(it->action))
+ {
+ if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
+ return atoi(it->action.c_str());
+ }
+ }
+ return 0;
+}
+
+void CGUIAction::SetNavigation(int id)
+{
+ if (id == 0) return;
+ CStdString strId;
+ strId.Format("%i", id);
+ for (iActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ {
+ if (StringUtils::IsInteger(it->action) && it->condition.IsEmpty())
+ {
+ it->action = strId;
+ return;
+ }
+ }
+ cond_action_pair pair;
+ pair.action = strId;
+ m_actions.push_back(pair);
+}
+
+bool CGUIAction::HasActionsMeetingCondition() const
+{
+ for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
+ {
+ if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->action))
+ return true;
+ }
+ return false;
+}
diff --git a/xbmc/guilib/GUIAction.h b/xbmc/guilib/GUIAction.h
new file mode 100644
index 0000000000..19c5f32539
--- /dev/null
+++ b/xbmc/guilib/GUIAction.h
@@ -0,0 +1,72 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2011 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include <vector>
+#include "utils/StdString.h"
+
+class CGUIControl;
+
+/**
+ * Class containing vector of condition->(action/navigation route) pairs and handling its execution.
+ */
+class CGUIAction
+{
+public:
+ CGUIAction();
+
+ /**
+ * Execute actions, if action is paired with condition - evaluate condition first
+ */
+ bool Execute(int controlID, int parentID, int direction = 0) const;
+ /**
+ * Check if there is any action that meet its condition
+ */
+ bool HasActionsMeetingCondition() const;
+ /**
+ * Check if there is any action
+ */
+ bool HasAnyActions() const { return m_actions.size() > 0; };
+ /**
+ * Get navigation route that meet its conditions first
+ */
+ int GetNavigation() const;
+ /**
+ * Set navigation route
+ */
+ void SetNavigation(int id);
+
+ // GetFirstAction is only needed in deprecated http api
+ CStdString GetFirstAction() const { return m_actions.size() > 0 ? m_actions[0].action : ""; };
+private:
+ struct cond_action_pair
+ {
+ CStdString condition;
+ CStdString action;
+ };
+
+ std::vector<cond_action_pair> m_actions;
+ bool m_sendThreadMessages;
+
+ typedef std::vector<cond_action_pair>::const_iterator ciActions;
+ typedef std::vector<cond_action_pair>::iterator iActions;
+ friend class CGUIControlFactory; // no need for setters / adders
+};
diff --git a/xbmc/guilib/GUIActionDescriptor.h b/xbmc/guilib/GUIActionDescriptor.h
deleted file mode 100644
index b80479fee1..0000000000
--- a/xbmc/guilib/GUIActionDescriptor.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifndef GUI_ACTION_DESCRIPTOR
-#define GUI_ACTION_DESCRIPTOR
-
-#include "utils/StdString.h"
-#include "system.h"
-
-class CGUIActionDescriptor
-{
-public:
- typedef enum { LANG_XBMC = 0, LANG_PYTHON = 1 /*, LANG_JAVASCRIPT = 2 */ } ActionLang;
-
- CGUIActionDescriptor()
- {
- m_lang = LANG_XBMC;
- m_action = "";
- m_sourceWindowId = -1;
- }
-
- CGUIActionDescriptor(CStdString& action)
- {
- m_lang = LANG_XBMC;
- m_action = action;
- m_sourceWindowId = -1;
- }
-
- CGUIActionDescriptor(ActionLang lang, CStdString& action)
- {
- m_lang = lang;
- m_action = action;
- m_sourceWindowId = -1;
- }
-
- CStdString m_action;
- ActionLang m_lang;
- int m_sourceWindowId; // the id of the window that was a source of an action
-};
-
-#endif
diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp
index 7cf29bb3ef..958cca58b4 100644
--- a/xbmc/guilib/GUIBaseContainer.cpp
+++ b/xbmc/guilib/GUIBaseContainer.cpp
@@ -427,7 +427,7 @@ bool CGUIBaseContainer::OnMessage(CGUIMessage& message)
void CGUIBaseContainer::OnUp()
{
- bool wrapAround = m_controlUp == GetID() || !(m_controlUp || m_upActions.size());
+ bool wrapAround = m_actionUp.GetNavigation() == GetID() || !m_actionUp.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveUp(wrapAround))
return;
// with horizontal lists it doesn't make much sense to have multiselect labels
@@ -436,7 +436,7 @@ void CGUIBaseContainer::OnUp()
void CGUIBaseContainer::OnDown()
{
- bool wrapAround = m_controlDown == GetID() || !(m_controlDown || m_downActions.size());
+ bool wrapAround = m_actionDown.GetNavigation() == GetID() || !m_actionDown.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveDown(wrapAround))
return;
// with horizontal lists it doesn't make much sense to have multiselect labels
@@ -445,7 +445,7 @@ void CGUIBaseContainer::OnDown()
void CGUIBaseContainer::OnLeft()
{
- bool wrapAround = m_controlLeft == GetID() || !(m_controlLeft || m_leftActions.size());
+ bool wrapAround = m_actionLeft.GetNavigation() == GetID() || !m_actionLeft.HasActionsMeetingCondition();
if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
return;
else if (m_orientation == VERTICAL)
@@ -459,7 +459,7 @@ void CGUIBaseContainer::OnLeft()
void CGUIBaseContainer::OnRight()
{
- bool wrapAround = m_controlRight == GetID() || !(m_controlRight || m_rightActions.size());
+ bool wrapAround = m_actionRight.GetNavigation() == GetID() || !m_actionRight.HasActionsMeetingCondition();
if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
return;
else if (m_orientation == VERTICAL)
@@ -693,20 +693,8 @@ bool CGUIBaseContainer::OnClick(int actionID)
int selected = GetSelectedItem();
if (selected >= 0 && selected < (int)m_items.size())
{
- CFileItemPtr item = boost::static_pointer_cast<CFileItem>(m_items[selected]);
- // multiple action strings are concat'd together, separated with " , "
- int controlID = GetID(); // save as these could go away as we send messages
- int parentID = GetParentID();
- vector<CStdString> actions;
- StringUtils::SplitString(item->GetPath(), " , ", actions);
- for (unsigned int i = 0; i < actions.size(); i++)
- {
- CStdString action = actions[i];
- action.Replace(",,", ",");
- CGUIMessage message(GUI_MSG_EXECUTE, controlID, parentID);
- message.SetStringParam(action);
- g_windowManager.SendMessage(message);
- }
+ CGUIStaticItemPtr item = boost::static_pointer_cast<CGUIStaticItem>(m_items[selected]);
+ item->GetClickActions().Execute(GetID(), GetParentID());
}
return true;
}
diff --git a/xbmc/guilib/GUIButtonControl.cpp b/xbmc/guilib/GUIButtonControl.cpp
index f7181e8856..4a8fa3db41 100644
--- a/xbmc/guilib/GUIButtonControl.cpp
+++ b/xbmc/guilib/GUIButtonControl.cpp
@@ -301,39 +301,23 @@ void CGUIButtonControl::OnClick()
// Save values, as the click message may deactivate the window
int controlID = GetID();
int parentID = GetParentID();
- vector<CGUIActionDescriptor> clickActions = m_clickActions;
+ CGUIAction clickActions = m_clickActions;
// button selected, send a message
CGUIMessage msg(GUI_MSG_CLICKED, controlID, parentID, 0);
SendWindowMessage(msg);
- // and execute our actions
- for (unsigned int i = 0; i < clickActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, controlID, parentID);
- message.SetAction(clickActions[i]);
- g_windowManager.SendMessage(message);
- }
+ clickActions.Execute(controlID, parentID);
}
void CGUIButtonControl::OnFocus()
{
- for (unsigned int i = 0; i < m_focusActions.size(); i++)
- { // send using a thread message to ensure the UI is updated prior to message firing.
- CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID);
- message.SetAction(m_focusActions[i]);
- g_windowManager.SendThreadMessage(message);
- }
+ m_focusActions.Execute(GetID(), GetParentID());
}
void CGUIButtonControl::OnUnFocus()
{
- for (unsigned int i = 0; i < m_unfocusActions.size(); i++)
- { // send using a thread message to ensure the UI is updated prior to message firing.
- CGUIMessage message(GUI_MSG_EXECUTE, m_controlID, m_parentID);
- message.SetAction(m_unfocusActions[i]);
- g_windowManager.SendThreadMessage(message);
- }
+ m_unfocusActions.Execute(GetID(), GetParentID());
}
void CGUIButtonControl::SetSelected(bool bSelected)
diff --git a/xbmc/guilib/GUIButtonControl.h b/xbmc/guilib/GUIButtonControl.h
index 4a36af401f..b5e2323c71 100644
--- a/xbmc/guilib/GUIButtonControl.h
+++ b/xbmc/guilib/GUIButtonControl.h
@@ -59,10 +59,10 @@ public:
virtual void SetPosition(float posX, float posY);
virtual void SetLabel(const std::string & aLabel);
virtual void SetLabel2(const std::string & aLabel2);
- void SetClickActions(const std::vector<CGUIActionDescriptor>& clickActions) { m_clickActions = clickActions; };
- const std::vector<CGUIActionDescriptor> &GetClickActions() const { return m_clickActions; };
- void SetFocusActions(const std::vector<CGUIActionDescriptor>& focusActions) { m_focusActions = focusActions; };
- void SetUnFocusActions(const std::vector<CGUIActionDescriptor>& unfocusActions) { m_unfocusActions = unfocusActions; };
+ void SetClickActions(const CGUIAction& clickActions) { m_clickActions = clickActions; };
+ const CGUIAction &GetClickActions() const { return m_clickActions; };
+ void SetFocusActions(const CGUIAction& focusActions) { m_focusActions = focusActions; };
+ void SetUnFocusActions(const CGUIAction& unfocusActions) { m_unfocusActions = unfocusActions; };
const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
virtual CStdString GetLabel() const { return GetDescription(); };
virtual CStdString GetLabel2() const;
@@ -76,7 +76,7 @@ public:
void SettingsCategorySetTextAlign(uint32_t align);
virtual void OnClick();
- bool HasClickActions() { return m_clickActions.size() > 0; };
+ bool HasClickActions() { return m_clickActions.HasActionsMeetingCondition(); };
virtual bool UpdateColors();
@@ -100,9 +100,9 @@ protected:
CGUILabel m_label;
CGUILabel m_label2;
- std::vector<CGUIActionDescriptor> m_clickActions;
- std::vector<CGUIActionDescriptor> m_focusActions;
- std::vector<CGUIActionDescriptor> m_unfocusActions;
+ CGUIAction m_clickActions;
+ CGUIAction m_focusActions;
+ CGUIAction m_unfocusActions;
bool m_bSelected;
};
diff --git a/xbmc/guilib/GUIControl.cpp b/xbmc/guilib/GUIControl.cpp
index 939040a205..236066d12f 100644
--- a/xbmc/guilib/GUIControl.cpp
+++ b/xbmc/guilib/GUIControl.cpp
@@ -48,13 +48,6 @@ CGUIControl::CGUIControl()
m_posY = 0;
m_width = 0;
m_height = 0;
- m_controlLeft = 0;
- m_controlRight = 0;
- m_controlUp = 0;
- m_controlDown = 0;
- m_controlBack = 0;
- m_controlNext = 0;
- m_controlPrev = 0;
ControlType = GUICONTROL_UNKNOWN;
m_bInvalidated = true;
m_bAllocated=false;
@@ -82,13 +75,6 @@ CGUIControl::CGUIControl(int parentID, int controlID, float posX, float posY, fl
m_visibleCondition = 0;
m_enableCondition = 0;
m_enabled = true;
- m_controlLeft = 0;
- m_controlRight = 0;
- m_controlUp = 0;
- m_controlDown = 0;
- m_controlBack = 0;
- m_controlNext = 0;
- m_controlPrev = 0;
ControlType = GUICONTROL_UNKNOWN;
m_bInvalidated = true;
m_bAllocated=false;
@@ -243,97 +229,42 @@ bool CGUIControl::OnAction(const CAction &action)
void CGUIControl::OnUp()
{
if (HasFocus())
- {
- if (m_upActions.size())
- ExecuteActions(m_upActions);
- else if (m_controlID != m_controlUp)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_UP);
- SendWindowMessage(msg);
- }
- }
+ m_actionUp.Execute(GetID(), GetParentID(), ACTION_MOVE_UP);
}
void CGUIControl::OnDown()
{
if (HasFocus())
- {
- if (m_downActions.size())
- ExecuteActions(m_downActions);
- else if (m_controlID != m_controlDown)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_DOWN);
- SendWindowMessage(msg);
- }
- }
+ m_actionDown.Execute(GetID(), GetParentID(), ACTION_MOVE_DOWN);
}
void CGUIControl::OnLeft()
{
if (HasFocus())
- {
- if (m_leftActions.size())
- ExecuteActions(m_leftActions);
- else if (m_controlID != m_controlLeft)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_LEFT);
- SendWindowMessage(msg);
- }
- }
+ m_actionLeft.Execute(GetID(), GetParentID(), ACTION_MOVE_LEFT);
}
void CGUIControl::OnRight()
{
if (HasFocus())
- {
- if (m_rightActions.size())
- ExecuteActions(m_rightActions);
- else if (m_controlID != m_controlRight)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_MOVE_RIGHT);
- SendWindowMessage(msg);
- }
- }
+ m_actionRight.Execute(GetID(), GetParentID(), ACTION_MOVE_RIGHT);
}
bool CGUIControl::OnBack()
{
- if (m_backActions.size())
- {
- ExecuteActions(m_backActions);
- return true;
- }
- else if (m_controlBack && m_controlID != m_controlBack)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_NAV_BACK);
- return SendWindowMessage(msg);
- }
- return false;
+ return HasFocus() ? m_actionBack.Execute(GetID(), GetParentID(), ACTION_NAV_BACK) : false;
}
void CGUIControl::OnNextControl()
{
- if (m_controlID != m_controlNext)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_NEXT_CONTROL, m_controlNext);
- SendWindowMessage(msg);
- }
+ if (HasFocus())
+ m_actionNext.Execute(GetID(), GetParentID(), ACTION_NEXT_CONTROL);
}
void CGUIControl::OnPrevControl()
{
- if (m_controlID != m_controlPrev)
- {
- // Send a message to the window with the sender set as the window
- CGUIMessage msg(GUI_MSG_MOVE, GetParentID(), GetID(), ACTION_PREV_CONTROL, m_controlPrev);
- SendWindowMessage(msg);
- }
+ if (HasFocus())
+ m_actionPrev.Execute(GetID(), GetParentID(), ACTION_PREV_CONTROL);
}
bool CGUIControl::SendWindowMessage(CGUIMessage &message)
@@ -524,28 +455,28 @@ CRect CGUIControl::CalcRenderRegion() const
void CGUIControl::SetNavigation(int up, int down, int left, int right, int back)
{
- m_controlUp = up;
- m_controlDown = down;
- m_controlLeft = left;
- m_controlRight = right;
- m_controlBack = back;
+ m_actionUp.SetNavigation(up);
+ m_actionDown.SetNavigation(down);
+ m_actionLeft.SetNavigation(left);
+ m_actionRight.SetNavigation(right);
+ m_actionBack.SetNavigation(back);
}
void CGUIControl::SetTabNavigation(int next, int prev)
{
- m_controlNext = next;
- m_controlPrev = prev;
+ m_actionNext.SetNavigation(next);
+ m_actionPrev.SetNavigation(prev);
}
-void CGUIControl::SetNavigationActions(const vector<CGUIActionDescriptor> &up, const vector<CGUIActionDescriptor> &down,
- const vector<CGUIActionDescriptor> &left, const vector<CGUIActionDescriptor> &right,
- const vector<CGUIActionDescriptor> &back, bool replace)
+void CGUIControl::SetNavigationActions(const CGUIAction &up, const CGUIAction &down,
+ const CGUIAction &left, const CGUIAction &right,
+ const CGUIAction &back, bool replace)
{
- if (m_leftActions.empty() || replace) m_leftActions = left;
- if (m_rightActions.empty() || replace) m_rightActions = right;
- if (m_upActions.empty() || replace) m_upActions = up;
- if (m_downActions.empty() || replace) m_downActions = down;
- if (m_backActions.empty() || replace) m_backActions = back;
+ if (!m_actionLeft.HasAnyActions() || replace) m_actionLeft = left;
+ if (!m_actionRight.HasAnyActions() || replace) m_actionRight = right;
+ if (!m_actionUp.HasAnyActions() || replace) m_actionUp = up;
+ if (!m_actionDown.HasAnyActions() || replace) m_actionDown = down;
+ if (!m_actionBack.HasAnyActions() || replace) m_actionBack = back;
}
void CGUIControl::SetWidth(float width)
@@ -938,15 +869,15 @@ int CGUIControl::GetNextControl(int direction) const
switch (direction)
{
case ACTION_MOVE_UP:
- return m_controlUp;
+ return m_actionUp.GetNavigation();
case ACTION_MOVE_DOWN:
- return m_controlDown;
+ return m_actionDown.GetNavigation();
case ACTION_MOVE_LEFT:
- return m_controlLeft;
+ return m_actionLeft.GetNavigation();
case ACTION_MOVE_RIGHT:
- return m_controlRight;
+ return m_actionRight.GetNavigation();
case ACTION_NAV_BACK:
- return m_controlBack;
+ return m_actionBack.GetNavigation();
default:
return -1;
}
@@ -991,21 +922,6 @@ void CGUIControl::SetCamera(const CPoint &camera)
m_hasCamera = true;
}
-void CGUIControl::ExecuteActions(const vector<CGUIActionDescriptor> &actions)
-{
- // we should really save anything we need, as the action may cause the window to close
- int savedID = GetID();
- int savedParent = GetParentID();
- vector<CGUIActionDescriptor> savedActions = actions;
-
- for (unsigned int i = 0; i < savedActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, savedID, savedParent);
- message.SetAction(savedActions[i]);
- g_windowManager.SendMessage(message);
- }
-}
-
CPoint CGUIControl::GetRenderPosition() const
{
float z = 0;
diff --git a/xbmc/guilib/GUIControl.h b/xbmc/guilib/GUIControl.h
index e6d54a6a58..d184a4caae 100644
--- a/xbmc/guilib/GUIControl.h
+++ b/xbmc/guilib/GUIControl.h
@@ -32,8 +32,8 @@
#include "GUIMessage.h" // needed by practically all controls
#include "VisibleEffect.h" // needed for the CAnimation members
#include "GUIInfoTypes.h" // needed for CGUIInfoColor to handle infolabel'ed colors
-#include "GUIActionDescriptor.h"
#include "DirtyRegion.h"
+#include "GUIAction.h"
class CGUIListItem; // forward
class CAction;
@@ -180,23 +180,22 @@ public:
/*! \brief Set actions to perform on navigation
Navigations are set if replace is true or if there is no previously set action
- \param up vector of CGUIActionDescriptors to execute on up
- \param down vector of CGUIActionDescriptors to execute on down
- \param left vector of CGUIActionDescriptors to execute on left
- \param right vector of CGUIActionDescriptors to execute on right
- \param back vector of CGUIActionDescriptors to execute on back
+ \param up CGUIAction to execute on up
+ \param down CGUIAction to execute on down
+ \param left CGUIAction to execute on left
+ \param right CGUIAction to execute on right
+ \param back CGUIAction to execute on back
\param replace Actions are set only if replace is true or there is no previously set action. Defaults to true
- \sa SetNavigation, ExecuteActions
+ \sa SetNavigation
*/
- virtual void SetNavigationActions(const std::vector<CGUIActionDescriptor> &up, const std::vector<CGUIActionDescriptor> &down,
- const std::vector<CGUIActionDescriptor> &left, const std::vector<CGUIActionDescriptor> &right,
- const std::vector<CGUIActionDescriptor> &back, bool replace = true);
- void ExecuteActions(const std::vector<CGUIActionDescriptor> &actions);
- int GetControlIdUp() const { return m_controlUp;};
- int GetControlIdDown() const { return m_controlDown;};
- int GetControlIdLeft() const { return m_controlLeft;};
- int GetControlIdRight() const { return m_controlRight;};
- int GetControlIdBack() const { return m_controlBack; };
+ virtual void SetNavigationActions(const CGUIAction &up, const CGUIAction &down,
+ const CGUIAction &left, const CGUIAction &right,
+ const CGUIAction &back, bool replace = true);
+ int GetControlIdUp() const { return m_actionUp.GetNavigation(); };
+ int GetControlIdDown() const { return m_actionDown.GetNavigation(); };
+ int GetControlIdLeft() const { return m_actionLeft.GetNavigation(); };
+ int GetControlIdRight() const { return m_actionRight.GetNavigation(); };
+ int GetControlIdBack() const { return m_actionBack.GetNavigation(); };
virtual int GetNextControl(int direction) const;
virtual void SetFocus(bool focus);
virtual void SetWidth(float width);
@@ -305,22 +304,14 @@ protected:
void UpdateStates(ANIMATION_TYPE type, ANIMATION_PROCESS currentProcess, ANIMATION_STATE currentState);
bool SendWindowMessage(CGUIMessage &message);
- // navigation
- int m_controlLeft;
- int m_controlRight;
- int m_controlUp;
- int m_controlDown;
- int m_controlBack;
- int m_controlNext;
- int m_controlPrev;
-
- std::vector<CGUIActionDescriptor> m_leftActions;
- std::vector<CGUIActionDescriptor> m_rightActions;
- std::vector<CGUIActionDescriptor> m_upActions;
- std::vector<CGUIActionDescriptor> m_downActions;
- std::vector<CGUIActionDescriptor> m_backActions;
- std::vector<CGUIActionDescriptor> m_nextActions;
- std::vector<CGUIActionDescriptor> m_prevActions;
+ // navigation and actions
+ CGUIAction m_actionLeft;
+ CGUIAction m_actionRight;
+ CGUIAction m_actionUp;
+ CGUIAction m_actionDown;
+ CGUIAction m_actionBack;
+ CGUIAction m_actionNext;
+ CGUIAction m_actionPrev;
float m_posX;
float m_posY;
diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp
index 812b61e3be..92526a0cc1 100644
--- a/xbmc/guilib/GUIControlFactory.cpp
+++ b/xbmc/guilib/GUIControlFactory.cpp
@@ -61,6 +61,7 @@
#include "GUIColorManager.h"
#include "settings/Settings.h"
#include "utils/StringUtils.h"
+#include "GUIAction.h"
using namespace std;
@@ -188,45 +189,6 @@ bool CGUIControlFactory::GetDimension(const TiXmlNode *pRootNode, const char* st
return true;
}
-bool CGUIControlFactory::GetMultipleString(const TiXmlNode* pRootNode, const char* strTag, std::vector<CGUIActionDescriptor>& vecStringValue)
-{
- const TiXmlNode* pNode = pRootNode->FirstChild(strTag );
- if (!pNode) return false;
- vecStringValue.clear();
- bool bFound = false;
- while (pNode)
- {
- CGUIActionDescriptor action;
- if (CGUIControlFactory::GetAction((const TiXmlElement*) pNode, action))
- {
- vecStringValue.push_back(action);
- bFound = true;
- }
- pNode = pNode->NextSibling(strTag);
- }
- return bFound;
-}
-
-bool CGUIControlFactory::GetAction(const TiXmlElement* pElement, CGUIActionDescriptor &action)
-{
- CStdString langStr = pElement->Attribute("lang");
- if (langStr.CompareNoCase("python") == 0 )
- action.m_lang = CGUIActionDescriptor::LANG_PYTHON;
- else
- action.m_lang = CGUIActionDescriptor::LANG_XBMC;
-
- if (pElement->FirstChild())
- {
- action.m_action = pElement->FirstChild()->Value();
- return true;
- }
- else
- {
- action.m_action = "";
- return false;
- }
-}
-
bool CGUIControlFactory::GetAspectRatio(const TiXmlNode* pRootNode, const char* strTag, CAspectRatio &aspect)
{
CStdString ratio;
@@ -424,6 +386,24 @@ bool CGUIControlFactory::GetAnimations(TiXmlNode *control, const CRect &rect, in
return ret;
}
+bool CGUIControlFactory::GetActions(const TiXmlNode* pRootNode, const char* strTag, CGUIAction& action)
+{
+ action.m_actions.clear();
+ const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag);
+ while (pElement)
+ {
+ if (pElement->FirstChild())
+ {
+ CGUIAction::cond_action_pair pair;
+ pair.condition = pElement->Attribute("condition");
+ pair.action = pElement->FirstChild()->Value();
+ action.m_actions.push_back(pair);
+ }
+ pElement = pElement->NextSiblingElement(strTag);
+ }
+ return action.m_actions.size() > 0;
+}
+
bool CGUIControlFactory::GetHitRect(const TiXmlNode *control, CRect &rect)
{
const TiXmlElement* node = control->FirstChildElement("hitrect");
@@ -477,20 +457,6 @@ bool CGUIControlFactory::GetInfoColor(const TiXmlNode *control, const char *strT
return false;
}
-bool CGUIControlFactory::GetNavigation(const TiXmlElement *node, const char *tag, int &direction, vector<CGUIActionDescriptor> &actions)
-{
- if (!GetMultipleString(node, tag, actions))
- return false; // no tag specified
- if (actions.size() == 1 && StringUtils::IsNaturalNumber(actions[0].m_action))
- { // single numeric tag specified
- direction = atol(actions[0].m_action.c_str());
- actions.clear();
- }
- else
- direction = 0;
- return true;
-}
-
void CGUIControlFactory::GetInfoLabel(const TiXmlNode *pControlNode, const CStdString &labelTag, CGUIInfoLabel &infoLabel)
{
vector<CGUIInfoLabel> labels;
@@ -610,8 +576,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
float width = 0, height = 0;
float minWidth = 0;
- int left = 0, right = 0, up = 0, down = 0, back = 0, next = 0, prev = 0;
- vector<CGUIActionDescriptor> leftActions, rightActions, upActions, downActions, backActions, nextActions, prevActions;
+ CGUIAction leftActions, rightActions, upActions, downActions, backActions, nextActions, prevActions;
int pageControl = 0;
CGUIInfoColor colorDiffuse(0xFFFFFFFF);
@@ -656,11 +621,11 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
CPoint offset;
bool bHasPath = false;
- vector<CGUIActionDescriptor> clickActions;
- vector<CGUIActionDescriptor> altclickActions;
- vector<CGUIActionDescriptor> focusActions;
- vector<CGUIActionDescriptor> unfocusActions;
- vector<CGUIActionDescriptor> textChangeActions;
+ CGUIAction clickActions;
+ CGUIAction altclickActions;
+ CGUIAction focusActions;
+ CGUIAction unfocusActions;
+ CGUIAction textChangeActions;
CStdString strTitle = "";
CStdString strRSSTags = "";
@@ -756,13 +721,13 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
hitRect.SetRect(posX, posY, posX + width, posY + height);
GetHitRect(pControlNode, hitRect);
- if (!GetNavigation(pControlNode, "onup", up, upActions)) up = id;
- if (!GetNavigation(pControlNode, "ondown", down, downActions)) down = id;
- if (!GetNavigation(pControlNode, "onleft", left, leftActions)) left = id;
- if (!GetNavigation(pControlNode, "onright", right, rightActions)) right = id;
- if (!GetNavigation(pControlNode, "onback", back, backActions)) back = 0;
- if (!GetNavigation(pControlNode, "onnext", next, nextActions)) next = id;
- if (!GetNavigation(pControlNode, "onprev", prev, prevActions)) prev = id;
+ if (!GetActions(pControlNode, "onup", upActions)) upActions.SetNavigation(id);
+ if (!GetActions(pControlNode, "ondown", downActions)) downActions.SetNavigation(id);
+ if (!GetActions(pControlNode, "onleft", leftActions)) leftActions.SetNavigation(id);
+ if (!GetActions(pControlNode, "onright", rightActions)) rightActions.SetNavigation(id);
+ if (!GetActions(pControlNode, "onnext", nextActions)) nextActions.SetNavigation(id);
+ if (!GetActions(pControlNode, "onprev", prevActions)) prevActions.SetNavigation(id);
+ GetActions(pControlNode, "onback", backActions);
if (XMLUtils::GetInt(pControlNode, "defaultcontrol", defaultControl))
{
@@ -799,11 +764,12 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
if (XMLUtils::GetFloat(pControlNode, "textwidth", labelInfo.width))
labelInfo.align |= XBFONT_TRUNCATED;
- GetMultipleString(pControlNode, "onclick", clickActions);
- GetMultipleString(pControlNode, "ontextchange", textChangeActions);
- GetMultipleString(pControlNode, "onfocus", focusActions);
- GetMultipleString(pControlNode, "onunfocus", unfocusActions);
- GetMultipleString(pControlNode, "altclick", altclickActions);
+ GetActions(pControlNode, "onclick", clickActions);
+ GetActions(pControlNode, "ontextchange", textChangeActions);
+ GetActions(pControlNode, "onfocus", focusActions);
+ GetActions(pControlNode, "onunfocus", unfocusActions);
+ focusActions.m_sendThreadMessages = unfocusActions.m_sendThreadMessages = true;
+ GetActions(pControlNode, "altclick", altclickActions);
CStdString infoString;
if (XMLUtils::GetString(pControlNode, "info", infoString))
@@ -1348,8 +1314,6 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
control->SetEnableCondition(enableCondition);
control->SetAnimations(animations);
control->SetColorDiffuse(colorDiffuse);
- control->SetNavigation(up, down, left, right, back);
- control->SetTabNavigation(next,prev);
control->SetNavigationActions(upActions, downActions, leftActions, rightActions, backActions);
control->SetPulseOnSelect(bPulse);
if (hasCamera)
diff --git a/xbmc/guilib/GUIControlFactory.h b/xbmc/guilib/GUIControlFactory.h
index 1f56fa4d14..48803bc243 100644
--- a/xbmc/guilib/GUIControlFactory.h
+++ b/xbmc/guilib/GUIControlFactory.h
@@ -35,6 +35,7 @@ class CTextureInfo; // forward
class CAspectRatio;
class CGUIInfoLabel;
class TiXmlNode;
+class CGUIAction;
/*!
\ingroup controls
@@ -96,14 +97,12 @@ public:
static bool GetInfoColor(const TiXmlNode* pRootNode, const char* strTag, CGUIInfoColor &value);
static CStdString FilterLabel(const CStdString &label);
static bool GetConditionalVisibility(const TiXmlNode* control, CStdString &condition);
- static bool GetMultipleString(const TiXmlNode* pRootNode, const char* strTag, std::vector<CGUIActionDescriptor>& vecStringValue);
+ static bool GetActions(const TiXmlNode* pRootNode, const char* strTag, CGUIAction& actions);
static void GetRectFromString(const CStdString &string, CRect &rect);
- static bool GetAction(const TiXmlElement* pElement, CGUIActionDescriptor &action);
static bool GetHitRect(const TiXmlNode* pRootNode, CRect &rect);
static bool GetScroller(const TiXmlNode *pControlNode, const CStdString &scrollerTag, CScroller& scroller);
private:
static CStdString GetType(const TiXmlElement *pControlNode);
- bool GetNavigation(const TiXmlElement *node, const char *tag, int &direction, std::vector<CGUIActionDescriptor> &actions);
static bool GetConditionalVisibility(const TiXmlNode* control, CStdString &condition, CStdString &allowHiddenFocus);
bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strString);
bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue);
diff --git a/xbmc/guilib/GUIControlGroupList.cpp b/xbmc/guilib/GUIControlGroupList.cpp
index 055cf2fb82..9259a25c88 100644
--- a/xbmc/guilib/GUIControlGroupList.cpp
+++ b/xbmc/guilib/GUIControlGroupList.cpp
@@ -274,16 +274,16 @@ void CGUIControlGroupList::AddControl(CGUIControl *control, int position /*= -1*
}
}
// now the control's nav
- std::vector<CGUIActionDescriptor> empty;
+ CGUIAction empty;
if (m_orientation == VERTICAL)
{
control->SetNavigation(beforeID, afterID, GetControlIdLeft(), GetControlIdRight(), GetControlIdBack());
- control->SetNavigationActions(empty, empty, m_leftActions, m_rightActions, empty, false);
+ control->SetNavigationActions(empty, empty, m_actionLeft, m_actionRight, empty, false);
}
else
{
control->SetNavigation(GetControlIdUp(), GetControlIdDown(), beforeID, afterID, GetControlIdBack());
- control->SetNavigationActions(m_upActions, m_downActions, empty, empty, empty, false);
+ control->SetNavigationActions(m_actionUp, m_actionDown, empty, empty, empty, false);
}
if (!m_useControlPositions)
diff --git a/xbmc/guilib/GUIEditControl.cpp b/xbmc/guilib/GUIEditControl.cpp
index ea3d3a9579..43dbd6c5db 100644
--- a/xbmc/guilib/GUIEditControl.cpp
+++ b/xbmc/guilib/GUIEditControl.cpp
@@ -306,13 +306,7 @@ void CGUIEditControl::UpdateText(bool sendUpdate)
{
SEND_CLICK_MESSAGE(GetID(), GetParentID(), 0);
- vector<CGUIActionDescriptor> textChangeActions = m_textChangeActions;
- for (unsigned int i = 0; i < textChangeActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, GetID(), GetParentID());
- message.SetAction(textChangeActions[i]);
- g_windowManager.SendMessage(message);
- }
+ m_textChangeActions.Execute(GetID(), GetParentID());
}
SetInvalid();
}
diff --git a/xbmc/guilib/GUIEditControl.h b/xbmc/guilib/GUIEditControl.h
index 2204a78e29..90d3395137 100644
--- a/xbmc/guilib/GUIEditControl.h
+++ b/xbmc/guilib/GUIEditControl.h
@@ -74,9 +74,9 @@ public:
void SetInputType(INPUT_TYPE type, int heading);
- void SetTextChangeActions(const std::vector<CGUIActionDescriptor>& textChangeActions) { m_textChangeActions = textChangeActions; };
+ void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; };
- bool HasTextChangeActions() { return m_textChangeActions.size() > 0; };
+ bool HasTextChangeActions() { return m_textChangeActions.HasActionsMeetingCondition(); };
protected:
virtual void ProcessText(unsigned int currentTime);
@@ -108,8 +108,7 @@ protected:
INPUT_TYPE m_inputType;
bool m_isMD5;
- std::vector<CGUIActionDescriptor> m_textChangeActions;
-
+ CGUIAction m_textChangeActions;
unsigned int m_smsKeyIndex;
unsigned int m_smsLastKey;
diff --git a/xbmc/guilib/GUIMessage.cpp b/xbmc/guilib/GUIMessage.cpp
index 437aa9ff4f..e6f73af499 100644
--- a/xbmc/guilib/GUIMessage.cpp
+++ b/xbmc/guilib/GUIMessage.cpp
@@ -115,7 +115,6 @@ const CGUIMessage& CGUIMessage::operator = (const CGUIMessage& msg)
m_senderID = msg.m_senderID;
m_params = msg.m_params;
m_item = msg.m_item;
- m_action = msg.m_action;
return *this;
}
@@ -173,13 +172,3 @@ size_t CGUIMessage::GetNumStringParams() const
{
return m_params.size();
}
-
-void CGUIMessage::SetAction(const CGUIActionDescriptor& action)
-{
- m_action = action;
-}
-
-const CGUIActionDescriptor& CGUIMessage::GetAction() const
-{
- return m_action;
-}
diff --git a/xbmc/guilib/GUIMessage.h b/xbmc/guilib/GUIMessage.h
index 863f0918e6..a3ef506304 100644
--- a/xbmc/guilib/GUIMessage.h
+++ b/xbmc/guilib/GUIMessage.h
@@ -6,8 +6,6 @@
#ifndef GUILIB_MESSAGE_H
#define GUILIB_MESSAGE_H
-#include "GUIActionDescriptor.h"
-
#pragma once
/*
@@ -294,13 +292,10 @@ public:
void SetStringParams(const std::vector<CStdString> &params);
const CStdString& GetStringParam(size_t param = 0) const;
size_t GetNumStringParams() const;
- void SetAction(const CGUIActionDescriptor& action);
- const CGUIActionDescriptor& GetAction() const;
private:
std::string m_strLabel;
std::vector<CStdString> m_params;
- CGUIActionDescriptor m_action;
int m_senderID;
int m_controlID;
int m_message;
diff --git a/xbmc/guilib/GUIMultiSelectText.cpp b/xbmc/guilib/GUIMultiSelectText.cpp
index 35f8009ca1..a22baa0747 100644
--- a/xbmc/guilib/GUIMultiSelectText.cpp
+++ b/xbmc/guilib/GUIMultiSelectText.cpp
@@ -216,7 +216,7 @@ bool CGUIMultiSelectTextControl::MoveLeft()
{
if (m_selectedItem > 0)
ScrollToItem(m_selectedItem - 1);
- else if (GetNumSelectable() && m_controlLeft && m_controlLeft == m_controlID)
+ else if (GetNumSelectable() && m_actionLeft.GetNavigation() && m_actionLeft.GetNavigation() == m_controlID)
ScrollToItem(GetNumSelectable() - 1);
else
return false;
@@ -227,7 +227,7 @@ bool CGUIMultiSelectTextControl::MoveRight()
{
if (GetNumSelectable() && m_selectedItem < GetNumSelectable() - 1)
ScrollToItem(m_selectedItem + 1);
- else if (m_controlRight && m_controlRight == m_controlID)
+ else if (m_actionRight.GetNavigation() && m_actionRight.GetNavigation() == m_controlID)
ScrollToItem(0);
else
return false;
diff --git a/xbmc/guilib/GUIPanelContainer.cpp b/xbmc/guilib/GUIPanelContainer.cpp
index f70a1ca9cd..c914bf1685 100644
--- a/xbmc/guilib/GUIPanelContainer.cpp
+++ b/xbmc/guilib/GUIPanelContainer.cpp
@@ -257,7 +257,7 @@ bool CGUIPanelContainer::OnMessage(CGUIMessage& message)
void CGUIPanelContainer::OnLeft()
{
- bool wrapAround = m_controlLeft == GetID() || !(m_controlLeft || m_leftActions.size());
+ bool wrapAround = m_actionLeft.GetNavigation() == GetID() || !m_actionLeft.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveLeft(wrapAround))
return;
if (m_orientation == HORIZONTAL && MoveUp(wrapAround))
@@ -267,7 +267,7 @@ void CGUIPanelContainer::OnLeft()
void CGUIPanelContainer::OnRight()
{
- bool wrapAround = m_controlRight == GetID() || !(m_controlRight || m_rightActions.size());
+ bool wrapAround = m_actionRight.GetNavigation() == GetID() || !m_actionRight.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveRight(wrapAround))
return;
if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
@@ -277,7 +277,7 @@ void CGUIPanelContainer::OnRight()
void CGUIPanelContainer::OnUp()
{
- bool wrapAround = m_controlUp == GetID() || !(m_controlUp || m_upActions.size());
+ bool wrapAround = m_actionUp.GetNavigation() == GetID() || !m_actionUp.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveUp(wrapAround))
return;
if (m_orientation == HORIZONTAL && MoveLeft(wrapAround))
@@ -287,7 +287,7 @@ void CGUIPanelContainer::OnUp()
void CGUIPanelContainer::OnDown()
{
- bool wrapAround = m_controlDown == GetID() || !(m_controlDown || m_downActions.size());
+ bool wrapAround = m_actionDown.GetNavigation() == GetID() || !m_actionDown.HasActionsMeetingCondition();
if (m_orientation == VERTICAL && MoveDown(wrapAround))
return;
if (m_orientation == HORIZONTAL && MoveRight(wrapAround))
diff --git a/xbmc/guilib/GUIStaticItem.cpp b/xbmc/guilib/GUIStaticItem.cpp
index 1ca926be3d..fd852ff347 100644
--- a/xbmc/guilib/GUIStaticItem.cpp
+++ b/xbmc/guilib/GUIStaticItem.cpp
@@ -46,20 +46,7 @@ CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileIt
CStdString condition;
CGUIControlFactory::GetConditionalVisibility(item, condition);
m_visCondition = g_infoManager.Register(condition, parentID);
- // multiple action strings are concat'd together, separated with " , "
- vector<CGUIActionDescriptor> actions;
- CGUIControlFactory::GetMultipleString(item, "onclick", actions);
- CStdString path;
- for (vector<CGUIActionDescriptor>::iterator it = actions.begin(); it != actions.end(); ++it)
- {
- (*it).m_action.Replace(",", ",,");
- if (!path.IsEmpty())
- {
- path += " , ";
- }
- path += (*it).m_action;
- }
- SetPath(path);
+ CGUIControlFactory::GetActions(item, "onclick", m_clickActions);
SetLabel(label.GetLabel(parentID));
SetLabel2(label2.GetLabel(parentID));
SetThumbnailImage(thumb.GetLabel(parentID, true));
diff --git a/xbmc/guilib/GUIStaticItem.h b/xbmc/guilib/GUIStaticItem.h
index 00e6a5ca1f..66fc49c1a3 100644
--- a/xbmc/guilib/GUIStaticItem.h
+++ b/xbmc/guilib/GUIStaticItem.h
@@ -28,6 +28,7 @@
#include "GUIInfoTypes.h"
#include "../xbmc/FileItem.h"
+#include "GUIAction.h"
class TiXmlElement;
@@ -77,11 +78,14 @@ public:
/*! \brief whether this item is visible or not
*/
bool IsVisible() const;
+
+ const CGUIAction &GetClickActions() const { return m_clickActions; };
private:
typedef std::vector< std::pair<CGUIInfoLabel, CStdString> > InfoVector;
InfoVector m_info;
unsigned int m_visCondition;
bool m_visState;
+ CGUIAction m_clickActions;
};
typedef boost::shared_ptr<CGUIStaticItem> CGUIStaticItemPtr;
diff --git a/xbmc/guilib/GUIToggleButtonControl.cpp b/xbmc/guilib/GUIToggleButtonControl.cpp
index 34366dc6a3..370a931fad 100644
--- a/xbmc/guilib/GUIToggleButtonControl.cpp
+++ b/xbmc/guilib/GUIToggleButtonControl.cpp
@@ -156,7 +156,7 @@ CStdString CGUIToggleButtonControl::GetDescription() const
return CGUIButtonControl::GetDescription();
}
-void CGUIToggleButtonControl::SetAltClickActions(const vector<CGUIActionDescriptor> &clickActions)
+void CGUIToggleButtonControl::SetAltClickActions(const CGUIAction &clickActions)
{
m_selectButton.SetClickActions(clickActions);
}
diff --git a/xbmc/guilib/GUIToggleButtonControl.h b/xbmc/guilib/GUIToggleButtonControl.h
index 10f3793f85..4760515765 100644
--- a/xbmc/guilib/GUIToggleButtonControl.h
+++ b/xbmc/guilib/GUIToggleButtonControl.h
@@ -56,7 +56,7 @@ public:
void SetAltLabel(const std::string& label);
virtual CStdString GetDescription() const;
void SetToggleSelect(const CStdString &toggleSelect);
- void SetAltClickActions(const std::vector<CGUIActionDescriptor> &clickActions);
+ void SetAltClickActions(const CGUIAction &clickActions);
protected:
virtual bool UpdateColors();
diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp
index c0196a8de7..93ff224281 100644
--- a/xbmc/guilib/GUIWindow.cpp
+++ b/xbmc/guilib/GUIWindow.cpp
@@ -143,8 +143,8 @@ bool CGUIWindow::Load(TiXmlDocument &xmlDoc)
SetDefaults();
CGUIControlFactory::GetInfoColor(pRootElement, "backgroundcolor", m_clearBackground);
- CGUIControlFactory::GetMultipleString(pRootElement, "onload", m_loadActions);
- CGUIControlFactory::GetMultipleString(pRootElement, "onunload", m_unloadActions);
+ CGUIControlFactory::GetActions(pRootElement, "onload", m_loadActions);
+ CGUIControlFactory::GetActions(pRootElement, "onunload", m_unloadActions);
CGUIControlFactory::GetHitRect(pRootElement, m_hitRect);
TiXmlElement *pChild = pRootElement->FirstChildElement();
@@ -963,19 +963,6 @@ void CGUIWindow::ClearProperties()
m_mapProperties.clear();
}
-void CGUIWindow::RunActions(std::vector<CGUIActionDescriptor>& actions)
-{
- vector<CGUIActionDescriptor> tempActions = actions;
-
- // and execute our actions
- for (unsigned int i = 0; i < tempActions.size(); i++)
- {
- CGUIMessage message(GUI_MSG_EXECUTE, 0, GetID());
- message.SetAction(tempActions[i]);
- g_windowManager.SendMessage(message);
- }
-}
-
void CGUIWindow::SetRunActionsManually()
{
m_manualRunActions = true;
@@ -983,12 +970,12 @@ void CGUIWindow::SetRunActionsManually()
void CGUIWindow::RunLoadActions()
{
- RunActions(m_loadActions);
+ m_loadActions.Execute(GetID(), GetParentID());
}
void CGUIWindow::RunUnloadActions()
{
- RunActions(m_unloadActions);
+ m_unloadActions.Execute(GetID(), GetParentID());
}
void CGUIWindow::ClearBackground()
diff --git a/xbmc/guilib/GUIWindow.h b/xbmc/guilib/GUIWindow.h
index 342f20ecfa..82d97b2ea7 100644
--- a/xbmc/guilib/GUIWindow.h
+++ b/xbmc/guilib/GUIWindow.h
@@ -256,8 +256,6 @@ protected:
void ChangeButtonToEdit(int id, bool singleLabel = false);
//#endif
- void RunActions(std::vector<CGUIActionDescriptor>& actions);
-
int m_idRange;
OVERLAY_STATE m_overlayState;
RESOLUTION_INFO m_coordsRes; // resolution that the window coordinates are in.
@@ -294,8 +292,8 @@ protected:
}
};
- std::vector<CGUIActionDescriptor> m_loadActions;
- std::vector<CGUIActionDescriptor> m_unloadActions;
+ CGUIAction m_loadActions;
+ CGUIAction m_unloadActions;
bool m_manualRunActions;
diff --git a/xbmc/guilib/Makefile.in b/xbmc/guilib/Makefile.in
index 67c9f7086d..0d274d9c9e 100644
--- a/xbmc/guilib/Makefile.in
+++ b/xbmc/guilib/Makefile.in
@@ -6,6 +6,7 @@ SRCS=AnimatedGif.cpp \
DirtyRegionTracker.cpp \
FrameBufferObject.cpp \
GraphicContext.cpp \
+ GUIAction.cpp \
GUIAudioManager.cpp \
GUIBaseContainer.cpp \
GUIBorderedImage.cpp \
diff --git a/xbmc/interfaces/http-api/XBMChttp.cpp b/xbmc/interfaces/http-api/XBMChttp.cpp
index b4683048ba..6da3670fe2 100644
--- a/xbmc/interfaces/http-api/XBMChttp.cpp
+++ b/xbmc/interfaces/http-api/XBMChttp.cpp
@@ -1746,9 +1746,8 @@ int CXbmcHttp::xbmcGetGUIStatus()
output += closeTag+openTag+"Type:Button";
if (strTmp!="")
output += closeTag+openTag+"Description:" + strTmp;
- vector<CGUIActionDescriptor> actions = ((CGUIButtonControl *)pControl)->GetClickActions();
- if (actions.size())
- output += closeTag+openTag+"Execution:" + actions[0].m_action;
+ if (((CGUIButtonControl *)pControl)->HasClickActions())
+ output += closeTag+openTag+"Execution:" + ((CGUIButtonControl *)pControl)->GetClickActions().GetFirstAction();
}
else if (pControl->GetControlType() == CGUIControl::GUICONTROL_SPIN)
{
diff --git a/xbmc/utils/StringUtils.cpp b/xbmc/utils/StringUtils.cpp
index f98bcd4785..4c2a0a64e6 100644
--- a/xbmc/utils/StringUtils.cpp
+++ b/xbmc/utils/StringUtils.cpp
@@ -267,6 +267,14 @@ bool StringUtils::IsNaturalNumber(const CStdString& str)
return true;
}
+bool StringUtils::IsInteger(const CStdString& str)
+{
+ if (str.size() > 0 && str[0] == '-')
+ return IsNaturalNumber(str.Mid(1));
+ else
+ return IsNaturalNumber(str);
+}
+
void StringUtils::RemoveCRLF(CStdString& strLine)
{
while ( strLine.size() && (strLine.Right(1) == "\n" || strLine.Right(1) == "\r") )
diff --git a/xbmc/utils/StringUtils.h b/xbmc/utils/StringUtils.h
index 9de22b0082..f2afc4bb7a 100644
--- a/xbmc/utils/StringUtils.h
+++ b/xbmc/utils/StringUtils.h
@@ -56,6 +56,7 @@ public:
static CStdString SecondsToTimeString(long seconds, TIME_FORMAT format = TIME_FORMAT_GUESS);
static bool IsNaturalNumber(const CStdString& str);
+ static bool IsInteger(const CStdString& str);
static CStdString SizeToString(int64_t size);
static const CStdString EmptyString;
static size_t FindWords(const char *str, const char *wordLowerCase);