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)
|
||||
{
|
||||
@ -23,13 +22,6 @@ 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,31 +265,11 @@ 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)
|
||||
{
|
||||
float max_x = 0, lines = 0, char_x = 0F;
|
||||
@ -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();
|
||||
DrawSelf();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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,15 +148,11 @@ 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
|
||||
{
|
||||
set
|
||||
protected virtual void SetPoints(float[] Points)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -301,7 +171,7 @@ public class Rectangle : ITextureObject
|
||||
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.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);
|
||||
@ -314,45 +184,11 @@ public class Rectangle : ITextureObject
|
||||
Console.WriteLine(v.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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
|
||||
@ -766,25 +558,8 @@ public class Rectangle : ITextureObject
|
||||
}
|
||||
|
||||
UpdateOnCALL = draw;
|
||||
Points = temp;
|
||||
SetPoints(temp);
|
||||
UpdateOnCALL = true;
|
||||
temp = Array.Empty<float>();
|
||||
}
|
||||
|
||||
public virtual Vector2i Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return loc_;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetLocation(value.X, value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 laf = new(), saf = new();
|
||||
|
||||
public Vector2 LocationAsFloat { get { return laf; } }
|
||||
public Vector2 SizeAsFloat { get { return saf; } }
|
||||
}
|
213
GraphicsManager/Objects/Core/RenderObjectCore.cs
Normal file
213
GraphicsManager/Objects/Core/RenderObjectCore.cs
Normal file
@ -0,0 +1,213 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace GraphicsManager.Objects.Core;
|
||||
|
||||
public abstract class RenderObjectCore
|
||||
{
|
||||
public event Func<RenderObjectCore, Task>? Clicked;
|
||||
public event Func<RenderObjectCore, string[], Task>? FilesDroped;
|
||||
public event Func<RenderObjectCore, Task>? MouseEnter;
|
||||
public event Func<RenderObjectCore, Task>? MouseLeave;
|
||||
public event Func<RenderObjectCore, Task>? SizeChanged;
|
||||
public event Func<RenderObjectCore, Task>? WindowLoaded;
|
||||
|
||||
internal void SendFilesEvent(string[] Files)
|
||||
{
|
||||
if (FilesDroped is not null) _ = FilesDroped.Invoke(this, Files);
|
||||
}
|
||||
|
||||
public abstract void DrawSelf();
|
||||
|
||||
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
||||
public bool Loaded { get; protected set; }
|
||||
public bool AllowHoverFromBehind
|
||||
{
|
||||
get => ahfb;
|
||||
set
|
||||
{
|
||||
ahfb = value;
|
||||
if (!value && MouseInside && Window is not null && Window.HoveringControl != this)
|
||||
{
|
||||
mi = false;
|
||||
MouseLeave?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool BlockDraw
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent is null) return bd != 0;
|
||||
return Parent.BlockDraw || bd != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public BetterContextMenu? ContextMenu { get; set; } = null;
|
||||
public Vector2i Distance { get; internal set; }
|
||||
public bool IgnoreHover { get; set; }
|
||||
internal virtual void NotifiNotVisible()
|
||||
{
|
||||
IsVisible = false;
|
||||
}
|
||||
public bool IsVisible
|
||||
{
|
||||
get => iv && Visible;
|
||||
protected set => iv = value;
|
||||
}
|
||||
public virtual Vector4i Margins { get; set; } = new();
|
||||
public virtual MouseCursor HoverMouse { get; set; } = MouseCursor.Default;
|
||||
public bool MouseInside
|
||||
{
|
||||
get => mi;
|
||||
internal set
|
||||
{
|
||||
if (Window is null) return;
|
||||
if (AllowHoverFromBehind)
|
||||
{
|
||||
mi = value;
|
||||
if (value) MouseEnter?.Invoke(this);
|
||||
else MouseLeave?.Invoke(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value && Window.HoveringControl == this) MouseEnter?.Invoke(this);
|
||||
if (!value && Window.HoveringControl != this) MouseLeave?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
public IParent? Parent { get; internal set; }
|
||||
public virtual Vector2i Location
|
||||
{
|
||||
get => loc_;
|
||||
set => SetLocation(value.X, value.Y);
|
||||
}
|
||||
public List<SubHitBox> SubHitBoxes { get; } = new();
|
||||
public object? Tag { get; set; }
|
||||
public virtual bool Visible
|
||||
{
|
||||
get => _Visible;
|
||||
set
|
||||
{
|
||||
_Visible = value;
|
||||
if (value) TryDraw();
|
||||
else Parent?.TryDraw();
|
||||
}
|
||||
}
|
||||
public virtual Vector2i Size
|
||||
{
|
||||
get => size_;
|
||||
set => SetSize(value.X, value.Y);
|
||||
}
|
||||
public IWindow? Window { get; internal set; }
|
||||
|
||||
private bool ahfb = false;
|
||||
private bool iv;
|
||||
private bool mi = false;
|
||||
private bool _Visible = true;
|
||||
protected int bd = 0;
|
||||
private readonly object BD_LOCK = new();
|
||||
protected Vector2i loc_ = new(), size_ = new();
|
||||
|
||||
public virtual void Focus() { }
|
||||
public virtual void UnFocus() { }
|
||||
|
||||
public void ForceDistanceUpdate()
|
||||
{
|
||||
if (Parent is null) return;
|
||||
ForceDistanceUpdate(Parent);
|
||||
}
|
||||
public void ForceDistanceUpdate(IParent parent)
|
||||
{
|
||||
Distance = parent is IWindow w
|
||||
? new Vector2i(w.CS.X - Size.X - Location.X, w.CS.Y - Size.Y - Location.Y)
|
||||
: new Vector2i(parent.Size.X - Size.X - Location.X, parent.Size.Y - Size.Y - Location.Y);
|
||||
}
|
||||
|
||||
public abstract void TryDraw();
|
||||
public void AddBlockDraw()
|
||||
{
|
||||
lock (BD_LOCK) bd++;
|
||||
}
|
||||
public void RemoveBlockDraw()
|
||||
{
|
||||
lock (BD_LOCK) bd--;
|
||||
}
|
||||
|
||||
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 SetSize(int wh,
|
||||
bool UpdateOpenGLCords = true,
|
||||
bool TrigerSizeEvent = true,
|
||||
bool TrigerParentSizeEvent = true,
|
||||
bool TryDraw = true,
|
||||
bool UpdateDistance = false) => SetSize(wh, wh, UpdateOpenGLCords, TrigerSizeEvent, TrigerParentSizeEvent, TryDraw, UpdateDistance);
|
||||
public virtual void SetSize(int w, int h,
|
||||
bool UpdateOpenGLCords = true,
|
||||
bool TrigerSizeEvent = true,
|
||||
bool TrigerParentSizeEvent = true,
|
||||
bool TryDraw = true,
|
||||
bool UpdateDistance = false)
|
||||
{
|
||||
size_.X = w;
|
||||
size_.Y = h;
|
||||
if (UpdateOpenGLCords) this.UpdateOpenGLCords(TryDraw);
|
||||
else
|
||||
{
|
||||
if (TryDraw) this.TryDraw();
|
||||
}
|
||||
if (TrigerSizeEvent) SizeChanged?.Invoke(this);
|
||||
if (Parent is null) return;
|
||||
if (UpdateDistance) ForceDistanceUpdate(Parent);
|
||||
if (TrigerParentSizeEvent) Parent.ReportSizeUpdate(this);
|
||||
|
||||
}
|
||||
|
||||
public abstract void UpdateOpenGLCords(bool draw = false);
|
||||
internal abstract void LoadToParent(IParent Parent, IWindow Window);
|
||||
|
||||
protected virtual void CallWindowLoaded()
|
||||
{
|
||||
if (WindowLoaded is not null) WindowLoaded.Invoke(this);
|
||||
Window!.MouseDown += Window_MouseDown;
|
||||
}
|
||||
|
||||
public virtual void TrigerClick()
|
||||
{
|
||||
if (Clicked is not null) Clicked.Invoke(this);
|
||||
}
|
||||
|
||||
protected 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!);
|
||||
}
|
||||
|
||||
internal abstract void Clean();
|
||||
|
||||
protected Vector2 laf = new(), saf = new();
|
||||
|
||||
public Vector2 LocationAsFloat { get { return laf; } }
|
||||
public Vector2 SizeAsFloat { get { return saf; } }
|
||||
|
||||
public virtual void SendClipEvent(string ClipString)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using GraphicsManager.Structs;
|
||||
using GraphicsManager.Objects.Core.Fonts;
|
||||
using GraphicsManager.Structs;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using SharpFont;
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Timers;
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
@ -10,7 +9,7 @@ using Timer = System.Timers.Timer;
|
||||
|
||||
namespace GraphicsManager.Objects;
|
||||
|
||||
public class FlowLayout : ParentBase, IFlow
|
||||
public class FlowLayout : ParentBase
|
||||
{
|
||||
public FlowLayout(Texture? texture = null)
|
||||
:base(texture)
|
||||
@ -43,7 +42,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
}
|
||||
|
||||
[Obsolete("Not Working", true)]
|
||||
public void ScrollToControl(IRenderObject Control)
|
||||
public void ScrollToControl(RenderObjectCore Control)
|
||||
{
|
||||
if (Controls.Length < 1 || !Controls.Contains(Control)) throw new Exception("Control does not exist");
|
||||
if (Control.Location.Y >= 0 && (Control.Location.Y + Control.Size.Y) <= Size.Y) return;
|
||||
@ -53,7 +52,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
int loc = 0;
|
||||
if ((Control.Location.Y + Control.Size.Y) >= Size.Y) loc = Size.Y - Control.Size.Y;
|
||||
int start = loc + Control.Size.Y;
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
bool top = false;
|
||||
if (startbottom)
|
||||
{
|
||||
@ -96,7 +95,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
ScrollValueBackEnd = c - (uint)Controls[i].Location.Y;
|
||||
}
|
||||
}
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
}
|
||||
|
||||
@ -110,9 +109,9 @@ public class FlowLayout : ParentBase, IFlow
|
||||
ScrollValue = MaxScrollValue;
|
||||
}
|
||||
|
||||
public override void ReportSizeUpdate(IRenderObject Control)
|
||||
public override void ReportSizeUpdate(RenderObjectCore Control)
|
||||
{
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
int index = Controls.IndexOf(Control);
|
||||
if (index < Controls.Length - 1)
|
||||
{
|
||||
@ -131,7 +130,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
{
|
||||
ForceScrollUpdate();
|
||||
}
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
|
||||
private Task ControlsOnControlRemoved()
|
||||
@ -154,7 +153,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ControlsOnControlAdded(int index, IRenderObject arg)
|
||||
private Task ControlsOnControlAdded(int index, RenderObjectCore arg)
|
||||
{
|
||||
ScrollSum += (uint)arg.Size.Y;
|
||||
if (Controls.Length > 0)
|
||||
@ -181,7 +180,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
|
||||
}
|
||||
}
|
||||
if (arg is not ILabel) arg.Size = new(Size.X, arg.Size.Y);
|
||||
if (arg is not LabelBase) arg.Size = new(Size.X, arg.Size.Y);
|
||||
if (arg is IParent par)
|
||||
{
|
||||
for (int i = 0; i < par.Controls.Length; i++)
|
||||
@ -200,7 +199,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
par.Controls[i].Location = new(lx, ly);
|
||||
}
|
||||
}
|
||||
if (arg is not ILabel) arg.Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top;
|
||||
if (arg is not LabelBase) arg.Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@ -223,17 +222,16 @@ public class FlowLayout : ParentBase, IFlow
|
||||
int nsh = sh - OldHeight+1;
|
||||
if (nsh <= 0) return;
|
||||
GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, nsh);
|
||||
DrawBase();
|
||||
DrawSelf();
|
||||
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 ||
|
||||
@ -248,7 +246,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
}
|
||||
else
|
||||
{
|
||||
Controls[i].Draw(x,y,sx,sy,sw,sh);
|
||||
Controls[i].DrawSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,16 +265,17 @@ public class FlowLayout : ParentBase, IFlow
|
||||
else Draw(x,y,sx,sy,sw,sh);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
BlockDraw = true;
|
||||
base.SetSize(w, h);
|
||||
AddBlockDraw();
|
||||
base.SetSize(w, h, UpdateOpenGLCords, TrigerSizeEvent, TrigerParentSizeEvent, TryDraw, UpdateDistance);
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
Controls[i].SetSize(w, Controls[i].Size.Y);
|
||||
Controls[i].SetSize(w, Controls[i].Size.Y, TryDraw: false);
|
||||
}
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
|
||||
public override Vector2i Size
|
||||
@ -290,7 +289,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
|
||||
public Vector2 MousePosition => Window!.MousePosition;
|
||||
|
||||
public override void LoadToParent(IParent Parent, IWindow Window)
|
||||
internal override void LoadToParent(IParent Parent, IWindow Window)
|
||||
{
|
||||
base.LoadToParent(Parent,Window);
|
||||
Window.MouseWheel += WindowOnMouseWheel;
|
||||
@ -331,14 +330,14 @@ public class FlowLayout : ParentBase, IFlow
|
||||
dist = 0;
|
||||
return;
|
||||
}
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
Vector2i v3i = new(0, (int)(value - ScrollValueBackEnd));
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
Controls[i].Location -= v3i;
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
dist = 0;
|
||||
ScrollValueBackEnd = value;
|
||||
@ -347,7 +346,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
|
||||
public override void ParentResize()
|
||||
{
|
||||
BlockDraw = true;
|
||||
AddBlockDraw();
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
{
|
||||
if (Controls[i] is IParent parent)
|
||||
@ -356,7 +355,7 @@ public class FlowLayout : ParentBase, IFlow
|
||||
}
|
||||
}
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
BlockDraw = false;
|
||||
RemoveBlockDraw();
|
||||
}
|
||||
|
||||
public uint MaxScrollValue
|
||||
|
@ -1,14 +1,9 @@
|
||||
using System.Text;
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using GraphicsManager.Objects.Core;
|
||||
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;
|
||||
|
||||
@ -27,7 +22,7 @@ public class Label : LabelBase
|
||||
}
|
||||
|
||||
public Color4 Color { get; set; } = new Color4(255, 255, 255, 255);
|
||||
public override 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)
|
||||
{
|
||||
|
@ -124,16 +124,6 @@ public class ProgressBar<TNumber> : ParentBase where TNumber : INumber<TNumber>
|
||||
|
||||
public bool DisallowAboveMax { get; set; } = true;
|
||||
|
||||
public void AddAtomic(TNumber value)
|
||||
{
|
||||
if (DisallowAboveMax && value > MaxProgressValue) value = MaxProgressValue;
|
||||
if (typeof(TNumber) == typeof(ulong))
|
||||
{
|
||||
Interlocked.Add(ref Unsafe.As<TNumber, ulong>(ref pv), (ulong)(object)value!);
|
||||
}
|
||||
if (!UpdateOnDraw) UpdateProgress();
|
||||
}
|
||||
|
||||
public TNumber ProgressValue
|
||||
{
|
||||
get
|
||||
|
@ -1,5 +1,6 @@
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using GraphicsManager.Objects.Core.Fonts;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace GraphicsManager.Objects;
|
||||
@ -54,7 +55,7 @@ public class RoundedButton : Rectangle
|
||||
}
|
||||
}
|
||||
|
||||
public override void Clean()
|
||||
internal override void Clean()
|
||||
{
|
||||
_label.Clean();
|
||||
base.Clean();
|
||||
@ -64,10 +65,10 @@ public class RoundedButton : Rectangle
|
||||
{
|
||||
if (!Visible || !Loaded) return;
|
||||
base.Draw(x,y,sx,sy,sw,sh);
|
||||
_label.Draw(x,y,sx,sy,sw,sh);
|
||||
_label.DrawSelf();
|
||||
}
|
||||
|
||||
public override void LoadToParent(IParent Parent, IWindow Window)
|
||||
internal override void LoadToParent(IParent Parent, IWindow Window)
|
||||
{
|
||||
if (Loaded) return;
|
||||
base.LoadToParent(Parent, Window);
|
@ -1,224 +0,0 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
|
||||
namespace GraphicsManager.Objects;
|
||||
|
||||
public class TabControl : ParentBase, IParent
|
||||
{
|
||||
private Texture t;
|
||||
public TabControl(Texture tex, FontFamily fam)
|
||||
{
|
||||
t = tex;
|
||||
TitleFont = FontInteraction.Load(fam);
|
||||
}
|
||||
|
||||
public TabControl(Texture tex, FontInteraction fam)
|
||||
{
|
||||
t = tex;
|
||||
TitleFont = fam;
|
||||
}
|
||||
|
||||
private ControlList Buttonts = new();
|
||||
|
||||
public void AddPage(string Title, UserControl page)
|
||||
{
|
||||
RoundedButton tmp;
|
||||
uint loc = (uint)Buttonts.Length;
|
||||
int locc = 0, loccc = 0;
|
||||
if (loc != 0)
|
||||
{
|
||||
locc = Buttonts[loc - 1].Location.X;
|
||||
loccc = Buttonts[loc - 1].Size.X;
|
||||
}
|
||||
Buttonts.Add(tmp = new RoundedButton(t, TitleFont)
|
||||
{
|
||||
Location = new(locc+ loccc + (TabSpace * (int)loc) + Border, Border),
|
||||
Text = Title,
|
||||
Tag = loc,
|
||||
FontColor = this.TextColor
|
||||
});
|
||||
|
||||
if (loc == PageIndex) tmp.BackgroundColor = this.SelectedColor;
|
||||
tmp.Clicked += TmpOnClicked;
|
||||
tmp.Size = new(tmp._label.Size.X + ((TextBorder + 4) * 2), tmp._label.Size.Y + ((TextBorder + 4) * 2));
|
||||
page.Anchor = ObjectAnchor.All;
|
||||
page.Location = new(Border, tmp.Location.Y + tmp.Size.Y + TabSpace);
|
||||
page.Size = new(Size.X - Border - Border, Size.Y - page.Location.Y - Border);
|
||||
if (PageIndex != loc) page.Visible = false;
|
||||
Controls.Add(page);
|
||||
}
|
||||
|
||||
public void AddPage(string Title, FlowLayout page)
|
||||
{
|
||||
RoundedButton tmp;
|
||||
uint loc = (uint)Buttonts.Length;
|
||||
int locc = 0, loccc = 0;
|
||||
if (loc != 0)
|
||||
{
|
||||
locc = Buttonts[loc - 1].Location.X;
|
||||
loccc = Buttonts[loc - 1].Size.X;
|
||||
}
|
||||
Buttonts.Add(tmp = new RoundedButton(t, TitleFont)
|
||||
{
|
||||
Location = new(locc+ loccc + (TabSpace * (int)loc) + Border, Border),
|
||||
Text = Title,
|
||||
Tag = loc,
|
||||
FontColor = this.TextColor,
|
||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left
|
||||
});
|
||||
|
||||
if (loc == PageIndex) tmp.BackgroundColor = this.SelectedColor;
|
||||
tmp.Clicked += TmpOnClicked;
|
||||
tmp.Size = new(tmp._label.Size.X + ((TextBorder + 4) * 2), tmp._label.Size.Y + ((TextBorder + 4) * 2));
|
||||
page.Anchor = ObjectAnchor.All;
|
||||
page.Location = new(Border, tmp.Location.Y + tmp.Size.Y + TabSpace);
|
||||
page.Size = new(Size.X - Border - Border, Size.Y - page.Location.Y - Border);
|
||||
if (PageIndex != loc) page.Visible = false;
|
||||
Controls.Add(page);
|
||||
}
|
||||
|
||||
private Task TmpOnClicked(IRenderObject arg)
|
||||
{
|
||||
PageIndex = (uint)arg.Tag!;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Color4 TextColor { get; set; } = new(255, 255, 255, 255);
|
||||
public Color4 BorderColor { get; set; } = new(40, 40, 40, 255);
|
||||
public Color4 SelectedColor { get; set; } = Color4.DarkCyan;
|
||||
public Color4 InsideColor { get; set; } = new(0, 0, 0, 255);
|
||||
public int TextBorder { get; set; } = 5;
|
||||
public int TabSpace { get; set; } = 5;
|
||||
public int Border { get; set; } = 10;
|
||||
public FontInteraction TitleFont { get; set; } = null!;
|
||||
|
||||
public override bool Visible
|
||||
{
|
||||
get => base.Visible;
|
||||
set
|
||||
{
|
||||
BlockDraw = true;
|
||||
base.Visible = value;
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
Buttonts[i].Visible = value;
|
||||
if (value) PageIndex = PageIndex;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
Controls[i].Visible = value;
|
||||
}
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
BlockDraw = false;
|
||||
}
|
||||
}
|
||||
private uint pgi = 0;
|
||||
public uint PageIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return pgi;
|
||||
}
|
||||
set
|
||||
{
|
||||
pgi = value;
|
||||
BlockDraw = true;
|
||||
if (base.Visible)
|
||||
{
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
((RoundedButton)Buttonts[i]).BackgroundColor = BorderColor;
|
||||
((RoundedButton)Buttonts[value]).BackgroundColor = SelectedColor;
|
||||
for (int i = 0; i < Controls.Length; i++)
|
||||
Controls[i].Visible = false;
|
||||
Controls[value].Visible = true;
|
||||
}
|
||||
|
||||
if (Parent is not null) Parent.TryDraw();
|
||||
BlockDraw = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ParentResize()
|
||||
{
|
||||
BlockDraw = true;
|
||||
if (!(Controls.Length >= PageIndex)) return;
|
||||
if (!Controls[PageIndex].Loaded) return;
|
||||
bool top = (Controls[PageIndex].Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
||||
bool left = (Controls[PageIndex].Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
||||
bool right = (Controls[PageIndex].Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
||||
bool bottom = (Controls[PageIndex].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||
if (!top && !bottom) { Controls[PageIndex].Anchor |= ObjectAnchor.Top; top = true; }
|
||||
if (!left && !right) { Controls[PageIndex].Anchor |= ObjectAnchor.Left; left = true; }
|
||||
int lx = (left ? Controls[PageIndex].Location.X : Size.X - Controls[PageIndex].Distance.X - Controls[PageIndex].Size.X);
|
||||
int ly = (top ? Controls[PageIndex].Location.Y : Size.Y - Controls[PageIndex].Distance.Y - Controls[PageIndex].Size.Y);
|
||||
int sy = (bottom ? Size.Y - Controls[PageIndex].Distance.Y - ly : Controls[PageIndex].Size.Y);
|
||||
int sx = (right ? Size.X - Controls[PageIndex].Distance.X - lx : Controls[PageIndex].Size.X);
|
||||
Controls[PageIndex].Size = new(sx, sy);
|
||||
Controls[PageIndex].Location = new(lx, ly);
|
||||
if (Controls[PageIndex] is IParent parent)
|
||||
{
|
||||
parent.ParentResize();
|
||||
}
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
{
|
||||
if (!Buttonts[i].Loaded) continue;
|
||||
top = (Buttonts[i].Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
||||
left = (Buttonts[i].Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
||||
right = (Buttonts[i].Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
||||
bottom = (Buttonts[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||
if (!top && !bottom) { Buttonts[i].Anchor |= ObjectAnchor.Top; top = true; }
|
||||
if (!left && !right) { Buttonts[i].Anchor |= ObjectAnchor.Left; left = true; }
|
||||
lx = (left ? Buttonts[i].Location.X : Size.X - Buttonts[i].Distance.X - Buttonts[i].Size.X);
|
||||
ly = (top ? Buttonts[i].Location.Y : Size.Y - Buttonts[i].Distance.Y - Buttonts[i].Size.Y);
|
||||
sy = (bottom ? Size.Y - Buttonts[i].Distance.Y - ly : Buttonts[i].Size.Y);
|
||||
sx = (right ? Size.X - Buttonts[i].Distance.X - lx : Buttonts[i].Size.X);
|
||||
Buttonts[i].Size = new(sx, sy);
|
||||
Buttonts[i].Location = new(lx, ly);
|
||||
if (Buttonts[i] is IParent parent2)
|
||||
{
|
||||
parent2.ParentResize();
|
||||
}
|
||||
}
|
||||
Parent!.TryDraw();
|
||||
BlockDraw = false;
|
||||
}
|
||||
|
||||
public override void LoadToParent(IParent Parent, IWindow Window)
|
||||
{
|
||||
if (Loaded) return;
|
||||
BlockDraw = true;
|
||||
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
|
||||
base.LoadToParent(Parent, Window);
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
{
|
||||
Buttonts[i].LoadToParent(this, Window);
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
}
|
||||
|
||||
public override void Draw(int x, int y, int sx, int sy, int sw, int sh)
|
||||
{
|
||||
if (Loaded && Visible)
|
||||
{
|
||||
base.Draw(x,y,sx,sy,sw,sh);
|
||||
if (!(Controls.Length >= (PageIndex))) return;
|
||||
if (!Controls[PageIndex].Loaded) return;
|
||||
Controls[PageIndex].Draw(x,y,sx,sy,sw,sh);
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
Buttonts[i].Draw(x,y,sx,sy,sw,sh);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Clean()
|
||||
{
|
||||
for (int i = 0; i < Buttonts.Length; i++)
|
||||
{
|
||||
Buttonts[i].Clean();
|
||||
}
|
||||
base.Clean();
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class Window : NativeWindow , IWindow
|
||||
|
||||
public bool ShowMissingChar { get; set; }
|
||||
|
||||
public IRenderObject? focused { get; set; }
|
||||
public RenderObjectCore? focused { get; set; }
|
||||
public void CenterWindow(int mon)
|
||||
{
|
||||
Box2i clientArea = Monitors.GetMonitors()[mon].ClientArea;
|
||||
@ -80,6 +80,30 @@ public class Window : NativeWindow , IWindow
|
||||
FileDrop += OnFileDrop;
|
||||
GL.Enable(EnableCap.Blend);
|
||||
GL.Enable(EnableCap.ScissorTest);
|
||||
MouseDown += OnMouseDown;
|
||||
}
|
||||
|
||||
private void OnMouseDown(MouseButtonEventArgs obj)
|
||||
{
|
||||
if (HoveringControl is null) return;
|
||||
if (obj.Button == MouseButton.Button1)
|
||||
{
|
||||
bool subnothit = true;
|
||||
if (HoveringControl.SubHitBoxes.Count > 0)
|
||||
{
|
||||
foreach (SubHitBox hb in HoveringControl.SubHitBoxes)
|
||||
{
|
||||
if (hb.MouseInside)
|
||||
{
|
||||
hb.SendClick();
|
||||
subnothit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subnothit) HoveringControl.TrigerClick();
|
||||
}
|
||||
if (obj.Button == MouseButton.Button2 && HoveringControl.ContextMenu is not null) HoveringControl.ContextMenu.ShowContext(this);
|
||||
if (obj.Button != MouseButton.Button2 && HoveringControl.ContextMenu is not null && HoveringControl.ContextMenu.Visible) HoveringControl.ContextMenu.HideContext(this);
|
||||
}
|
||||
|
||||
protected virtual void OnFileDrop(FileDropEventArgs obj)
|
||||
@ -114,7 +138,7 @@ public class Window : NativeWindow , IWindow
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && p is IRenderObject renderObject)
|
||||
if (!found && p is RenderObjectCore renderObject)
|
||||
{
|
||||
renderObject.SendFilesEvent(obj.FileNames);
|
||||
}
|
||||
@ -304,7 +328,7 @@ public class Window : NativeWindow , IWindow
|
||||
|
||||
public int Frame { get; protected set; } = 0;
|
||||
|
||||
public void ReportSizeUpdate(IRenderObject Control)
|
||||
public void ReportSizeUpdate(RenderObjectCore Control)
|
||||
{
|
||||
|
||||
}
|
||||
@ -377,16 +401,16 @@ public class Window : NativeWindow , IWindow
|
||||
}
|
||||
}
|
||||
|
||||
public IRenderObject? HoveringControl { get; set; }
|
||||
public RenderObjectCore? HoveringControl { get; set; }
|
||||
public SubHitBox? HoveringHitBox { get; set; }
|
||||
|
||||
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)
|
||||
{
|
||||
@ -459,7 +483,7 @@ public class Window : NativeWindow , IWindow
|
||||
|
||||
if (cb != HoveringControl)
|
||||
{
|
||||
IRenderObject? old = HoveringControl;
|
||||
RenderObjectCore? old = HoveringControl;
|
||||
HoveringControl = cb;
|
||||
if (cb is not null)
|
||||
{
|
||||
@ -560,8 +584,16 @@ public class Window : NativeWindow , 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,7 +626,7 @@ public class Window : NativeWindow , IWindow
|
||||
}
|
||||
else
|
||||
{
|
||||
Controls[i].Draw(0,0,0,0,CS.X, CS.Y);
|
||||
Controls[i].DrawSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -602,9 +634,9 @@ public class Window : NativeWindow , 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 ||
|
||||
|
Loading…
Reference in New Issue
Block a user