Skip to content

Commit 930386b

Browse files
committed
[Editor API] - Added animate to marching ants interface to allow for multiple calls to the draw without messing up the animation timing.
1 parent 4f94779 commit 930386b

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

PlugIns/Gorgon.Editor.ImageEditor/_Internal/Renderers/TextureCubeViewer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ protected override void DrawTexture()
180180
{
181181
Renderer.DrawRectangle(_cubeScreenBounds[i], new GorgonColor(GorgonColor.Black, Opacity * 0.88f), 1);
182182
}
183-
183+
184+
_selectionRect.Animate();
184185
_selectionRect.Draw(_cubeScreenBounds[selectedImage]);
185186

186187
var offset = new Vector2(0, "+X".MeasureLine(_axisFont, true).Height);

PlugIns/Gorgon.Editor.SpriteEditor/_Internal/Renderers/DefaultSpriteViewer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ protected override void DrawSprite()
268268
Renderer.DrawEllipse(new DX.RectangleF(transformedAnchor.X - 4, transformedAnchor.Y - 4, 8, 8), GorgonColor.Black);
269269
Renderer.DrawEllipse(new DX.RectangleF(transformedAnchor.X - 3, transformedAnchor.Y - 3, 6, 6), GorgonColor.White);
270270

271+
_marchAnts.Animate();
271272
_marchAnts.Draw(marchAntsRect);
272273
Renderer.End();
273274
}

PlugIns/Gorgon.Editor.SpriteEditor/_Internal/Renderers/PickSpriteViewer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ protected override void DrawSprite()
227227

228228
// Draw in client space.
229229
Renderer.Begin();
230+
_marchAnts.Animate();
230231
_marchAnts.Draw(marchAntsRect);
231232
Renderer.End();
232233
}

Tools/Editor/Gorgon.Editor.API/Rendering/MarchingAnts.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,27 @@ public void Dispose()
6767
}
6868

6969
/// <summary>
70-
/// Function to draw the marching ants rectangle.
70+
/// Function to animate the marching ants.
7171
/// </summary>
72-
/// <param name="rect">The rectangular region to draw in.</param>
73-
public void Draw(DX.RectangleF rect)
72+
public void Animate()
7473
{
7574
_step += _marchAntsTexture.Value.Width * (GorgonTiming.Delta * 0.4f);
7675

7776
if (_step > _marchAntsTexture.Value.Width)
7877
{
7978
_step -= _marchAntsTexture.Value.Width;
8079
}
81-
82-
_renderer.DrawRectangle(rect, GorgonColor.White,
83-
texture: _marchAntsTexture.Value,
84-
textureRegion: _marchAntsTexture.Value.ToTexel(new DX.Rectangle((int)-_step, 0, (int)rect.Width, (int)rect.Height)),
85-
textureSampler: GorgonSamplerState.PointFilteringWrapping);
8680
}
8781

82+
/// <summary>
83+
/// Function to draw the marching ants rectangle.
84+
/// </summary>
85+
/// <param name="rect">The rectangular region to draw in.</param>
86+
public void Draw(DX.RectangleF rect) => _renderer.DrawRectangle(rect, GorgonColor.White,
87+
texture: _marchAntsTexture.Value,
88+
textureRegion: _marchAntsTexture.Value.ToTexel(new DX.Rectangle((int)-_step, 0, (int)rect.Width, (int)rect.Height)),
89+
textureSampler: GorgonSamplerState.PointFilteringWrapping);
90+
8891
/// <summary>
8992
/// Function to build an instance of the marching ants texture.
9093
/// </summary>

Tools/Editor/Gorgon.Editor.API/Rendering/_Interfaces/IMarchingAnts.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace Gorgon.Editor.Rendering
99
public interface IMarchingAnts
1010
: IDisposable
1111
{
12+
/// <summary>
13+
/// Function to animate the marching ants.
14+
/// </summary>
15+
void Animate();
16+
1217
/// <summary>
1318
/// Function to draw the marching ants rectangle.
1419
/// </summary>

Tools/Editor/Gorgon.Editor.API/Services/RectClipperService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ public void Render()
699699

700700
GetActiveHandle();
701701

702+
_marchingAnts.Animate();
702703
_marchingAnts.Draw(_screenRect);
703704

704705
for (int i = 0; i < _handles.Length; ++i)

0 commit comments

Comments
 (0)