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

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

Issue 2559173002: Move xfa/fwl/core to xfa/fwl. (Closed)
Patch Set: 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_scrollbar.h ('k') | xfa/fwl/cfwl_spinbutton.h » ('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/core/cfwl_scrollbar.h" 7 #include "xfa/fwl/cfwl_scrollbar.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "third_party/base/ptr_util.h" 13 #include "third_party/base/ptr_util.h"
14 #include "xfa/fwl/core/cfwl_msgmouse.h" 14 #include "xfa/fwl/cfwl_messagemouse.h"
15 #include "xfa/fwl/core/cfwl_msgmousewheel.h" 15 #include "xfa/fwl/cfwl_messagemousewheel.h"
16 #include "xfa/fwl/core/cfwl_notedriver.h" 16 #include "xfa/fwl/cfwl_notedriver.h"
17 #include "xfa/fwl/core/cfwl_themebackground.h" 17 #include "xfa/fwl/cfwl_themebackground.h"
18 #include "xfa/fwl/core/cfwl_themepart.h" 18 #include "xfa/fwl/cfwl_themepart.h"
19 #include "xfa/fwl/core/cfwl_timerinfo.h" 19 #include "xfa/fwl/cfwl_timerinfo.h"
20 #include "xfa/fwl/core/ifwl_themeprovider.h" 20 #include "xfa/fwl/ifwl_themeprovider.h"
21 21
22 #define FWL_SCROLLBAR_Elapse 500 22 #define FWL_SCROLLBAR_Elapse 500
23 #define FWL_SCROLLBAR_MinThumb 5 23 #define FWL_SCROLLBAR_MinThumb 5
24 24
25 CFWL_ScrollBar::CFWL_ScrollBar( 25 CFWL_ScrollBar::CFWL_ScrollBar(
26 const CFWL_App* app, 26 const CFWL_App* app,
27 std::unique_ptr<CFWL_WidgetProperties> properties, 27 std::unique_ptr<CFWL_WidgetProperties> properties,
28 CFWL_Widget* pOuter) 28 CFWL_Widget* pOuter)
29 : CFWL_Widget(app, std::move(properties), pOuter), 29 : CFWL_Widget(app, std::move(properties), pOuter),
30 m_pTimerInfo(nullptr), 30 m_pTimerInfo(nullptr),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 DrawThumb(pGraphics, pTheme, pMatrix); 90 DrawThumb(pGraphics, pTheme, pMatrix);
91 } 91 }
92 92
93 void CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { 93 void CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
94 m_fTrackPos = fTrackPos; 94 m_fTrackPos = fTrackPos;
95 CalcThumbButtonRect(m_rtThumb); 95 CalcThumbButtonRect(m_rtThumb);
96 CalcMinTrackRect(m_rtMinTrack); 96 CalcMinTrackRect(m_rtMinTrack);
97 CalcMaxTrackRect(m_rtMaxTrack); 97 CalcMaxTrackRect(m_rtMaxTrack);
98 } 98 }
99 99
100 bool CFWL_ScrollBar::DoScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos) { 100 bool CFWL_ScrollBar::DoScroll(CFWL_EventScroll::Code dwCode, FX_FLOAT fPos) {
101 if (dwCode == CFWL_EvtScroll::Code::None) 101 if (dwCode == CFWL_EventScroll::Code::None)
102 return false; 102 return false;
103 return OnScroll(dwCode, fPos); 103 return OnScroll(dwCode, fPos);
104 } 104 }
105 105
106 void CFWL_ScrollBar::DrawTrack(CFX_Graphics* pGraphics, 106 void CFWL_ScrollBar::DrawTrack(CFX_Graphics* pGraphics,
107 IFWL_ThemeProvider* pTheme, 107 IFWL_ThemeProvider* pTheme,
108 bool bLower, 108 bool bLower,
109 const CFX_Matrix* pMatrix) { 109 const CFX_Matrix* pMatrix) {
110 CFWL_ThemeBackground param; 110 CFWL_ThemeBackground param;
111 param.m_pWidget = this; 111 param.m_pWidget = this;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 fPos = fRange * fDiffX / 286 fPos = fRange * fDiffX /
287 (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width); 287 (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
288 } 288 }
289 289
290 fPos += m_fLastTrackPos; 290 fPos += m_fLastTrackPos;
291 return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax); 291 return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax);
292 } 292 }
293 293
294 bool CFWL_ScrollBar::SendEvent() { 294 bool CFWL_ScrollBar::SendEvent() {
295 if (m_iMinButtonState == CFWL_PartState_Pressed) { 295 if (m_iMinButtonState == CFWL_PartState_Pressed) {
296 DoScroll(CFWL_EvtScroll::Code::StepBackward, m_fTrackPos); 296 DoScroll(CFWL_EventScroll::Code::StepBackward, m_fTrackPos);
297 return false; 297 return false;
298 } 298 }
299 if (m_iMaxButtonState == CFWL_PartState_Pressed) { 299 if (m_iMaxButtonState == CFWL_PartState_Pressed) {
300 DoScroll(CFWL_EvtScroll::Code::StepForward, m_fTrackPos); 300 DoScroll(CFWL_EventScroll::Code::StepForward, m_fTrackPos);
301 return false; 301 return false;
302 } 302 }
303 if (m_iMinTrackState == CFWL_PartState_Pressed) { 303 if (m_iMinTrackState == CFWL_PartState_Pressed) {
304 DoScroll(CFWL_EvtScroll::Code::PageBackward, m_fTrackPos); 304 DoScroll(CFWL_EventScroll::Code::PageBackward, m_fTrackPos);
305 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); 305 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
306 } 306 }
307 if (m_iMaxTrackState == CFWL_PartState_Pressed) { 307 if (m_iMaxTrackState == CFWL_PartState_Pressed) {
308 DoScroll(CFWL_EvtScroll::Code::PageForward, m_fTrackPos); 308 DoScroll(CFWL_EventScroll::Code::PageForward, m_fTrackPos);
309 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); 309 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
310 } 310 }
311 if (m_iMouseWheel) { 311 if (m_iMouseWheel) {
312 CFWL_EvtScroll::Code dwCode = m_iMouseWheel < 0 312 CFWL_EventScroll::Code dwCode = m_iMouseWheel < 0
313 ? CFWL_EvtScroll::Code::StepForward 313 ? CFWL_EventScroll::Code::StepForward
314 : CFWL_EvtScroll::Code::StepBackward; 314 : CFWL_EventScroll::Code::StepBackward;
315 DoScroll(dwCode, m_fTrackPos); 315 DoScroll(dwCode, m_fTrackPos);
316 } 316 }
317 return true; 317 return true;
318 } 318 }
319 319
320 bool CFWL_ScrollBar::OnScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos) { 320 bool CFWL_ScrollBar::OnScroll(CFWL_EventScroll::Code dwCode, FX_FLOAT fPos) {
321 CFWL_EvtScroll ev(this); 321 CFWL_EventScroll ev(this);
322 ev.m_iScrollCode = dwCode; 322 ev.m_iScrollCode = dwCode;
323 ev.m_fPos = fPos; 323 ev.m_fPos = fPos;
324 DispatchEvent(&ev); 324 DispatchEvent(&ev);
325 return true; 325 return true;
326 } 326 }
327 327
328 void CFWL_ScrollBar::OnProcessMessage(CFWL_Message* pMessage) { 328 void CFWL_ScrollBar::OnProcessMessage(CFWL_Message* pMessage) {
329 if (!pMessage) 329 if (!pMessage)
330 return; 330 return;
331 331
332 CFWL_Message::Type type = pMessage->GetType(); 332 CFWL_Message::Type type = pMessage->GetType();
333 if (type == CFWL_Message::Type::Mouse) { 333 if (type == CFWL_Message::Type::Mouse) {
334 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 334 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
335 switch (pMsg->m_dwCmd) { 335 switch (pMsg->m_dwCmd) {
336 case FWL_MouseCommand::LeftButtonDown: 336 case FWL_MouseCommand::LeftButtonDown:
337 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); 337 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
338 break; 338 break;
339 case FWL_MouseCommand::LeftButtonUp: 339 case FWL_MouseCommand::LeftButtonUp:
340 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); 340 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
341 break; 341 break;
342 case FWL_MouseCommand::Move: 342 case FWL_MouseCommand::Move:
343 OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); 343 OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
344 break; 344 break;
345 case FWL_MouseCommand::Leave: 345 case FWL_MouseCommand::Leave:
346 OnMouseLeave(); 346 OnMouseLeave();
347 break; 347 break;
348 default: 348 default:
349 break; 349 break;
350 } 350 }
351 } else if (type == CFWL_Message::Type::MouseWheel) { 351 } else if (type == CFWL_Message::Type::MouseWheel) {
352 CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage); 352 CFWL_MessageMouseWheel* pMsg =
353 static_cast<CFWL_MessageMouseWheel*>(pMessage);
353 OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, 354 OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX,
354 pMsg->m_fDeltaY); 355 pMsg->m_fDeltaY);
355 } 356 }
356 } 357 }
357 358
358 void CFWL_ScrollBar::OnDrawWidget(CFX_Graphics* pGraphics, 359 void CFWL_ScrollBar::OnDrawWidget(CFX_Graphics* pGraphics,
359 const CFX_Matrix* pMatrix) { 360 const CFX_Matrix* pMatrix) {
360 DrawWidget(pGraphics, pMatrix); 361 DrawWidget(pGraphics, pMatrix);
361 } 362 }
362 363
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 int32_t& iState, 441 int32_t& iState,
441 FX_FLOAT fx, 442 FX_FLOAT fx,
442 FX_FLOAT fy) { 443 FX_FLOAT fy) {
443 int32_t iNewState = 444 int32_t iNewState =
444 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; 445 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
445 if (iState == iNewState) 446 if (iState == iNewState)
446 return; 447 return;
447 448
448 iState = iNewState; 449 iState = iNewState;
449 Repaint(&rtItem); 450 Repaint(&rtItem);
450 OnScroll(CFWL_EvtScroll::Code::EndScroll, m_fTrackPos); 451 OnScroll(CFWL_EventScroll::Code::EndScroll, m_fTrackPos);
451 } 452 }
452 453
453 void CFWL_ScrollBar::DoMouseMove(int32_t iItem, 454 void CFWL_ScrollBar::DoMouseMove(int32_t iItem,
454 const CFX_RectF& rtItem, 455 const CFX_RectF& rtItem,
455 int32_t& iState, 456 int32_t& iState,
456 FX_FLOAT fx, 457 FX_FLOAT fx,
457 FX_FLOAT fy) { 458 FX_FLOAT fy) {
458 if (!m_bMouseDown) { 459 if (!m_bMouseDown) {
459 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered 460 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered
460 : CFWL_PartState_Normal; 461 : CFWL_PartState_Normal;
461 if (iState == iNewState) 462 if (iState == iNewState)
462 return; 463 return;
463 464
464 iState = iNewState; 465 iState = iNewState;
465 Repaint(&rtItem); 466 Repaint(&rtItem);
466 } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) { 467 } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) {
467 FX_FLOAT fPos = GetTrackPointPos(fx, fy); 468 FX_FLOAT fPos = GetTrackPointPos(fx, fy);
468 m_fTrackPos = fPos; 469 m_fTrackPos = fPos;
469 OnScroll(CFWL_EvtScroll::Code::TrackPos, fPos); 470 OnScroll(CFWL_EventScroll::Code::TrackPos, fPos);
470 } 471 }
471 } 472 }
472 473
473 void CFWL_ScrollBar::DoMouseLeave(int32_t iItem, 474 void CFWL_ScrollBar::DoMouseLeave(int32_t iItem,
474 const CFX_RectF& rtItem, 475 const CFX_RectF& rtItem,
475 int32_t& iState) { 476 int32_t& iState) {
476 if (iState == CFWL_PartState_Normal) 477 if (iState == CFWL_PartState_Normal)
477 return; 478 return;
478 479
479 iState = CFWL_PartState_Normal; 480 iState = CFWL_PartState_Normal;
(...skipping 14 matching lines...) Expand all
494 495
495 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) { 496 void CFWL_ScrollBar::Timer::Run(CFWL_TimerInfo* pTimerInfo) {
496 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget); 497 CFWL_ScrollBar* pButton = static_cast<CFWL_ScrollBar*>(m_pWidget);
497 498
498 if (pButton->m_pTimerInfo) 499 if (pButton->m_pTimerInfo)
499 pButton->m_pTimerInfo->StopTimer(); 500 pButton->m_pTimerInfo->StopTimer();
500 501
501 if (!pButton->SendEvent()) 502 if (!pButton->SendEvent())
502 pButton->m_pTimerInfo = StartTimer(0, true); 503 pButton->m_pTimerInfo = StartTimer(0, true);
503 } 504 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_scrollbar.h ('k') | xfa/fwl/cfwl_spinbutton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698