Trying to make faster
This commit is contained in:
parent
ec6d6064b1
commit
a2250893d4
@ -1,11 +1,16 @@
|
|||||||
namespace GraphicsManager.Enums;
|
namespace GraphicsManager.Enums;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum ObjectAnchor
|
public enum ObjectAnchor : byte
|
||||||
{
|
{
|
||||||
Left = 0b_0001,
|
Left = 0b_00_0001,
|
||||||
Top = 0b_0010,
|
Top = 0b_00_0010,
|
||||||
Right = 0b_0100,
|
Right = 0b_00_0100,
|
||||||
Bottom = 0b_1000,
|
Bottom = 0b_00_1000,
|
||||||
|
|
||||||
|
PreventWidthChange = 0b_01_0000 | Left | Right,
|
||||||
|
PreventHeightChange = 0b_10_0000 | Top | Bottom,
|
||||||
|
|
||||||
All = Left | Top | Right | Bottom,
|
All = Left | Top | Right | Bottom,
|
||||||
|
Prevent = PreventWidthChange | PreventHeightChange,
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ public class FPSWindow : GameWindow , IWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IRenderObject? focused { get; set; }
|
public IRenderObject? focused { get; set; }
|
||||||
|
|
||||||
|
public bool LogFrames { get; set; } = true;
|
||||||
|
public int SubFrameCount { get; set; }
|
||||||
|
public int Frame { get; set; }
|
||||||
public void CenterWindow(int mon)
|
public void CenterWindow(int mon)
|
||||||
{
|
{
|
||||||
Box2i clientArea = Monitors.GetMonitors()[mon].ClientArea;
|
Box2i clientArea = Monitors.GetMonitors()[mon].ClientArea;
|
||||||
@ -345,11 +349,37 @@ public class FPSWindow : GameWindow , IWindow
|
|||||||
|
|
||||||
public bool BlockDraw { get; set; }
|
public bool BlockDraw { get; set; }
|
||||||
|
|
||||||
public void TryDraw()
|
public void TryDraw(int depth = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IgnoreVisForChildren { get; set; }
|
||||||
|
|
||||||
|
public virtual void CheckParent(IParent p, IRenderObject c, int xx, Vector3i di)
|
||||||
|
{
|
||||||
|
if (p.Controls.Length <= 1 || xx >= p.Controls.Length || !c.Visible || c is ILabel) return;
|
||||||
|
for (int i = xx; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (!p.Controls[i].IsVisible ||
|
||||||
|
(p.Controls[i].Location.X + di.X >= c.Location.X && p.Controls[i].Location.X + p.Controls[i].Size.X + di.X - c.Size.X <= c.Location.X) ||
|
||||||
|
(p.Controls[i].Location.Y + di.Y >= c.Location.Y && p.Controls[i].Location.Y + p.Controls[i].Size.Y + di.X - c.Size.Y <= c.Location.Y))
|
||||||
|
{
|
||||||
|
p.Controls[i].NotifiNotVisible();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p.Controls[i] is IParent pp) CheckParent(pp, c, pp.Controls.Length-1, di + p.Controls[i].Location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void CheckParent(IParent p)
|
||||||
|
{
|
||||||
|
for (int i = p.Controls.Length - 1; i > 0; i++)
|
||||||
|
{
|
||||||
|
CheckParent(p, p.Controls[i], i-1, new());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int initthread;
|
private int initthread;
|
||||||
|
|
||||||
public bool InvokeRequired
|
public bool InvokeRequired
|
||||||
@ -362,6 +392,13 @@ public class FPSWindow : GameWindow , IWindow
|
|||||||
|
|
||||||
private Queue<Action> invokes = new();
|
private Queue<Action> invokes = new();
|
||||||
|
|
||||||
|
public int LastX { get; } = 0;
|
||||||
|
public int LastY { get; } = 0;
|
||||||
|
public int LastSX { get; } = 0;
|
||||||
|
public int LastSY { get; } = 0;
|
||||||
|
public int LastSW { get; set; } = 0;
|
||||||
|
public int LastSH { get; set; } = 0;
|
||||||
|
|
||||||
public void Invoke(Action A)
|
public void Invoke(Action A)
|
||||||
{
|
{
|
||||||
invokes.Enqueue(A);
|
invokes.Enqueue(A);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<IncludeSymbols>False</IncludeSymbols>
|
<IncludeSymbols>False</IncludeSymbols>
|
||||||
<RepositoryUrl>https://git.jacobtech.com/JacobTech.com/GraphicsManager</RepositoryUrl>
|
<RepositoryUrl>https://git.jacobtech.com/JacobTech.com/GraphicsManager</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<Version>1.1.0-alpha50</Version>
|
<Version>1.1.0-alpha98</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
@ -13,8 +13,16 @@ public interface IParent
|
|||||||
public Vector2i Size { get; }
|
public Vector2i Size { get; }
|
||||||
public void ParentResize();
|
public void ParentResize();
|
||||||
public float IntToWindow(float p, bool Y = false);
|
public float IntToWindow(float p, bool Y = false);
|
||||||
public void TryDraw();
|
public void TryDraw(int depth = 0);
|
||||||
public void ReportSizeUpdate(IRenderObject Control);
|
public void ReportSizeUpdate(IRenderObject Control);
|
||||||
public Vector3i Position { get; }
|
public Vector3i Position { get; }
|
||||||
public MouseCursor HoverMouse { get; set; }
|
public MouseCursor HoverMouse { get; set; }
|
||||||
|
public int LastX { get; }
|
||||||
|
public int LastY { get; }
|
||||||
|
public int LastSX { get; }
|
||||||
|
public int LastSY { get; }
|
||||||
|
public int LastSW { get; }
|
||||||
|
public int LastSH { get; }
|
||||||
|
public bool BlockDraw { get; set; }
|
||||||
|
public bool IgnoreVisForChildren { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ public interface IRenderObject
|
|||||||
public ObjectAnchor Anchor { get; set; }
|
public ObjectAnchor Anchor { get; set; }
|
||||||
public bool MouseInside { get; set; }
|
public bool MouseInside { get; set; }
|
||||||
public bool IgnoreHover { get; set; }
|
public bool IgnoreHover { get; set; }
|
||||||
|
public bool BlockDraw { get; set; }
|
||||||
|
public bool IsVisible { get; }
|
||||||
|
public void NotifiNotVisible();
|
||||||
public bool AllowHoverFromBehind { get; set; }
|
public bool AllowHoverFromBehind { get; set; }
|
||||||
public bool Loaded { get; }
|
public bool Loaded { get; }
|
||||||
public void LoadToParent(IParent Parent, IWindow Window);
|
public void LoadToParent(IParent Parent, IWindow Window);
|
||||||
@ -28,6 +31,7 @@ public interface IRenderObject
|
|||||||
public void Clean();
|
public void Clean();
|
||||||
public void Focus();
|
public void Focus();
|
||||||
public void UnFocus();
|
public void UnFocus();
|
||||||
|
public void TryDraw(int depth = 0);
|
||||||
public void SendKeyEvent(KeyboardKeyEventArgs KeyArgs);
|
public void SendKeyEvent(KeyboardKeyEventArgs KeyArgs);
|
||||||
public void SendClipEvent(string Text);
|
public void SendClipEvent(string Text);
|
||||||
public void SendFilesEvent(string[] Files);
|
public void SendFilesEvent(string[] Files);
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
|
|
||||||
namespace GraphicsManager.Interfaces;
|
namespace GraphicsManager.Interfaces;
|
||||||
|
@ -13,11 +13,17 @@ public interface IWindow : IParent
|
|||||||
public Matrix4 WindowSizeMatrix { get; }
|
public Matrix4 WindowSizeMatrix { get; }
|
||||||
public Vector2i CS { get; }
|
public Vector2i CS { get; }
|
||||||
|
|
||||||
|
public void CheckParent(IParent p, IRenderObject c, int xx, Vector3i di);
|
||||||
|
public void CheckParent(IParent p);
|
||||||
|
|
||||||
public event Action<MouseButtonEventArgs> MouseDown;
|
public event Action<MouseButtonEventArgs> MouseDown;
|
||||||
|
|
||||||
public event Action<FileDropEventArgs> FileDrop;
|
public event Action<FileDropEventArgs> FileDrop;
|
||||||
|
|
||||||
public event Action<MouseWheelEventArgs> MouseWheel;
|
public event Action<MouseWheelEventArgs> MouseWheel;
|
||||||
|
public event Action<MouseButtonEventArgs> MouseUp;
|
||||||
|
|
||||||
|
public event Action<MouseMoveEventArgs> MouseMove;
|
||||||
|
|
||||||
public event Action<KeyboardKeyEventArgs> KeyDown;
|
public event Action<KeyboardKeyEventArgs> KeyDown;
|
||||||
|
|
||||||
@ -37,4 +43,8 @@ public interface IWindow : IParent
|
|||||||
void Invoke(Action A);
|
void Invoke(Action A);
|
||||||
|
|
||||||
bool InvokeRequired { get; }
|
bool InvokeRequired { get; }
|
||||||
|
|
||||||
|
public bool LogFrames { get; set; }
|
||||||
|
public int SubFrameCount { get; }
|
||||||
|
public int Frame { get; }
|
||||||
}
|
}
|
@ -265,10 +265,7 @@ public class LabelBase : ILabel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Window.Context.IsCurrent)
|
TryDraw();
|
||||||
{
|
|
||||||
Parent!.TryDraw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,6 +402,20 @@ public class LabelBase : ILabel
|
|||||||
|
|
||||||
public event Func<IRenderObject, Task>? SizeChanged;
|
public event Func<IRenderObject, Task>? SizeChanged;
|
||||||
|
|
||||||
|
public void TryDraw(int depth = 0)
|
||||||
|
{
|
||||||
|
if (Parent is not null) Parent.TryDraw(depth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BlockDraw { get; set; }
|
||||||
|
|
||||||
|
public bool IsVisible { get; private set; } = false;
|
||||||
|
|
||||||
|
public virtual void NotifiNotVisible()
|
||||||
|
{
|
||||||
|
IsVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
public virtual void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
||||||
{
|
{
|
||||||
if (Visible && Loaded && this.Font is not null)
|
if (Visible && Loaded && this.Font is not null)
|
||||||
|
@ -14,16 +14,15 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ControlList Controls { get; } = new();
|
public ControlList Controls { get; } = new();
|
||||||
|
public int LastX { get; private set; }
|
||||||
public bool BlockDraw { get; set; }
|
public int LastY { get; private set; }
|
||||||
|
public int LastSX { get; private set; }
|
||||||
|
public int LastSY { get; private set; }
|
||||||
|
public int LastSW { get; private set; }
|
||||||
|
public int LastSH { get; private set; }
|
||||||
|
|
||||||
public Vector3i Position => Location;
|
public Vector3i Position => Location;
|
||||||
|
|
||||||
public void TryDraw()
|
|
||||||
{
|
|
||||||
if (!BlockDraw && Parent is not null) Parent.TryDraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ParentResize()
|
public virtual void ParentResize()
|
||||||
{
|
{
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
@ -36,10 +35,32 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||||
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
||||||
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
||||||
int lx = (left ? Controls[i].Location.X : Size.X - Controls[i].Distance.X - Controls[i].Size.X);
|
|
||||||
int ly = (top ? Controls[i].Location.Y : Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
int lx, ly, sy, sx;
|
||||||
int sy = (bottom ? Size.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
bool UpdateDistance = false;
|
||||||
int sx = (right ? Size.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
if ((Controls[i].Anchor & ObjectAnchor.PreventWidthChange) == ObjectAnchor.PreventWidthChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
lx = Controls[i].Location.X + ((Size.X - Controls[i].Distance.X - Controls[i].Size.X - Controls[i].Location.X) / 2);
|
||||||
|
sx = Controls[i].Size.X;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lx = (left ? Controls[i].Location.X : Size.X - Controls[i].Distance.X - Controls[i].Size.X);
|
||||||
|
sx = (right ? Size.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
||||||
|
}
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventHeightChange) == ObjectAnchor.PreventHeightChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
ly = Controls[i].Location.Y + ((Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y - Controls[i].Location.Y) / 2);
|
||||||
|
sy = Controls[i].Size.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ly = (top ? Controls[i].Location.Y : Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
||||||
|
sy = (bottom ? Size.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
||||||
|
}
|
||||||
|
|
||||||
bool mooved = false;
|
bool mooved = false;
|
||||||
if (sx != Controls[i].Size.X || sy != Controls[i].Size.Y)
|
if (sx != Controls[i].Size.X || sy != Controls[i].Size.Y)
|
||||||
{
|
{
|
||||||
@ -51,6 +72,10 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
mooved = true;
|
mooved = true;
|
||||||
Controls[i].SetLocation(lx, ly);
|
Controls[i].SetLocation(lx, ly);
|
||||||
}
|
}
|
||||||
|
if (UpdateDistance)
|
||||||
|
{
|
||||||
|
Controls[i].ForceDistanceUpdate(this);
|
||||||
|
}
|
||||||
if (mooved && Controls[i] is IParent parent)
|
if (mooved && Controls[i] is IParent parent)
|
||||||
{
|
{
|
||||||
parent.ParentResize();
|
parent.ParentResize();
|
||||||
@ -69,8 +94,11 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
{
|
{
|
||||||
if (Loaded && Visible && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
if (Loaded && Visible && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
||||||
{
|
{
|
||||||
if (Location.X - sx + x > sw || Location.Y - sy + y > sh)
|
if (Location.X - sx + x > sw || Location.Y - sy + y > sh)
|
||||||
|
{
|
||||||
|
NotifiNotVisible();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Location.X - sx + x > -1)
|
if (Location.X - sx + x > -1)
|
||||||
{
|
{
|
||||||
@ -102,8 +130,18 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
x += Location.X;
|
x += Location.X;
|
||||||
y += Location.Y;
|
y += Location.Y;
|
||||||
|
|
||||||
if (sw <= 0 || sh <= 0) return;
|
if (sw <= 0 || sh <= 0)
|
||||||
|
{
|
||||||
|
NotifiNotVisible();
|
||||||
|
return;
|
||||||
|
}
|
||||||
base.Draw(x,y,sx,sy,sw,sh);
|
base.Draw(x,y,sx,sy,sw,sh);
|
||||||
|
LastX = x;
|
||||||
|
LastY = y;
|
||||||
|
LastSX = sx;
|
||||||
|
LastSY = sy;
|
||||||
|
LastSW = sw;
|
||||||
|
LastSH = sh;
|
||||||
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
||||||
|
|
||||||
if (needload.Any())
|
if (needload.Any())
|
||||||
@ -125,6 +163,18 @@ public abstract class ParentBase : Rectangle, IParent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IgnoreVisForChildren { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public override void NotifiNotVisible()
|
||||||
|
{
|
||||||
|
base.NotifiNotVisible();
|
||||||
|
for (int i = 0; i < Controls.Length; i++)
|
||||||
|
{
|
||||||
|
Controls[i].NotifiNotVisible();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Clean()
|
public override void Clean()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Controls.Length; i++)
|
for (int i = 0; i < Controls.Length; i++)
|
||||||
|
@ -10,6 +10,7 @@ public class Shader : IDisposable
|
|||||||
private readonly int VertexShader;
|
private readonly int VertexShader;
|
||||||
private readonly int FragmentShader;
|
private readonly int FragmentShader;
|
||||||
private bool disposedValue = false;
|
private bool disposedValue = false;
|
||||||
|
public bool CanBlend = false;
|
||||||
|
|
||||||
public Shader(string VertexShaderSource, string FragmentShaderSource, bool VertextBuiltIn = false, bool FragmentShaderBuiltIn = false, Assembly? Assembly = null)
|
public Shader(string VertexShaderSource, string FragmentShaderSource, bool VertextBuiltIn = false, bool FragmentShaderBuiltIn = false, Assembly? Assembly = null)
|
||||||
{
|
{
|
||||||
|
@ -200,6 +200,11 @@ public class FlowLayout : ParentBase, IFlow
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ParentResize()
|
||||||
|
{
|
||||||
|
//Child objects dont need to be updated
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetSize(int w, int h)
|
public override void SetSize(int w, int h)
|
||||||
{
|
{
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
using System.Numerics;
|
||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace GraphicsManager.Objects;
|
namespace GraphicsManager.Objects;
|
||||||
|
|
||||||
public class ProgressBar : ParentBase
|
public class ProgressBar<TNumber> : ParentBase where TNumber : INumber<TNumber>
|
||||||
{
|
{
|
||||||
private Rectangle ProgresRct;
|
private Rectangle ProgresRct;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public class ProgressBar : ParentBase
|
|||||||
{
|
{
|
||||||
ProgresRct = new()
|
ProgresRct = new()
|
||||||
{
|
{
|
||||||
Location = new((int)gap, (int)gap, 0),
|
Location = new(DrawingGap.X, DrawingGap.Y, 0),
|
||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
BackgroundColor = Color4.Green,
|
BackgroundColor = Color4.Green,
|
||||||
Anchor = ObjectAnchor.All
|
Anchor = ObjectAnchor.All
|
||||||
@ -39,7 +40,7 @@ public class ProgressBar : ParentBase
|
|||||||
{
|
{
|
||||||
ProgresRct = new(Progress)
|
ProgresRct = new(Progress)
|
||||||
{
|
{
|
||||||
Location = new((int)gap, (int)gap, 0),
|
Location = new(DrawingGap.X, DrawingGap.Y, 0),
|
||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
BackgroundColor = Color4.Green,
|
BackgroundColor = Color4.Green,
|
||||||
TextureDisplay = TextureDisplay.ProgressHorizontalCenter,
|
TextureDisplay = TextureDisplay.ProgressHorizontalCenter,
|
||||||
@ -54,7 +55,7 @@ public class ProgressBar : ParentBase
|
|||||||
{
|
{
|
||||||
ProgresRct = new(Background)
|
ProgresRct = new(Background)
|
||||||
{
|
{
|
||||||
Location = new((int)gap, (int)gap, 0),
|
Location = new(DrawingGap.X, DrawingGap.Y, 0),
|
||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
BackgroundColor = Color4.Green,
|
BackgroundColor = Color4.Green,
|
||||||
TextureDisplay = TextureDisplay.ProgressHorizontalCenter,
|
TextureDisplay = TextureDisplay.ProgressHorizontalCenter,
|
||||||
@ -103,10 +104,11 @@ public class ProgressBar : ParentBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong mpv = 100, pv = 0;
|
private TNumber mpv = TNumber.One, pv = TNumber.Zero;
|
||||||
private uint gap = 5;
|
public Vector2i ProgressGap = new(0);
|
||||||
|
public Vector4i DrawingGap = new(0);
|
||||||
|
|
||||||
public ulong MaxProgressValue
|
public TNumber MaxProgressValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -119,7 +121,9 @@ public class ProgressBar : ParentBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong ProgressValue
|
public bool DisallowAboveMax { get; set; } = true;
|
||||||
|
|
||||||
|
public TNumber ProgressValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -127,40 +131,64 @@ public class ProgressBar : ParentBase
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value > MaxProgressValue) pv = MaxProgressValue;
|
if (DisallowAboveMax && value > MaxProgressValue) pv = MaxProgressValue;
|
||||||
else pv = value;
|
else pv = value;
|
||||||
if (!UpdateOnDraw) UpdateProgress();
|
if (!UpdateOnDraw) UpdateProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint ProgressGap
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return gap;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
gap = value;
|
|
||||||
if (!UpdateOnDraw) UpdateProgress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
public override void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
||||||
{
|
{
|
||||||
if (UpdateOnDraw) UpdateProgress();
|
if (UpdateOnDraw) UpdateProgress();
|
||||||
base.Draw(x, y, sx,sy, sw, sh);
|
base.Draw(x, y, sx,sy, sw, sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TNumber GetValueFromX(int x)
|
||||||
|
{
|
||||||
|
if (x <= ProgressGap.X + DrawingGap.X) return TNumber.Zero;
|
||||||
|
if (x >= Size.X - ProgressGap.Y - DrawingGap.Z) return MaxProgressValue;
|
||||||
|
x -= DrawingGap.X;
|
||||||
|
x -= ProgressGap.X;
|
||||||
|
double max_x = Size.X - ProgressGap.X - ProgressGap.Y - DrawingGap.X - DrawingGap.Z;
|
||||||
|
double v = (x / max_x) * Convert.ToDouble(MaxProgressValue);
|
||||||
|
Type tt = typeof(TNumber);
|
||||||
|
if (tt == typeof(byte) || tt == typeof(sbyte) ||
|
||||||
|
tt == typeof(ushort) || tt == typeof(short) ||
|
||||||
|
tt == typeof(uint) || tt == typeof(int) ||
|
||||||
|
tt == typeof(ulong) || tt == typeof(long))
|
||||||
|
{
|
||||||
|
return TNumber.CreateTruncating(Math.Round(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TNumber.CreateTruncating(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetInternalocation(TNumber Value, bool IgnoreStart = false, bool IgnoreEnd = false)
|
||||||
|
{
|
||||||
|
int x = ProgressGap.X;
|
||||||
|
int xx = 0;
|
||||||
|
if (IgnoreStart) x = 0;
|
||||||
|
if (IgnoreEnd) xx = ProgressGap.Y;
|
||||||
|
if (Value <= TNumber.Zero) return DrawingGap.X + x;
|
||||||
|
if (Value >= MaxProgressValue) return Size.X - DrawingGap.X - DrawingGap.Z - xx;
|
||||||
|
double percent = Convert.ToDouble(Value) / Convert.ToDouble(MaxProgressValue);
|
||||||
|
int MaxPixels = Size.X - DrawingGap.X - DrawingGap.Z - x - ProgressGap.Y;
|
||||||
|
return (int)(MaxPixels * percent) + ProgressGap.X;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetParentLocation(TNumber Value, bool IgnoreStart = false, bool IgnoreEnd = false)
|
||||||
|
{
|
||||||
|
return GetInternalocation(Value, IgnoreStart, IgnoreEnd) + DrawingGap.X;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateProgress()
|
public void UpdateProgress()
|
||||||
{
|
{
|
||||||
double percent = (double)ProgressValue / MaxProgressValue;
|
var x = GetInternalocation(ProgressValue);
|
||||||
long MaxPixels = Size.X - gap - gap;
|
if (ProgresRct.Location.X != DrawingGap.X || ProgresRct.Location.Y != DrawingGap.Y)
|
||||||
if (ProgresRct.Location.X != gap)
|
|
||||||
{
|
{
|
||||||
ProgresRct.Location = new((int)gap, (int)gap, 0);
|
ProgresRct.Location = new(DrawingGap.X, DrawingGap.Y, 0);
|
||||||
ProgresRct.Size = new((int)(MaxPixels * percent), (int)(Size.Y - gap - gap));
|
ProgresRct.Size = new(x, Size.Y - DrawingGap.Y - DrawingGap.W);
|
||||||
}
|
}
|
||||||
else ProgresRct.Size = new((int)(MaxPixels * percent), ProgresRct.Size.Y);
|
else ProgresRct.Size = new(x, ProgresRct.Size.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Enums;
|
|
||||||
using GraphicsManager.Globals;
|
using GraphicsManager.Globals;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Platform.Windows;
|
|
||||||
using OpenTK.Windowing.Common;
|
using OpenTK.Windowing.Common;
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
using OpenTK.Windowing.Desktop;
|
using OpenTK.Windowing.Desktop;
|
||||||
@ -52,12 +50,9 @@ public class Rectangle : ITextureObject
|
|||||||
public List<Texture> Textures { get; set; } = new();
|
public List<Texture> Textures { get; set; } = new();
|
||||||
public BetterContextMenu? ContextMenu { get; set; } = null;
|
public BetterContextMenu? ContextMenu { get; set; } = null;
|
||||||
|
|
||||||
public Rectangle(Texture? texture)
|
public Rectangle(Texture? texture = null)
|
||||||
{
|
|
||||||
if (texture is not null) Textures.Add(texture);;
|
|
||||||
}
|
|
||||||
public Rectangle()
|
|
||||||
{
|
{
|
||||||
|
if (texture is not null) Textures.Add(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Focus()
|
public virtual void Focus()
|
||||||
@ -77,7 +72,7 @@ public class Rectangle : ITextureObject
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_BackgroundColor = value;
|
_BackgroundColor = value;
|
||||||
if (Parent is not null) Parent.TryDraw();
|
TryDraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +83,11 @@ public class Rectangle : ITextureObject
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_Visible = value;
|
_Visible = value;
|
||||||
if (Parent is not null) Parent.TryDraw();
|
if (value) TryDraw();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Parent is not null) Parent.TryDraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +105,7 @@ public class Rectangle : ITextureObject
|
|||||||
{
|
{
|
||||||
if (Visible && Loaded && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
if (Visible && Loaded && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
||||||
{
|
{
|
||||||
|
IsVisible = true;
|
||||||
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
|
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
|
||||||
foreach (Texture tex in Textures)
|
foreach (Texture tex in Textures)
|
||||||
{
|
{
|
||||||
@ -264,7 +264,7 @@ public class Rectangle : ITextureObject
|
|||||||
GL.DeleteVertexArray(ArrayObject);
|
GL.DeleteVertexArray(ArrayObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shader Shader { get; set; } = null;
|
public Shader Shader { get; set; } = null!;
|
||||||
public int ElementBufferObject { get; private set; }
|
public int ElementBufferObject { get; private set; }
|
||||||
public int BufferObject { get; private set; }
|
public int BufferObject { get; private set; }
|
||||||
public bool IgnoreHover { get; set; }
|
public bool IgnoreHover { get; set; }
|
||||||
@ -310,6 +310,76 @@ public class Rectangle : ITextureObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool iv;
|
||||||
|
|
||||||
|
public bool IsVisible
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return iv && Visible;
|
||||||
|
}
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
iv = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void NotifiNotVisible()
|
||||||
|
{
|
||||||
|
IsVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool bd = false;
|
||||||
|
|
||||||
|
public bool BlockDraw
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Parent is not null) return Parent.BlockDraw || bd;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bd = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BlendOverride;
|
||||||
|
|
||||||
|
public void TryDraw(int deapth = 0)
|
||||||
|
{
|
||||||
|
if (BlockDraw) return;
|
||||||
|
if (Parent is null) return;
|
||||||
|
if (!IsVisible) return;
|
||||||
|
if (Window is null) return;
|
||||||
|
if (BackgroundColor.A < 0.98 || !(BlendOverride || !Shader.CanBlend))
|
||||||
|
{
|
||||||
|
Parent.TryDraw(deapth+1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action a;
|
||||||
|
int sf = Window.SubFrameCount;
|
||||||
|
if (sf == 100) a = () =>
|
||||||
|
{
|
||||||
|
Window.TryDraw();
|
||||||
|
};
|
||||||
|
else a = () =>
|
||||||
|
{
|
||||||
|
if (Window.LogFrames) Console.WriteLine("Drawing Sub Frame: " + Window.Frame + "." + sf + " at depth of " + deapth);
|
||||||
|
Window.Context.MakeCurrent();
|
||||||
|
GL.Scissor(Parent.LastSX, Window!.CS.Y - Parent.LastSY - Parent.LastSH, Parent.LastSW, Parent.LastSH);
|
||||||
|
Draw(Parent.LastX, Parent.LastY, Parent.LastSX, Parent.LastSY, Parent.LastSW, Parent.LastSH);
|
||||||
|
Window.Context.SwapBuffers();
|
||||||
|
Draw(Parent.LastX, Parent.LastY, Parent.LastSX, Parent.LastSY, Parent.LastSW, Parent.LastSH);
|
||||||
|
Window.CheckParent(Window);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Window.InvokeRequired) Window.Invoke(a);
|
||||||
|
else a.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public event Func<IRenderObject, Task>? SizeChanged;
|
public event Func<IRenderObject, Task>? SizeChanged;
|
||||||
|
|
||||||
public ushort[] Indexs { get; set; } = new ushort[6] { 0, 1, 3, 1, 2, 3 };
|
public ushort[] Indexs { get; set; } = new ushort[6] { 0, 1, 3, 1, 2, 3 };
|
||||||
@ -384,7 +454,7 @@ public class Rectangle : ITextureObject
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TextureDisplay.Center:
|
case TextureDisplay.Center:
|
||||||
per = (float)Textures[0].RawSize!.Value.X / 3;;
|
per = (float)Textures[0].RawSize!.Value.X / 3;
|
||||||
diff = 0;
|
diff = 0;
|
||||||
if (Window is not null)
|
if (Window is not null)
|
||||||
{
|
{
|
||||||
|
@ -55,12 +55,12 @@ public class Window : NativeWindow , IWindow
|
|||||||
{
|
{
|
||||||
TextureManager = TextureManager.GetTextureManager(Context, this);
|
TextureManager = TextureManager.GetTextureManager(Context, this);
|
||||||
Context.MakeCurrent();
|
Context.MakeCurrent();
|
||||||
if (!Texture.TextureShader.ContainsKey(Context)) Texture.TextureShader.Add(Context, new("RectangleTexture", true, Texture:true));
|
if (!Texture.TextureShader.ContainsKey(Context)) Texture.TextureShader.Add(Context, new("RectangleTexture", true, Texture:true){CanBlend = true});
|
||||||
if (!Rectangle.DefaultShader.ContainsKey(Context)) Rectangle.DefaultShader.Add(Context, new("Rectangle", true));
|
if (!Rectangle.DefaultShader.ContainsKey(Context)) Rectangle.DefaultShader.Add(Context, new("Rectangle", true));
|
||||||
if (!Rectangle.DefaultAlphaShader.ContainsKey(Context)) Rectangle.DefaultAlphaShader.Add(Context, new("AlphaChannel", true, Texture:true));
|
if (!Rectangle.DefaultAlphaShader.ContainsKey(Context)) Rectangle.DefaultAlphaShader.Add(Context, new("AlphaChannel", true, Texture:true){CanBlend = true});
|
||||||
if (!Rectangle.DefaultAlphaTextureShader.ContainsKey(Context))
|
if (!Rectangle.DefaultAlphaTextureShader.ContainsKey(Context))
|
||||||
{
|
{
|
||||||
Rectangle.DefaultAlphaTextureShader.Add(Context, new("AlphaChannelTexture", true, Texture:true));
|
Rectangle.DefaultAlphaTextureShader.Add(Context, new("AlphaChannelTexture", true, Texture:true){CanBlend = true});
|
||||||
Rectangle.DefaultAlphaTextureShader[Context].Use();
|
Rectangle.DefaultAlphaTextureShader[Context].Use();
|
||||||
Rectangle.DefaultAlphaTextureShader[Context].SetInt("bob", 0);
|
Rectangle.DefaultAlphaTextureShader[Context].SetInt("bob", 0);
|
||||||
Rectangle.DefaultAlphaTextureShader[Context].SetInt("smith", 1);
|
Rectangle.DefaultAlphaTextureShader[Context].SetInt("smith", 1);
|
||||||
@ -68,7 +68,7 @@ public class Window : NativeWindow , IWindow
|
|||||||
|
|
||||||
if (!Label.DefaultTextShader.ContainsKey(Context))
|
if (!Label.DefaultTextShader.ContainsKey(Context))
|
||||||
{
|
{
|
||||||
Label.DefaultTextShader.Add(Context, new("Label", true));
|
Label.DefaultTextShader.Add(Context, new("Label", true){CanBlend = true});
|
||||||
Label.DefaultTextShader[Context].Use();
|
Label.DefaultTextShader[Context].Use();
|
||||||
Label.DefaultTextShader[Context].SetInt("u_texture", Label.DefaultTextShader[Context].GetUniformLocation("u_texture"));
|
Label.DefaultTextShader[Context].SetInt("u_texture", Label.DefaultTextShader[Context].GetUniformLocation("u_texture"));
|
||||||
}
|
}
|
||||||
@ -82,11 +82,6 @@ public class Window : NativeWindow , IWindow
|
|||||||
GL.Enable(EnableCap.ScissorTest);
|
GL.Enable(EnableCap.ScissorTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFileDrop(FileDropEventArgs obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTextInputEvent(TextInputEventArgs obj)
|
private void OnTextInputEvent(TextInputEventArgs obj)
|
||||||
{
|
{
|
||||||
if (focused is not null)
|
if (focused is not null)
|
||||||
@ -169,12 +164,38 @@ public class Window : NativeWindow , IWindow
|
|||||||
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||||
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
||||||
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
||||||
int lx = (left ? Controls[i].Location.X : CS.X - Controls[i].Distance.X - Controls[i].Size.X);
|
|
||||||
int ly = (top ? Controls[i].Location.Y : CS.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
int lx, ly, sy, sx;
|
||||||
int sy = (bottom ? CS.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
bool UpdateDistance = false;
|
||||||
int sx = (right ? CS.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
if ((Controls[i].Anchor & ObjectAnchor.PreventWidthChange) == ObjectAnchor.PreventWidthChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
lx = Controls[i].Location.X + ((CS.X - Controls[i].Distance.X - Controls[i].Size.X - Controls[i].Location.X) / 2);
|
||||||
|
sx = Controls[i].Size.X;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lx = (left ? Controls[i].Location.X : CS.X - Controls[i].Distance.X - Controls[i].Size.X);
|
||||||
|
sx = (right ? CS.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
||||||
|
}
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventHeightChange) == ObjectAnchor.PreventHeightChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
ly = Controls[i].Location.Y + ((CS.Y - Controls[i].Distance.Y - Controls[i].Size.Y - Controls[i].Location.Y) / 2);
|
||||||
|
sy = Controls[i].Size.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ly = (top ? Controls[i].Location.Y : CS.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
||||||
|
sy = (bottom ? CS.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
||||||
|
}
|
||||||
|
|
||||||
Controls[i].SetSize(sx, sy);
|
Controls[i].SetSize(sx, sy);
|
||||||
Controls[i].SetLocation(lx, ly);
|
Controls[i].SetLocation(lx, ly);
|
||||||
|
if (UpdateDistance)
|
||||||
|
{
|
||||||
|
Controls[i].ForceDistanceUpdate(this);
|
||||||
|
}
|
||||||
if (Controls[i] is IParent parent)
|
if (Controls[i] is IParent parent)
|
||||||
{
|
{
|
||||||
parent.ParentResize();
|
parent.ParentResize();
|
||||||
@ -191,7 +212,7 @@ public class Window : NativeWindow , IWindow
|
|||||||
ForceUpdate();
|
ForceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int frame = 0;
|
public int Frame { get; protected set; } = 0;
|
||||||
|
|
||||||
public void ReportSizeUpdate(IRenderObject Control)
|
public void ReportSizeUpdate(IRenderObject Control)
|
||||||
{
|
{
|
||||||
@ -388,8 +409,28 @@ public class Window : NativeWindow , IWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool BlockDraw { get; set; }
|
public bool BlockDraw { get; set; }
|
||||||
|
public int LastX { get; } = 0;
|
||||||
|
public int LastY { get; } = 0;
|
||||||
|
public int LastSX { get; } = 0;
|
||||||
|
public int LastSY { get; } = 0;
|
||||||
|
public int LastSW { get; set; } = 0;
|
||||||
|
public int LastSH { get; set; } = 0;
|
||||||
|
|
||||||
public void TryDraw()
|
public int SubFrameCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
sf++;
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
protected set
|
||||||
|
{
|
||||||
|
sf = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int sf = 0;
|
||||||
|
public void TryDraw(int depth = 0)
|
||||||
{
|
{
|
||||||
if (!BlockDraw) DrawFrame();
|
if (!BlockDraw) DrawFrame();
|
||||||
}
|
}
|
||||||
@ -411,14 +452,8 @@ public class Window : NativeWindow , IWindow
|
|||||||
invokes.Enqueue(A);
|
invokes.Enqueue(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DrawFrame()
|
public virtual void LoadControls()
|
||||||
{
|
{
|
||||||
Context.MakeCurrent();
|
|
||||||
frame++;
|
|
||||||
if (LogFrames) Console.WriteLine($"Drawing Frame: {frame}");
|
|
||||||
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
|
|
||||||
GL.BlendFunc(0, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
|
|
||||||
GL.ClearColor(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
|
|
||||||
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
||||||
|
|
||||||
if (needload.Any())
|
if (needload.Any())
|
||||||
@ -430,6 +465,15 @@ public class Window : NativeWindow , IWindow
|
|||||||
}
|
}
|
||||||
BlockDraw = false;
|
BlockDraw = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DrawNewFrameToBackBuffer()
|
||||||
|
{
|
||||||
|
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
|
||||||
|
GL.BlendFunc(0, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
|
||||||
|
GL.ClearColor(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
|
||||||
|
LastSW = CS.X;
|
||||||
|
LastSH = CS.Y;
|
||||||
GL.Scissor(0,0,CS.X, CS.Y);
|
GL.Scissor(0,0,CS.X, CS.Y);
|
||||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||||
for (int i = 0; i < Controls.Length; i++)
|
for (int i = 0; i < Controls.Length; i++)
|
||||||
@ -438,6 +482,46 @@ public class Window : NativeWindow , IWindow
|
|||||||
GL.Scissor(0, 0, CS.X, CS.Y);
|
GL.Scissor(0, 0, CS.X, CS.Y);
|
||||||
Controls[i].Draw(0,0,0,0,CS.X, CS.Y);
|
Controls[i].Draw(0,0,0,0,CS.X, CS.Y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IgnoreVisForChildren { get; set; }
|
||||||
|
public const float alpha = 254f / byte.MaxValue;
|
||||||
|
|
||||||
|
public virtual void CheckParent(IParent p, IRenderObject c, int xx, Vector3i di)
|
||||||
|
{
|
||||||
|
if (p.IgnoreVisForChildren || p.Controls.Length <= 1 || xx >= p.Controls.Length || !c.Visible || c is ILabel || (c is Rectangle r && r.BackgroundColor.A <= alpha)) return;
|
||||||
|
for (int i = xx; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (!p.Controls[i].IsVisible ||
|
||||||
|
((p.Controls[i].Location.X + di.X >= c.Location.X && p.Controls[i].Location.X + p.Controls[i].Size.X + di.X - c.Size.X <= c.Location.X) &&
|
||||||
|
(p.Controls[i].Location.Y + di.Y >= c.Location.Y && p.Controls[i].Location.Y + p.Controls[i].Size.Y + di.X - c.Size.Y <= c.Location.Y)))
|
||||||
|
{
|
||||||
|
p.Controls[i].NotifiNotVisible();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p.Controls[i] is IParent pp) CheckParent(pp, c, pp.Controls.Length-1, di + p.Controls[i].Location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void CheckParent(IParent p)
|
||||||
|
{
|
||||||
|
for (int i = p.Controls.Length - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
CheckParent(p, p.Controls[i], i-1, new());
|
||||||
|
if (p.Controls[i] is IParent pp) CheckParent(pp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DrawFrame()
|
||||||
|
{
|
||||||
|
Context.MakeCurrent();
|
||||||
|
Frame++;
|
||||||
|
if (LogFrames) Console.WriteLine($"Drawing Frame: {Frame}");
|
||||||
|
SubFrameCount = 0;
|
||||||
|
LoadControls();
|
||||||
|
DrawNewFrameToBackBuffer();
|
||||||
Context.SwapBuffers();
|
Context.SwapBuffers();
|
||||||
|
DrawNewFrameToBackBuffer();
|
||||||
|
CheckParent(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user