void CPlayerSeekBar::SyncThumbToVideo(REFERENCE_TIME rtPos) { m_rtPos = rtPos; if (m_bHasDuration) { CRect newThumbRect(GetThumbRect()); bool bSetTaskbar = (rtPos <= 0); if (newThumbRect != m_lastThumbRect) { bSetTaskbar = true; InvalidateRect(newThumbRect | m_lastThumbRect); } if (bSetTaskbar && AfxGetAppSettings().fUseWin7TaskBar && m_pMainFrame->m_pTaskbarList) { VERIFY(S_OK == m_pMainFrame->m_pTaskbarList->SetProgressValue(m_pMainFrame->m_hWnd, max(m_rtPos, 1), m_rtStop)); } } }
void CPlayerSeekBar::SyncThumbToVideo(REFERENCE_TIME rtPos) { if (m_rtPos == rtPos) { return; } m_rtPos = rtPos; if (m_bHasDuration) { CRect newThumbRect(GetThumbRect()); if (newThumbRect != m_lastThumbRect) { InvalidateRect(newThumbRect | m_lastThumbRect); auto pFrame = AfxGetMainFrame(); if (pFrame && AfxGetAppSettings().fUseWin7TaskBar && pFrame->m_pTaskbarList) { pFrame->m_pTaskbarList->SetProgressValue(pFrame->m_hWnd, m_rtPos, m_rtStop); } } } }
// called when the current position changed and we need to update the thumb's location nsresult nsSliderFrame::CurrentPositionChanged(nsPresContext* aPresContext, PRBool aImmediateRedraw) { nsIBox* scrollbarBox = GetScrollbar(); nsCOMPtr<nsIContent> scrollbar; scrollbar = GetContentOfBox(scrollbarBox); // get the current position PRInt32 curPos = GetCurrentPosition(scrollbar); // do nothing if the position did not change if (mCurPos == curPos) return NS_OK; // get our current min and max position from our content node PRInt32 minPos = GetMinPosition(scrollbar); PRInt32 maxPos = GetMaxPosition(scrollbar); maxPos = NS_MAX(minPos, maxPos); curPos = NS_MAX(minPos, NS_MIN(curPos, maxPos)); // get the thumb's rect nsIFrame* thumbFrame = mFrames.FirstChild(); if (!thumbFrame) return NS_OK; // The thumb may stream in asynchronously via XBL. nsRect thumbRect = thumbFrame->GetRect(); nsRect clientRect; GetClientRect(clientRect); // figure out the new rect nsRect newThumbRect(thumbRect); PRBool reverse = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir, nsGkAtoms::reverse, eCaseMatters); nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos); if (IsHorizontal()) newThumbRect.x = clientRect.x + NSToCoordRound(pos * mRatio); else newThumbRect.y = clientRect.y + NSToCoordRound(pos * mRatio); // set the rect thumbFrame->SetRect(newThumbRect); // Redraw the scrollbar InvalidateWithFlags(clientRect, aImmediateRedraw ? INVALIDATE_IMMEDIATE : 0); mCurPos = curPos; // inform the parent <scale> if it exists that the value changed nsIFrame* parent = GetParent(); if (parent) { nsCOMPtr<nsISliderListener> sliderListener = do_QueryInterface(parent->GetContent()); if (sliderListener) { nsContentUtils::AddScriptRunner( new nsValueChangedRunnable(sliderListener, nsGkAtoms::curpos, mCurPos, mUserChanged)); } } return NS_OK; }