aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2018-08-15 22:32:55 +0200
committerKai Sommerfeld <kai.sommerfeld@gmx.com>2018-08-25 15:58:32 +0200
commit604ee3f5c7bc1fcf38e843539f001d4b410db7be (patch)
tree896a88eb3032966b533e4899d0ccf4dce1a3ac5e
parentbb713e69b00fcca5b92ff9a2212781b004ae36bd (diff)
[dialogs] Cleanup and simplify CGUIDialogSeekBar.
-rw-r--r--xbmc/dialogs/GUIDialogSeekBar.cpp97
-rw-r--r--xbmc/dialogs/GUIDialogSeekBar.h10
-rw-r--r--xbmc/guilib/guiinfo/PlayerGUIInfo.cpp7
3 files changed, 42 insertions, 72 deletions
diff --git a/xbmc/dialogs/GUIDialogSeekBar.cpp b/xbmc/dialogs/GUIDialogSeekBar.cpp
index 7e13d70be8..138fa83621 100644
--- a/xbmc/dialogs/GUIDialogSeekBar.cpp
+++ b/xbmc/dialogs/GUIDialogSeekBar.cpp
@@ -55,106 +55,83 @@ void CGUIDialogSeekBar::FrameMove()
return;
}
- unsigned int percent = g_application.GetAppPlayer().GetSeekHandler().InProgress()
- ? std::lrintf(GetSeekPercent())
- : std::lrintf(g_application.GetPercentage());
+ int progress = GetProgress();
+ if (progress != m_lastProgress)
+ CONTROL_SELECT_ITEM(POPUP_SEEK_PROGRESS, m_lastProgress = progress);
- if (percent != m_lastPercent)
- CONTROL_SELECT_ITEM(POPUP_SEEK_PROGRESS, m_lastPercent = percent);
+ int epgEventProgress = GetEpgEventProgress();
+ if (epgEventProgress != m_lastEpgEventProgress)
+ CONTROL_SELECT_ITEM(POPUP_SEEK_EPG_EVENT_PROGRESS, m_lastEpgEventProgress = epgEventProgress);
- unsigned int epgEventPercent = g_application.GetAppPlayer().GetSeekHandler().InProgress()
- ? GetEpgEventSeekPercent()
- : GetEpgEventProgress();
-
- if (epgEventPercent != m_lastEpgEventPercent)
- CONTROL_SELECT_ITEM(POPUP_SEEK_EPG_EVENT_PROGRESS, m_lastEpgEventPercent = epgEventPercent);
-
- unsigned int timeshiftPercent = g_application.GetAppPlayer().GetSeekHandler().InProgress()
- ? GetTimeshiftSeekPercent()
- : GetTimeshiftProgress();
-
- if (timeshiftPercent != m_lastTimeshiftPercent)
- CONTROL_SELECT_ITEM(POPUP_SEEK_TIMESHIFT_PROGRESS, m_lastTimeshiftPercent = timeshiftPercent);
+ int timeshiftProgress = GetTimeshiftProgress();
+ if (timeshiftProgress != m_lastTimeshiftProgress)
+ CONTROL_SELECT_ITEM(POPUP_SEEK_TIMESHIFT_PROGRESS, m_lastTimeshiftProgress = timeshiftProgress);
CGUIDialog::FrameMove();
}
-float CGUIDialogSeekBar::GetSeekPercent() const
+int CGUIDialogSeekBar::GetProgress() const
{
- int totaltime = std::lrint(g_application.GetTotalTime());
- if (totaltime == 0)
- return 0.0f;
+ CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
- float percentPlayTime = static_cast<float>(std::lrint(g_application.GetTime() * 1000)) / totaltime * 0.1f;
- float percentPerSecond = 100.0f / static_cast<float>(totaltime);
- float percent = percentPlayTime + percentPerSecond * g_application.GetAppPlayer().GetSeekHandler().GetSeekSize();
+ int progress = 0;
- if (percent > 100.0f)
- percent = 100.0f;
- if (percent < 0.0f)
- percent = 0.0f;
+ if (g_application.GetAppPlayer().GetSeekHandler().GetSeekSize() != 0)
+ infoMgr.GetInt(progress, PLAYER_SEEKBAR);
+ else
+ infoMgr.GetInt(progress, PLAYER_PROGRESS);
- return percent;
+ return progress;
}
int CGUIDialogSeekBar::GetEpgEventProgress() const
{
- int value = 0;
- CServiceBroker::GetGUI()->GetInfoManager().GetInt(value, PVR_EPG_EVENT_PROGRESS);
- return value;
-}
+ CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
+
+ int progress = 0;
+ infoMgr.GetInt(progress, PVR_EPG_EVENT_PROGRESS);
-int CGUIDialogSeekBar::GetEpgEventSeekPercent() const
-{
int seekSize = g_application.GetAppPlayer().GetSeekHandler().GetSeekSize();
if (seekSize != 0)
{
- CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
-
- int progress = 0;
- infoMgr.GetInt(progress, PVR_EPG_EVENT_PROGRESS);
-
int total = 0;
infoMgr.GetInt(total, PVR_EPG_EVENT_DURATION);
float totalTime = static_cast<float>(total);
+ if (totalTime == 0.0f)
+ return 0;
+
float percentPerSecond = 100.0f / totalTime;
float percent = progress + percentPerSecond * seekSize;
+ percent = std::max(0.0f, std::min(percent, 100.0f));
return std::lrintf(percent);
}
- else
- {
- return GetEpgEventProgress();
- }
+
+ return progress;
}
int CGUIDialogSeekBar::GetTimeshiftProgress() const
{
- int value = 0;
- CServiceBroker::GetGUI()->GetInfoManager().GetInt(value, PVR_TIMESHIFT_PROGRESS_PLAY_POS);
- return value;
-}
+ CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
+
+ int progress = 0;
+ infoMgr.GetInt(progress, PVR_TIMESHIFT_PROGRESS_PLAY_POS);
-int CGUIDialogSeekBar::GetTimeshiftSeekPercent() const
-{
int seekSize = g_application.GetAppPlayer().GetSeekHandler().GetSeekSize();
if (seekSize != 0)
{
- CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
-
- int progress = 0;
- infoMgr.GetInt(progress, PVR_TIMESHIFT_PROGRESS_PLAY_POS);
-
int total = 0;
infoMgr.GetInt(total, PVR_TIMESHIFT_PROGRESS_DURATION);
float totalTime = static_cast<float>(total);
+ if (totalTime == 0.0f)
+ return 0;
+
float percentPerSecond = 100.0f / totalTime;
float percent = progress + percentPerSecond * seekSize;
+ percent = std::max(0.0f, std::min(percent, 100.0f));
return std::lrintf(percent);
}
- else
- {
- return GetTimeshiftProgress();
- }
+
+ return progress;
}
diff --git a/xbmc/dialogs/GUIDialogSeekBar.h b/xbmc/dialogs/GUIDialogSeekBar.h
index 90b686abb4..314bf2724e 100644
--- a/xbmc/dialogs/GUIDialogSeekBar.h
+++ b/xbmc/dialogs/GUIDialogSeekBar.h
@@ -18,13 +18,11 @@ public:
bool OnMessage(CGUIMessage& message) override;
void FrameMove() override;
private:
- float GetSeekPercent() const;
+ int GetProgress() const;
int GetEpgEventProgress() const;
- int GetEpgEventSeekPercent() const;
int GetTimeshiftProgress() const;
- int GetTimeshiftSeekPercent() const;
- unsigned int m_lastPercent = ~0U;
- unsigned int m_lastEpgEventPercent = ~0U;
- unsigned int m_lastTimeshiftPercent = ~0U;
+ int m_lastProgress = 0;
+ int m_lastEpgEventProgress = 0;
+ int m_lastTimeshiftProgress = 0;
};
diff --git a/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp b/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp
index c721ad60d1..572edc22c3 100644
--- a/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp
+++ b/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp
@@ -66,12 +66,7 @@ float CPlayerGUIInfo::GetSeekPercent() const
float fPercentPlayTime = static_cast<float>(GetPlayTime() * 1000) / iTotal * 0.1f;
float fPercentPerSecond = 100.0f / static_cast<float>(iTotal);
float fPercent = fPercentPlayTime + fPercentPerSecond * g_application.GetAppPlayer().GetSeekHandler().GetSeekSize();
-
- if (fPercent > 100.0f)
- fPercent = 100.0f;
- if (fPercent < 0.0f)
- fPercent = 0.0f;
-
+ fPercent = std::max(0.0f, std::min(fPercent, 100.0f));
return fPercent;
}