Skip to content

Commit ec783cc

Browse files
chore: path moveable
1 parent 1143da9 commit ec783cc

4 files changed

Lines changed: 40 additions & 104 deletions

File tree

FreeFrame/Components/Shapes/Path/DrawAttribute.cs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public abstract class DrawAttribute
3333
public abstract float[] GetVertices();
3434
public abstract uint[] GetVerticesIndexes();
3535
public abstract void MoveDelta(Vector2i deltaPosition);
36-
public abstract void ResizeDelta(Vector2i size);
3736
public abstract List<Vector2i> GetSelectablePoints();
3837
public abstract override string ToString();
3938
}
@@ -98,11 +97,6 @@ public override void MoveDelta(Vector2i deltaPosition)
9897
//throw new NotImplementedException();
9998
}
10099

101-
public override void ResizeDelta(Vector2i size)
102-
{
103-
//throw new NotImplementedException();
104-
}
105-
106100
public override (Vector2i position, Vector2i? controlPosition) Information() => (new Vector2i(X, Y), null);
107101
}
108102
/// <summary>
@@ -180,12 +174,6 @@ public override void MoveDelta(Vector2i deltaPosition)
180174
X += deltaPosition.X;
181175
Y += deltaPosition.Y;
182176
}
183-
184-
public override void ResizeDelta(Vector2i deltaSize)
185-
{
186-
X += deltaSize.X;
187-
Y += deltaSize.Y;
188-
}
189177
public override (Vector2i position, Vector2i? controlPosition) Information() => (new Vector2i(X, Y), null);
190178
}
191179
/// <summary>
@@ -259,12 +247,6 @@ public override void MoveDelta(Vector2i deltaPosition)
259247
X += deltaPosition.X;
260248
//LastY += deltaPosition.Y;
261249
}
262-
263-
public override void ResizeDelta(Vector2i size)
264-
{
265-
X += size.X;
266-
//LastY += size.Y;
267-
}
268250
public override (Vector2i position, Vector2i? controlPosition) Information() => (new Vector2i(X, Last.Y), null);
269251
}
270252
/// <summary>
@@ -337,10 +319,6 @@ public override void MoveDelta(Vector2i deltaPosition)
337319
throw new NotImplementedException();
338320
}
339321

340-
public override void ResizeDelta(Vector2i size)
341-
{
342-
throw new NotImplementedException();
343-
}
344322
public override (Vector2i position, Vector2i? controlPosition) Information()
345323
{
346324
throw new NotImplementedException();
@@ -476,15 +454,6 @@ public override void MoveDelta(Vector2i deltaPosition)
476454
Y += deltaPosition.Y;
477455
}
478456

479-
public override void ResizeDelta(Vector2i size)
480-
{
481-
X1 += size.X;
482-
Y1 += size.Y;
483-
X2 += size.X;
484-
Y2 += size.Y;
485-
X += size.X;
486-
Y += size.Y;
487-
}
488457

489458
public override (Vector2i position, Vector2i? controlPosition) Information()
490459
{
@@ -610,12 +579,6 @@ public override void MoveDelta(Vector2i deltaPosition)
610579
{
611580
throw new NotImplementedException();
612581
}
613-
614-
public override void ResizeDelta(Vector2i size)
615-
{
616-
throw new NotImplementedException();
617-
}
618-
619582
public override (Vector2i position, Vector2i? controlPosition) Information()
620583
{
621584
throw new NotImplementedException();
@@ -735,11 +698,6 @@ public override void MoveDelta(Vector2i deltaPosition)
735698
throw new NotImplementedException();
736699
}
737700

738-
public override void ResizeDelta(Vector2i size)
739-
{
740-
throw new NotImplementedException();
741-
}
742-
743701
public override (Vector2i position, Vector2i? controlPosition) Information()
744702
{
745703
throw new NotImplementedException();
@@ -853,11 +811,6 @@ public override void MoveDelta(Vector2i deltaPosition)
853811
throw new NotImplementedException();
854812
}
855813

856-
public override void ResizeDelta(Vector2i size)
857-
{
858-
throw new NotImplementedException();
859-
}
860-
861814
public override (Vector2i position, Vector2i? controlPosition) Information()
862815
{
863816
throw new NotImplementedException();
@@ -931,11 +884,6 @@ public override void MoveDelta(Vector2i deltaPosition)
931884
{
932885
throw new NotImplementedException();
933886
}
934-
935-
public override void ResizeDelta(Vector2i size)
936-
{
937-
throw new NotImplementedException();
938-
}
939887
public override (Vector2i position, Vector2i? controlPosition) Information()
940888
{
941889
throw new NotImplementedException();
@@ -972,11 +920,6 @@ public override void MoveDelta(Vector2i deltaPosition)
972920
{
973921
throw new NotImplementedException();
974922
}
975-
976-
public override void ResizeDelta(Vector2i size)
977-
{
978-
throw new NotImplementedException();
979-
}
980923
public override (Vector2i position, Vector2i? controlPosition) Information()
981924
{
982925
throw new NotImplementedException();

FreeFrame/Components/Shapes/SVGPath.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public override int Height
8181

8282
public SVGPath(XmlReader reader) //: this()
8383
{
84+
Resizeable = false;
8485
string d = reader["d"] ?? throw new Exception("d not here"); // TODO: Error handler if d is note here
8586
Match match;
8687
int startIndex = 0;
@@ -397,29 +398,6 @@ public override void Move(Vector2i position)
397398

398399
public override void Resize(Vector2i size)
399400
{
400-
foreach (VertexArrayObject vao in _vaos)
401-
vao.DeleteObjects();
402-
_vaos.Clear();
403-
404-
DrawAttribute previousAttribute = new MoveTo(0, 0);
405-
foreach (DrawAttribute attr in DrawAttributes)
406-
{
407-
if (attr.GetType() == typeof(CurveTo) ||
408-
attr.GetType() == typeof(SmoothCurveTo) ||
409-
attr.GetType() == typeof(QuadraticBezierCurveTo) ||
410-
attr.GetType() == typeof(SmoothQuadraticBezierCurveTo) ||
411-
attr.GetType() == typeof(EllipticalArc))
412-
{
413-
_vaos.Add(new VertexArrayObject(attr.GetVertices(), attr.GetVerticesIndexes(), PrimitiveType.LineStrip));
414-
}
415-
else
416-
{
417-
_vaos.Add(new VertexArrayObject(attr.GetVertices(), attr.GetVerticesIndexes(), PrimitiveType.Lines));
418-
}
419-
attr.ResizeDelta(size - new Vector2i(attr.X, attr.Y));
420-
previousAttribute = attr;
421-
}
422-
423401
//List<Vector2i> points = GetSelectablePoints();
424402
//Properties = new DefaultProperties()
425403
//{

FreeFrame/Components/Shapes/Shape.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace FreeFrame.Components.Shapes
88
{
99
public abstract class Shape
1010
{
11+
bool _moveable = true;
12+
bool _resizeable = true;
1113
#region Common Geometry Properties
1214
private int _x, _y, _width, _height;
1315
private Color4 _color;
@@ -19,6 +21,10 @@ public abstract class Shape
1921
public virtual int Width { get => _width; set => _width = value; }
2022
public virtual int Height { get => _height; set => _height = value; }
2123
public Color4 Color { get => _color; set => _color = value; }
24+
public bool Moveable { get => _moveable; protected set => _moveable = value; }
25+
public bool Resizeable { get => _resizeable; protected set => _resizeable = value; }
26+
27+
List<Shape>[] _timeline;
2228

2329
public Shape()
2430
{
@@ -60,6 +66,11 @@ public void DeleteObjects()
6066
foreach (VertexArrayObject vao in _vaos)
6167
vao.DeleteObjects();
6268
}
69+
public Shape Clone()
70+
{
71+
Shape shape = (Shape)this.MemberwiseClone();
72+
return shape;
73+
}
6374
/// <summary>
6475
/// Should return the vertices position in NDC format
6576
/// </summary>

FreeFrame/Window.cs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected override void OnLoad()
5858
{
5959
base.OnLoad();
6060

61-
//Helper.EnableDebugMode();
61+
Helper.EnableDebugMode();
6262

6363
GL.ClearColor(0.1f, 0.1f, 0.1f, 1.0f); // TODO: Magic value
6464

@@ -88,8 +88,8 @@ protected override void OnUpdateFrame(FrameEventArgs e)
8888
{
8989
base.OnUpdateFrame(e);
9090

91-
if (_selectedShape != null)
92-
Console.WriteLine("x: {0}; y: {1}; width: {2}; height: {3}", _selectedShape.X, _selectedShape.Y, _selectedShape.Width, _selectedShape.Height);
91+
//if (_selectedShape != null)
92+
// Console.WriteLine("x: {0}; y: {1}; width: {2}; height: {3}", _selectedShape.X, _selectedShape.Y, _selectedShape.Width, _selectedShape.Height);
9393
}
9494
/// <summary>
9595
/// Triggered as often as possible (fps). (Drawing, etc.)
@@ -100,6 +100,7 @@ protected override void OnRenderFrame(FrameEventArgs e)
100100
base.OnRenderFrame(e);
101101
GL.Clear(ClearBufferMask.ColorBufferBit); // Clear the color
102102

103+
103104
if (KeyboardState.IsKeyDown(Keys.Escape))
104105
{
105106
_userMode = UserMode.Idle;
@@ -114,7 +115,6 @@ protected override void OnRenderFrame(FrameEventArgs e)
114115
_ioColor = new System.Numerics.Vector4(0);
115116
// TODO: Disable the inputs
116117
}
117-
118118
if (MouseState.WasButtonDown(MouseButton.Left) == false && MouseState.IsButtonDown(MouseButton.Left) == true) // First left click
119119
OnLeftMouseDown();
120120
else if (MouseState.WasButtonDown(MouseButton.Left) == true && MouseState.IsButtonDown(MouseButton.Left) == true) // Long left click
@@ -139,9 +139,9 @@ protected override void OnRenderFrame(FrameEventArgs e)
139139
else
140140
{
141141
//_selectedShape.UpdateProperties(properties);
142-
if (_selectedShape.X != _ioX ||
143-
_selectedShape.Y != _ioY ||
144-
_selectedShape.Width != _ioWidth ||
142+
if (_selectedShape.X != _ioX ||
143+
_selectedShape.Y != _ioY ||
144+
_selectedShape.Width != _ioWidth ||
145145
_selectedShape.Height != _ioHeight ||
146146
_selectedShape.Color != new Color4(_ioColor.X, _ioColor.Y, _ioColor.Z, _ioColor.W))
147147
{
@@ -154,7 +154,6 @@ protected override void OnRenderFrame(FrameEventArgs e)
154154
_selectedShape.ImplementObject();
155155
_selector.Select(_selectedShape);
156156
}
157-
158157
}
159158
}
160159
switch (_userMode)
@@ -291,24 +290,30 @@ public void OnLeftMouseEnter() // TODO: Rename this
291290
switch (_selectorType)
292291
{
293292
case SelectorType.Move:
294-
_selectedShape.Move(new Vector2i((int)MouseState.X, (int)MouseState.Y));
295-
_selector.Select(_selectedShape);
296-
UpdateIO_UI();
293+
if (_selectedShape.Moveable)
294+
{
295+
_selectedShape.Move(new Vector2i((int)MouseState.X, (int)MouseState.Y));
296+
_selector.Select(_selectedShape);
297+
UpdateIO_UI();
298+
}
297299
break;
298300
case SelectorType.Resize:
299-
float width, height;
300-
width = MouseState.X - _selectedShape.X;
301-
height = MouseState.Y - _selectedShape.Y;
302-
if (KeyboardState.IsKeyDown(Keys.LeftShift)) // SHIFT
301+
if (_selectedShape.Resizeable)
303302
{
304-
if (width > height)
305-
height = width;
306-
else
307-
width = height;
303+
float width, height;
304+
width = MouseState.X - _selectedShape.X;
305+
height = MouseState.Y - _selectedShape.Y;
306+
if (KeyboardState.IsKeyDown(Keys.LeftShift)) // SHIFT
307+
{
308+
if (width > height)
309+
height = width;
310+
else
311+
width = height;
312+
}
313+
_selectedShape.Resize(new Vector2i((int)width, (int)height));
314+
_selector.Select(_selectedShape);
315+
UpdateIO_UI();
308316
}
309-
_selectedShape.Resize(new Vector2i((int)width, (int)height));
310-
_selector.Select(_selectedShape);
311-
UpdateIO_UI();
312317
break;
313318
case SelectorType.Edge:
314319
case SelectorType.None:
@@ -382,13 +387,13 @@ public void ShowUI()
382387
ImGui.Text("Animation");
383388
ImGui.End();
384389

390+
385391
// Timeline side
386392
ImGui.Begin("Timeline", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoTitleBar);
387393
ImGui.SetWindowSize(new System.Numerics.Vector2(ClientSize.X / 2 - 200, 200));
388394
ImGui.SetWindowPos(new System.Numerics.Vector2(ClientSize.X / 2, ClientSize.Y - ImGui.GetWindowHeight()));
389395
ImGui.Text("Timeline");
390396
ImGui.Spacing();
391-
ImGui.SliderInt("(seconds)", ref _ioTimeline, 0, 60);
392397
ImGui.End();
393398

394399
// Navbar side
@@ -443,7 +448,6 @@ public void ShowUI()
443448
FilePicker.RemoveFilePicker(this);
444449
if (compatibilityFlag)
445450
_dialogCompatibility = true;
446-
447451
}
448452
_dialogFilePicker = false;
449453
ImGui.EndPopup();

0 commit comments

Comments
 (0)