Mercurial > hg > orthanc-stone
comparison Framework/Widgets/LayoutWidget.cpp @ 457:3b4df9925db6 am-touch-events
added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 24 Jan 2019 16:42:27 +0100 |
parents | b70e9be013e4 |
children | b1377625e4ba |
comparison
equal
deleted
inserted
replaced
456:b70fcc134ba4 | 457:3b4df9925db6 |
---|---|
66 { | 66 { |
67 tracker_->MouseUp(); | 67 tracker_->MouseUp(); |
68 } | 68 } |
69 | 69 |
70 virtual void MouseMove(int x, | 70 virtual void MouseMove(int x, |
71 int y) | 71 int y, |
72 { | 72 const std::vector<Touch>& displayTouches) |
73 tracker_->MouseMove(x - left_, y - top_); | 73 { |
74 std::vector<Touch> relativeTouches; | |
75 for (size_t t = 0; t < displayTouches.size(); t++) | |
76 { | |
77 relativeTouches.push_back(Touch((int)displayTouches[t].x - left_, (int)displayTouches[t].y - top_)); | |
78 } | |
79 | |
80 tracker_->MouseMove(x - left_, y - top_, relativeTouches); | |
74 } | 81 } |
75 }; | 82 }; |
76 | 83 |
77 | 84 |
78 class LayoutWidget::ChildWidget : public boost::noncopyable | 85 class LayoutWidget::ChildWidget : public boost::noncopyable |
148 } | 155 } |
149 | 156 |
150 IMouseTracker* CreateMouseTracker(MouseButton button, | 157 IMouseTracker* CreateMouseTracker(MouseButton button, |
151 int x, | 158 int x, |
152 int y, | 159 int y, |
153 KeyboardModifiers modifiers) | 160 KeyboardModifiers modifiers, |
161 const std::vector<Touch>& touches) | |
154 { | 162 { |
155 if (Contains(x, y)) | 163 if (Contains(x, y)) |
156 { | 164 { |
157 IMouseTracker* tracker = widget_->CreateMouseTracker(button, | 165 IMouseTracker* tracker = widget_->CreateMouseTracker(button, |
158 x - left_, | 166 x - left_, |
159 y - top_, | 167 y - top_, |
160 modifiers); | 168 modifiers, |
169 touches); | |
161 if (tracker) | 170 if (tracker) |
162 { | 171 { |
163 return new LayoutMouseTracker(tracker, left_, top_, width_, height_); | 172 return new LayoutMouseTracker(tracker, left_, top_, width_, height_); |
164 } | 173 } |
165 } | 174 } |
411 | 420 |
412 | 421 |
413 IMouseTracker* LayoutWidget::CreateMouseTracker(MouseButton button, | 422 IMouseTracker* LayoutWidget::CreateMouseTracker(MouseButton button, |
414 int x, | 423 int x, |
415 int y, | 424 int y, |
416 KeyboardModifiers modifiers) | 425 KeyboardModifiers modifiers, |
417 { | 426 const std::vector<Touch>& touches) |
418 for (size_t i = 0; i < children_.size(); i++) | 427 { |
419 { | 428 for (size_t i = 0; i < children_.size(); i++) |
420 IMouseTracker* tracker = children_[i]->CreateMouseTracker(button, x, y, modifiers); | 429 { |
430 IMouseTracker* tracker = children_[i]->CreateMouseTracker(button, x, y, modifiers, touches); | |
421 if (tracker != NULL) | 431 if (tracker != NULL) |
422 { | 432 { |
423 return tracker; | 433 return tracker; |
424 } | 434 } |
425 } | 435 } |