Framework Update
A few changes, mostly to update the .NET framework version.
This commit is contained in:
parent
f479409fe9
commit
ecf4e808ea
@ -36,7 +36,7 @@ public class ContextMenu : Window
|
||||
BackgroundColor = new(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private Task ItemsOnControlAdded(IRenderObject arg)
|
||||
private Task ItemsOnControlAdded(int index, IRenderObject arg)
|
||||
{
|
||||
arg.Clicked += ArgOnClicked;
|
||||
this.Context.MakeCurrent();
|
||||
|
@ -4,6 +4,7 @@ public enum TextureDisplay : byte
|
||||
{
|
||||
Clamped,
|
||||
HorizontalCenter,
|
||||
TextureHorizontalCenter,
|
||||
VerticalCenter,
|
||||
Center,
|
||||
ProgressHorizontalCenter,
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
@ -10,7 +10,7 @@
|
||||
<IncludeSymbols>False</IncludeSymbols>
|
||||
<RepositoryUrl>https://git.jacobtech.com/JacobTech.com/GraphicsManager</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Version>1.0.7-alpha48</Version>
|
||||
<Version>1.0.7-alpha69</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
|
@ -24,6 +24,8 @@ public interface IWindow : IParent
|
||||
|
||||
public string ClipboardString { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public Vector2 MousePosition { get; set; }
|
||||
|
||||
public ContextMenu? ActiveMenu { get; set; }
|
||||
|
@ -18,7 +18,7 @@ public class ControlList
|
||||
|
||||
public int Length => _internal.Count;
|
||||
|
||||
internal event Func<IRenderObject, Task>? ControlAdded;
|
||||
internal event Func<int, IRenderObject, Task>? ControlAdded;
|
||||
internal event Func<Task>? ControlRemoved;
|
||||
|
||||
public void Remove(IRenderObject item, bool purge = true)
|
||||
@ -33,15 +33,21 @@ public class ControlList
|
||||
if (ControlRemoved is not null && !Clearing) _ = ControlRemoved.Invoke();
|
||||
}
|
||||
|
||||
public void MoveControlToEnd(IRenderObject item)
|
||||
{
|
||||
_internal.Remove(item);
|
||||
_internal.Add(item);
|
||||
}
|
||||
|
||||
public void Add(IRenderObject item)
|
||||
{
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(item).Wait();
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(_internal.Count, item).Wait();
|
||||
_internal.Add(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, IRenderObject item)
|
||||
{
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(item).Wait();
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(index, item).Wait();
|
||||
_internal.Insert(index, item);
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,21 @@ public class FlowLayout : ParentBase
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ControlsOnControlAdded(IRenderObject arg)
|
||||
private Task ControlsOnControlAdded(int index, IRenderObject arg)
|
||||
{
|
||||
if (Controls.Length > 0) arg.Location = new(0, Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y, arg.Location.Z);
|
||||
if (Controls.Length > 0)
|
||||
{
|
||||
if (index < Controls.Length)
|
||||
{
|
||||
arg.Location = Controls[index].Location;
|
||||
Controls[index].Location = new(arg.Location.X, arg.Location.Y + arg.Size.Y, arg.Location.Z);
|
||||
for (int i = index + 1; i < Controls.Length; i++)
|
||||
{
|
||||
Controls[i].Location = new(0, Controls[i - 1].Location.Y + Controls[i - 1].Size.Y, arg.Location.Z);
|
||||
}
|
||||
}
|
||||
else arg.Location = new(0, Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y, arg.Location.Z);
|
||||
}
|
||||
else arg.Location = new(0);
|
||||
if (arg is IParent par2)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using GraphicsManager.Enums;
|
||||
using System.Diagnostics;
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
@ -18,6 +19,34 @@ public class Rectangle : ITextureObject
|
||||
|
||||
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
||||
|
||||
public Vector3i GetWindowLocation()
|
||||
{
|
||||
if (!Loaded) return Location;
|
||||
Vector3i loc = Location;
|
||||
IParent? p = Parent;
|
||||
while (p is not null)
|
||||
{
|
||||
loc += p.Position;
|
||||
p = p.Parent;
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Vector3i GetParentLocation(IParent par)
|
||||
{
|
||||
if (!Loaded) return Location;
|
||||
Vector3i loc = Location;
|
||||
IParent? p = Parent;
|
||||
while (p is not null && p != par)
|
||||
{
|
||||
loc += p.Position;
|
||||
p = p.Parent;
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public List<Texture> Textures { get; set; } = new();
|
||||
public ContextMenu? ContextMenu { get; set; } = null;
|
||||
public event Func<string[], Task>? FilesDroped;
|
||||
@ -63,12 +92,13 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
|
||||
public Action? OnDrawAction;
|
||||
public Action? OnDrawExitAction;
|
||||
//public Action? OnDrawExitAction;
|
||||
|
||||
public virtual void Draw(int x, int y, int w, int h)
|
||||
{
|
||||
if (Visible && Loaded)
|
||||
{
|
||||
if (OnDrawAction is not null) OnDrawAction.Invoke();
|
||||
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
|
||||
foreach (Texture tex in Textures)
|
||||
{
|
||||
@ -132,6 +162,17 @@ public class Rectangle : ITextureObject
|
||||
if (WindowLoaded is not null) WindowLoaded.Invoke(this);
|
||||
}
|
||||
|
||||
public void TransferOwners(IWindow w, IParent p)
|
||||
{
|
||||
if (Parent is not null)
|
||||
{
|
||||
Parent.Controls._internal.Remove(this);
|
||||
Window = w;
|
||||
Parent = p;
|
||||
}
|
||||
p.Controls.Add(this);
|
||||
}
|
||||
|
||||
private void WindowOnFileDrop(FileDropEventArgs obj)
|
||||
{
|
||||
if (!MouseInside) return;
|
||||
@ -279,12 +320,25 @@ public class Rectangle : ITextureObject
|
||||
default:
|
||||
switch (value)
|
||||
{
|
||||
case TextureDisplay.HorizontalCenter or TextureDisplay.ProgressHorizontalCenter:
|
||||
case TextureDisplay.Clamped:
|
||||
Points = new float[]
|
||||
{
|
||||
saf.X, laf.Y, 0, Textures[0].MaxText.X, Textures[0].MaxText.Y,
|
||||
saf.X, saf.Y, 0, Textures[0].MaxText.X, 0,
|
||||
laf.X, saf.Y, 0, 0, 0,
|
||||
laf.X, laf.Y, 0, 0, Textures[0].MaxText.Y,
|
||||
};
|
||||
break;
|
||||
case TextureDisplay.HorizontalCenter or TextureDisplay.ProgressHorizontalCenter or TextureDisplay.TextureHorizontalCenter:
|
||||
float per = (float)Textures[0].RawSize!.Value.Y / Textures[0].RawSize!.Value.X;
|
||||
float diff = 0;
|
||||
if (Window is not null)
|
||||
{
|
||||
diff = Window.IntToFloat(Size.Y) + 1;
|
||||
if (value == TextureDisplay.TextureHorizontalCenter)
|
||||
{
|
||||
diff = Window.IntToFloat(Textures[0].RawSize!.Value.Y);
|
||||
}
|
||||
}
|
||||
Points = new float[]
|
||||
{
|
||||
@ -326,7 +380,15 @@ public class Rectangle : ITextureObject
|
||||
if (Window is null || Parent is null) return;
|
||||
Parent.ReportSizeUpdate(this);
|
||||
//float[] temp = Points;
|
||||
float[] temp = Textures.Count == 0 ? new float[12] : (TextureDisplay == TextureDisplay.Center ? new float[20] : new float[40]);
|
||||
float[] temp = Textures.Count == 0
|
||||
? new float[12]
|
||||
: TextureDisplay switch
|
||||
{
|
||||
TextureDisplay.Clamped => new float[20],
|
||||
TextureDisplay.HorizontalCenter or TextureDisplay.ProgressHorizontalCenter
|
||||
or TextureDisplay.Center or TextureDisplay.TextureHorizontalCenter => new float[40],
|
||||
_ => new float[20]
|
||||
};
|
||||
saf = new Vector2(Parent.IntToFloat(value.X + loc_.X, false), Parent.IntToFloat(value.Y + loc_.Y, true));
|
||||
temp[2] = Location.Z;
|
||||
temp[(!Textures.Any() ? 5 : 7)] = Location.Z;
|
||||
@ -347,8 +409,16 @@ public class Rectangle : ITextureObject
|
||||
Vector2i s = value;
|
||||
float diff = Window.IntToFloat(s.Y) + 1;
|
||||
float per = (float)Textures[0].RawSize!.Value.Y / Textures[0].RawSize!.Value.X;
|
||||
if (TextureDisplay == TextureDisplay.TextureHorizontalCenter)
|
||||
diff = Window.IntToFloat(Textures[0].RawSize!.Value.Y);
|
||||
switch (TextureDisplay)
|
||||
{
|
||||
case TextureDisplay.Clamped:
|
||||
temp[3] = Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = Textures[0].MaxText.X;
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
break;
|
||||
case TextureDisplay.HorizontalCenter:
|
||||
temp[3] = Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
@ -413,21 +483,21 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
else
|
||||
{
|
||||
temp[3] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.X;
|
||||
temp[4] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.Y;
|
||||
temp[8] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.X;
|
||||
temp[19] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.Y;
|
||||
temp[3] = (0.666666f + (((s.X - s.Y) / (float)s.Y)* per)) * Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = temp[3];
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
//start last 33% of texture
|
||||
temp[20] =laf.X + diff; // top r
|
||||
temp[20] = saf.X; // top r
|
||||
temp[21] = laf.Y;
|
||||
temp[22] = 0;
|
||||
temp[23] = per;
|
||||
temp[23] = temp[3];
|
||||
temp[24] = 1;
|
||||
|
||||
temp[25] = laf.X + diff; // bot r
|
||||
temp[25] = saf.X; // bot r
|
||||
temp[26] = saf.Y;
|
||||
temp[27] = 0;
|
||||
temp[28] = per;
|
||||
temp[28] = temp[3];
|
||||
temp[29] = 0;
|
||||
|
||||
temp[30] = laf.X + diff; // bot l
|
||||
@ -446,33 +516,33 @@ public class Rectangle : ITextureObject
|
||||
else
|
||||
{
|
||||
//first 33% of texture
|
||||
temp[3] = (s.X/(s.Y*3));
|
||||
temp[3] = ((s.X/(float)s.Y)*per);
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = (s.X/(s.Y*3));
|
||||
temp[8] = temp[3];
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
temp[20] = laf.X; // top r
|
||||
temp[20] = saf.X; // top r
|
||||
temp[21] = laf.Y;
|
||||
temp[22] = 0;
|
||||
temp[23] = (s.X/(s.Y*3));
|
||||
temp[24] = 1;
|
||||
temp[23] = temp[3];
|
||||
temp[24] = Textures[0].MaxText.Y;
|
||||
|
||||
temp[25] = saf.X; // bot r
|
||||
temp[26] = saf.Y;
|
||||
temp[27] = 0;
|
||||
temp[28] = (s.X/(s.Y*3));
|
||||
temp[28] = temp[3];
|
||||
temp[29] = 0;
|
||||
|
||||
temp[30] = saf.X; // bot l
|
||||
temp[31] = saf.Y;
|
||||
temp[32] = 0;
|
||||
temp[33] = (s.X/(s.Y*3));
|
||||
temp[33] = temp[3];
|
||||
temp[34] = 0;
|
||||
|
||||
temp[35] = laf.X; // top l
|
||||
temp[35] = saf.X; // top l
|
||||
temp[36] = laf.Y;
|
||||
temp[37] = 0;
|
||||
temp[38] = (s.X/(s.Y*3));
|
||||
temp[39] = 1;
|
||||
temp[38] = temp[3];
|
||||
temp[39] = Textures[0].MaxText.Y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -492,7 +562,15 @@ public class Rectangle : ITextureObject
|
||||
{
|
||||
loc_ = value;
|
||||
if (Window is null || Parent is null) return;
|
||||
float[] temp = Textures.Count == 0 ? new float[12] : (TextureDisplay == TextureDisplay.Center ? new float[20] : new float[40]);
|
||||
float[] temp = Textures.Count == 0
|
||||
? new float[12]
|
||||
: TextureDisplay switch
|
||||
{
|
||||
TextureDisplay.Clamped => new float[20],
|
||||
TextureDisplay.HorizontalCenter or TextureDisplay.ProgressHorizontalCenter
|
||||
or TextureDisplay.Center => new float[40],
|
||||
_ => new float[20]
|
||||
};
|
||||
laf = new Vector2(Parent.IntToFloat(value.X, false), Parent.IntToFloat(value.Y, true));
|
||||
temp[2] = value.Z;
|
||||
temp[(!Textures.Any() ? 5 : 7)] = value.Z;
|
||||
@ -515,6 +593,12 @@ public class Rectangle : ITextureObject
|
||||
float per = (float)Textures[0].RawSize!.Value.Y / Textures[0].RawSize!.Value.X;
|
||||
switch (TextureDisplay)
|
||||
{
|
||||
case TextureDisplay.Clamped:
|
||||
temp[3] = Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = Textures[0].MaxText.X;
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
break;
|
||||
case TextureDisplay.HorizontalCenter:
|
||||
temp[3] = Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
@ -579,21 +663,21 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
else
|
||||
{
|
||||
temp[3] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.X;
|
||||
temp[4] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.Y;
|
||||
temp[8] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.X;
|
||||
temp[19] = (0.666666f + ((s.X - s.Y) / s.Y)) * Textures[0].MaxText.Y;
|
||||
temp[3] = (0.666666f + (((s.X - s.Y) / (float)s.Y)* per)) * Textures[0].MaxText.X;
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = temp[3];
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
//start last 33% of texture
|
||||
temp[20] =laf.X + diff; // top r
|
||||
temp[20] = saf.X; // top r
|
||||
temp[21] = laf.Y;
|
||||
temp[22] = 0;
|
||||
temp[23] = per;
|
||||
temp[23] = temp[3];
|
||||
temp[24] = 1;
|
||||
|
||||
temp[25] = laf.X + diff; // bot r
|
||||
temp[25] = saf.X; // bot r
|
||||
temp[26] = saf.Y;
|
||||
temp[27] = 0;
|
||||
temp[28] = per;
|
||||
temp[28] = temp[3];
|
||||
temp[29] = 0;
|
||||
|
||||
temp[30] = laf.X + diff; // bot l
|
||||
@ -612,33 +696,33 @@ public class Rectangle : ITextureObject
|
||||
else
|
||||
{
|
||||
//first 33% of texture
|
||||
temp[3] = (s.X/(s.Y*3));
|
||||
temp[3] = ((s.X/(float)s.Y)*per);
|
||||
temp[4] = Textures[0].MaxText.Y;
|
||||
temp[8] = (s.X/(s.Y*3));
|
||||
temp[8] = temp[3];
|
||||
temp[19] = Textures[0].MaxText.Y;
|
||||
temp[20] = laf.X; // top r
|
||||
temp[20] = saf.X; // top r
|
||||
temp[21] = laf.Y;
|
||||
temp[22] = 0;
|
||||
temp[23] = (s.X/(s.Y*3));
|
||||
temp[24] = 1;
|
||||
temp[23] = temp[3];
|
||||
temp[24] = Textures[0].MaxText.Y;
|
||||
|
||||
temp[25] = saf.X; // bot r
|
||||
temp[26] = saf.Y;
|
||||
temp[27] = 0;
|
||||
temp[28] = (s.X/(s.Y*3));
|
||||
temp[28] = temp[3];
|
||||
temp[29] = 0;
|
||||
|
||||
temp[30] = saf.X; // bot l
|
||||
temp[31] = saf.Y;
|
||||
temp[32] = 0;
|
||||
temp[33] = (s.X/(s.Y*3));
|
||||
temp[33] = temp[3];
|
||||
temp[34] = 0;
|
||||
|
||||
temp[35] = laf.X; // top l
|
||||
temp[35] = saf.X; // top l
|
||||
temp[36] = laf.Y;
|
||||
temp[37] = 0;
|
||||
temp[38] = (s.X/(s.Y*3));
|
||||
temp[39] = 1;
|
||||
temp[38] = temp[3];
|
||||
temp[39] = Textures[0].MaxText.Y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ public class TexturedTextBox : Rectangle
|
||||
{
|
||||
private Label _label;
|
||||
private Label _watermark;
|
||||
public ContextMenu? ContextMenu { get; set; }
|
||||
|
||||
public TextLocation TextLocation { get; set; } = TextLocation.TopLeft;
|
||||
|
||||
@ -23,13 +22,15 @@ public class TexturedTextBox : Rectangle
|
||||
base.HoverMouse = MouseCursor.IBeam;
|
||||
_label = new Label(LabelFam)
|
||||
{
|
||||
HoverMouse = MouseCursor.IBeam
|
||||
HoverMouse = MouseCursor.IBeam,
|
||||
IgnoreHover = true
|
||||
};
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
_watermark = new(WaterFam)
|
||||
{
|
||||
Color = new(128, 128, 128, 255),
|
||||
HoverMouse = MouseCursor.IBeam
|
||||
HoverMouse = MouseCursor.IBeam,
|
||||
IgnoreHover = true
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,13 +53,15 @@ public class TexturedTextBox : Rectangle
|
||||
base.HoverMouse = MouseCursor.IBeam;
|
||||
_label = new Label(LabelFam)
|
||||
{
|
||||
HoverMouse = MouseCursor.IBeam
|
||||
HoverMouse = MouseCursor.IBeam,
|
||||
IgnoreHover = true
|
||||
};
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
_watermark = new(WaterFam)
|
||||
{
|
||||
Color = new(128, 128, 128, 255),
|
||||
HoverMouse = MouseCursor.IBeam
|
||||
HoverMouse = MouseCursor.IBeam,
|
||||
IgnoreHover = true
|
||||
};
|
||||
}
|
||||
|
||||
@ -212,28 +215,29 @@ public class TexturedTextBox : Rectangle
|
||||
{
|
||||
if (!Visible || !Loaded) return;
|
||||
int nx = x, ny = y, nw = w, nh = h;
|
||||
if (Location.X + Border > nw)
|
||||
if (Location.X > nw)
|
||||
return;
|
||||
else
|
||||
{
|
||||
nx += (Location.X + Border);
|
||||
nw -= (Location.X + Border);
|
||||
if (Size.X - Border < nw)
|
||||
nw = Size.X - Border;
|
||||
nx += Location.X;
|
||||
nw -= Location.X;
|
||||
if (Size.X < nw)
|
||||
nw = Size.X;
|
||||
}
|
||||
|
||||
if (Location.Y + Border > nh)
|
||||
if (Location.Y > nh)
|
||||
return;
|
||||
else
|
||||
{
|
||||
ny += (Location.Y + Border);
|
||||
nh -= (Location.Y + Border);
|
||||
if (Size.Y - Border < nh)
|
||||
nh = Size.Y - Border;
|
||||
ny += Location.Y;
|
||||
nh -= Location.Y;
|
||||
if (Size.Y < nh)
|
||||
nh = Size.Y;
|
||||
}
|
||||
if (nh < 1 || nw < 1) return;
|
||||
GL.Scissor(nx,ny,nw,nh);
|
||||
if (nw == 0 || nh == 0) return;
|
||||
GL.Scissor(nx, Window!.Size.Y - ny - nh, nw, nh);
|
||||
base.Draw(nx,ny,nw,nh);
|
||||
GL.Scissor(nx, Window!.Size.Y - ny - nh, nw, nh);
|
||||
if (!string.IsNullOrEmpty(_label.Text)) _label.Draw(nx,ny,nw,nh);
|
||||
else _watermark.Draw(nx,ny,nw,nh);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user