Mercurial > hg > orthanc-stone
annotate Framework/Widgets/LayoutWidget.cpp @ 535:79bb0a02d1cc bgo-commands-codegen
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
- Last fixes to new style command handling (removed useless commands and switch command handling in simple samples to use XxxxSerializedMessageXxxx instead of XxxxCommandXxxx
- Fixed hardcoded input instance in SingleFrameEditorApplication
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 19 Mar 2019 09:13:57 +0100 |
parents | b1377625e4ba |
children | 4f2416d519b4 |
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 | |
29 namespace OrthancStone | |
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: | |
88 std::auto_ptr<IWidget> widget_; | |
89 int left_; | |
90 int top_; | |
91 unsigned int width_; | |
92 unsigned int height_; | |
93 | |
94 public: | |
95 ChildWidget(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 | |
157 IMouseTracker* CreateMouseTracker(MouseButton button, | |
158 int x, | |
159 int y, | |
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
|
160 KeyboardModifiers 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
|
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 | |
192 void MouseWheel(MouseWheelDirection direction, | |
193 int x, | |
194 int y, | |
195 KeyboardModifiers modifiers) | |
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 | |
357 IWidget& LayoutWidget::AddWidget(IWidget* widget) // Takes ownership | |
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 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
378 |
0 | 379 return *widget; |
380 } | |
381 | |
382 | |
383 void LayoutWidget::SetStatusBar(IStatusBar& statusBar) | |
384 { | |
385 WidgetBase::SetStatusBar(statusBar); | |
386 | |
387 for (size_t i = 0; i < children_.size(); i++) | |
388 { | |
389 children_[i]->GetWidget().SetStatusBar(statusBar); | |
390 } | |
391 } | |
392 | |
393 | |
394 void LayoutWidget::SetSize(unsigned int width, | |
395 unsigned int height) | |
396 { | |
397 width_ = width; | |
398 height_ = height; | |
399 ComputeChildrenExtents(); | |
400 } | |
401 | |
402 | |
403 bool LayoutWidget::Render(Orthanc::ImageAccessor& surface) | |
404 { | |
405 if (!WidgetBase::Render(surface)) | |
406 { | |
407 return false; | |
408 } | |
409 | |
410 for (size_t i = 0; i < children_.size(); i++) | |
411 { | |
412 if (!children_[i]->Render(surface)) | |
413 { | |
414 return false; | |
415 } | |
416 } | |
417 | |
418 return true; | |
419 } | |
420 | |
421 | |
422 IMouseTracker* LayoutWidget::CreateMouseTracker(MouseButton button, | |
423 int x, | |
424 int y, | |
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
|
425 KeyboardModifiers 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
|
426 const std::vector<Touch>& touches) |
0 | 427 { |
428 for (size_t i = 0; i < children_.size(); i++) | |
429 { | |
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
|
430 IMouseTracker* tracker = children_[i]->CreateMouseTracker(button, x, y, modifiers, touches); |
0 | 431 if (tracker != NULL) |
432 { | |
433 return tracker; | |
434 } | |
435 } | |
436 | |
437 return NULL; | |
438 } | |
439 | |
440 | |
441 void LayoutWidget::RenderMouseOver(Orthanc::ImageAccessor& target, | |
442 int x, | |
443 int y) | |
444 { | |
445 for (size_t i = 0; i < children_.size(); i++) | |
446 { | |
447 children_[i]->RenderMouseOver(target, x, y); | |
448 } | |
449 } | |
450 | |
451 | |
452 void LayoutWidget::MouseWheel(MouseWheelDirection direction, | |
453 int x, | |
454 int y, | |
455 KeyboardModifiers modifiers) | |
456 { | |
457 for (size_t i = 0; i < children_.size(); i++) | |
458 { | |
459 children_[i]->MouseWheel(direction, x, y, modifiers); | |
460 } | |
461 } | |
462 | |
463 | |
327 | 464 void LayoutWidget::KeyPressed(KeyboardKeys key, |
465 char keyChar, | |
0 | 466 KeyboardModifiers modifiers) |
467 { | |
468 for (size_t i = 0; i < children_.size(); i++) | |
469 { | |
327 | 470 children_[i]->GetWidget().KeyPressed(key, keyChar, modifiers); |
0 | 471 } |
472 } | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
473 |
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 void LayoutWidget::DoAnimation() |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
476 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
477 if (hasAnimation_) |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
478 { |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
479 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
|
480 { |
386
e33659decec5
renamed UpdateContent() as DoAnimation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
481 children_[i]->DoAnimation(); |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
482 } |
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 else |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
487 } |
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
488 } |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
489 |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
490 |
55 | 491 bool LayoutWidget::HasRenderMouseOver() |
54
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
492 { |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
493 for (size_t i = 0; i < children_.size(); i++) |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
494 { |
55 | 495 if (children_[i]->HasRenderMouseOver()) |
54
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 return true; |
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 } |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
500 |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
501 return false; |
01aa453d4d5b
IWidget::HasRenderMouseOver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
502 } |
0 | 503 } |