Skip to content

Commit b37ec4f

Browse files
fix: picker filter reset
1 parent 780e5b3 commit b37ec4f

7 files changed

Lines changed: 22 additions & 30 deletions

File tree

FreeFrame/Components/Shapes/SVGPolygon.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public SVGPolygon(XmlReader reader)
2424
IsResizeable = false;
2525
IsCornerRadiusChangeable = false;
2626

27-
string points = reader["points"] ?? throw new Exception("points not here"); // TODO: Error handler if points is note here
27+
string points = reader["points"] ?? throw new Exception("points not here");
2828
MatchCollection matches = _pointsAttributeRegex.Matches(points); // Retrieve every points
2929

3030
foreach (Match match in matches)
3131
Points.Add((Convert.ToInt32(match.Groups[1].Value), Convert.ToInt32(match.Groups[2].Value)));
3232

33-
string color = reader["fill"] ?? DefaultColor; // TODO: Error handler if d is note here
33+
string color = reader["fill"] ?? DefaultColor;
3434
Color = Importer.HexadecimalToRGB(color);
3535

3636
// Fill geometry values
@@ -72,7 +72,7 @@ public SVGPolygon(int x, int y, int width, int height, string color)
7272
public override float[] GetVertices()
7373
{
7474
if (Points.Count == 3) // Because a triangle is also base on the size
75-
return new float[] { X + Width / 2, Y, X, Y + Height, X + Width, Y + Height }; // TODO: Use Select, Cast, whatever
75+
return new float[] { X + Width / 2, Y, X, Y + Height, X + Width, Y + Height };
7676
else // Any other polygon
7777
{
7878
List<float> vertices = new List<float>();

FreeFrame/Components/Shapes/SVGRectangle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public SVGRectangle(XmlReader reader) : this(
2525
Convert.ToInt32(reader["y"]),
2626
Convert.ToInt32(reader["rx"]),
2727
Convert.ToInt32(reader["ry"]),
28-
Convert.ToString(reader["fill"] == null ? DefaultColor : reader["fill"])) // TODO: Error handler if one of the properties in reader is note here, it should be dynamic
28+
Convert.ToString(reader["fill"] == null ? DefaultColor : reader["fill"]))
2929
{
3030
}
3131
public SVGRectangle() : this(DefaultWidth, DefaultHeight, DefaultX, DefaultY) { }

FreeFrame/Components/Shapes/Shape.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ namespace FreeFrame.Components.Shapes
99
{
1010
public abstract class Shape : IDrawable
1111
{
12-
bool _isMoveable = true;
13-
bool _isResizeable = true;
14-
bool _isAngleChangeable = true;
15-
bool _isCornerRadiusChangeable = true;
16-
1712
#region Default values
1813
public const string DefaultColor = "#000000FF";
1914
#endregion
@@ -22,6 +17,10 @@ public abstract class Shape : IDrawable
2217
private int _x, _y, _width, _height, _angle, _cornerRadius;
2318
private Color4 _color;
2419
Guid _id;
20+
bool _isMoveable = true;
21+
bool _isResizeable = true;
22+
bool _isAngleChangeable = true;
23+
bool _isCornerRadiusChangeable = true;
2524
#endregion
2625

2726
private List<Renderer> renderers;
@@ -46,7 +45,6 @@ public string ShortId
4645
{
4746
get => Id.ToString().Substring(0, 6);
4847
}
49-
5048
public Shape()
5149
{
5250
Renderers = new List<Renderer>();

FreeFrame/Helper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,5 @@ static public void EnableDebugMode()
5757
GL.Enable(EnableCap.DebugOutput);
5858
GL.Enable(EnableCap.DebugOutputSynchronous);
5959
}
60-
6160
}
6261
}

FreeFrame/Lib/ImGuiFile/FilePicker.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace FreeFrame.Lib.FileExplorer
1212
{
1313
public class FilePicker
1414
{
15-
static readonly Dictionary<object, FilePicker> _filePickers = new Dictionary<object, FilePicker>();
15+
static Dictionary<object, FilePicker> _filePickers = new Dictionary<object, FilePicker>();
1616

1717
public string RootFolder;
1818
public string CurrentFolder;
@@ -52,13 +52,13 @@ public static FilePicker GetFilePicker(object o, string startingPath, string sea
5252

5353
fp.AllowedExtensions.AddRange(searchFilter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
5454

55-
5655
_filePickers.Add(o, fp);
5756
}
58-
5957
return fp;
6058
}
6159

60+
public static void Clear() => _filePickers.Clear();
61+
6262
public bool Draw()
6363
{
6464
if (CurrentFolder.Length >= 50)
@@ -101,7 +101,6 @@ public bool Draw()
101101
result = true;
102102
ImGui.CloseCurrentPopup();
103103
}
104-
105104
}
106105
}
107106
}
@@ -114,6 +113,7 @@ public bool Draw()
114113
{
115114
result = false;
116115
ImGui.CloseCurrentPopup();
116+
Clear();
117117
}
118118

119119
if (OnlyAllowFolders)
@@ -166,6 +166,5 @@ List<string> GetFileSystemEntries(string fullName)
166166

167167
return ret;
168168
}
169-
170169
}
171170
}

FreeFrame/Lib/ImGuiFile/FileSaver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static FileSaver GetFilePicker(object o, string startingPath)
4646

4747
return fp;
4848
}
49-
public static void Remove(object o) => _fileSavers.Remove(o);
49+
public static void Clear() => _fileSavers.Clear();
5050

5151
public bool Draw()
5252
{
@@ -86,6 +86,7 @@ public bool Draw()
8686
{
8787
result = false;
8888
ImGui.CloseCurrentPopup();
89+
Clear();
8990
}
9091
ImGui.SameLine();
9192
if (ImGui.Button("Save here"))

FreeFrame/Window.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ protected override void OnUnload()
270270

271271
Shapes.ForEach(shape => shape.DeleteObjects());
272272
}
273-
273+
274274
private void OnLeftMouseDown()
275275
{
276276
if (_userMode != UserMode.Create) // If it's not to create
@@ -929,9 +929,9 @@ private void ShowUI()
929929
if (ImGui.Button(String.Format("Remove keyframe {0} for {1}", _timeline.TimelineIndex, _selectedShape.GetType().Name)))
930930
{
931931
_timeline.SortedTimeline[_timeline.TimelineIndex].Remove(_timeline.SortedTimeline[_timeline.TimelineIndex].Find(x => x.Id == _selectedShape.Id)!); // Can't be null
932+
// If timeline empty then null it
932933
if (_timeline.SortedTimeline[_timeline.TimelineIndex].Count == 0)
933934
_timeline.SortedTimeline.Remove(_timeline.TimelineIndex);
934-
// If list _timeline[_ioTimeline] empty then null it
935935
}
936936
}
937937
else
@@ -992,31 +992,26 @@ private void ShowUI()
992992
{
993993
_dialogFileSaver = true;
994994
_exportMode = ExportMode.Workspace;
995-
//SaveFreeFrameWorkspace();
996995
}
997996
if (ImGui.MenuItem("Save as SVG"))
998997
{
999998
_dialogFileSaver = true;
1000999
_exportMode = ExportMode.SVG;
1001-
//SaveCurrentScreenToSVG();
10021000
}
10031001
if (ImGui.MenuItem("Save as MP4"))
10041002
{
10051003
_dialogFileSaver = true;
10061004
_exportMode = ExportMode.MP4;
1007-
//SaveCurrentScreenToMP4();
10081005
}
10091006
if (ImGui.MenuItem("Save as GIF"))
10101007
{
10111008
_dialogFileSaver = true;
10121009
_exportMode = ExportMode.GIF;
1013-
//SaveCurrentScreenToGIF();
10141010
}
10151011
if (ImGui.MenuItem("Save as PNG"))
10161012
{
10171013
_dialogFileSaver = true;
10181014
_exportMode = ExportMode.PNG;
1019-
//SaveCurrentScreenToPNG();
10201015
}
10211016
ImGui.EndMenu();
10221017
}
@@ -1059,7 +1054,7 @@ private void ShowUI()
10591054
// File picker dialog
10601055
if (_dialogFileSaver)
10611056
ImGui.OpenPopup("save-file");
1062-
if (ImGui.BeginPopupModal("save-file")) // ImGuiWindowFlags.AlwaysAutoResize
1057+
if (ImGui.BeginPopupModal("save-file"))
10631058
{
10641059
var picker = FileSaver.GetFilePicker(this, Path.Combine(Environment.CurrentDirectory, "Content/Atlases"));
10651060
if (picker.Draw())
@@ -1085,16 +1080,16 @@ private void ShowUI()
10851080
default:
10861081
break;
10871082
}
1083+
FileSaver.Clear();
10881084
}
1089-
//FileSaver.Remove(this);
10901085
_dialogFileSaver = false;
10911086
ImGui.EndPopup();
10921087
}
10931088

10941089
// File picker dialog
10951090
if (_dialogFilePicker)
10961091
ImGui.OpenPopup("open-file");
1097-
if (ImGui.BeginPopupModal("open-file")) // ImGuiWindowFlags.AlwaysAutoResize
1092+
if (ImGui.BeginPopupModal("open-file"))
10981093
{
10991094
var picker = FilePicker.GetFilePicker(this, Path.Combine(Environment.CurrentDirectory, "Content/Atlases"), _importMode == ImportMode.Workspace ? ".freeframe" : ".svg");
11001095
if (picker.Draw())
@@ -1130,15 +1125,16 @@ private void ShowUI()
11301125
//if (compatibilityFlag)
11311126
// _dialogCompatibility = true;
11321127

1128+
FilePicker.Clear();
11331129
}
1134-
//FilePicker.Remove(this);
11351130
_dialogFilePicker = false;
11361131
ImGui.EndPopup();
11371132
}
11381133

11391134
// Compatibility alert
11401135
if (_dialogCompatibility)
11411136
ImGui.OpenPopup("Compatibility Problem");
1137+
11421138
if (ImGui.BeginPopupModal("Compatibility Problem")) // ImGuiWindowFlags.AlwaysAutoResize
11431139
{
11441140
ImGui.Text("Some SVG elements are not compatible. Go to the list of compatible SVG elements");
@@ -1310,7 +1306,6 @@ public void SaveCurrentScreenToPNG(string path)
13101306
TakeSnap().Save(path + ".png", ImageFormat.Png);
13111307
}
13121308

1313-
13141309
/// <summary>
13151310
/// Render the timeline
13161311
/// </summary>
@@ -1340,7 +1335,7 @@ public Bitmap TakeSnap()
13401335

13411336
// Lock the bits
13421337
BitmapData bmpData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, ClientSize.X, ClientSize.Y), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
1343-
1338+
13441339
// Fill with current window
13451340
GL.ReadPixels(0, 0, ClientSize.X, ClientSize.Y, OpenTK.Graphics.OpenGL4.PixelFormat.Bgr, PixelType.UnsignedByte, bmpData.Scan0);
13461341

0 commit comments

Comments
 (0)