@@ -92,14 +92,16 @@ private void OnRender(double obj)
92
92
if ( ! isInitialized )
93
93
return ;
94
94
95
+ //is this correct?
96
+
95
97
var start = Stopwatch . GetTimestamp ( ) ;
96
98
97
99
using var _ = Systrace . BeginEvent ( nameof ( OnRender ) ) ;
98
100
99
101
Render ( ) ;
100
102
101
103
//ToDo cleanup
102
- Input . OnAfterFrame ( ) ;
104
+
103
105
104
106
OldHoveredElements . Clear ( ) ;
105
107
foreach ( var uiContainer in HoveredElements )
@@ -136,13 +138,10 @@ private void OnUpdate(double obj)
136
138
HandleZoomAndStuff ( ) ;
137
139
138
140
BuildUi ( ) ;
139
- }
140
141
141
- public enum ZoomType
142
- {
143
- ScaleContent , //Makes the content bigger changes the layout to still fit everything
144
- ZoomContent , //Zooms in on part of the ui, while keeping everything sharp, allows pan
145
- ZoomCanvas //Zoom in on part of the image, without changing the resolution, allows pan
142
+ CreateRenderInstructions ( ) ;
143
+
144
+ Input . OnAfterFrame ( ) ;
146
145
}
147
146
148
147
private void HandleZoomAndStuff ( )
@@ -152,47 +151,27 @@ private void HandleZoomAndStuff()
152
151
Close ( ) ;
153
152
}
154
153
155
- if ( IsKeyPressed ( Key . Number1 ) )
156
- {
157
- zoomType = ZoomType . ScaleContent ;
158
- }
159
- else if ( IsKeyPressed ( Key . Number2 ) )
160
- {
161
- zoomType = ZoomType . ZoomContent ;
162
- }
163
- else if ( IsKeyPressed ( Key . Number3 ) )
164
- {
165
- zoomType = ZoomType . ZoomCanvas ;
166
- }
167
-
168
- if ( IsMouseButtonDown ( MouseButton . Right ) && zoomType is ZoomType . ZoomContent )
154
+ if ( IsMouseButtonDown ( MouseButton . Right ) )
169
155
{
170
156
var mouseDelta = MouseDelta ;
171
157
ZoomTarget += mouseDelta * - 1 / Zoom ;
172
158
}
173
-
159
+
174
160
if ( IsKeyDown ( Key . ControlLeft ) && ScrollDeltaY != 0 )
175
161
{
176
162
var factor = ( float ) Math . Pow ( 1.1 , ScrollDeltaY ) ;
163
+ UserScaling *= new Vector2 ( factor , factor ) ;
164
+ UserScaling = new Vector2 ( Math . Clamp ( UserScaling . X , 0.1f , 10f ) , Math . Clamp ( UserScaling . Y , 0.1f , 10f ) ) ;
165
+ }
177
166
178
- switch ( zoomType )
179
- {
180
- case ZoomType . ScaleContent :
181
- UserScaling *= new Vector2 ( factor , factor ) ;
182
- UserScaling = new Vector2 ( Math . Clamp ( UserScaling . X , 0.1f , 10f ) , Math . Clamp ( UserScaling . Y , 0.1f , 10f ) ) ;
183
- break ;
184
- case ZoomType . ZoomContent :
185
- var mouseWorldPos = MousePosition ;
186
- ZoomOffset = MouseScreenPosition ;
187
- ZoomTarget = mouseWorldPos ;
188
- Zoom *= new Vector2 ( factor , factor ) ;
189
- Zoom = new Vector2 ( Math . Clamp ( Zoom . X , 0.01f , 100f ) , Math . Clamp ( Zoom . Y , 0.01f , 100f ) ) ;
190
- break ;
191
- case ZoomType . ZoomCanvas :
192
- break ;
193
- default :
194
- throw new ArgumentOutOfRangeException ( ) ;
195
- }
167
+ if ( IsKeyDown ( Key . AltLeft ) && ScrollDeltaY != 0 )
168
+ {
169
+ var factor = ( float ) Math . Pow ( 1.1 , ScrollDeltaY ) ;
170
+ var mouseWorldPos = MousePosition ;
171
+ ZoomOffset = MouseScreenPosition ;
172
+ ZoomTarget = mouseWorldPos ;
173
+ Zoom *= new Vector2 ( factor , factor ) ;
174
+ Zoom = new Vector2 ( Math . Clamp ( Zoom . X , 0.01f , 100f ) , Math . Clamp ( Zoom . Y , 0.01f , 100f ) ) ;
196
175
}
197
176
198
177
if ( IsKeyPressed ( Key . R ) )
@@ -224,7 +203,7 @@ private Matrix4X4<float> GetWorldToScreenMatrix()
224
203
return origin * scale * translate ;
225
204
}
226
205
227
- private ZoomType zoomType = ZoomType . ScaleContent ;
206
+ // private ZoomType zoomType = ZoomType.ScaleContent;
228
207
229
208
public Vector2 Zoom = new ( 1 , 1 ) ;
230
209
public Vector2 ZoomOffset = new ( 0 , 0 ) ;
@@ -308,7 +287,6 @@ private void HitDetection()
308
287
309
288
private void Render ( )
310
289
{
311
- CreateRenderInstructions ( ) ;
312
290
RenderToCanvas ( ) ;
313
291
}
314
292
0 commit comments