Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Widgets/LayoutWidget.cpp @ 1138:1a73f852810a broker
integration mainline->broker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Nov 2019 07:28:39 +0100 |
parents | d7887f88710f |
children | 0ca50d275b9a |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "LayoutWidget.h" | |
23 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
24 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
25 #include <Core/OrthancException.h> |
0 | 26 |
27 #include <boost/math/special_functions/round.hpp> | |
28 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
29 namespace Deprecated |
0 | 30 { |
31 class LayoutWidget::LayoutMouseTracker : public IMouseTracker | |
32 { | |
33 private: | |
34 std::auto_ptr<IMouseTracker> tracker_; | |
35 int left_; | |
36 int top_; | |
37 unsigned int width_; | |
38 unsigned int height_; | |
39 | |
40 public: | |
41 LayoutMouseTracker(IMouseTracker* tracker, | |
42 int left, | |
43 int top, | |
44 unsigned int width, | |
45 unsigned int height) : | |
46 tracker_(tracker), | |
47 left_(left), | |
48 top_(top), | |
49 width_(width), | |
50 height_(height) | |
51 { | |
52 if (tracker == NULL) | |
53 { | |
54 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
55 } | |
56 } | |
57 | |
58 virtual void Render(Orthanc::ImageAccessor& surface) | |
59 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
60 Orthanc::ImageAccessor accessor; |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
61 surface.GetRegion(accessor, left_, top_, width_, height_); |
0 | 62 tracker_->Render(accessor); |
63 } | |
64 | |
65 virtual void MouseUp() | |
66 { | |
67 tracker_->MouseUp(); | |
68 } | |
69 | |
70 virtual void MouseMove(int x, | |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
71 int y, |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
72 const std::vector<Touch>& displayTouches) |
0 | 73 { |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
74 std::vector<Touch> relativeTouches; |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
75 for (size_t t = 0; t < displayTouches.size(); t++) |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
76 { |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
457
diff
changeset
|
77 relativeTouches.push_back(Touch(displayTouches[t].x - left_, displayTouches[t].y - top_)); |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
78 } |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
79 |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
80 tracker_->MouseMove(x - left_, y - top_, relativeTouches); |
0 | 81 } |
82 }; | |
83 | |
84 | |
85 class LayoutWidget::ChildWidget : public boost::noncopyable | |
86 { | |
87 private: | |
1070 | 88 boost::shared_ptr<IWidget> widget_; |
0 | 89 int left_; |
90 int top_; | |
91 unsigned int width_; | |
92 unsigned int height_; | |
93 | |
94 public: | |
1070 | 95 ChildWidget(boost::shared_ptr<IWidget> widget) : |
232
7d3b2c4f9ba1
don't cache hasUpdate_ since its not updated when we update the underlying hierarchy (i.e: when the child of a layout is a layout without child when it is added but childs are added later ...)
am@osimis.io
parents:
212
diff
changeset
|
96 widget_(widget) |
0 | 97 { |
98 assert(widget != NULL); | |
99 SetEmpty(); | |
100 } | |
101 | |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
102 void DoAnimation() |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
103 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
104 if (widget_->HasAnimation()) |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
105 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
106 widget_->DoAnimation(); |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
107 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
108 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
109 |
0 | 110 IWidget& GetWidget() const |
111 { | |
112 return *widget_; | |
113 } | |
114 | |
115 void SetRectangle(unsigned int left, | |
116 unsigned int top, | |
117 unsigned int width, | |
118 unsigned int height) | |
119 { | |
120 left_ = left; | |
121 top_ = top; | |
122 width_ = width; | |
123 height_ = height; | |
124 | |
125 widget_->SetSize(width, height); | |
126 } | |
127 | |
128 void SetEmpty() | |
129 { | |
130 SetRectangle(0, 0, 0, 0); | |
131 } | |
132 | |
133 bool Contains(int x, | |
134 int y) const | |
135 { | |
136 return (x >= left_ && | |
137 y >= top_ && | |
138 x < left_ + static_cast<int>(width_) && | |
139 y < top_ + static_cast<int>(height_)); | |
140 } | |
141 | |
142 bool Render(Orthanc::ImageAccessor& target) | |
143 { | |
144 if (width_ == 0 || | |
145 height_ == 0) | |
146 { | |
147 return true; | |
148 } | |
149 else | |
150 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
151 Orthanc::ImageAccessor accessor; |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
152 target.GetRegion(accessor, left_, top_, width_, height_); |
0 | 153 return widget_->Render(accessor); |
154 } | |
155 } | |
156 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
157 IMouseTracker* CreateMouseTracker(OrthancStone::MouseButton button, |
0 | 158 int x, |
159 int y, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
160 OrthancStone::KeyboardModifiers modifiers, |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
161 const std::vector<Touch>& touches) |
0 | 162 { |
163 if (Contains(x, y)) | |
164 { | |
165 IMouseTracker* tracker = widget_->CreateMouseTracker(button, | |
166 x - left_, | |
167 y - top_, | |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
168 modifiers, |
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
169 touches); |
0 | 170 if (tracker) |
171 { | |
172 return new LayoutMouseTracker(tracker, left_, top_, width_, height_); | |
173 } | |
174 } | |
175 | |
176 return NULL; | |
177 } | |
178 | |
179 void RenderMouseOver(Orthanc::ImageAccessor& target, | |
180 int x, | |
181 int y) | |
182 { | |
183 if (Contains(x, y)) | |
184 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
185 Orthanc::ImageAccessor accessor; |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
186 target.GetRegion(accessor, left_, top_, width_, height_); |
0 | 187 |
188 widget_->RenderMouseOver(accessor, x - left_, y - top_); | |
189 } | |
190 } | |
191 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
192 void MouseWheel(OrthancStone::MouseWheelDirection direction, |
0 | 193 int x, |
194 int y, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
195 OrthancStone::KeyboardModifiers modifiers) |
0 | 196 { |
197 if (Contains(x, y)) | |
198 { | |
199 widget_->MouseWheel(direction, x - left_, y - top_, modifiers); | |
200 } | |
201 } | |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
202 |
55 | 203 bool HasRenderMouseOver() |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
204 { |
55 | 205 return widget_->HasRenderMouseOver(); |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
206 } |
0 | 207 }; |
208 | |
209 | |
210 void LayoutWidget::ComputeChildrenExtents() | |
211 { | |
212 if (children_.size() == 0) | |
213 { | |
214 return; | |
215 } | |
216 | |
217 float internal = static_cast<float>(paddingInternal_); | |
218 | |
219 if (width_ <= paddingLeft_ + paddingRight_ || | |
220 height_ <= paddingTop_ + paddingBottom_) | |
221 { | |
222 for (size_t i = 0; i < children_.size(); i++) | |
223 { | |
224 children_[i]->SetEmpty(); | |
225 } | |
226 } | |
227 else if (isHorizontal_) | |
228 { | |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
457
diff
changeset
|
229 unsigned int padding = paddingLeft_ + paddingRight_ + (static_cast<unsigned int>(children_.size()) - 1) * paddingInternal_; |
0 | 230 float childWidth = ((static_cast<float>(width_) - static_cast<float>(padding)) / |
231 static_cast<float>(children_.size())); | |
232 | |
233 for (size_t i = 0; i < children_.size(); i++) | |
234 { | |
235 float left = static_cast<float>(paddingLeft_) + static_cast<float>(i) * (childWidth + internal); | |
236 float right = left + childWidth; | |
237 | |
238 if (left >= right) | |
239 { | |
240 children_[i]->SetEmpty(); | |
241 } | |
242 else | |
243 { | |
244 children_[i]->SetRectangle(static_cast<unsigned int>(left), | |
245 paddingTop_, | |
246 boost::math::iround(right - left), | |
247 height_ - paddingTop_ - paddingBottom_); | |
248 } | |
249 } | |
250 } | |
251 else | |
252 { | |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
457
diff
changeset
|
253 unsigned int padding = paddingTop_ + paddingBottom_ + (static_cast<unsigned int>(children_.size()) - 1) * paddingInternal_; |
0 | 254 float childHeight = ((static_cast<float>(height_) - static_cast<float>(padding)) / |
255 static_cast<float>(children_.size())); | |
256 | |
257 for (size_t i = 0; i < children_.size(); i++) | |
258 { | |
259 float top = static_cast<float>(paddingTop_) + static_cast<float>(i) * (childHeight + internal); | |
260 float bottom = top + childHeight; | |
261 | |
262 if (top >= bottom) | |
263 { | |
264 children_[i]->SetEmpty(); | |
265 } | |
266 else | |
267 { | |
268 children_[i]->SetRectangle(paddingTop_, | |
269 static_cast<unsigned int>(top), | |
270 width_ - paddingLeft_ - paddingRight_, | |
271 boost::math::iround(bottom - top)); | |
272 } | |
273 } | |
274 } | |
275 | |
278 | 276 NotifyContentChanged(*this); |
0 | 277 } |
278 | |
279 | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
232
diff
changeset
|
280 LayoutWidget::LayoutWidget(const std::string& name) : |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
232
diff
changeset
|
281 WidgetBase(name), |
0 | 282 isHorizontal_(true), |
283 width_(0), | |
284 height_(0), | |
285 paddingLeft_(0), | |
286 paddingTop_(0), | |
287 paddingRight_(0), | |
288 paddingBottom_(0), | |
289 paddingInternal_(0) | |
290 { | |
291 } | |
292 | |
293 | |
294 LayoutWidget::~LayoutWidget() | |
295 { | |
296 for (size_t i = 0; i < children_.size(); i++) | |
297 { | |
298 delete children_[i]; | |
299 } | |
300 } | |
301 | |
302 | |
330 | 303 void LayoutWidget::FitContent() |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
304 { |
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
305 for (size_t i = 0; i < children_.size(); i++) |
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
306 { |
330 | 307 children_[i]->GetWidget().FitContent(); |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
308 } |
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
309 } |
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
310 |
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
311 |
278 | 312 void LayoutWidget::NotifyContentChanged(const IWidget& widget) |
0 | 313 { |
314 // One of the children has changed | |
278 | 315 WidgetBase::NotifyContentChanged(); |
0 | 316 } |
317 | |
318 | |
319 void LayoutWidget::SetHorizontal() | |
320 { | |
321 isHorizontal_ = true; | |
322 ComputeChildrenExtents(); | |
323 } | |
324 | |
325 | |
326 void LayoutWidget::SetVertical() | |
327 { | |
328 isHorizontal_ = false; | |
329 ComputeChildrenExtents(); | |
330 } | |
331 | |
332 | |
333 void LayoutWidget::SetPadding(unsigned int left, | |
334 unsigned int top, | |
335 unsigned int right, | |
336 unsigned int bottom, | |
337 unsigned int spacing) | |
338 { | |
339 paddingLeft_ = left; | |
340 paddingTop_ = top; | |
341 paddingRight_ = right; | |
342 paddingBottom_ = bottom; | |
343 paddingInternal_ = spacing; | |
344 } | |
345 | |
346 | |
347 void LayoutWidget::SetPadding(unsigned int padding) | |
348 { | |
349 paddingLeft_ = padding; | |
350 paddingTop_ = padding; | |
351 paddingRight_ = padding; | |
352 paddingBottom_ = padding; | |
353 paddingInternal_ = padding; | |
354 } | |
355 | |
356 | |
1070 | 357 void LayoutWidget::AddWidget(boost::shared_ptr<IWidget> widget) // Takes ownership |
0 | 358 { |
359 if (widget == NULL) | |
360 { | |
361 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
362 } | |
363 | |
364 if (GetStatusBar() != NULL) | |
365 { | |
366 widget->SetStatusBar(*GetStatusBar()); | |
367 } | |
368 | |
369 children_.push_back(new ChildWidget(widget)); | |
61
ca644004d2ee
MAJOR - removal of Start/Stop and observers in IWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
370 widget->SetParent(*this); |
0 | 371 |
372 ComputeChildrenExtents(); | |
373 | |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
374 if (widget->HasAnimation()) |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
375 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
376 hasAnimation_ = true; |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
377 } |
0 | 378 } |
379 | |
380 | |
381 void LayoutWidget::SetStatusBar(IStatusBar& statusBar) | |
382 { | |
383 WidgetBase::SetStatusBar(statusBar); | |
384 | |
385 for (size_t i = 0; i < children_.size(); i++) | |
386 { | |
387 children_[i]->GetWidget().SetStatusBar(statusBar); | |
388 } | |
389 } | |
390 | |
391 | |
392 void LayoutWidget::SetSize(unsigned int width, | |
393 unsigned int height) | |
394 { | |
395 width_ = width; | |
396 height_ = height; | |
397 ComputeChildrenExtents(); | |
398 } | |
399 | |
400 | |
401 bool LayoutWidget::Render(Orthanc::ImageAccessor& surface) | |
402 { | |
403 if (!WidgetBase::Render(surface)) | |
404 { | |
405 return false; | |
406 } | |
407 | |
408 for (size_t i = 0; i < children_.size(); i++) | |
409 { | |
410 if (!children_[i]->Render(surface)) | |
411 { | |
412 return false; | |
413 } | |
414 } | |
415 | |
416 return true; | |
417 } | |
418 | |
419 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
420 IMouseTracker* LayoutWidget::CreateMouseTracker(OrthancStone::MouseButton button, |
0 | 421 int x, |
422 int y, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
423 OrthancStone::KeyboardModifiers modifiers, |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
424 const std::vector<Touch>& touches) |
0 | 425 { |
426 for (size_t i = 0; i < children_.size(); i++) | |
427 { | |
457
3b4df9925db6
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
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
428 IMouseTracker* tracker = children_[i]->CreateMouseTracker(button, x, y, modifiers, touches); |
0 | 429 if (tracker != NULL) |
430 { | |
431 return tracker; | |
432 } | |
433 } | |
434 | |
435 return NULL; | |
436 } | |
437 | |
438 | |
439 void LayoutWidget::RenderMouseOver(Orthanc::ImageAccessor& target, | |
440 int x, | |
441 int y) | |
442 { | |
443 for (size_t i = 0; i < children_.size(); i++) | |
444 { | |
445 children_[i]->RenderMouseOver(target, x, y); | |
446 } | |
447 } | |
448 | |
449 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
450 void LayoutWidget::MouseWheel(OrthancStone::MouseWheelDirection direction, |
0 | 451 int x, |
452 int y, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
453 OrthancStone::KeyboardModifiers modifiers) |
0 | 454 { |
455 for (size_t i = 0; i < children_.size(); i++) | |
456 { | |
457 children_[i]->MouseWheel(direction, x, y, modifiers); | |
458 } | |
459 } | |
460 | |
461 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
462 void LayoutWidget::KeyPressed(OrthancStone::KeyboardKeys key, |
327 | 463 char keyChar, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
527
diff
changeset
|
464 OrthancStone::KeyboardModifiers modifiers) |
0 | 465 { |
466 for (size_t i = 0; i < children_.size(); i++) | |
467 { | |
327 | 468 children_[i]->GetWidget().KeyPressed(key, keyChar, modifiers); |
0 | 469 } |
470 } | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
471 |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
472 |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
473 void LayoutWidget::DoAnimation() |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
474 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
475 if (hasAnimation_) |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
476 { |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
477 for (size_t i = 0; i < children_.size(); i++) |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
478 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
479 children_[i]->DoAnimation(); |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
480 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
481 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
482 else |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
483 { |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
484 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
485 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
486 } |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
487 |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
488 |
55 | 489 bool LayoutWidget::HasRenderMouseOver() |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
490 { |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
491 for (size_t i = 0; i < children_.size(); i++) |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
492 { |
55 | 493 if (children_[i]->HasRenderMouseOver()) |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
494 { |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
495 return true; |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
496 } |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
497 } |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
498 |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
499 return false; |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
500 } |
0 | 501 } |