diff --git a/GraphicsManager/GraphicsManager.csproj b/GraphicsManager/GraphicsManager.csproj index f4c0d1f..b221b32 100644 --- a/GraphicsManager/GraphicsManager.csproj +++ b/GraphicsManager/GraphicsManager.csproj @@ -10,7 +10,7 @@ False https://git.jacobtech.com/JacobTech.com/GraphicsManager git - 1.0.0-alpha99999999999999996 + 1.0.0-beta1 diff --git a/GraphicsManager/Interfaces/IRenderObject.cs b/GraphicsManager/Interfaces/IRenderObject.cs index 5e29c0d..26e9ea1 100755 --- a/GraphicsManager/Interfaces/IRenderObject.cs +++ b/GraphicsManager/Interfaces/IRenderObject.cs @@ -11,6 +11,8 @@ public interface IRenderObject public void LoadToParent(IParent Parent, Window Window); public void Draw(); public void Clean(); + public void Focus(); + public void UnFocus(); public Vector2i Size { get; set; } public Vector2i Location { get; set; } public Vector2 SizeAsFloat { get; } diff --git a/GraphicsManager/Objects/FlowLayout.cs b/GraphicsManager/Objects/FlowLayout.cs index f23cec7..72ea478 100644 --- a/GraphicsManager/Objects/FlowLayout.cs +++ b/GraphicsManager/Objects/FlowLayout.cs @@ -29,8 +29,8 @@ public class FlowLayout : IRenderObject, IParent public void ReportSizeUpdate(IRenderObject Control) { - if (isrole) return; - isrole = true; + if (BlockDraw) return; + BlockDraw = true; bool notfount = true; for (int i = 0; i < Controls.Length; i++) { @@ -47,7 +47,7 @@ public class FlowLayout : IRenderObject, IParent } } - isrole = false; + BlockDraw = false; } private Task ControlsOnControlRemoved() @@ -63,7 +63,6 @@ public class FlowLayout : IRenderObject, IParent private Task ControlsOnControlAdded(IRenderObject arg) { - if (Controls.Length > 0) arg.Location = new(0, Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y); else arg.Location = new(0, 0); arg.Size = new(Size.X, arg.Size.Y); @@ -94,37 +93,65 @@ public class FlowLayout : IRenderObject, IParent public ControlList Controls { get; } = new(); public ObjectAnchor Anchor { get => _bounds.Anchor; set => _bounds.Anchor = value; } public Color4 BackgroundColor { get => _bounds.BackgroundColor; set => _bounds.BackgroundColor = value; } - public bool Visible { get => _bounds.Visible; set => _bounds.Visible = value; } + public bool Visible + { + get => _bounds.Visible; + set + { + BlockDraw = true; + _bounds.Visible = value; + for (int i = 0; i < Controls.Length; i++) + Controls[i].Visible = value; + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; + } + } public Vector2i Size { get => _bounds.Size; set { + BlockDraw = true; _bounds.Size = value; for (int i = 0; i < Controls.Length; i++) { - Controls[i].Size = Controls[i].Size; + Controls[i].Size = new(value.X, Controls[i].Size.Y); } + ParentResize(new()); + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; } } public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; } + public void Focus() + { + + } + public void UnFocus() + { + + } public Vector2i Location { get => _bounds.Location; set { + BlockDraw = true; _bounds.Location = value; for (int i = 0; i < Controls.Length; i++) { Controls[i].Location = Controls[i].Location; } + ParentResize(new()); + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; } } public Vector2i Position => Location; public Vector2 LocationAsFloat { get => _bounds.LocationAsFloat; } - public Vector2i Distance { get => _bounds.Distance; } + public Vector2i Distance { get => _bounds.Distance; internal set => _bounds.Distance = value; } public event Func? Clicked; public event Action MouseDown; public event Action KeyDown; @@ -143,19 +170,19 @@ public class FlowLayout : IRenderObject, IParent if (Loaded) return; this.Parent = Parent; this.Window = Window; - isrole = true; + BlockDraw = true; Loaded = true; _bounds.LoadToParent(Parent, Window); for (int i = 0; i < Controls.Length; i++) { Controls[i].LoadToParent(this, Window); } - isrole = false; + BlockDraw = false; Window.MouseWheel += WindowOnMouseWheel; if (WindowLoaded is not null) WindowLoaded.Invoke(this); } - private bool isrole = false; + public bool BlockDraw { get; set; } = false; private MouseWheelEventArgs dis; Timer t; private Queue scrols = new(); @@ -163,14 +190,14 @@ public class FlowLayout : IRenderObject, IParent public void TryDraw() { - if (!isrole) Parent!.TryDraw(); + if (!BlockDraw) Parent!.TryDraw(); } private void WindowOnMouseWheel(MouseWheelEventArgs obj) { try { if (!inside) return; - isrole = true; + BlockDraw = true; dis = obj; if (scrols.Any()) { @@ -193,7 +220,7 @@ public class FlowLayout : IRenderObject, IParent { try { - if (isrole) + if (BlockDraw) { scrols.Enqueue(new Action(() => { @@ -229,7 +256,7 @@ public class FlowLayout : IRenderObject, IParent })); } - isrole = false; + BlockDraw = false; } catch (Exception exception) { @@ -270,7 +297,7 @@ public class FlowLayout : IRenderObject, IParent public void ParentResize(ResizeEventArgs e) { if (e.Width == 0 && e.Height == 0) return; - isrole = true; + BlockDraw = true; for (int i = 0; i < Controls.Length; i++) { if (!Controls[i].Loaded) continue; @@ -292,7 +319,7 @@ public class FlowLayout : IRenderObject, IParent } } Parent!.TryDraw(); - isrole = false; + BlockDraw = false; } #region Cool Math Things diff --git a/GraphicsManager/Objects/Label.cs b/GraphicsManager/Objects/Label.cs index 32150be..c0d83d5 100755 --- a/GraphicsManager/Objects/Label.cs +++ b/GraphicsManager/Objects/Label.cs @@ -48,6 +48,15 @@ public class Label : IRenderObject public static readonly Dictionary>> _characters = new(); private string text = string.Empty; public int VAO { get; private set; } + + public void Focus() + { + + } + public void UnFocus() + { + + } public int VBO { get; private set; } public Vector2 DIR { get; set; } = new Vector2(1f, 0f); public string Text @@ -83,7 +92,7 @@ public class Label : IRenderObject if (Loaded) { GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); - if (Window is not null && Window.CanControleUpdate && Loaded) Parent!.TryDraw(); + if (Window is not null && Window.CanControleUpdate) Parent!.TryDraw(); } } } @@ -91,7 +100,7 @@ public class Label : IRenderObject public Font Font { get; set; } = DefaultFont; public float Scale { get; set; } = 1.0f; public Color4 Color { get; set; } = new Color4(255, 255, 255, 255); - public Vector2i Distance { get; private set; } + public Vector2i Distance { get; internal set; } private Vector2i loc_ = new(); public Vector2i Location { @@ -234,7 +243,8 @@ public class Label : IRenderObject private bool mouseinside = false; private void WindowOnMouseMove(MouseMoveEventArgs obj) { - if (Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && + if (Visible && + Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Size.X + Location.X) >= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Location.Y + Size.Y, true) <= Window?.IntToFloat((float)Window?.MousePosition.Y!, true) && Parent?.IntToFloat(Location.Y, true) >= Window?.IntToFloat((float)Window?.MousePosition.Y!, true)) diff --git a/GraphicsManager/Objects/Rectangle.cs b/GraphicsManager/Objects/Rectangle.cs index 8af1ceb..880999d 100755 --- a/GraphicsManager/Objects/Rectangle.cs +++ b/GraphicsManager/Objects/Rectangle.cs @@ -17,6 +17,7 @@ public class Rectangle : ITextureObject public Texture? Texture { get; private set; } public ContextMenu? ContextMenu { get; set; } = null; + public event Func? FilesDroped; public Rectangle(Texture? texture = null) { @@ -34,8 +35,26 @@ public class Rectangle : ITextureObject } } } + public void Focus() + { + + } + public void UnFocus() + { + + } - public Color4 BackgroundColor { get; set; } = new(0, 0, 0, 255); + public Color4 _BackgroundColor { get; set; } = new(0, 0, 0, 255); + + public Color4 BackgroundColor + { + get => _BackgroundColor; + set + { + _BackgroundColor = value; + if (Parent is not null) Parent.TryDraw(); + } + } private bool _Visible = true; public bool Visible @@ -108,15 +127,23 @@ public class Rectangle : ITextureObject Loaded = true; Window.MouseDown += Window_MouseDown; Window.MouseMove += WindowOnMouseMove; + Window.FileDrop += WindowOnFileDrop; Location = Location; Distance = new(Parent.Size.X - Size.X - Location.X, Parent.Size.Y - Size.Y - Location.Y); if (WindowLoaded is not null) WindowLoaded.Invoke(this); } + private void WindowOnFileDrop(FileDropEventArgs obj) + { + if (!mouseinside) return; + if (FilesDroped is not null) _ = FilesDroped.Invoke(obj.FileNames); + } + private bool mouseinside = false; private void WindowOnMouseMove(MouseMoveEventArgs e) { - if (Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && + if (Visible && + Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Size.X + Location.X) >= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Location.Y + Size.Y, true) <= Window?.IntToFloat((float)Window?.MousePosition.Y!, true) && Parent?.IntToFloat(Location.Y, true) >= Window?.IntToFloat((float)Window?.MousePosition.Y!, true)) @@ -202,7 +229,7 @@ public class Rectangle : ITextureObject public event Func? MouseEnter; public event Func? MouseLeave; public object? Tag { get; set; } = null; - public Vector2i Distance { get; private set; } + public Vector2i Distance { get; internal set; } public Vector2i Size { diff --git a/GraphicsManager/Objects/RoundedButton.cs b/GraphicsManager/Objects/RoundedButton.cs index 2e1d5a9..219ce77 100755 --- a/GraphicsManager/Objects/RoundedButton.cs +++ b/GraphicsManager/Objects/RoundedButton.cs @@ -75,7 +75,7 @@ public class RoundedButton : IRenderObject } public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; } public Vector2 LocationAsFloat { get => _bounds.LocationAsFloat; } - public Vector2i Distance { get => _bounds.Distance; } + public Vector2i Distance { get => _bounds.Distance; internal set => _bounds.Distance = value;} public IParent? Parent { get; private set; } = null; public Window? Window { get; private set; } = null; public Color4 InsideColor { get => _inside.BackgroundColor; set => _inside.BackgroundColor = value; } @@ -84,7 +84,20 @@ public class RoundedButton : IRenderObject public bool Visible { get => _bounds.Visible; - set => _bounds.Visible = value; + set + { + _bounds.Visible = value; + _inside.Visible = value; + _label.Visible = value; + } + } + public void Focus() + { + + } + public void UnFocus() + { + } public event Func? Clicked; diff --git a/GraphicsManager/Objects/RoundedRectangle.cs b/GraphicsManager/Objects/RoundedRectangle.cs index cebfef1..7e79d04 100755 --- a/GraphicsManager/Objects/RoundedRectangle.cs +++ b/GraphicsManager/Objects/RoundedRectangle.cs @@ -25,7 +25,17 @@ public class RoundedRectangle : IRenderObject public event Func? MouseLeave; public object? Tag { get; set; } = null; - public Color4 BackgroundColor { get; set; } = new(0, 0, 0, 255); + public Color4 _BackgroundColor { get; set; } = new(0, 0, 0, 255); + + public Color4 BackgroundColor + { + get => _BackgroundColor; + set + { + _BackgroundColor = value; + if (Parent is not null) Parent.TryDraw(); + } + } public int Radius { get @@ -156,9 +166,18 @@ public class RoundedRectangle : IRenderObject } private bool mouseinside = false; + public void Focus() + { + + } + public void UnFocus() + { + + } private void WindowOnMouseMove(MouseMoveEventArgs obj) { - if (Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && + if (Visible && + Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Size.X + Location.X) >= Window?.IntToFloat((float)Window?.MousePosition.X!) && Parent?.IntToFloat(Location.Y + Size.Y, true) <= Window?.IntToFloat((float)Window?.MousePosition.Y!, true) && Parent?.IntToFloat(Location.Y, true) >= Window?.IntToFloat((float)Window?.MousePosition.Y!, true)) @@ -256,7 +275,7 @@ public class RoundedRectangle : IRenderObject public event Func? Clicked; public bool Loaded { get; private set; } = false; - public Vector2i Distance { get; private set; } + public Vector2i Distance { get; internal set; } public Vector2i Size { diff --git a/GraphicsManager/Objects/TabControl.cs b/GraphicsManager/Objects/TabControl.cs index d95d0d2..55fff57 100644 --- a/GraphicsManager/Objects/TabControl.cs +++ b/GraphicsManager/Objects/TabControl.cs @@ -68,7 +68,8 @@ public class TabControl : IRenderObject, IParent Tag = loc, BorderColor = this.BorderColor, InsideColor = this.InsideColor, - FontColor = this.TextColor + FontColor = this.TextColor, + Anchor = ObjectAnchor.Top | ObjectAnchor.Left }); if (loc == PageIndex) tmp.BorderColor = this.SelectedColor; @@ -98,13 +99,32 @@ public class TabControl : IRenderObject, IParent public IParent? Parent { get; private set; } = null; public Font TitleFont { get; set; } = Label.DefaultFont; public Window? Window { get; private set; } = null; - public bool Visible { get => _bounds.Visible; set => _bounds.Visible = value; } + + public bool Visible + { + get => _bounds.Visible; + set + { + BlockDraw = true; + _bounds.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; + } + } public ObjectAnchor Anchor { get => _bounds.Anchor; set => _bounds.Anchor = value; } public object? Tag { get => _bounds.Tag; set => _bounds.Tag = value; } public Vector2i Size { get => _bounds.Size; set => _bounds.Size = value; } public Vector2i Location { get => _bounds.Location; set => _bounds.Location = value; } public ContextMenu? ContextMenu { get => _bounds.ContextMenu; set => _bounds.ContextMenu = value; } - public Vector2i Distance { get => _bounds.Distance; } + public Vector2i Distance { get => _bounds.Distance; internal set => _bounds.Distance = value; } public Vector2 LocationAsFloat { get => _bounds.LocationAsFloat; } public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; } private uint pgi = 0; @@ -117,19 +137,35 @@ public class TabControl : IRenderObject, IParent set { pgi = value; - res = true; - for (int i = 0; i < Buttonts.Length; i++) - ((RoundedButton)Buttonts[i]).BorderColor = BorderColor; - ((RoundedButton)Buttonts[value]).BorderColor = SelectedColor; + BlockDraw = true; + if (_bounds.Visible) + { + for (int i = 0; i < Buttonts.Length; i++) + ((RoundedButton)Buttonts[i]).BorderColor = BorderColor; + ((RoundedButton)Buttonts[value]).BorderColor = 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 void Focus() + { + + } + public void UnFocus() + { + } public Vector2i Position => Location; public bool Loaded { get; private set; } = false; public void TryDraw() { - if (!res) Parent!.TryDraw(); + if (!BlockDraw) Parent!.TryDraw(); } public void ReportSizeUpdate(IRenderObject Control) @@ -139,9 +175,9 @@ public class TabControl : IRenderObject, IParent public void ParentResize(ResizeEventArgs e) { - res = true; + BlockDraw = true; if (e.Width == 0 && e.Height == 0) return; - if (Controls.Length >= PageIndex) return; + 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; @@ -159,17 +195,37 @@ public class TabControl : IRenderObject, IParent { parent.ParentResize(e); } + 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(e); + } + } Parent!.TryDraw(); - res = false; + BlockDraw = false; } - private bool res = false; + public bool BlockDraw { get; set; } = false; public void LoadToParent(IParent Parent, Window Window) { if (Loaded) return; this.Parent = Parent; this.Window = Window; - res = true; + BlockDraw = true; Loaded = true; _bounds.LoadToParent(Parent, Window); for (int i = 0; i < Controls.Length; i++) @@ -181,7 +237,7 @@ public class TabControl : IRenderObject, IParent Buttonts[i].LoadToParent(this, Window); } - res = false; + BlockDraw = false; if (WindowLoaded is not null) WindowLoaded.Invoke(this); } diff --git a/GraphicsManager/Objects/Textbox.cs b/GraphicsManager/Objects/Textbox.cs index b0aae1f..0678b5b 100755 --- a/GraphicsManager/Objects/Textbox.cs +++ b/GraphicsManager/Objects/Textbox.cs @@ -56,7 +56,7 @@ public class Textbox : IRenderObject } public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; } public Vector2 LocationAsFloat { get => _bounds.LocationAsFloat; } - public Vector2i Distance { get => _bounds.Distance; } + public Vector2i Distance { get => _bounds.Distance; internal set => _bounds.Distance = value; } public IParent? Parent { get; private set; } = null; public Window? Window { get; private set; } = null; public Color4 InsideColor { get => _inside.BackgroundColor; set => _inside.BackgroundColor = value; } @@ -65,7 +65,12 @@ public class Textbox : IRenderObject public bool Visible { get => _bounds.Visible; - set => _bounds.Visible = value; + set + { + _bounds.Visible = value; + _inside.Visible = value; + _label.Visible = value; + } } public event Func? Clicked; private Task BoundsOnMouseLeave(IRenderObject arg) @@ -119,6 +124,26 @@ public class Textbox : IRenderObject private bool use = false; public event Func? KeyPress; + + public void UnFocus() + { + use = false; + if (Window is not null && Window.focused == this) + Window.focused = null; + } + public void Focus() + { + if (Window is not null) + { + if (Window.focused is not null) + { + Window.focused.UnFocus(); + } + + Window.focused = this; + use = true; + } + } private void Window_KeyDown(OpenTK.Windowing.Common.KeyboardKeyEventArgs obj) { if (!use) return; @@ -129,18 +154,21 @@ public class Textbox : IRenderObject Text = Text.Remove(Text.Length - 1, 1); } + if (obj.Key == Keys.V && obj.Control && Window is not null) Text += Window.ClipboardString; if (KeyPress is not null) _ = KeyPress.Invoke(obj); } private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e) { - if (e.Button == MouseButton.Button1 && + if (Visible && + e.Button == MouseButton.Button1 && Parent?.IntToFloat(Location.X) <= Window?.IntToFloat((int)Window?.MousePosition.X!) && Parent?.IntToFloat(Size.X + Location.X) >= Window?.IntToFloat((int)Window?.MousePosition.X!) && Parent?.IntToFloat(Location.Y + Size.Y, true) <= Window?.IntToFloat((int)Window?.MousePosition.Y!, true) && Parent?.IntToFloat(Location.Y, true) >= Window?.IntToFloat((int)Window?.MousePosition.Y!, true)) { use = true; + Focus(); if (Clicked is not null) Clicked.Invoke(this); } else use = false; diff --git a/GraphicsManager/Objects/UserControl.cs b/GraphicsManager/Objects/UserControl.cs index f5b7276..d075e41 100755 --- a/GraphicsManager/Objects/UserControl.cs +++ b/GraphicsManager/Objects/UserControl.cs @@ -20,7 +20,7 @@ public class UserControl : IRenderObject, IParent public void TryDraw() { - if (!res && Parent is not null) Parent.TryDraw(); + if (!BlockDraw && Parent is not null) Parent.TryDraw(); } private Task _bounds_Clicked(IRenderObject arg) @@ -34,18 +34,37 @@ public class UserControl : IRenderObject, IParent public Color4 BackgroundColor { get => _bounds.BackgroundColor; set => _bounds.BackgroundColor = value; } - public bool Visible { get => _bounds.Visible; set => _bounds.Visible = value; } - private bool res = false; + public bool Visible { get => _bounds.Visible; + set + { + BlockDraw = true; + _bounds.Visible = value; + for (int i = 0; i < Controls.Length; i++) + Controls[i].Visible = value; + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; + } + + } + public bool BlockDraw { get; set; } = false; + public void Focus() + { + + } + public void UnFocus() + { + + } public Vector2i Size { get => _bounds.Size; set { + BlockDraw = true; _bounds.Size = value; - for (int i = 0; i < Controls.Length; i++) - { - Controls[i].Size = Controls[i].Size; - } + ParentResize(new()); + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; } } @@ -60,11 +79,15 @@ public class UserControl : IRenderObject, IParent get => _bounds.Location; set { + BlockDraw = true; _bounds.Location = value; for (int i = 0; i < Controls.Length; i++) { Controls[i].Location = Controls[i].Location; } + ParentResize(new()); + if (Parent is not null) Parent.TryDraw(); + BlockDraw = false; } } @@ -86,7 +109,7 @@ public class UserControl : IRenderObject, IParent if (Loaded) return; this.Parent = Parent; this.Window = Window; - res = true; + BlockDraw = true; Loaded = true; _bounds.LoadToParent(Parent, Window); for (int i = 0; i < Controls.Length; i++) @@ -94,7 +117,7 @@ public class UserControl : IRenderObject, IParent Controls[i].LoadToParent(this, Window); } - res = false; + BlockDraw = false; if (WindowLoaded is not null) WindowLoaded.Invoke(this); } @@ -141,7 +164,7 @@ public class UserControl : IRenderObject, IParent public void ParentResize(ResizeEventArgs e) { - res = true; + BlockDraw = true; if (e.Width == 0 && e.Height == 0) return; for (int i = 0; i < Controls.Length; i++) { @@ -164,7 +187,7 @@ public class UserControl : IRenderObject, IParent } } Parent!.TryDraw(); - res = false; + BlockDraw = false; } #region Cool Math Things diff --git a/GraphicsManager/Window.cs b/GraphicsManager/Window.cs index 713e9f9..22b0d9f 100755 --- a/GraphicsManager/Window.cs +++ b/GraphicsManager/Window.cs @@ -22,6 +22,8 @@ public class Window : NativeWindow , IParent base.Dispose(disposing); } + internal IRenderObject? focused; + internal ContextMenu? ActiveMenu { get; set; } = null; public IParent? Parent { get; } = null; public Vector2 LocationAsFloat { get; } = new Vector2(0f, 0f); @@ -125,7 +127,7 @@ public class Window : NativeWindow , IParent public void ParentResize(ResizeEventArgs e) { if (e.Width == 0 && e.Height == 0) return; - res = true; + BlockDraw = true; base.OnResize(e); GL.Viewport(0, 0, e.Width, e.Height); for (int i = 0; i < Controls.Length; i++) @@ -149,7 +151,7 @@ public class Window : NativeWindow , IParent } } DrawFrame(); - res = false; + BlockDraw = false; } private int frame = 0; @@ -201,10 +203,11 @@ public class Window : NativeWindow , IParent } } - private bool res = false; + public bool BlockDraw { get; set; } = false; + public void TryDraw() { - if (!res) DrawFrame(); + if (!BlockDraw) DrawFrame(); } private int initthread = 0; @@ -234,12 +237,12 @@ public class Window : NativeWindow , IParent if (needload.Any()) { - res = true; + BlockDraw = true; foreach (IRenderObject obj in needload) { obj.LoadToParent(this, this); } - res = false; + BlockDraw = false; } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); for (int i = 0; i < Controls.Length; i++)