Permalink
Browse files

[seekbar] adds seek handler rather than handling seeking directly in …

…CGUIDialogSeekBar.
  • Loading branch information...
1 parent d9ca8ee commit 124b538fb92e104046fa50990751791c97da8ba3 Jonathan Marshall committed Jan 18, 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>
@@ -24,20 +24,14 @@
#include "GUIUserMessages.h"
#include "Application.h"
#include "GUIInfoManager.h"
-#include "utils/TimeUtils.h"
#include "utils/StringUtils.h"
-#define SEEK_BAR_DISPLAY_TIME 2000L
-#define SEEK_BAR_SEEK_TIME 500L
-
#define POPUP_SEEK_SLIDER 401
#define POPUP_SEEK_LABEL 402
CGUIDialogSeekBar::CGUIDialogSeekBar(void)
: CGUIDialog(WINDOW_DIALOG_SEEK_BAR, "DialogSeekBar.xml")
{
- m_fSeekPercentage = 0.0f;
- m_bRequireSeek = false;
m_loadOnDemand = false; // the application class handles our resources
}
@@ -49,40 +43,7 @@ bool CGUIDialogSeekBar::OnAction(const CAction &action)
{
if (action.GetID() == ACTION_ANALOG_SEEK_FORWARD || action.GetID() == ACTION_ANALOG_SEEK_BACK)
{
- if (!m_bRequireSeek)
- { // start of seeking
-
- if (g_infoManager.GetTotalPlayTime())
- m_fSeekPercentage = (float)g_infoManager.GetPlayTime() / g_infoManager.GetTotalPlayTime() * 0.1f;
- else
- m_fSeekPercentage = 0.0f;
-
- // tell info manager that we have started a seekbar operation
- m_bRequireSeek = true;
- g_infoManager.SetSeeking(true);
- }
-
- // calculate our seek amount
- if (g_application.m_pPlayer && !g_infoManager.m_performingSeek)
- {
- //100% over 1 second.
- float speed = 100.0f;
- if( action.GetRepeat() )
- speed *= action.GetRepeat();
- else
- speed /= g_infoManager.GetFPS();
-
- if (action.GetID() == ACTION_ANALOG_SEEK_FORWARD)
- m_fSeekPercentage += action.GetAmount() * action.GetAmount() * speed;
- else
- m_fSeekPercentage -= action.GetAmount() * action.GetAmount() * speed;
- if (m_fSeekPercentage > 100.0f) m_fSeekPercentage = 100.0f;
- if (m_fSeekPercentage < 0.0f) m_fSeekPercentage = 0.0f;
- CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
- if (pSlider) pSlider->SetPercentage((int)m_fSeekPercentage); // Update our seek bar accordingly
- }
-
- ResetTimer();
+ m_handler.Seek(action.GetID() == ACTION_ANALOG_SEEK_FORWARD, action.GetAmount(), action.GetRepeat());
return true;
}
return CGUIDialog::OnAction(action);
@@ -103,23 +64,15 @@ bool CGUIDialogSeekBar::OnMessage(CGUIMessage& message)
}
break;
case GUI_MSG_PLAYBACK_STARTED:
- { // new song started while our window is up - update our details
-
- m_bRequireSeek = false;
- m_fSeekPercentage = 0.0f;
-
+ { // new song started while our window is up - reset our seek handler
+ m_handler.Reset();
}
break;
}
return false; // don't process anything other than what we need!
}
-void CGUIDialogSeekBar::ResetTimer()
-{
- m_timer = CTimeUtils::GetFrameTime();
-}
-
void CGUIDialogSeekBar::FrameMove()
{
if (!g_application.m_pPlayer)
@@ -128,12 +81,8 @@ void CGUIDialogSeekBar::FrameMove()
return;
}
- // check if we should seek or exit
- if (!g_infoManager.m_performingSeek && CTimeUtils::GetFrameTime() - m_timer > SEEK_BAR_DISPLAY_TIME)
- g_infoManager.SetSeeking(false);
-
- // render our controls
- if (!m_bRequireSeek && !g_infoManager.m_performingSeek)
+ // update controls
+ if (!m_handler.InProgress() && !g_infoManager.m_performingSeek)
{ // position the bar at our current time
CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
if (pSlider && g_infoManager.GetTotalPlayTime())
@@ -145,25 +94,24 @@ void CGUIDialogSeekBar::FrameMove()
}
else
{
+ CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
+ if (pSlider)
+ pSlider->SetPercentage((int)m_handler.GetPercent());
+
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
msg.SetLabel(GetSeekTimeLabel());
OnMessage(msg);
}
// Check for seek timeout, and perform the seek
- if (m_bRequireSeek && CTimeUtils::GetFrameTime() - m_timer > SEEK_BAR_SEEK_TIME)
- {
- g_infoManager.m_performingSeek = true;
- double time = g_infoManager.GetTotalPlayTime() * m_fSeekPercentage * 0.01;
- g_application.SeekTime(time);
- m_bRequireSeek = false;
- }
+ m_handler.Process();
+
CGUIDialog::FrameMove();
}
CStdString CGUIDialogSeekBar::GetSeekTimeLabel(TIME_FORMAT format)
{
- int time = (int)(g_infoManager.GetTotalPlayTime() * m_fSeekPercentage * 0.01f);
+ int time = (int)(g_infoManager.GetTotalPlayTime() * m_handler.GetPercent() * 0.01f);
return StringUtils::SecondsToTimeString(time, format);
}
@@ -23,6 +23,7 @@
#include "guilib/GUIDialog.h"
#include "XBDateTime.h"
+#include "utils/SeekHandler.h"
class CGUIDialogSeekBar : public CGUIDialog
{
@@ -32,11 +33,8 @@ class CGUIDialogSeekBar : public CGUIDialog
virtual bool OnMessage(CGUIMessage& message);
virtual bool OnAction(const CAction &action);
virtual void FrameMove();
- void ResetTimer();
- float GetPercentage() {return m_fSeekPercentage;};
+ float GetPercentage() {return m_handler.GetPercent();};
CStdString GetSeekTimeLabel(TIME_FORMAT format = TIME_FORMAT_GUESS);
protected:
- unsigned int m_timer;
- float m_fSeekPercentage;
- bool m_bRequireSeek;
+ CSeekHandler m_handler;
};
View
@@ -46,6 +46,7 @@ SRCS=AlarmClock.cpp \
RssReader.cpp \
ScraperParser.cpp \
ScraperUrl.cpp \
+ SeekHandler.cpp \
SortUtils.cpp \
Splash.cpp \
ssrc.cpp \
Oops, something went wrong.

2 comments on commit 124b538

Member

da-anda replied Nov 6, 2012

Hey Jonathan, any plans to extend this seekHandler and f.e. also move the calculation for stepForward/bigStepForward out of DVDplayer into this handler, as well as all other seeking stuff (like from CApplication) into this class? Would IMO make the current seeking mess (tons of functions spread everywhere) much better.

Member

jmarshallnz replied Nov 6, 2012

Please sign in to comment.