Mercurial > hg > orthanc-stone
annotate Samples/Sdl/TrackerSampleApp.cpp @ 656:002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
might also be needed on macos and GNU/Linux ?) + fixed text info overlay pos
for angle measure (this requires the app to be aware of the compositor)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 14 May 2019 16:54:13 +0200 |
parents | 462a5074f914 |
children | cb3b76d16234 |
rev | line source |
---|---|
644 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
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. | |
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 | |
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 | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 #include "TrackerSampleApp.h" | |
22 | |
23 #include "../Common/CreateLineMeasureTracker.h" | |
651
62f6ff016085
Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
24 #include "../Common/CreateAngleMeasureTracker.h" |
644 | 25 |
26 #include "../../Applications/Sdl/SdlOpenGLWindow.h" | |
27 | |
28 #include "../../Framework/Scene2D/PanSceneTracker.h" | |
29 #include "../../Framework/Scene2D/RotateSceneTracker.h" | |
30 #include "../../Framework/Scene2D/Scene2D.h" | |
31 #include "../../Framework/Scene2D/ZoomSceneTracker.h" | |
32 #include "../../Framework/Scene2D/CairoCompositor.h" | |
33 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h" | |
34 #include "../../Framework/Scene2D/OpenGLCompositor.h" | |
35 #include "../../Framework/StoneInitialization.h" | |
36 | |
37 // From Orthanc framework | |
38 #include <Core/Logging.h> | |
39 #include <Core/OrthancException.h> | |
40 #include <Core/Images/Image.h> | |
41 #include <Core/Images/ImageProcessing.h> | |
42 #include <Core/Images/PngWriter.h> | |
43 | |
44 #include <SDL.h> | |
45 #include <stdio.h> | |
46 | |
47 using namespace Orthanc; | |
48 | |
49 namespace OrthancStone | |
50 { | |
51 const char* MeasureToolToString(size_t i) | |
52 { | |
53 static const char* descs[] = { | |
54 "GuiTool_Rotate", | |
55 "GuiTool_Pan", | |
56 "GuiTool_Zoom", | |
57 "GuiTool_LineMeasure", | |
58 "GuiTool_CircleMeasure", | |
59 "GuiTool_AngleMeasure", | |
60 "GuiTool_EllipseMeasure", | |
61 "GuiTool_LAST" | |
62 }; | |
63 if (i >= GuiTool_LAST) | |
64 { | |
65 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Wrong tool index"); | |
66 } | |
67 return descs[i]; | |
68 } | |
69 | |
70 Scene2D& TrackerSampleApp::GetScene() | |
71 { | |
72 return scene_; | |
73 } | |
74 | |
75 void TrackerSampleApp::SelectNextTool() | |
76 { | |
77 currentTool_ = static_cast<GuiTool>(currentTool_ + 1); | |
78 if (currentTool_ == GuiTool_LAST) | |
79 currentTool_ = static_cast<GuiTool>(0);; | |
80 printf("Current tool is now: %s\n", MeasureToolToString(currentTool_)); | |
81 } | |
82 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
83 void TrackerSampleApp::DisplayInfoText() |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
84 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
85 char buf[256]; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
86 sprintf(buf, "INFO TEXT\n*** INFO TEXT ***\ntoto tata tutu titi\nprrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrout"); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
87 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
88 TextSceneLayer* layerP = NULL; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
89 if (scene_.HasLayer(FIXED_INFOTEXT_LAYER_ZINDEX)) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
90 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
91 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>( |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
92 scene_.GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX)); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
93 layerP = &layer; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
94 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
95 else |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
96 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
97 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
98 layerP = layer.get(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
99 layer->SetColor(0, 255, 0); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
100 layer->SetFontIndex(1); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
101 layer->SetText(buf); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
102 layer->SetBorder(20); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
103 layer->SetAnchor(BitmapAnchor_TopLeft); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
104 //layer->SetPosition(0,0); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
105 scene_.SetLayer(FIXED_INFOTEXT_LAYER_ZINDEX, layer.release()); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
106 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
107 // position the fixed info text in the upper right corner |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
108 layerP->SetText(buf); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
109 double cX = compositor_->GetCanvasWidth() * (-0.5); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
110 double cY = compositor_->GetCanvasHeight() * (-0.5); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
111 scene_.GetCanvasToSceneTransform().Apply(cX,cY); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
112 layerP->SetPosition(cX, cY); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
113 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
114 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
115 void TrackerSampleApp::DisplayFloatingCtrlInfoText(const PointerEvent& e) |
644 | 116 { |
117 ScenePoint2D p = e.GetMainPosition().Apply(scene_.GetCanvasToSceneTransform()); | |
118 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
119 char buf[128]; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
120 sprintf(buf, "S:(%0.02f,%0.02f) C:(%0.02f,%0.02f)", |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
121 p.GetX(), p.GetY(), |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
122 e.GetMainPosition().GetX(), e.GetMainPosition().GetY()); |
644 | 123 |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
124 if (scene_.HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)) |
644 | 125 { |
126 TextSceneLayer& layer = | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
127 dynamic_cast<TextSceneLayer&>(scene_.GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)); |
644 | 128 layer.SetText(buf); |
129 layer.SetPosition(p.GetX(), p.GetY()); | |
130 } | |
131 else | |
132 { | |
133 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer); | |
134 layer->SetColor(0, 255, 0); | |
135 layer->SetText(buf); | |
136 layer->SetBorder(20); | |
137 layer->SetAnchor(BitmapAnchor_BottomCenter); | |
138 layer->SetPosition(p.GetX(), p.GetY()); | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
139 scene_.SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release()); |
644 | 140 } |
141 } | |
142 | |
143 void TrackerSampleApp::HideInfoText() | |
144 { | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
145 scene_.DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX); |
644 | 146 } |
147 | |
148 void TrackerSampleApp::HandleApplicationEvent( | |
149 const SDL_Event & event) | |
150 { | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
151 DisplayInfoText(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
152 |
644 | 153 if (event.type == SDL_MOUSEMOTION) |
154 { | |
155 int scancodeCount = 0; | |
156 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); | |
157 | |
158 if (activeTracker_.get() == NULL && | |
159 SDL_SCANCODE_LCTRL < scancodeCount && | |
160 keyboardState[SDL_SCANCODE_LCTRL]) | |
161 { | |
162 // The "left-ctrl" key is down, while no tracker is present | |
163 // Let's display the info text | |
164 PointerEvent e; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
165 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
166 event.button.x, event.button.y)); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
167 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
168 DisplayFloatingCtrlInfoText(e); |
644 | 169 } |
170 else | |
171 { | |
172 HideInfoText(); | |
173 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)"; | |
174 if (activeTracker_.get() != NULL) | |
175 { | |
176 //LOG(TRACE) << "(activeTracker_.get() != NULL)"; | |
177 PointerEvent e; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
178 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
179 event.button.x, event.button.y)); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
180 |
644 | 181 //LOG(TRACE) << "event.button.x = " << event.button.x << " " << |
182 // "event.button.y = " << event.button.y; | |
183 //LOG(TRACE) << "activeTracker_->PointerMove(e); " << | |
184 // e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY(); | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
185 |
644 | 186 activeTracker_->PointerMove(e); |
187 if (!activeTracker_->IsActive()) | |
188 activeTracker_ = NULL; | |
189 } | |
190 } | |
191 } | |
192 else if (event.type == SDL_MOUSEBUTTONUP) | |
193 { | |
194 if (activeTracker_) | |
195 { | |
196 PointerEvent e; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
197 e.AddPosition(compositor_->GetPixelCenterCoordinates(event.button.x, event.button.y)); |
644 | 198 activeTracker_->PointerUp(e); |
199 if (!activeTracker_->IsActive()) | |
200 activeTracker_ = NULL; | |
201 } | |
202 } | |
203 else if (event.type == SDL_MOUSEBUTTONDOWN) | |
204 { | |
205 PointerEvent e; | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
206 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
651
62f6ff016085
Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
207 event.button.x, event.button.y)); |
644 | 208 if (activeTracker_) |
209 { | |
210 activeTracker_->PointerDown(e); | |
211 if (!activeTracker_->IsActive()) | |
212 activeTracker_ = NULL; | |
213 } | |
214 else | |
215 { | |
216 // we ATTEMPT to create a tracker if need be | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
217 activeTracker_ = CreateSuitableTracker(event, e); |
644 | 218 } |
219 } | |
220 else if (event.type == SDL_KEYDOWN && | |
221 event.key.repeat == 0 /* Ignore key bounce */) | |
222 { | |
223 switch (event.key.keysym.sym) | |
224 { | |
225 case SDLK_ESCAPE: | |
226 if (activeTracker_) | |
227 { | |
228 activeTracker_->Cancel(); | |
229 if (!activeTracker_->IsActive()) | |
230 activeTracker_ = NULL; | |
231 } | |
232 break; | |
233 | |
234 case SDLK_t: | |
235 if (!activeTracker_) | |
236 SelectNextTool(); | |
237 else | |
238 { | |
239 LOG(WARNING) << "You cannot change the active tool when an interaction" | |
240 " is taking place"; | |
241 } | |
242 break; | |
243 | |
244 case SDLK_s: | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
245 scene_.FitContent(compositor_->GetCanvasWidth(), |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
246 compositor_->GetCanvasHeight()); |
644 | 247 break; |
248 | |
249 case SDLK_c: | |
250 TakeScreenshot( | |
251 "screenshot.png", | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
252 compositor_->GetCanvasWidth(), |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
253 compositor_->GetCanvasHeight()); |
644 | 254 break; |
255 | |
256 default: | |
257 break; | |
258 } | |
259 } | |
260 } | |
261 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
262 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
263 void TrackerSampleApp::OnSceneTransformChanged(const Scene2D::SceneTransformChanged& message) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
264 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
265 // do not try to call this too early! |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
266 if(compositor_.get() != NULL) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
267 DisplayInfoText(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
268 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
269 |
644 | 270 FlexiblePointerTrackerPtr TrackerSampleApp::CreateSuitableTracker( |
271 const SDL_Event & event, | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
272 const PointerEvent & e) |
644 | 273 { |
274 switch (event.button.button) | |
275 { | |
276 case SDL_BUTTON_MIDDLE: | |
277 return CreateSimpleTrackerAdapter(PointerTrackerPtr( | |
278 new PanSceneTracker(scene_, e))); | |
279 | |
280 case SDL_BUTTON_RIGHT: | |
281 return CreateSimpleTrackerAdapter(PointerTrackerPtr( | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
282 new ZoomSceneTracker(scene_, e, compositor_->GetCanvasHeight()))); |
644 | 283 |
284 case SDL_BUTTON_LEFT: | |
285 { | |
286 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:"; | |
287 // TODO: we need to iterate on the set of measuring tool and perform | |
288 // a hit test to check if a tracker needs to be created for edition. | |
289 // Otherwise, depending upon the active tool, we might want to create | |
290 // a "measuring tool creation" tracker | |
291 | |
292 // TODO: if there are conflicts, we should prefer a tracker that | |
293 // pertains to the type of measuring tool currently selected (TBD?) | |
294 FlexiblePointerTrackerPtr hitTestTracker = TrackerHitTest(e); | |
295 | |
296 if (hitTestTracker != NULL) | |
297 { | |
298 //LOG(TRACE) << "hitTestTracker != NULL"; | |
299 return hitTestTracker; | |
300 } | |
301 else | |
302 { | |
303 switch (currentTool_) | |
304 { | |
305 case GuiTool_Rotate: | |
306 //LOG(TRACE) << "Creating RotateSceneTracker"; | |
307 return CreateSimpleTrackerAdapter(PointerTrackerPtr( | |
308 new RotateSceneTracker(scene_, e))); | |
309 case GuiTool_Pan: | |
310 return CreateSimpleTrackerAdapter(PointerTrackerPtr( | |
311 new PanSceneTracker(scene_, e))); | |
312 case GuiTool_Zoom: | |
313 return CreateSimpleTrackerAdapter(PointerTrackerPtr( | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
314 new ZoomSceneTracker(scene_, e, compositor_->GetCanvasHeight()))); |
644 | 315 //case GuiTool_AngleMeasure: |
316 // return new AngleMeasureTracker(scene_, measureTools_, undoStack_, e); | |
317 //case GuiTool_CircleMeasure: | |
318 // return new CircleMeasureTracker(scene_, measureTools_, undoStack_, e); | |
319 //case GuiTool_EllipseMeasure: | |
320 // return new EllipseMeasureTracker(scene_, measureTools_, undoStack_, e); | |
651
62f6ff016085
Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
321 case GuiTool_LineMeasure: |
62f6ff016085
Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
322 return FlexiblePointerTrackerPtr(new CreateLineMeasureTracker( |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
651
diff
changeset
|
323 IObserver::GetBroker(), scene_, undoStack_, measureTools_, e)); |
644 | 324 case GuiTool_AngleMeasure: |
651
62f6ff016085
Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
325 return FlexiblePointerTrackerPtr(new CreateAngleMeasureTracker( |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
651
diff
changeset
|
326 IObserver::GetBroker(), scene_, undoStack_, measureTools_, e)); |
644 | 327 return NULL; |
328 case GuiTool_CircleMeasure: | |
329 LOG(ERROR) << "Not implemented yet!"; | |
330 return NULL; | |
331 case GuiTool_EllipseMeasure: | |
332 LOG(ERROR) << "Not implemented yet!"; | |
333 return NULL; | |
334 default: | |
335 throw OrthancException(ErrorCode_InternalError, "Wrong tool!"); | |
336 } | |
337 } | |
338 } | |
339 default: | |
340 return NULL; | |
341 } | |
342 } | |
343 | |
344 | |
345 void TrackerSampleApp::PrepareScene() | |
346 { | |
347 // Texture of 2x2 size | |
348 { | |
349 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false); | |
350 | |
351 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0)); | |
352 p[0] = 255; | |
353 p[1] = 0; | |
354 p[2] = 0; | |
355 | |
356 p[3] = 0; | |
357 p[4] = 255; | |
358 p[5] = 0; | |
359 | |
360 p = reinterpret_cast<uint8_t*>(i.GetRow(1)); | |
361 p[0] = 0; | |
362 p[1] = 0; | |
363 p[2] = 255; | |
364 | |
365 p[3] = 255; | |
366 p[4] = 0; | |
367 p[5] = 0; | |
368 | |
369 scene_.SetLayer(TEXTURE_2x2_1_ZINDEX, new ColorTextureSceneLayer(i)); | |
370 | |
371 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i)); | |
372 l->SetOrigin(-3, 2); | |
373 l->SetPixelSpacing(1.5, 1); | |
374 l->SetAngle(20.0 / 180.0 * M_PI); | |
375 scene_.SetLayer(TEXTURE_2x2_2_ZINDEX, l.release()); | |
376 } | |
377 | |
378 // Texture of 1x1 size | |
379 { | |
380 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false); | |
381 | |
382 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0)); | |
383 p[0] = 255; | |
384 p[1] = 0; | |
385 p[2] = 0; | |
386 | |
387 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i)); | |
388 l->SetOrigin(-2, 1); | |
389 l->SetAngle(20.0 / 180.0 * M_PI); | |
390 scene_.SetLayer(TEXTURE_1x1_ZINDEX, l.release()); | |
391 } | |
392 | |
393 // Some lines | |
394 { | |
395 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer); | |
396 | |
397 layer->SetThickness(1); | |
398 | |
399 PolylineSceneLayer::Chain chain; | |
400 chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5)); | |
401 chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5)); | |
402 chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5)); | |
403 chain.push_back(ScenePoint2D(2 - 0.5, 0 - 0.5)); | |
404 layer->AddChain(chain, true); | |
405 | |
406 chain.clear(); | |
407 chain.push_back(ScenePoint2D(-5, -5)); | |
408 chain.push_back(ScenePoint2D(5, -5)); | |
409 chain.push_back(ScenePoint2D(5, 5)); | |
410 chain.push_back(ScenePoint2D(-5, 5)); | |
411 layer->AddChain(chain, true); | |
412 | |
413 double dy = 1.01; | |
414 chain.clear(); | |
415 chain.push_back(ScenePoint2D(-4, -4)); | |
416 chain.push_back(ScenePoint2D(4, -4 + dy)); | |
417 chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy)); | |
418 chain.push_back(ScenePoint2D(4, 2)); | |
419 layer->AddChain(chain, false); | |
420 | |
421 layer->SetColor(0, 255, 255); | |
422 scene_.SetLayer(LINESET_1_ZINDEX, layer.release()); | |
423 } | |
424 | |
425 // Some text | |
426 { | |
427 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer); | |
428 layer->SetText("Hello"); | |
429 scene_.SetLayer(LINESET_2_ZINDEX, layer.release()); | |
430 } | |
431 } | |
432 | |
433 | |
434 void TrackerSampleApp::DisableTracker() | |
435 { | |
436 if (activeTracker_) | |
437 { | |
438 activeTracker_->Cancel(); | |
439 activeTracker_ = NULL; | |
440 } | |
441 } | |
442 | |
443 void TrackerSampleApp::TakeScreenshot(const std::string& target, | |
444 unsigned int canvasWidth, | |
445 unsigned int canvasHeight) | |
446 { | |
447 CairoCompositor compositor(scene_, canvasWidth, canvasHeight); | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
448 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, FONT_SIZE_0, Orthanc::Encoding_Latin1); |
644 | 449 compositor.Refresh(); |
450 | |
451 Orthanc::ImageAccessor canvas; | |
452 compositor.GetCanvas().GetReadOnlyAccessor(canvas); | |
453 | |
454 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false); | |
455 Orthanc::ImageProcessing::Convert(png, canvas); | |
456 | |
457 Orthanc::PngWriter writer; | |
458 writer.WriteToFile(target, png); | |
459 } | |
460 | |
461 | |
462 FlexiblePointerTrackerPtr TrackerSampleApp::TrackerHitTest(const PointerEvent & e) | |
463 { | |
464 // std::vector<MeasureToolPtr> measureTools_; | |
465 return nullptr; | |
466 } | |
467 | |
656
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
468 static void GLAPIENTRY |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
469 OpenGLMessageCallback(GLenum source, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
470 GLenum type, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
471 GLuint id, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
472 GLenum severity, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
473 GLsizei length, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
474 const GLchar* message, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
475 const void* userParam) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
476 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
477 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
478 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
479 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
480 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
481 type, severity, message); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
482 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
483 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
484 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
485 static bool g_stopApplication = false; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
486 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
487 void TrackerSampleApp::Run() |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
488 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
489 // False means we do NOT let Windows treat this as a legacy application |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
490 // that needs to be scaled |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
491 SdlOpenGLWindow window("Hello", 1024, 1024, false); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
492 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
493 GetScene().FitContent(window.GetCanvasWidth(), window.GetCanvasHeight()); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
494 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
495 glEnable(GL_DEBUG_OUTPUT); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
496 glDebugMessageCallback(OpenGLMessageCallback, 0); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
497 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
498 compositor_.reset(new OpenGLCompositor(window, GetScene())); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
499 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
500 compositor_->SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
501 FONT_SIZE_0, Orthanc::Encoding_Latin1); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
502 compositor_->SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT, |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
503 FONT_SIZE_1, Orthanc::Encoding_Latin1); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
504 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
505 while (!g_stopApplication) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
506 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
507 compositor_->Refresh(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
508 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
509 SDL_Event event; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
510 while (!g_stopApplication && SDL_PollEvent(&event)) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
511 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
512 if (event.type == SDL_QUIT) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
513 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
514 g_stopApplication = true; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
515 break; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
516 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
517 else if (event.type == SDL_WINDOWEVENT && |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
518 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
519 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
520 DisableTracker(); // was: tracker.reset(NULL); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
521 compositor_->UpdateSize(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
522 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
523 else if (event.type == SDL_KEYDOWN && |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
524 event.key.repeat == 0 /* Ignore key bounce */) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
525 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
526 switch (event.key.keysym.sym) |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
527 { |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
528 case SDLK_f: |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
529 window.GetWindow().ToggleMaximize(); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
530 break; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
531 |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
532 case SDLK_q: |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
533 g_stopApplication = true; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
534 break; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
535 default: |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
536 break; |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
537 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
538 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
539 HandleApplicationEvent(event); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
540 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
541 SDL_Delay(1); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
542 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
543 compositor_.reset(NULL); |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
544 } |
002d9562c8f5
Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents:
654
diff
changeset
|
545 |
644 | 546 |
547 | |
548 } |