From a1e3d4cf123ee1a491c3c56a31853100db4fb990 Mon Sep 17 00:00:00 2001 From: JacobTech Date: Mon, 18 Nov 2024 23:24:43 -0500 Subject: [PATCH] Project --- GraphicsManager/FPSWindow.cs | 3 ++ GraphicsManager/GraphicsManager.csproj | 2 +- GraphicsManager/Interfaces/IParent.cs | 2 + GraphicsManager/Interfaces/IWindow.cs | 2 + GraphicsManager/Objects/Core/ParentBase.cs | 17 +++++++-- GraphicsManager/Objects/Rectangle.cs | 5 ++- GraphicsManager/Window.cs | 43 ++++++++++++++++++++++ 7 files changed, 67 insertions(+), 7 deletions(-) diff --git a/GraphicsManager/FPSWindow.cs b/GraphicsManager/FPSWindow.cs index 85db3d0..5a6dec4 100755 --- a/GraphicsManager/FPSWindow.cs +++ b/GraphicsManager/FPSWindow.cs @@ -381,6 +381,9 @@ public class FPSWindow : GameWindow , IWindow } private int frame = 0; + + public bool UseLiveView { get; set; } = false; + public bool CollectUpperFiles { get; set; } public void ReportSizeUpdate(IRenderObject Control) { diff --git a/GraphicsManager/GraphicsManager.csproj b/GraphicsManager/GraphicsManager.csproj index c36affd..abd5d9d 100644 --- a/GraphicsManager/GraphicsManager.csproj +++ b/GraphicsManager/GraphicsManager.csproj @@ -10,7 +10,7 @@ False https://git.jacobtech.com/JacobTech.com/GraphicsManager git - 1.1.1-alpha29 + 1.1.1-alpha35 diff --git a/GraphicsManager/Interfaces/IParent.cs b/GraphicsManager/Interfaces/IParent.cs index 8aba00d..1193d8f 100755 --- a/GraphicsManager/Interfaces/IParent.cs +++ b/GraphicsManager/Interfaces/IParent.cs @@ -28,4 +28,6 @@ public interface IParent 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; } } diff --git a/GraphicsManager/Interfaces/IWindow.cs b/GraphicsManager/Interfaces/IWindow.cs index 706e08d..f04ab4e 100644 --- a/GraphicsManager/Interfaces/IWindow.cs +++ b/GraphicsManager/Interfaces/IWindow.cs @@ -15,6 +15,8 @@ public interface IWindow : IParent public bool LastFrameIsResize { get; } public bool UseSubFrames { get; set; } + + public bool UseLiveView { get; set; } public void CheckParent(IParent p, IRenderObject c, int xx, Vector2i di); public void CheckParent(IParent p); diff --git a/GraphicsManager/Objects/Core/ParentBase.cs b/GraphicsManager/Objects/Core/ParentBase.cs index cbfbe3b..46591f5 100644 --- a/GraphicsManager/Objects/Core/ParentBase.cs +++ b/GraphicsManager/Objects/Core/ParentBase.cs @@ -87,7 +87,16 @@ public abstract class ParentBase : Rectangle, IParent { BaseParentResize(); } - + + public override void UpdateOpenGLCords(bool draw = false) + { + base.UpdateOpenGLCords(draw); + for (int i = 0; i < Controls.Length; i++) + { + Controls[i].UpdateOpenGLCords(); + } + } + public override void SetLocation(int x, int y) { base.SetLocation(x, y); @@ -115,8 +124,7 @@ public abstract class ParentBase : Rectangle, IParent { DrawBase(); 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) @@ -136,9 +144,10 @@ public abstract class ParentBase : Rectangle, IParent } } + public bool CollectUpperFiles { get; set; } + public virtual bool UpdateScissorBox(ref int x, ref int y, ref int sx, ref int sy, ref int sw, ref int sh, int xx = 0, int xy = 0, int lw = 0, int lh = 0, bool UpdateBoxInfo = true) { - int nw = Size.X - xx - lw, nh = Size.Y - xy - lh, nx = Location.X + xx, diff --git a/GraphicsManager/Objects/Rectangle.cs b/GraphicsManager/Objects/Rectangle.cs index cb7190c..766262b 100755 --- a/GraphicsManager/Objects/Rectangle.cs +++ b/GraphicsManager/Objects/Rectangle.cs @@ -350,12 +350,12 @@ public class Rectangle : ITextureObject public bool BlendOverride; - public void TryDraw(int deapth = 0) + public virtual void TryDraw(int deapth = 0) { if (BlockDraw) return; if (Parent is null) return; - if (!IsVisible) return; if (Window is null) return; + if (Window.UseLiveView && !IsVisible) return; if (!Window.UseSubFrames) { Parent.TryDraw(); @@ -555,6 +555,7 @@ public class Rectangle : ITextureObject 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) diff --git a/GraphicsManager/Window.cs b/GraphicsManager/Window.cs index 6ecbcad..56ccb0e 100755 --- a/GraphicsManager/Window.cs +++ b/GraphicsManager/Window.cs @@ -81,8 +81,51 @@ public class Window : NativeWindow , IWindow GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.ScissorTest); } + + protected virtual void OnFileDrop(FileDropEventArgs obj) + { + void CheckFileDrop(IParent p, Vector2i diff) + { + bool found = false; + for (int i = p.Controls.Length - 1; i >= 0; i--) + { + if ((p.Controls[i].Location + diff).X <= (int)MousePosition.X && + (p.Controls[i].Location + diff).Y <= (int)MousePosition.Y && + (p.Controls[i].Location + p.Controls[i].Size + diff).X >= (int)MousePosition.X && + (p.Controls[i].Location + p.Controls[i].Size + diff).Y >= (int)MousePosition.Y) + { + if (p.Controls[i] is IParent pp) + { + if (pp.CollectUpperFiles) + { + found = true; + p.Controls[i].SendFilesEvent(obj.FileNames); + } + else + { + CheckFileDrop(pp, pp.Controls[i].Location + diff); + } + } + else + { + found = true; + p.Controls[i].SendFilesEvent(obj.FileNames); + } + } + } + + if (!found && p is IRenderObject renderObject) + { + renderObject.SendFilesEvent(obj.FileNames); + } + } + CheckFileDrop(this, new(0)); + } + public bool CollectUpperFiles { get; set; } + public bool UseSubFrames { get; set; } = false; + public bool UseLiveView { get; set; } = false; private void OnTextInputEvent(TextInputEventArgs obj) {