Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2DViewport/OneGesturePointerTracker.cpp @ 1972:9c0adcc8feec
refactoring to simplify OneGesturePointerTracker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 28 Oct 2022 16:21:28 +0200 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
comparison
equal
deleted
inserted
replaced
1971:e5b31d55206d | 1972:9c0adcc8feec |
---|---|
27 | 27 |
28 #include "../StoneException.h" | 28 #include "../StoneException.h" |
29 | 29 |
30 namespace OrthancStone | 30 namespace OrthancStone |
31 { | 31 { |
32 OneGesturePointerTracker::OneGesturePointerTracker(boost::weak_ptr<IViewport> viewport) : | 32 OneGesturePointerTracker::OneGesturePointerTracker() : |
33 alive_(true), | 33 alive_(true), |
34 currentTouchCount_(1), | 34 currentTouchCount_(1) |
35 viewport_(viewport) | |
36 { | 35 { |
37 } | 36 } |
38 | 37 |
39 IViewport::ILock* OneGesturePointerTracker::GetViewportLock() | 38 void OneGesturePointerTracker::PointerUp(const PointerEvent& event, |
40 { | 39 const Scene2D& scene) |
41 boost::shared_ptr<IViewport> viewport = viewport_.lock(); | |
42 if (viewport) | |
43 return viewport->Lock(); | |
44 else | |
45 return NULL; | |
46 } | |
47 | |
48 void OneGesturePointerTracker::PointerUp(const PointerEvent& event) | |
49 { | 40 { |
50 // pointer up is only called for the LAST up event in case of a multi-touch | 41 // pointer up is only called for the LAST up event in case of a multi-touch |
51 // gesture | 42 // gesture |
52 ORTHANC_ASSERT(currentTouchCount_ > 0, "Wrong state in tracker"); | 43 ORTHANC_ASSERT(currentTouchCount_ > 0, "Wrong state in tracker"); |
53 currentTouchCount_--; | 44 currentTouchCount_--; |
57 //LOG(TRACE) << "currentTouchCount_ == 0 --> alive_ = false"; | 48 //LOG(TRACE) << "currentTouchCount_ == 0 --> alive_ = false"; |
58 alive_ = false; | 49 alive_ = false; |
59 } | 50 } |
60 } | 51 } |
61 | 52 |
62 void OneGesturePointerTracker::PointerDown(const PointerEvent& event) | 53 void OneGesturePointerTracker::PointerDown(const PointerEvent& event, |
54 const Scene2D& scene) | |
63 { | 55 { |
64 // additional touches are not taken into account but we need to count | 56 // additional touches are not taken into account but we need to count |
65 // the number of active touches | 57 // the number of active touches |
66 currentTouchCount_++; | 58 currentTouchCount_++; |
67 //LOG(TRACE) << "currentTouchCount_ becomes: " << currentTouchCount_; | 59 //LOG(TRACE) << "currentTouchCount_ becomes: " << currentTouchCount_; |