Handle "analog" seeking in a separate handler rather than in GUIDialogSeekBar #1134

Merged
merged 2 commits into from Jul 12, 2012
@@ -28,6 +28,7 @@
7C0A7FC913A9E75400AFC2BD /* DirtyRegionTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FC613A9E75400AFC2BD /* DirtyRegionTracker.cpp */; };
7C0A7FCC13A9E76E00AFC2BD /* GUIWindowDebugInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FCA13A9E76E00AFC2BD /* GUIWindowDebugInfo.cpp */; };
7C0B990A154B80200065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B9908154B80200065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A493D15A968BA004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */; };
7C1A89BB152671FB00C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A89B9152671FB00C63311 /* TextureCacheJob.cpp */; };
7C1D698B15A8142F00658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D698915A8142F00658B65 /* DatabaseManager.cpp */; };
7C1F6F8C13ED17CC001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6F8A13ED17CC001726AB /* LibraryDirectory.cpp */; };
@@ -1027,6 +1028,8 @@
7C0B9908154B80200065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B9909154B80200065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A494015A968D6004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A493C15A968BA004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A89B9152671FB00C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A89BA152671FB00C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D698915A8142F00658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5454,6 +5457,8 @@
F56C775F131EC154000AD0F6 /* ScraperParser.h */,
F56C7760131EC154000AD0F6 /* ScraperUrl.cpp */,
F56C7761131EC154000AD0F6 /* ScraperUrl.h */,
+ 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */,
+ 7C1A493C15A968BA004AF4A4 /* SeekHandler.h */,
36A9445B15821FAB00727135 /* SortUtils.cpp */,
36A9445C15821FAB00727135 /* SortUtils.h */,
F56C7762131EC154000AD0F6 /* Splash.cpp */,
@@ -7233,6 +7238,7 @@
DF08E84515829BA600058C77 /* Exception.cpp in Sources */,
36A9465315AA269B00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D698B15A8142F00658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A493D15A968BA004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -29,6 +29,7 @@
7C0A7FB213A9E72E00AFC2BD /* DirtyRegionSolvers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FAE13A9E72E00AFC2BD /* DirtyRegionSolvers.cpp */; };
7C0A7FB313A9E72E00AFC2BD /* DirtyRegionTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FB013A9E72E00AFC2BD /* DirtyRegionTracker.cpp */; };
7C0B98F9154B7FF30065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B98F7154B7FF30065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A495315A968FB004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */; };
7C1A89CE1526722200C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A89CC1526722200C63311 /* TextureCacheJob.cpp */; };
7C1D697815A8141000658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D697615A8141000658B65 /* DatabaseManager.cpp */; };
7C1F6F7A13ED178F001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6F7813ED178F001726AB /* LibraryDirectory.cpp */; };
@@ -1027,6 +1028,8 @@
7C0B98F7154B7FF30065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B98F8154B7FF30065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A495415A96908004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A495215A968FB004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A89CC1526722200C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A89CD1526722200C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D697615A8141000658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5819,6 +5822,8 @@
F56C874E131F42EC000AD0F6 /* ScraperParser.h */,
F56C874F131F42EC000AD0F6 /* ScraperUrl.cpp */,
F56C8750131F42EC000AD0F6 /* ScraperUrl.h */,
+ 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */,
+ 7C1A495215A968FB004AF4A4 /* SeekHandler.h */,
36A9445015821F5300727135 /* SortUtils.cpp */,
36A9445115821F5300727135 /* SortUtils.h */,
F56C8751131F42EC000AD0F6 /* Splash.cpp */,
@@ -7244,6 +7249,7 @@
DFC3867E158296EC008AE277 /* Exception.cpp in Sources */,
36A9465B15AA26BC00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D697815A8141000658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A495315A968FB004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -258,6 +258,7 @@
43BF09AB1080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF09A81080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp */; };
7C0A7EC013A5DBCE00AFC2BD /* AppParamParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7EBE13A5DBCE00AFC2BD /* AppParamParser.cpp */; };
7C0B98A4154B79C30065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B98A1154B79C30065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A492315A962EE004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */; };
7C1A85661520522500C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A85631520522500C63311 /* TextureCacheJob.cpp */; };
7C1D682915A7D2FD00658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
7C1F6EBB13ECCFA7001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6EB913ECCFA7001726AB /* LibraryDirectory.cpp */; };
@@ -1533,6 +1534,8 @@
7C0B98A1154B79C30065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B98A2154B79C30065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A495B15A96918004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A492215A962EE004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A85631520522500C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A85641520522500C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5898,6 +5901,8 @@
E38E1E780D25F9FD00618676 /* ScraperParser.h */,
E36C29E70DA72486001F0C9D /* ScraperUrl.cpp */,
7CAA25381085971C0096DE39 /* ScraperUrl.h */,
+ 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */,
+ 7C1A492215A962EE004AF4A4 /* SeekHandler.h */,
36A9443F15821E7C00727135 /* SortUtils.cpp */,
36A9444015821E7C00727135 /* SortUtils.h */,
E38E1E7F0D25F9FD00618676 /* Splash.cpp */,
@@ -7325,6 +7330,7 @@
1DE0443515828F4B005DDB4D /* Exception.cpp in Sources */,
36A9464C15AA25FD00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D682915A7D2FD00658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A492315A962EE004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1110,6 +1110,7 @@
<ClCompile Include="..\..\xbmc\utils\RssReader.cpp" />
<ClCompile Include="..\..\xbmc\utils\ScraperParser.cpp" />
<ClCompile Include="..\..\xbmc\utils\ScraperUrl.cpp" />
+ <ClCompile Include="..\..\xbmc\utils\SeekHandler.cpp" />
<ClCompile Include="..\..\xbmc\utils\SortUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\Splash.cpp" />
<ClCompile Include="..\..\xbmc\utils\ssrc.cpp" />
@@ -1906,6 +1907,7 @@
<ClInclude Include="..\..\xbmc\utils\SaveFileStateJob.h" />
<ClInclude Include="..\..\xbmc\utils\ScraperParser.h" />
<ClInclude Include="..\..\xbmc\utils\ScraperUrl.h" />
+ <ClInclude Include="..\..\xbmc\utils\SeekHandler.h" />
<ClInclude Include="..\..\xbmc\utils\SortUtils.h" />
<ClInclude Include="..\..\xbmc\utils\Splash.h" />
<ClInclude Include="..\..\xbmc\utils\ssrc.h" />
@@ -2581,6 +2581,9 @@
<ClCompile Include="..\..\xbmc\network\AirTunesServer.cpp">
<Filter>network</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\utils\SeekHandler.cpp">
+ <Filter>utils</Filter>
+ </ClCompile>
<ClCompile Include="..\..\xbmc\utils\SortUtils.cpp">
<Filter>utils</Filter>
</ClCompile>
@@ -5215,6 +5218,9 @@
<ClInclude Include="..\..\xbmc\network\DllLibShairplay.h">
<Filter>network</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\utils\SeekHandler.h">
+ <Filter>utils</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\utils\SortUtils.h">
<Filter>utils</Filter>
</ClInclude>
View
@@ -104,6 +104,7 @@
#include "settings/AdvancedSettings.h"
#include "guilib/LocalizeStrings.h"
#include "utils/CPUInfo.h"
+#include "utils/SeekHandler.h"
#include "input/KeyboardStat.h"
#include "input/XBMC_vkeys.h"
@@ -375,6 +376,7 @@ CApplication::CApplication(void)
, m_progressTrackingItem(new CFileItem)
, m_videoInfoScanner(new CVideoInfoScanner)
, m_musicInfoScanner(new CMusicInfoScanner)
+ , m_seekHandler(new CSeekHandler)
{
TiXmlBase::SetCondenseWhiteSpace(false);
m_iPlaySpeed = 1;
@@ -445,6 +447,7 @@ CApplication::~CApplication(void)
#endif
delete m_dpms;
+ delete m_seekHandler;
delete m_pInertialScrollingHandler;
}
@@ -2712,9 +2715,7 @@ bool CApplication::OnAction(const CAction &action)
if (IsPlaying() && action.GetAmount() && (action.GetID() == ACTION_ANALOG_SEEK_FORWARD || action.GetID() == ACTION_ANALOG_SEEK_BACK))
{
if (!m_pPlayer->CanSeek()) return false;
- CGUIWindow *seekBar = g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- if (seekBar)
- seekBar->OnAction(action);
+ m_seekHandler->Seek(action.GetID() == ACTION_ANALOG_SEEK_FORWARD, action.GetAmount(), action.GetRepeat());
return true;
}
if (action.GetID() == ACTION_GUIPROFILE_BEGIN)
@@ -2807,7 +2808,10 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
ProcessEventServer(frameTime);
ProcessPeripherals(frameTime);
if (processGUI)
+ {
m_pInertialScrollingHandler->ProcessInertialScroll(frameTime);
+ m_seekHandler->Process();
+ }
}
if (processGUI)
{
@@ -4721,6 +4725,9 @@ bool CApplication::OnMessage(CGUIMessage& message)
#ifdef TARGET_DARWIN
DarwinSetScheduling(message.GetMessage());
#endif
+ // reset the seek handler
+ m_seekHandler->Reset();
+
// Update our infoManager with the new details etc.
if (m_nextPlaylistItem >= 0)
{ // we've started a previously queued item
View
@@ -62,6 +62,7 @@ namespace MEDIA_DETECT
#include "windowing/XBMC_events.h"
#include "threads/Thread.h"
+class CSeekHandler;
class CKaraokeLyricsManager;
class CInertialScrollingHandler;
class CApplicationMessenger;
@@ -337,6 +338,12 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ToggleDPMS(bool manual);
float GetDimScreenSaverLevel() const;
+
+ /*! \brief Retrieve the applications seek handler.
+ \return a constant pointer to the seek handler.
+ \sa CSeekHandler
+ */
+ const CSeekHandler *GetSeekHandler() const { return m_seekHandler; };
protected:
bool LoadSkin(const CStdString& skinID);
void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
@@ -436,6 +443,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool InitDirectoriesWin32();
void CreateUserDirs();
+ CSeekHandler *m_seekHandler;
CInertialScrollingHandler *m_pInertialScrollingHandler;
CApplicationMessenger m_applicationMessenger;
#if defined(HAS_LINUX_NETWORK)
@@ -20,7 +20,6 @@
*/
#include "system.h"
-#include "dialogs/GUIDialogSeekBar.h"
#include "windows/GUIMediaWindow.h"
#include "dialogs/GUIDialogFileBrowser.h"
#include "settings/GUIDialogContentSettings.h"
@@ -58,6 +57,7 @@
#include "utils/CPUInfo.h"
#include "utils/StringUtils.h"
#include "utils/MathUtils.h"
+#include "utils/SeekHandler.h"
// stuff for current song
#include "music/tags/MusicInfoTagLoaderFactory.h"
@@ -1731,11 +1731,8 @@ bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUI
value = (int)(g_application.GetCachePercentage());
break;
case PLAYER_SEEKBAR:
- {
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- value = seekBar ? (int)seekBar->GetPercentage() : 0;
- break;
- }
+ value = (int)g_application.GetSeekHandler()->GetPercent();
+ break;
case PLAYER_CACHELEVEL:
value = (int)(g_application.m_pPlayer->GetCacheLevel());
break;
@@ -2128,7 +2125,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
break;
case PLAYER_SEEKBAR:
{
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
+ CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
bReturn = seekBar ? seekBar->IsDialogRunning() : false;
}
break;
@@ -2736,12 +2733,7 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi
}
else if (info.m_info == PLAYER_SEEKTIME)
{
- TIME_FORMAT format = (TIME_FORMAT)info.GetData1();
- if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
- format = TIME_FORMAT_HH_MM_SS;
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- if (seekBar)
- return seekBar->GetSeekTimeLabel(format);
+ return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_SEEKOFFSET)
{
@@ -3493,6 +3485,14 @@ CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
return "";
}
+CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const
+{
+ if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
+ format = TIME_FORMAT_HH_MM_SS;
+ float time = GetTotalPlayTime() * g_application.GetSeekHandler()->GetPercent() * 0.01f;
+ return StringUtils::SecondsToTimeString((int)time, format);
+}
+
int CGUIInfoManager::GetTotalPlayTime() const
{
int iTotalTime = (int)g_application.GetTotalTime();
@@ -651,6 +651,7 @@ class CGUIInfoManager : public IMsgTargetCallback
int64_t GetPlayTime() const; // in ms
CStdString GetCurrentPlayTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
+ CStdString GetCurrentSeekTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
int GetPlayTimeRemaining() const;
int GetTotalPlayTime() const;
CStdString GetCurrentPlayTimeRemaining(TIME_FORMAT format) const;
Oops, something went wrong. Retry.