Combined
This commit is contained in:
parent
276a54026c
commit
6571972d96
@ -29,7 +29,7 @@ public class FPSWindow : GameWindow , IWindow
|
||||
}
|
||||
}
|
||||
|
||||
public IRenderObject? focused { get; set; }
|
||||
public RenderObjectCore? focused { get; set; }
|
||||
|
||||
public bool LogFrames { get; set; } = true;
|
||||
public int SubFrameCount { get; set; }
|
||||
@ -329,14 +329,14 @@ public class FPSWindow : GameWindow , IWindow
|
||||
Controls[i].Location.X + Controls[i].Size.X < 0 ||
|
||||
Controls[i].Location.Y + Controls[i].Size.Y < 0) continue;
|
||||
|
||||
if (Controls[i] is IParent pp)
|
||||
if (Controls[i] is ParentBase p)
|
||||
{
|
||||
pp.ResizeDraw(0,0,0,0,CS.X, CS.Y);
|
||||
p.Draw(0, 0, 0, 0, CS.X, CS.Y);
|
||||
GL.Scissor(0, 0, CS.X, CS.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
Controls[i].Draw(0,0,0,0,CS.X, CS.Y);
|
||||
Controls[i].DrawSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ public class FPSWindow : GameWindow , IWindow
|
||||
public bool UseLiveView { get; set; } = false;
|
||||
public bool CollectUpperFiles { get; set; }
|
||||
|
||||
public void ReportSizeUpdate(IRenderObject Control)
|
||||
public void ReportSizeUpdate(RenderObjectCore Control)
|
||||
{
|
||||
|
||||
}
|
||||
@ -431,7 +431,7 @@ public class FPSWindow : GameWindow , IWindow
|
||||
public event Func<FPSWindow, Task>? WindowLoaded;
|
||||
public List<Window> Windows = new();
|
||||
|
||||
public IRenderObject? HoveringControl { get; set; }
|
||||
public RenderObjectCore? HoveringControl { get; set; }
|
||||
|
||||
private void WhenMouseMove(MouseMoveEventArgs obj)
|
||||
{
|
||||
@ -440,11 +440,11 @@ public class FPSWindow : GameWindow , IWindow
|
||||
|
||||
protected virtual void HoverCheck(MouseMoveEventArgs obj)
|
||||
{
|
||||
IRenderObject? cb = null;
|
||||
RenderObjectCore? cb = null;
|
||||
SubHitBox? cbhb = null;
|
||||
IRenderObject? checkcontrol(IRenderObject render, int add_x = 0, int addy = 0, IRenderObject? CurrentBest = null)
|
||||
RenderObjectCore? checkcontrol(RenderObjectCore render, int add_x = 0, int addy = 0, RenderObjectCore? CurrentBest = null)
|
||||
{
|
||||
void ClearHoverChain(IRenderObject ChainObject)
|
||||
void ClearHoverChain(RenderObjectCore ChainObject)
|
||||
{
|
||||
if (ChainObject is IParent parent)
|
||||
{
|
||||
@ -517,7 +517,7 @@ public class FPSWindow : GameWindow , IWindow
|
||||
|
||||
if (cb != HoveringControl)
|
||||
{
|
||||
IRenderObject? old = HoveringControl;
|
||||
RenderObjectCore? old = HoveringControl;
|
||||
HoveringControl = cb;
|
||||
if (cb is not null)
|
||||
{
|
||||
@ -554,9 +554,9 @@ public class FPSWindow : GameWindow , IWindow
|
||||
public bool IgnoreVisForChildren { get; set; }
|
||||
public const float alpha = 254f / byte.MaxValue;
|
||||
|
||||
public virtual void CheckParent(IParent p, IRenderObject c, int xx, Vector2i di)
|
||||
public virtual void CheckParent(IParent p, RenderObjectCore c, int xx, Vector2i 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;
|
||||
if (p.IgnoreVisForChildren || p.Controls.Length <= 1 || xx >= p.Controls.Length || !c.Visible || c is LabelBase || (c is Rectangle r && r.BackgroundColor.A <= alpha)) return;
|
||||
for (int i = xx; i > 0; i--)
|
||||
{
|
||||
if (!p.Controls[i].IsVisible ||
|
||||
@ -624,8 +624,15 @@ public class FPSWindow : GameWindow , IWindow
|
||||
Controls[i].Location.Y >= CS.Y ||
|
||||
Controls[i].Location.X + Controls[i].Size.X < 0 ||
|
||||
Controls[i].Location.Y + Controls[i].Size.Y < 0) continue;
|
||||
Controls[i].Draw(0,0,0,0,CS.X, CS.Y);
|
||||
if (Controls[i] is IParent) GL.Scissor(0, 0, CS.X, CS.Y);
|
||||
if (Controls[i] is ParentBase p)
|
||||
{
|
||||
p.Draw(0, 0, 0, 0, CS.X, CS.Y);
|
||||
GL.Scissor(0, 0, CS.X, CS.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
Controls[i].DrawSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<IncludeSymbols>False</IncludeSymbols>
|
||||
<RepositoryUrl>https://git.jacobtech.com/JacobTech.com/GraphicsManager</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Version>1.1.1-alpha36</Version>
|
||||
<Version>1.1.1-alpha42</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
|
@ -1,6 +0,0 @@
|
||||
namespace GraphicsManager.Interfaces;
|
||||
|
||||
public interface IFlow : IParent
|
||||
{
|
||||
void ForceScrollUpdate();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace GraphicsManager.Interfaces;
|
||||
|
||||
public interface ILabel : IRenderObject
|
||||
{
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ public interface IParent
|
||||
public void ParentResize();
|
||||
public float IntToWindow(float p, bool Y = false);
|
||||
public void TryDraw(int depth = 0);
|
||||
public void ReportSizeUpdate(IRenderObject Control);
|
||||
public void ReportSizeUpdate(RenderObjectCore Control);
|
||||
public Vector2i Position { get; }
|
||||
public MouseCursor HoverMouse { get; set; }
|
||||
public int LastX { get; }
|
||||
@ -23,11 +23,10 @@ public interface IParent
|
||||
public int LastSY { get; }
|
||||
public int LastSW { get; }
|
||||
public int LastSH { get; }
|
||||
public bool BlockDraw { get; set; }
|
||||
public bool BlockDraw { get; }
|
||||
public bool IgnoreVisForChildren { get; set; }
|
||||
public void ResizeDraw(int x, int y, int sx, int sy, int sw, int sh);
|
||||
public int OldWidth { get; }
|
||||
public int OldHeight { get; }
|
||||
|
||||
public bool CollectUpperFiles { get; set; }
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
|
||||
namespace GraphicsManager.Interfaces;
|
||||
|
||||
public interface IRenderObject
|
||||
{
|
||||
public void ForceDistanceUpdate();
|
||||
public void ForceDistanceUpdate(IParent parent);
|
||||
public BetterContextMenu? ContextMenu { get; set; }
|
||||
public ObjectAnchor Anchor { get; set; }
|
||||
|
||||
public Vector4i Margins { get; set; }
|
||||
public bool MouseInside { 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 Loaded { get; }
|
||||
public void LoadToParent(IParent Parent, IWindow Window);
|
||||
public void UpdateOpenGLCords(bool draw = false);
|
||||
public void Draw(int x, int y, int sx, int sy, int sw, int sh);
|
||||
public MouseCursor HoverMouse { get; set; }
|
||||
public void SetSize(int wh);
|
||||
public void SetSize(int w, int h);
|
||||
public void SetLocation(int xy);
|
||||
public void SetLocation(int x, int y);
|
||||
public void Clean();
|
||||
public void Focus();
|
||||
public void UnFocus();
|
||||
public void TryDraw(int depth = 0);
|
||||
public void SendKeyEvent(KeyboardKeyEventArgs KeyArgs);
|
||||
public void SendClipEvent(string Text);
|
||||
public void SendFilesEvent(string[] Files);
|
||||
public Vector2i Size { get; set; }
|
||||
public Vector2i Location { get; set; }
|
||||
public Vector2 SizeAsFloat { get; }
|
||||
public Vector2 LocationAsFloat { get; }
|
||||
public Vector2i Distance { get; set; }
|
||||
public IParent? Parent { get; }
|
||||
public IWindow? Window { get; }
|
||||
public bool Visible { get; set; }
|
||||
public object? Tag { get; set; }
|
||||
public List<SubHitBox> SubHitBoxes { get; }
|
||||
|
||||
public event Func<IRenderObject, Task>? Clicked;
|
||||
public event Func<IRenderObject, Task>? MouseLeave;
|
||||
public event Func<IRenderObject, string[], Task>? FilesDroped;
|
||||
public event Func<IRenderObject, Task>? MouseEnter;
|
||||
public event Func<IRenderObject, Task>? SizeChanged;
|
||||
public event Func<IRenderObject, Task>? WindowLoaded;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using GraphicsManager.Objects.Core;
|
||||
using GraphicsManager.Enums;
|
||||
|
||||
namespace GraphicsManager.Interfaces;
|
||||
|
||||
public interface ITextureObject : IRenderObject
|
||||
{
|
||||
public List<Texture> Textures { get; }
|
||||
|
||||
public TextureDisplay TextureDisplay { get; set; }
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
@ -6,7 +7,7 @@ namespace GraphicsManager.Interfaces;
|
||||
|
||||
public interface IWindow : IParent
|
||||
{
|
||||
public IRenderObject? HoveringControl { get; set; }
|
||||
public RenderObjectCore? HoveringControl { get; set; }
|
||||
public IGLFWGraphicsContext Context { get; }
|
||||
|
||||
public bool ShowMissingChar { get; }
|
||||
@ -18,7 +19,7 @@ public interface IWindow : IParent
|
||||
|
||||
public bool UseLiveView { get; set; }
|
||||
|
||||
public void CheckParent(IParent p, IRenderObject c, int xx, Vector2i di);
|
||||
public void CheckParent(IParent p, RenderObjectCore c, int xx, Vector2i di);
|
||||
public void CheckParent(IParent p);
|
||||
|
||||
public event Action<MouseButtonEventArgs> MouseDown;
|
||||
@ -35,7 +36,7 @@ public interface IWindow : IParent
|
||||
public event Action<TextInputEventArgs> TextInput;
|
||||
public Vector2i Location { get; set; }
|
||||
|
||||
public IRenderObject? focused { get; set; }
|
||||
public RenderObjectCore? focused { get; set; }
|
||||
|
||||
public string ClipboardString { get; set; }
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using GraphicsManager.Objects.Core.Fonts;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace GraphicsManager.Objects;
|
||||
|
||||
public class BetterContextMenu : UserControl
|
||||
{
|
||||
public Vector4i Margins
|
||||
public override Vector4i Margins
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -15,7 +16,7 @@ public class BetterContextMenu : UserControl
|
||||
set
|
||||
{
|
||||
mg = value;
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
fl.Location = new(mg.W, mg.X);
|
||||
if (AutoSizeWidth || AutoSizeHeight)
|
||||
{
|
||||
@ -55,7 +56,7 @@ public class BetterContextMenu : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
TryDraw();
|
||||
}
|
||||
}
|
||||
@ -127,7 +128,7 @@ public class BetterContextMenu : UserControl
|
||||
AddOption(r);
|
||||
}
|
||||
|
||||
public void AddLabel(ILabel label)
|
||||
public void AddLabel(LabelBase label)
|
||||
{
|
||||
AddOption(label);
|
||||
}
|
||||
@ -139,7 +140,7 @@ public class BetterContextMenu : UserControl
|
||||
return l;
|
||||
}
|
||||
|
||||
public void AddOption(IRenderObject obj)
|
||||
public void AddOption(RenderObjectCore obj)
|
||||
{
|
||||
int x = fl.Size.X, y = fl.Size.Y;
|
||||
if (AutoSizeWidth && obj.Size.X > fl.Size.X)
|
||||
|
@ -4,25 +4,25 @@ namespace GraphicsManager.Objects.Core;
|
||||
|
||||
public class ControlList
|
||||
{
|
||||
internal List<IRenderObject> _internal = new();
|
||||
internal List<RenderObjectCore> _internal = new();
|
||||
private bool Clearing = false;
|
||||
|
||||
public IRenderObject this[int Index] => _internal[Index];
|
||||
public IRenderObject this[uint Index] => _internal[(int)Index];
|
||||
public RenderObjectCore this[int Index] => _internal[Index];
|
||||
public RenderObjectCore this[uint Index] => _internal[(int)Index];
|
||||
|
||||
public IEnumerable<IRenderObject> Where(Func<IRenderObject, bool> func) => _internal.Where(func);
|
||||
public IEnumerable<RenderObjectCore> Where(Func<RenderObjectCore, bool> func) => _internal.Where(func);
|
||||
|
||||
public bool Contains(IRenderObject Control) => _internal.Contains(Control);
|
||||
public bool Contains(RenderObjectCore Control) => _internal.Contains(Control);
|
||||
|
||||
public int IndexOf(IRenderObject Control) => _internal.IndexOf(Control);
|
||||
public int IndexOf(RenderObjectCore Control) => _internal.IndexOf(Control);
|
||||
|
||||
public int Length => _internal.Count;
|
||||
|
||||
public event Func<int, IRenderObject, Task>? ControlAdded;
|
||||
public event Func<int, IRenderObject, Task>? ControlAfterAdded;
|
||||
public event Func<int, RenderObjectCore, Task>? ControlAdded;
|
||||
public event Func<int, RenderObjectCore, Task>? ControlAfterAdded;
|
||||
public event Func<Task>? ControlRemoved;
|
||||
|
||||
public void Remove(IRenderObject item, bool purge = true)
|
||||
public void Remove(RenderObjectCore item, bool purge = true, bool GCC = false)
|
||||
{
|
||||
_internal.Remove(item);
|
||||
if (purge)
|
||||
@ -30,31 +30,31 @@ public class ControlList
|
||||
item.Clean();
|
||||
item = null!;
|
||||
}
|
||||
GC.Collect();
|
||||
if (GCC) GC.Collect();
|
||||
if (ControlRemoved is not null && !Clearing) _ = ControlRemoved.Invoke();
|
||||
}
|
||||
|
||||
public void MoveControlToEnd(IRenderObject item)
|
||||
public void MoveControlToEnd(RenderObjectCore item)
|
||||
{
|
||||
_internal.Remove(item);
|
||||
_internal.Add(item);
|
||||
}
|
||||
|
||||
public void Add(IRenderObject item)
|
||||
public void Add(RenderObjectCore item)
|
||||
{
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(_internal.Count, item).Wait();
|
||||
_internal.Add(item);
|
||||
if (ControlAfterAdded is not null) ControlAfterAdded.Invoke(_internal.Count-1, item).Wait();
|
||||
}
|
||||
|
||||
public void Insert(int index, IRenderObject item)
|
||||
public void Insert(int index, RenderObjectCore item)
|
||||
{
|
||||
if (ControlAdded is not null) ControlAdded.Invoke(index, item).Wait();
|
||||
_internal.Insert(index, item);
|
||||
if (ControlAfterAdded is not null) ControlAfterAdded.Invoke(index, item).Wait();
|
||||
}
|
||||
|
||||
public void Clear(bool purge = true)
|
||||
public void Clear(bool purge = true, bool GCC = false)
|
||||
{
|
||||
Clearing = true;
|
||||
for (int i = 0; i< _internal.Count; i++)
|
||||
@ -66,7 +66,7 @@ public class ControlList
|
||||
}
|
||||
}
|
||||
_internal.Clear();
|
||||
GC.Collect();
|
||||
if (GCC) GC.Collect();
|
||||
Clearing = false;
|
||||
if (ControlRemoved is not null) _ = ControlRemoved.Invoke();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using SharpFont;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
namespace GraphicsManager.Objects.Core.Fonts;
|
||||
|
||||
public class Font
|
||||
{
|
@ -3,7 +3,7 @@ using System.IO.Compression;
|
||||
using GraphicsManager.Enums;
|
||||
using SixLabors.Fonts;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
namespace GraphicsManager.Objects.Core.Fonts;
|
||||
|
||||
public class FontFamily
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
using GraphicsManager.Enums;
|
||||
using SharpFont;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
namespace GraphicsManager.Objects.Core.Fonts;
|
||||
|
||||
public class FontInteraction
|
||||
{
|
@ -1,17 +1,16 @@
|
||||
using System.Text;
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core.Fonts;
|
||||
using GraphicsManager.Structs;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
|
||||
public class LabelBase : ILabel
|
||||
public class LabelBase : RenderObjectCore
|
||||
{
|
||||
public LabelBase(FontFamily fontFamily)
|
||||
{
|
||||
@ -22,14 +21,7 @@ public class LabelBase : ILabel
|
||||
{
|
||||
Font = interaction;
|
||||
}
|
||||
|
||||
public BetterContextMenu? ContextMenu { get; set; } = null;
|
||||
public IParent? Parent { get; protected set; }
|
||||
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
||||
protected Vector2 laf = new(), saf = new();
|
||||
|
||||
public Vector2 LocationAsFloat { get { return laf; } }
|
||||
public Vector2 SizeAsFloat { get { return saf; } }
|
||||
protected Vector2i? msize = null;
|
||||
public virtual Vector2i? MaxSize
|
||||
{
|
||||
@ -102,31 +94,12 @@ public class LabelBase : ILabel
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
}
|
||||
}
|
||||
protected bool _Visible = true;
|
||||
|
||||
public virtual bool Visible
|
||||
{
|
||||
get => _Visible;
|
||||
set
|
||||
{
|
||||
_Visible = value;
|
||||
if (Parent is not null && Loaded) Parent.TryDraw();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly Dictionary<IGLFWGraphicsContext, Dictionary<FontInteraction, Dictionary<uint, Character>>> _characters = new();
|
||||
protected string text = string.Empty;
|
||||
protected string text_Calculated = string.Empty;
|
||||
public int VAO { get; protected set; }
|
||||
|
||||
public virtual void Focus()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual void UnFocus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int VBO { get; protected set; }
|
||||
public virtual Vector2 DIR { get; set; } = new Vector2(1f, 0f);
|
||||
|
||||
@ -181,7 +154,6 @@ public class LabelBase : ILabel
|
||||
return new((int)mx, (int)my);
|
||||
}
|
||||
|
||||
public List<SubHitBox> SubHitBoxes { get; } = new();
|
||||
|
||||
public virtual string Text
|
||||
{
|
||||
@ -280,24 +252,6 @@ public class LabelBase : ILabel
|
||||
public Shader Shader { get; set; } = null!;
|
||||
public FontInteraction Font { get; protected set; }
|
||||
public virtual float Scale { get; set; } = 1.0f;
|
||||
public virtual Vector2i Distance { get; set; }
|
||||
protected Vector2i loc_;
|
||||
public virtual Vector2i Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return loc_;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetLocation(value.X, value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetLocation(int xy)
|
||||
{
|
||||
SetLocation(xy, xy);
|
||||
}
|
||||
|
||||
public virtual void SetLocation(int x, int y)
|
||||
{
|
||||
@ -311,30 +265,10 @@ public class LabelBase : ILabel
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateOpenGLCords(bool draw = false)
|
||||
public override void UpdateOpenGLCords(bool draw = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SetSize(int wh)
|
||||
{
|
||||
SetSize(wh, wh);
|
||||
}
|
||||
|
||||
public virtual void SetSize(int w, int h)
|
||||
{
|
||||
_size.X = w;
|
||||
_size.Y = h;
|
||||
}
|
||||
|
||||
protected Vector2i _size;
|
||||
public virtual Vector2i Size { get => _size;
|
||||
set
|
||||
{
|
||||
_size = value;
|
||||
//if (Loaded && Parent is not null) ScissorLocation = Parent.GetParentRelLocPoint() + new Vector2i(Location.X, Parent.Size.Y - (loc_.Y + Size.Y));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Vector2i GetCharLocation(int index)
|
||||
{
|
||||
@ -377,7 +311,7 @@ public class LabelBase : ILabel
|
||||
|
||||
}
|
||||
|
||||
public virtual void Clean()
|
||||
internal override void Clean()
|
||||
{
|
||||
Tuple<int, int, int> tup = GlobalBuffers[Window!.Context];
|
||||
if (tup.Item3 - 1 == 0)
|
||||
@ -399,25 +333,20 @@ public class LabelBase : ILabel
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
public Vector4i Margins { get; set; } = new();
|
||||
|
||||
public event Func<IRenderObject, Task>? SizeChanged;
|
||||
|
||||
public void TryDraw(int depth = 0)
|
||||
public override void TryDraw()
|
||||
{
|
||||
if (Parent is not null) Parent.TryDraw(depth + 1);
|
||||
if (Parent is not null) Parent.TryDraw(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 override void DrawSelf()
|
||||
{
|
||||
if (Visible && Loaded && this.Font is not null)
|
||||
{
|
||||
@ -494,27 +423,10 @@ public class LabelBase : ILabel
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void ForceDistanceUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public virtual void ForceDistanceUpdate(IParent parent)
|
||||
{
|
||||
if (parent is IWindow w) Distance = new(w.CS.X - Size.X - Location.X, w.CS.Y - Size.Y - Location.Y);
|
||||
else Distance = new(parent.Size.X - Size.X - Location.X, parent.Size.Y - Size.Y - Location.Y);
|
||||
}
|
||||
public IWindow? Window { get; protected set; }
|
||||
protected static Dictionary<IGLFWGraphicsContext, Tuple<int, int, int>> GlobalBuffers = new();
|
||||
public bool IgnoreHover { get; set; }
|
||||
public bool AllowHoverFromBehind { get; set; }
|
||||
public event Func<IRenderObject, string[], Task>? FilesDroped;
|
||||
|
||||
public void SendFilesEvent(string[] Files)
|
||||
{
|
||||
if (FilesDroped is not null) _ = FilesDroped.Invoke(this, Files);
|
||||
}
|
||||
public virtual void LoadToParent(IParent window, IWindow win)
|
||||
|
||||
internal override void LoadToParent(IParent window, IWindow win)
|
||||
{
|
||||
if (Loaded) return;
|
||||
if (!_characters.ContainsKey(win!.Context)) _characters.Add(win!.Context, new());
|
||||
@ -562,7 +474,7 @@ public class LabelBase : ILabel
|
||||
Text = Text;
|
||||
Location = Location;
|
||||
if (Distance.X == 0 && Distance.Y == 0) ForceDistanceUpdate(Parent);
|
||||
if (WindowLoaded is not null) WindowLoaded.Invoke(this);
|
||||
CallWindowLoaded();
|
||||
}
|
||||
|
||||
private void WindowOnMouseDown(MouseButtonEventArgs obj)
|
||||
@ -581,55 +493,9 @@ public class LabelBase : ILabel
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subnothit && Clicked is not null) _ = Clicked.Invoke(this);
|
||||
if (subnothit) TrigerClick();
|
||||
}
|
||||
if (MouseInside && obj.Button == MouseButton.Button2 && ContextMenu is not null && Window!.HoveringControl == this) ContextMenu.ShowContext(Window!);
|
||||
if (obj.Button != MouseButton.Button2 && ContextMenu is not null && ContextMenu.Visible) ContextMenu.HideContext(Window!);
|
||||
}
|
||||
|
||||
public MouseCursor HoverMouse { get; set; } = MouseCursor.Default;
|
||||
|
||||
protected bool mi;
|
||||
|
||||
public virtual bool MouseInside
|
||||
{
|
||||
get => mi;
|
||||
set
|
||||
{
|
||||
if (Window is null) return;
|
||||
if (Window.HoveringControl == this && value)
|
||||
{
|
||||
mi = value;
|
||||
if (MouseEnter is not null) MouseEnter.Invoke(this);
|
||||
}
|
||||
|
||||
if (Window.HoveringControl != this && !value)
|
||||
{
|
||||
mi = value;
|
||||
if (MouseLeave is not null) MouseLeave.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Func<IRenderObject, Task>? Clicked;
|
||||
public event Func<IRenderObject, Task>? WindowLoaded;
|
||||
public event Func<IRenderObject, Task>? MouseEnter;
|
||||
public event Func<IRenderObject, Task>? MouseLeave;
|
||||
public object? Tag { get; set; } = null;
|
||||
|
||||
private bool l = false;
|
||||
|
||||
protected virtual void InvokeWindowLoaded()
|
||||
{
|
||||
if (WindowLoaded is not null) WindowLoaded.Invoke(this);
|
||||
}
|
||||
|
||||
public bool Loaded
|
||||
{
|
||||
get => l;
|
||||
protected set
|
||||
{
|
||||
l = value;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
|
||||
@ -25,7 +24,7 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
|
||||
public void BaseParentResize()
|
||||
{
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
if (!Controls[i].Loaded) continue;
|
||||
@ -74,13 +73,13 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
{
|
||||
Controls[i].ForceDistanceUpdate(this);
|
||||
}
|
||||
if (SizeChanged && Controls[i] is IParent parent)
|
||||
if (SizeChanged && Controls[i] is ParentBase parent)
|
||||
{
|
||||
parent.ParentResize();
|
||||
}
|
||||
}
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
|
||||
public virtual void ParentResize()
|
||||
@ -106,14 +105,15 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetSize(int w, int h)
|
||||
public override void SetSize(int w, int h, bool UpdateOpenGLCords = true, bool TrigerSizeEvent = true,
|
||||
bool TrigerParentSizeEvent = true, bool TryDraw = true, bool UpdateDistance = false)
|
||||
{
|
||||
OldHeight = Size.Y;
|
||||
OldWidth = Size.X;
|
||||
base.SetSize(w, h);
|
||||
base.SetSize(w, h, UpdateOpenGLCords, TrigerSizeEvent, TrigerParentSizeEvent, TryDraw, UpdateDistance);
|
||||
}
|
||||
|
||||
public virtual void ReportSizeUpdate(IRenderObject Control)
|
||||
public virtual void ReportSizeUpdate(RenderObjectCore Control)
|
||||
{
|
||||
|
||||
}
|
||||
@ -122,24 +122,30 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
{
|
||||
if (Loaded && Visible && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
||||
{
|
||||
DrawBase();
|
||||
DrawSelf();
|
||||
if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return;
|
||||
GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh);
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
if (!Controls[i].Loaded)
|
||||
{
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
Controls[i].LoadToParent(this, Window!);
|
||||
if (this is IFlow flow) flow.ForceScrollUpdate();
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
if (Controls[i].Location.X >= Size.X ||
|
||||
Controls[i].Location.Y >= Size.Y ||
|
||||
Controls[i].Location.X + Controls[i].Size.X < 0 ||
|
||||
Controls[i].Location.Y + Controls[i].Size.Y < 0) continue;
|
||||
Controls[i].Draw(x,y,sx,sy,sw,sh);
|
||||
if (Controls[i] is IParent) GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh);
|
||||
if (Controls[i] is ParentBase tmp_parent)
|
||||
{
|
||||
tmp_parent.Draw(x,y,sx,sy,sw,sh);
|
||||
GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh);
|
||||
}
|
||||
else
|
||||
{
|
||||
Controls[i].DrawSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,7 +231,7 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
public bool IgnoreVisForChildren { get; set; }
|
||||
|
||||
|
||||
public override void NotifiNotVisible()
|
||||
internal override void NotifiNotVisible()
|
||||
{
|
||||
base.NotifiNotVisible();
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
@ -234,7 +240,7 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
}
|
||||
}
|
||||
|
||||
public override void Clean()
|
||||
internal override void Clean()
|
||||
{
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
@ -243,19 +249,17 @@ public abstract class ParentBase : Rectangle, IParent
|
||||
base.Clean();
|
||||
}
|
||||
|
||||
public override void LoadToParent(IParent Parent, IWindow Window)
|
||||
internal override void LoadToParent(IParent Parent, IWindow Window)
|
||||
{
|
||||
if (Loaded) return;
|
||||
bool PastBlockState = BlockDraw;
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
base.LoadToParent(Parent, Window);
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
if (Controls[i].Loaded) continue;
|
||||
Controls[i].LoadToParent(this, Window);
|
||||
if (Controls[i] is IFlow flow) flow.ForceScrollUpdate();
|
||||
}
|
||||
BlockDraw = PastBlockState;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,24 +1,18 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Globals;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace GraphicsManager.Objects;
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
|
||||
public class Rectangle : ITextureObject
|
||||
public class Rectangle : RenderObjectCore
|
||||
{
|
||||
public static readonly Dictionary<IGLFWGraphicsContext, Shader> DefaultShader = new();
|
||||
public static readonly Dictionary<IGLFWGraphicsContext, Shader> DefaultAlphaShader = new();
|
||||
public static readonly Dictionary<IGLFWGraphicsContext, Shader> DefaultAlphaTextureShader = new();
|
||||
|
||||
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
||||
|
||||
|
||||
public Vector2i GetWindowLocation()
|
||||
{
|
||||
if (!Loaded) return Location;
|
||||
@ -48,21 +42,12 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
|
||||
public List<Texture> Textures { get; set; } = new();
|
||||
public BetterContextMenu? ContextMenu { get; set; } = null;
|
||||
|
||||
public Rectangle(Texture? texture = null)
|
||||
{
|
||||
if (texture is not null) Textures.Add(texture);
|
||||
}
|
||||
|
||||
public virtual void Focus()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual void UnFocus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private Color4 _BackgroundColor { get; set; } = new(0, 0, 0, 255);
|
||||
|
||||
@ -76,32 +61,7 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
}
|
||||
|
||||
private bool _Visible = true;
|
||||
public virtual bool Visible
|
||||
{
|
||||
get => _Visible;
|
||||
set
|
||||
{
|
||||
_Visible = value;
|
||||
if (value) TryDraw();
|
||||
else
|
||||
{
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SendClipEvent(string ClipString)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void DrawBase()
|
||||
public override void DrawSelf()
|
||||
{
|
||||
if (Visible && Loaded && Location.X > 0 - Size.X && Location.Y > 0 - Size.Y)
|
||||
{
|
||||
@ -122,34 +82,18 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
}
|
||||
|
||||
public override void TryDraw()
|
||||
{
|
||||
TryDraw(0);
|
||||
}
|
||||
|
||||
public virtual void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
||||
{
|
||||
DrawBase();
|
||||
}
|
||||
|
||||
public Vector4i Margins { get; set; } = new();
|
||||
|
||||
public virtual MouseCursor HoverMouse { get; set; } = MouseCursor.Default;
|
||||
public List<SubHitBox> SubHitBoxes { get; } = new();
|
||||
public event Func<IRenderObject, string[], Task>? FilesDroped;
|
||||
public void SendFilesEvent(string[] Files)
|
||||
{
|
||||
if (FilesDroped is not null) _ = FilesDroped.Invoke(this, Files);
|
||||
}
|
||||
|
||||
public void ForceDistanceUpdate()
|
||||
{
|
||||
if (Parent is null) return;
|
||||
ForceDistanceUpdate(Parent);
|
||||
DrawSelf();
|
||||
}
|
||||
|
||||
public void ForceDistanceUpdate(IParent parent)
|
||||
{
|
||||
if (parent is IWindow w) Distance = new(w.CS.X - Size.X - Location.X, w.CS.Y - Size.Y - Location.Y);
|
||||
else Distance = new(parent.Size.X - Size.X - Location.X, parent.Size.Y - Size.Y - Location.Y);
|
||||
}
|
||||
|
||||
public virtual void Clean()
|
||||
internal override void Clean()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
GL.DeleteBuffer(BufferObject);
|
||||
@ -157,7 +101,7 @@ public class Rectangle : ITextureObject
|
||||
GL.DeleteVertexArray(ArrayObject);
|
||||
}
|
||||
|
||||
public virtual void LoadToParent(IParent Parent, IWindow Window)
|
||||
internal override void LoadToParent(IParent Parent, IWindow Window)
|
||||
{
|
||||
if (Loaded) return;
|
||||
this.Parent = Parent;
|
||||
@ -177,11 +121,9 @@ public class Rectangle : ITextureObject
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(ushort), Indexs, Hint);
|
||||
Loaded = true;
|
||||
Window.MouseDown += Window_MouseDown;
|
||||
Window.FileDrop += WindowOnFileDrop;
|
||||
SetLocation(loc_.X, loc_.Y);
|
||||
if (Distance.X == 0 && Distance.Y == 0) ForceDistanceUpdate(Parent);
|
||||
if (WindowLoaded is not null) WindowLoaded.Invoke(this);
|
||||
CallWindowLoaded();
|
||||
}
|
||||
|
||||
public void TransferOwners(IWindow w, IParent p)
|
||||
@ -195,74 +137,6 @@ public class Rectangle : ITextureObject
|
||||
p.Controls.Add(this);
|
||||
}
|
||||
|
||||
private void WindowOnFileDrop(FileDropEventArgs obj)
|
||||
{
|
||||
if (!MouseInside) return;
|
||||
if (FilesDroped is not null) _ = FilesDroped.Invoke(this, obj.FileNames);
|
||||
}
|
||||
|
||||
private bool mi = false;
|
||||
|
||||
public bool MouseInside
|
||||
{
|
||||
get => mi;
|
||||
set
|
||||
{
|
||||
if (Window is null) return;
|
||||
if (AllowHoverFromBehind)
|
||||
{
|
||||
mi = value;
|
||||
if (value && MouseEnter is not null) MouseEnter.Invoke(this);
|
||||
if (!value && MouseLeave is not null) MouseLeave.Invoke(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Window.HoveringControl == this && value)
|
||||
{
|
||||
mi = value;
|
||||
if (MouseEnter is not null) MouseEnter.Invoke(this);
|
||||
}
|
||||
|
||||
if (Window.HoveringControl != this && !value)
|
||||
{
|
||||
mi = value;
|
||||
if (MouseLeave is not null) MouseLeave.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IParent? Parent { get; private set; }
|
||||
public IWindow? Window { get; private set; }
|
||||
private bool ahfb = false;
|
||||
|
||||
public bool AllowHoverFromBehind
|
||||
{
|
||||
get
|
||||
{
|
||||
return ahfb;
|
||||
}
|
||||
set
|
||||
{
|
||||
ahfb = value;
|
||||
if (!value)
|
||||
{
|
||||
if (MouseInside && Window is not null && Window.HoveringControl != this)
|
||||
{
|
||||
mi = false;
|
||||
if (MouseLeave is not null) MouseLeave.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
||||
{
|
||||
if (MouseInside && e.Button == MouseButton.Button1 && Clicked is not null) _ = Clicked.Invoke(this);
|
||||
if (MouseInside && e.Button == MouseButton.Button2 && ContextMenu is not null && Window!.HoveringControl == this) ContextMenu.ShowContext(Window!);
|
||||
if (e.Button != MouseButton.Button2 && ContextMenu is not null && ContextMenu.Visible) ContextMenu.HideContext(Window!);
|
||||
}
|
||||
|
||||
~Rectangle()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
@ -274,85 +148,47 @@ public class Rectangle : ITextureObject
|
||||
public Shader Shader { get; set; } = null!;
|
||||
public int ElementBufferObject { get; private set; }
|
||||
public int BufferObject { get; private set; }
|
||||
public bool IgnoreHover { get; set; }
|
||||
public int ArrayObject { get; private set; }
|
||||
private Vector2i size_ = new(), loc_;
|
||||
|
||||
private bool UpdateOnCALL = true;
|
||||
|
||||
public float[] Points
|
||||
protected virtual void SetPoints(float[] Points)
|
||||
{
|
||||
set
|
||||
try
|
||||
{
|
||||
try
|
||||
if (Loaded)
|
||||
{
|
||||
if (Loaded)
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||
GL.BindVertexArray(ArrayObject);
|
||||
int NumberOfCords = 2;
|
||||
if (Textures.Any())
|
||||
{
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||
GL.BindVertexArray(ArrayObject);
|
||||
int NumberOfCords = 2;
|
||||
if (Textures.Any())
|
||||
{
|
||||
NumberOfCords = 4;
|
||||
GL.EnableVertexAttribArray(Textures.First().Location);
|
||||
GL.VertexAttribPointer(Textures.First().Location, 2, VertexAttribPointerType.Float, false, NumberOfCords * sizeof(float), 2 * sizeof(float));
|
||||
}
|
||||
GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, NumberOfCords * sizeof(float), 0);
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, value.Length * sizeof(float), value, Hint);
|
||||
GL.BindVertexArray(ArrayObject);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(ushort), Indexs, Hint);
|
||||
if (Window is not null && Window.CanControleUpdate && Loaded && UpdateOnCALL) Parent!.TryDraw();
|
||||
|
||||
NumberOfCords = 4;
|
||||
GL.EnableVertexAttribArray(Textures.First().Location);
|
||||
GL.VertexAttribPointer(Textures.First().Location, 2, VertexAttribPointerType.Float, false, NumberOfCords * sizeof(float), 2 * sizeof(float));
|
||||
}
|
||||
}
|
||||
catch (AccessViolationException v)
|
||||
{
|
||||
Console.WriteLine(v.Message);
|
||||
GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, NumberOfCords * sizeof(float), 0);
|
||||
GL.EnableVertexAttribArray(0);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, Points.Length * sizeof(float), Points, Hint);
|
||||
GL.BindVertexArray(ArrayObject);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(ushort), Indexs, Hint);
|
||||
if (Window is not null && Window.CanControleUpdate && Loaded && UpdateOnCALL) Parent!.TryDraw();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool iv;
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get
|
||||
catch (AccessViolationException v)
|
||||
{
|
||||
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;
|
||||
Console.WriteLine(v.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool BlendOverride;
|
||||
|
||||
public virtual void TryDraw(int deapth = 0)
|
||||
public virtual void TryDraw(int deapth)
|
||||
{
|
||||
if (BlockDraw) return;
|
||||
if (Parent is null) return;
|
||||
@ -396,17 +232,9 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
|
||||
|
||||
public event Func<IRenderObject, Task>? SizeChanged;
|
||||
|
||||
public ushort[] Indexs { get; set; } = new ushort[6] { 0, 1, 3, 1, 2, 3 };
|
||||
public BufferUsageHint Hint { get; set; } = BufferUsageHint.StaticDraw;
|
||||
public event Func<IRenderObject, Task>? Clicked;
|
||||
public bool Loaded { get; private set; }
|
||||
public event Func<IRenderObject, Task>? WindowLoaded;
|
||||
public event Func<IRenderObject, Task>? MouseEnter;
|
||||
public event Func<IRenderObject, Task>? MouseLeave;
|
||||
public object? Tag { get; set; }
|
||||
public Vector2i Distance { get; set; }
|
||||
|
||||
private TextureDisplay td = TextureDisplay.Clamped;
|
||||
|
||||
@ -429,13 +257,13 @@ public class Rectangle : ITextureObject
|
||||
switch (value)
|
||||
{
|
||||
case TextureDisplay.Clamped:
|
||||
Points = new float[]
|
||||
SetPoints(new float[]
|
||||
{
|
||||
saf.X, laf.Y, Textures[0].MaxText.X, Textures[0].MaxText.Y,
|
||||
saf.X, saf.Y, Textures[0].MaxText.X, 0,
|
||||
laf.X, saf.Y, 0, 0,
|
||||
laf.X, laf.Y, 0, Textures[0].MaxText.Y,
|
||||
};
|
||||
});
|
||||
break;
|
||||
case TextureDisplay.HorizontalCenter or TextureDisplay.ProgressHorizontalCenter or TextureDisplay.TextureHorizontalCenter:
|
||||
|
||||
@ -447,7 +275,7 @@ public class Rectangle : ITextureObject
|
||||
diff = Window.IntToWindow(Textures[0].RawSize!.Value.Y);
|
||||
}
|
||||
}
|
||||
Points = new float[]
|
||||
SetPoints(new float[]
|
||||
{
|
||||
saf.X, laf.Y, Textures[0].MaxText.X, Textures[0].MaxText.Y, //4
|
||||
saf.X, saf.Y, Textures[0].MaxText.X, 0, //9
|
||||
@ -457,7 +285,7 @@ public class Rectangle : ITextureObject
|
||||
saf.X - diff, saf.Y, Textures[0].MaxText.X-per, 0, //29
|
||||
laf.X + diff, saf.Y, per, 0, //34
|
||||
laf.X + diff, laf.Y, per, Textures[0].MaxText.Y, //39
|
||||
};
|
||||
});
|
||||
Indexs = new ushort[]
|
||||
{
|
||||
0, 1, 4,
|
||||
@ -479,7 +307,7 @@ public class Rectangle : ITextureObject
|
||||
else
|
||||
diff = (Window.IntToWindow(Size.X) + 1) / 3;
|
||||
}
|
||||
Points = new float[]
|
||||
SetPoints(new float[]
|
||||
{
|
||||
saf.X, laf.Y, Textures[0].MaxText.X, Textures[0].MaxText.Y, //4
|
||||
saf.X, saf.Y, Textures[0].MaxText.X, 0, //9
|
||||
@ -497,7 +325,7 @@ public class Rectangle : ITextureObject
|
||||
saf.X - diff, saf.Y, Textures[0].MaxText.X-per, 0, //29
|
||||
laf.X + diff, saf.Y, per, 0, //34
|
||||
laf.X + diff, laf.Y, per, Textures[0].MaxText.Y, //39
|
||||
};
|
||||
});
|
||||
Indexs = new ushort[]
|
||||
{
|
||||
0, 4, 11,
|
||||
@ -535,43 +363,7 @@ public class Rectangle : ITextureObject
|
||||
temp[start + 3] = Ty;
|
||||
}
|
||||
|
||||
public virtual Vector2i Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetSize(value.X, value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetSize(int wh)
|
||||
{
|
||||
SetSize(wh, wh);
|
||||
}
|
||||
public virtual void SetSize(int w, int h)
|
||||
{
|
||||
size_.X = w;
|
||||
size_.Y = h;
|
||||
UpdateOpenGLCords(true);
|
||||
if (SizeChanged is not null) SizeChanged.Invoke(this);
|
||||
if (Parent is not null) Parent.ReportSizeUpdate(this);
|
||||
}
|
||||
|
||||
public virtual void SetLocation(int xy)
|
||||
{
|
||||
SetLocation(xy, xy);
|
||||
}
|
||||
public virtual void SetLocation(int x, int y)
|
||||
{
|
||||
loc_.X = x;
|
||||
loc_.Y = y;
|
||||
UpdateOpenGLCords(true);
|
||||
}
|
||||
|
||||
public virtual void UpdateOpenGLCords(bool draw = false)
|
||||
public override void UpdateOpenGLCords(bool draw = false)
|
||||
{
|
||||
if (Window is null || Parent is null) return;
|
||||
float[] temp = Textures.Count == 0
|
||||