2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIDialogSeekBar.h"
22 #include "guilib/GUISliderControl.h"
23 #include "Application.h"
24 #include "GUIInfoManager.h"
25 #include "utils/TimeUtils.h"
27 #include "utils/SeekHandler.h"
29 #define SEEK_BAR_DISPLAY_TIME 2000L
30 #define SEEK_BAR_SEEK_TIME 500L
32 #define POPUP_SEEK_SLIDER 401
33 #define POPUP_SEEK_LABEL 402
35 CGUIDialogSeekBar::CGUIDialogSeekBar(void)
36 : CGUIDialog(WINDOW_DIALOG_SEEK_BAR, "DialogSeekBar.xml")
38 m_loadType = LOAD_ON_GUI_INIT; // the application class handles our resources
41 CGUIDialogSeekBar::~CGUIDialogSeekBar(void)
45 bool CGUIDialogSeekBar::OnMessage(CGUIMessage& message)
47 switch ( message.GetMessage() )
49 case GUI_MSG_WINDOW_INIT:
50 case GUI_MSG_WINDOW_DEINIT:
51 return CGUIDialog::OnMessage(message);
53 case GUI_MSG_LABEL_SET:
55 if (message.GetSenderId() == GetID() && message.GetControlId() == POPUP_SEEK_LABEL)
56 CGUIDialog::OnMessage(message);
60 return false; // don't process anything other than what we need!
63 void CGUIDialogSeekBar::FrameMove()
65 if (!g_application.m_pPlayer->HasPlayer())
72 if (!g_application.GetSeekHandler()->InProgress() && !g_infoManager.m_performingSeek)
73 { // position the bar at our current time
74 CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
75 if (pSlider && g_infoManager.GetTotalPlayTime())
76 pSlider->SetPercentage((float)g_infoManager.GetPlayTime()/g_infoManager.GetTotalPlayTime() * 0.1f);
78 CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
79 msg.SetLabel(g_infoManager.GetCurrentPlayTime());
84 CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
86 pSlider->SetPercentage(g_application.GetSeekHandler()->GetPercent());
88 CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
89 msg.SetLabel(g_infoManager.GetCurrentSeekTime());
93 CGUIDialog::FrameMove();