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

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

Issue 2560873005: Cleanup CFWL_Widget code to return CFX_RectFs where appropriate (Closed)
Patch Set: Review feedback 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
« no previous file with comments | « xfa/fwl/cfwl_pushbutton.cpp ('k') | xfa/fwl/cfwl_spinbutton.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cfwl_scrollbar.h" 7 #include "xfa/fwl/cfwl_scrollbar.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 param.m_rtPart = m_rtThumb; 150 param.m_rtPart = m_rtThumb;
151 pTheme->DrawBackground(&param); 151 pTheme->DrawBackground(&param);
152 } 152 }
153 153
154 void CFWL_ScrollBar::Layout() { 154 void CFWL_ScrollBar::Layout() {
155 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 155 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
156 CFWL_ThemePart part; 156 CFWL_ThemePart part;
157 part.m_pWidget = this; 157 part.m_pWidget = this;
158 m_fMinThumb = *static_cast<FX_FLOAT*>( 158 m_fMinThumb = *static_cast<FX_FLOAT*>(
159 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size)); 159 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size));
160 GetClientRect(m_rtClient); 160 m_rtClient = GetClientRect();
161 CalcButtonLen(); 161 CalcButtonLen();
162 CalcMinButtonRect(m_rtMinBtn); 162 CalcMinButtonRect(m_rtMinBtn);
163 CalcMaxButtonRect(m_rtMaxBtn); 163 CalcMaxButtonRect(m_rtMaxBtn);
164 CalcThumbButtonRect(m_rtThumb); 164 CalcThumbButtonRect(m_rtThumb);
165 CalcMinTrackRect(m_rtMinTrack); 165 CalcMinTrackRect(m_rtMinTrack);
166 CalcMaxTrackRect(m_rtMaxTrack); 166 CalcMaxTrackRect(m_rtMaxTrack);
167 } 167 }
168 168
169 void CFWL_ScrollBar::CalcButtonLen() { 169 void CFWL_ScrollBar::CalcButtonLen() {
170 m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height; 170 m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 const CFX_RectF& rtItem, 426 const CFX_RectF& rtItem,
427 int32_t& iState, 427 int32_t& iState,
428 FX_FLOAT fx, 428 FX_FLOAT fx,
429 FX_FLOAT fy) { 429 FX_FLOAT fy) {
430 if (!rtItem.Contains(fx, fy)) 430 if (!rtItem.Contains(fx, fy))
431 return; 431 return;
432 if (iState == CFWL_PartState_Pressed) 432 if (iState == CFWL_PartState_Pressed)
433 return; 433 return;
434 434
435 iState = CFWL_PartState_Pressed; 435 iState = CFWL_PartState_Pressed;
436 Repaint(&rtItem); 436 RepaintRect(rtItem);
437 } 437 }
438 438
439 void CFWL_ScrollBar::DoMouseUp(int32_t iItem, 439 void CFWL_ScrollBar::DoMouseUp(int32_t iItem,
440 const CFX_RectF& rtItem, 440 const CFX_RectF& rtItem,
441 int32_t& iState, 441 int32_t& iState,
442 FX_FLOAT fx, 442 FX_FLOAT fx,
443 FX_FLOAT fy) { 443 FX_FLOAT fy) {
444 int32_t iNewState = 444 int32_t iNewState =
445 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; 445 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
446 if (iState == iNewState) 446 if (iState == iNewState)
447 return; 447 return;
448 448
449 iState = iNewState; 449 iState = iNewState;
450 Repaint(&rtItem); 450 RepaintRect(rtItem);
451 OnScroll(CFWL_EventScroll::Code::EndScroll, m_fTrackPos); 451 OnScroll(CFWL_EventScroll::Code::EndScroll, m_fTrackPos);
452 } 452 }
453 453
454 void CFWL_ScrollBar::DoMouseMove(int32_t iItem, 454 void CFWL_ScrollBar::DoMouseMove(int32_t iItem,
455 const CFX_RectF& rtItem, 455 const CFX_RectF& rtItem,
456 int32_t& iState, 456 int32_t& iState,
457 FX_FLOAT fx, 457 FX_FLOAT fx,
458 FX_FLOAT fy) { 458 FX_FLOAT fy) {
459 if (!m_bMouseDown) { 459 if (!m_bMouseDown) {
460 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered 460 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered
461 : CFWL_PartState_Normal; 461 : CFWL_PartState_Normal;
462 if (iState == iNewState) 462 if (iState == iNewState)
463 return; 463 return;
464 464
465 iState = iNewState; 465 iState = iNewState;
466 Repaint(&rtItem); 466 RepaintRect(rtItem);
467 } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) { 467 } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) {
468 FX_FLOAT fPos = GetTrackPointPos(fx, fy); 468 FX_FLOAT fPos = GetTrackPointPos(fx, fy);
469 m_fTrackPos = fPos; 469 m_fTrackPos = fPos;
470 OnScroll(CFWL_EventScroll::Code::TrackPos, fPos); 470 OnScroll(CFWL_EventScroll::Code::TrackPos, fPos);
471 } 471 }
472 } 472 }
473 473
474 void CFWL_ScrollBar::DoMouseLeave(int32_t iItem, 474 void CFWL_ScrollBar::DoMouseLeave(int32_t iItem,
475 const CFX_RectF& rtItem, 475 const CFX_RectF& rtItem,
476 int32_t& iState) { 476 int32_t& iState) {
477 if (iState == CFWL_PartState_Normal) 477 if (iState == CFWL_PartState_Normal)
478 return; 478 return;
479 479
480 iState = CFWL_PartState_Normal; 480 iState = CFWL_PartState_Normal;
481 Repaint(&rtItem); 481 RepaintRect(rtItem);
482 } 482 }
483 483
484 void CFWL_ScrollBar::DoMouseHover(int32_t iItem, 484 void CFWL_ScrollBar::DoMouseHover(int32_t iItem,
485 const CFX_RectF& rtItem, 485 const CFX_RectF& rtItem,
486 int32_t& iState) { 486 int32_t& iState) {
487 if (iState == CFWL_PartState_Hovered) 487 if (iState == CFWL_PartState_Hovered)
488 return; 488 return;
489 489
490 iState = CFWL_PartState_Hovered; 490 iState = CFWL_PartState_Hovered;
491 Repaint(&rtItem); 491 RepaintRect(rtItem);
492 } 492 }
493 493
494 CFWL_ScrollBar::Timer::Timer(CFWL_ScrollBar* pToolTip) : CFWL_Timer(pToolTip) {} 494 CFWL_ScrollBar::Timer::Timer(CFWL_ScrollBar* pToolTip) : CFWL_Timer(pToolTip) {}
495 495
496 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) { 496 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) {
497 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget); 497 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget);
498 498
499 if (pButton->m_pTimerInfo) 499 if (pButton->m_pTimerInfo)
500 pButton->m_pTimerInfo->StopTimer(); 500 pButton->m_pTimerInfo->StopTimer();
501 501
502 if (!pButton->SendEvent()) 502 if (!pButton->SendEvent())
503 pButton->m_pTimerInfo = StartTimer(0, true); 503 pButton->m_pTimerInfo = StartTimer(0, true);
504 } 504 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_pushbutton.cpp ('k') | xfa/fwl/cfwl_spinbutton.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698