Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: xfa/fwl/core/cfwl_scrollbar.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Unused Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/core/cfwl_scrollbar.h" 7 #include "xfa/fwl/core/cfwl_scrollbar.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); 302 (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height);
303 } else { 303 } else {
304 fPos = fRange * fDiffX / 304 fPos = fRange * fDiffX /
305 (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); 305 (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
306 } 306 }
307 307
308 fPos += m_fLastTrackPos; 308 fPos += m_fLastTrackPos;
309 return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax); 309 return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax);
310 } 310 }
311 311
312 void CFWL_ScrollBar::GetTrackRect(CFX_RectF& rect, bool bLower) {
313 bool bDisabled = !!(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled);
314 if (bDisabled) {
315 rect = bLower ? m_rtMinTrack : m_rtMaxTrack;
316 return;
317 }
318
319 FX_FLOAT fW = m_rtThumb.width / 2;
320 FX_FLOAT fH = m_rtThumb.height / 2;
321 bool bVert = IsVertical();
322 if (bLower) {
323 if (bVert) {
324 FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height;
325 fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f;
326 rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height,
327 m_rtMinTrack.width, fMinTrackHeight);
328 return;
329 }
330
331 FX_FLOAT fMinTrackWidth = m_rtMinTrack.width - fW - m_rtMinBtn.width + 2;
332 fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f;
333 rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top,
334 fMinTrackWidth, m_rtMinTrack.height);
335 return;
336 }
337
338 if (bVert) {
339 FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height;
340 fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f;
341 rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width,
342 fMaxTrackHeight);
343 return;
344 }
345
346 FX_FLOAT fMaxTrackWidth = m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2;
347 fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f;
348 rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth,
349 m_rtMaxTrack.height);
350 }
351
352 bool CFWL_ScrollBar::SendEvent() { 312 bool CFWL_ScrollBar::SendEvent() {
353 if (m_iMinButtonState == CFWL_PartState_Pressed) { 313 if (m_iMinButtonState == CFWL_PartState_Pressed) {
354 DoScroll(FWL_SCBCODE::StepBackward, m_fTrackPos); 314 DoScroll(FWL_SCBCODE::StepBackward, m_fTrackPos);
355 return false; 315 return false;
356 } 316 }
357 if (m_iMaxButtonState == CFWL_PartState_Pressed) { 317 if (m_iMaxButtonState == CFWL_PartState_Pressed) {
358 DoScroll(FWL_SCBCODE::StepForward, m_fTrackPos); 318 DoScroll(FWL_SCBCODE::StepForward, m_fTrackPos);
359 return false; 319 return false;
360 } 320 }
361 if (m_iMinTrackState == CFWL_PartState_Pressed) { 321 if (m_iMinTrackState == CFWL_PartState_Pressed) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 512
553 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) { 513 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) {
554 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget); 514 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget);
555 515
556 if (pButton->m_pTimerInfo) 516 if (pButton->m_pTimerInfo)
557 pButton->m_pTimerInfo->StopTimer(); 517 pButton->m_pTimerInfo->StopTimer();
558 518
559 if (!pButton->SendEvent()) 519 if (!pButton->SendEvent())
560 pButton->m_pTimerInfo = StartTimer(0, true); 520 pButton->m_pTimerInfo = StartTimer(0, true);
561 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698