diff --git a/Luski/Classes/Settings.cs b/Luski/Classes/Settings.cs index 8982a29..d9ac4a5 100644 --- a/Luski/Classes/Settings.cs +++ b/Luski/Classes/Settings.cs @@ -15,8 +15,8 @@ public class Settings [JsonInclude] [JsonPropertyName("scale")] [SettingInfo(SettingGroup.AppSettings, SettingsPage.Appearance)] - [Shared.GlobalAttributes.DisplayName("Message Font Size")] - [Description("Sets the px value for the message font size")] + [Shared.GlobalAttributes.DisplayName("App Scale")] + [Description("Sets the scale for the app. If disabled, the default system scale will be used.")] [NumberSelector(typeof(double?))] [NumberMin(0.25)] [NumberDefault(1)] @@ -81,12 +81,12 @@ public class Settings { get { - return _ScaleFonts; + return _ScaleFonts && Scale is not null; } set { _ScaleFonts = value; - if (Globals.ms is not null) + if (Globals.RootWindow is not null) { Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont(); Globals.MessageFont.PixelHeight = Globals.Settings.MessageFontPX.ScaleFont(); @@ -97,8 +97,8 @@ public class Settings Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear(); Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear(); - Globals.ms.ForceUpdate(); - Globals.ms.DrawFrame(); + Globals.RootWindow.ForceUpdate(); + Globals.RootWindow.DrawFrame(); } } } diff --git a/Luski/GUI/MainScreen/UI/AccountButton.cs b/Luski/GUI/MainScreen/UI/AccountButton.cs index aedbd1f..be7c255 100644 --- a/Luski/GUI/MainScreen/UI/AccountButton.cs +++ b/Luski/GUI/MainScreen/UI/AccountButton.cs @@ -49,7 +49,7 @@ public class AccountButton : UserControl }; } - private async Task OnClicked(IRenderObject arg) + private async Task OnClicked(RenderObjectCore arg) { if (!Selected) await ToggleSelected(); } @@ -67,7 +67,7 @@ public class AccountButton : UserControl f = Color4.Gray; } - BlockDraw = true; + AddBlockDraw(); Selected = !Selected; if (SM.Selected is not null && SM.Selected != this) @@ -84,7 +84,7 @@ public class AccountButton : UserControl Globals.ms.ForceUpdate(); } - BlockDraw = false; + RemoveBlockDraw(); TryDraw(); } catch (Exception e) diff --git a/Luski/GUI/MainScreen/UI/AddServerIcon.cs b/Luski/GUI/MainScreen/UI/AddServerIcon.cs index c0de8cc..c701eb4 100644 --- a/Luski/GUI/MainScreen/UI/AddServerIcon.cs +++ b/Luski/GUI/MainScreen/UI/AddServerIcon.cs @@ -1,4 +1,5 @@ using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using OpenTK.Mathematics; namespace Luski.GUI.MainScreen.UI; diff --git a/Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs b/Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs index 4eab866..03943b0 100644 --- a/Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs +++ b/Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs @@ -171,7 +171,7 @@ public class AddServerOverlayForm : UserControl version.DropDownContainer.BackgroundColor = version.BackgroundColor; version.OpenStatusChanged += b => { - BlockDraw = true; + AddBlockDraw(); if (b) { version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangleTop.png"); @@ -181,7 +181,7 @@ public class AddServerOverlayForm : UserControl version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"); } - BlockDraw = false; + RemoveBlockDraw(); return Task.CompletedTask; }; @@ -216,7 +216,7 @@ public class AddServerOverlayForm : UserControl public override void ParentResize() { - BlockDraw = true; + AddBlockDraw(); for (int i = 0; i < Controls.Length; i++) { if (!Controls[i].Loaded) continue; @@ -278,6 +278,6 @@ public class AddServerOverlayForm : UserControl } } if (Parent is not null) Parent.TryDraw(); - BlockDraw = false; + RemoveBlockDraw(); } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/AddServerOverlayld.cs b/Luski/GUI/MainScreen/UI/AddServerOverlayld.cs index 95c07d9..53304fd 100644 --- a/Luski/GUI/MainScreen/UI/AddServerOverlayld.cs +++ b/Luski/GUI/MainScreen/UI/AddServerOverlayld.cs @@ -1,5 +1,4 @@ using GraphicsManager.Enums; -using GraphicsManager.Interfaces; using GraphicsManager.Objects; using GraphicsManager.Objects.Core; using Luski.Classes; @@ -9,7 +8,7 @@ using Luski.net; using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; using OpenTK.Windowing.GraphicsLibraryFramework; -using Rectangle = GraphicsManager.Objects.Rectangle; +using Rectangle = GraphicsManager.Objects.Core.Rectangle; namespace Luski.GUI.MainScreen.UI; @@ -161,7 +160,7 @@ public class AddServerOverlayld : UserControl, IServerOverlay version.DropDownContainer.BackgroundColor = version.BackgroundColor; version.OpenStatusChanged += b => { - BlockDraw = true; + AddBlockDraw(); if (b) { version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangleTop.png"); @@ -171,7 +170,7 @@ public class AddServerOverlayld : UserControl, IServerOverlay version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"); } - BlockDraw = false; + RemoveBlockDraw(); return Task.CompletedTask; }; @@ -520,7 +519,7 @@ public class AddServerOverlayld : UserControl, IServerOverlay btn.Clicked += BtnOnClicked; } - private async Task BtnOnClicked(IRenderObject arg) + private async Task BtnOnClicked(RenderObjectCore arg) { if (btn.Textures[0].handel == Globals.ms.TextureManager.GetTextureResource("BadTextbox.png").handel) return; @@ -596,7 +595,7 @@ public class AddServerOverlayld : UserControl, IServerOverlay private string pfp = ""; - private Task RecOnFilesDroped(IRenderObject obj, string[] arg) + private Task RecOnFilesDroped(RenderObjectCore obj, string[] arg) { Console.WriteLine(arg[0]); if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask; diff --git a/Luski/GUI/MainScreen/UI/Generic/Category.cs b/Luski/GUI/MainScreen/UI/Generic/Category.cs index 73f8a75..cc77d38 100644 --- a/Luski/GUI/MainScreen/UI/Generic/Category.cs +++ b/Luski/GUI/MainScreen/UI/Generic/Category.cs @@ -72,9 +72,9 @@ public class Category : UserControl, IChannelAdder private Category() { } - private async Task TmpOnClicked(IRenderObject arg) + private async Task TmpOnClicked(RenderObjectCore arg) { - BlockDraw = true; + AddBlockDraw(); if (!Extended) { DateTime dt = DateTime.UtcNow; @@ -83,7 +83,7 @@ public class Category : UserControl, IChannelAdder foreach (SocketChannel v in Channels) { Channel c = await AddChannel(v); - c.LoadToParent(Members, Window!); + // c.LoadToParent(Members, Window!); _ = CatOnAddY(c.Size.Y); } Console.WriteLine(DateTime.UtcNow - dt); @@ -93,7 +93,7 @@ public class Category : UserControl, IChannelAdder foreach (SocketCategory v in cats) { var c = await AddCategory(v, dt); - c.LoadToParent(Members, Window!); + //c.LoadToParent(Members, Window!); _ = CatOnAddY(c.Size.Y); } Console.WriteLine(DateTime.UtcNow - dt); @@ -106,8 +106,7 @@ public class Category : UserControl, IChannelAdder //Members.Controls.Clear(false); } - BlockDraw = false; - + RemoveBlockDraw(); Extended = !Extended; // Window!.ForceUpdate(new(Window.Size)); @@ -133,7 +132,7 @@ public class Category : UserControl, IChannelAdder } } - private Task AllOnClicked(IRenderObject arg) + private Task AllOnClicked(RenderObjectCore arg) { if (ClickCon is not null) _ = ClickCon.Invoke(this); return Task.CompletedTask; diff --git a/Luski/GUI/MainScreen/UI/Generic/Channel.cs b/Luski/GUI/MainScreen/UI/Generic/Channel.cs index 38eeb25..3a05e7e 100644 --- a/Luski/GUI/MainScreen/UI/Generic/Channel.cs +++ b/Luski/GUI/MainScreen/UI/Generic/Channel.cs @@ -89,7 +89,7 @@ public class Channel : UserControl bc = CS.BackgroundColor; } - BlockDraw = true; + AddBlockDraw(); Selected = !Selected; if (CS.Selected is not null && CS.Selected != this) @@ -118,7 +118,7 @@ public class Channel : UserControl else Globals.ms.ChatBoxArea.MessageFlow.ScrollToTop(); Console.WriteLine("Done"); } - BlockDraw = false; + RemoveBlockDraw(); TryDraw(); } catch (Exception e) @@ -137,20 +137,20 @@ public class Channel : UserControl return c; } - private Task EditChannelButtonOnClicked(IRenderObject arg) + private Task EditChannelButtonOnClicked(RenderObjectCore arg) { arg.ContextMenu!.HideContext(Window!); return Task.CompletedTask; } - private Task ExportKeysButtonOnClicked(IRenderObject arg) + private Task ExportKeysButtonOnClicked(RenderObjectCore arg) { //_ = CurrentChannel.SendKeysToUsers(CancellationToken.None); ContextMenu!.HideContext(Window!); return Task.CompletedTask; } - private async Task AllOnClicked(IRenderObject arg) + private async Task AllOnClicked(RenderObjectCore arg) { if (!Selected) await ToggleSelected(); //if (ClickCon is not null) _ = ClickCon.Invoke(this); diff --git a/Luski/GUI/MainScreen/UI/Generic/ChannelSelector.cs b/Luski/GUI/MainScreen/UI/Generic/ChannelSelector.cs index e1ff088..0e23a9a 100644 --- a/Luski/GUI/MainScreen/UI/Generic/ChannelSelector.cs +++ b/Luski/GUI/MainScreen/UI/Generic/ChannelSelector.cs @@ -1,5 +1,6 @@ using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.GUI.MainScreen.Interfaces; using Luski.GUI.MainScreen.UI.PublicServers; using Luski.net.Structures.Public; @@ -15,55 +16,6 @@ public class ChannelSelector : FlowLayout, IChannelAdder private readonly List LoadedChannels = new(); public Dictionary ChannelAdders = new(); public Channel? Selected; - - public override void ResizeDraw(int x, int y, int sx, int sy, int sw, int sh) - { - if (OldHeight == Size.Y) - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, Size.X, Size.Y, x, y); - } - else if (OldHeight < Size.Y) - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, OldWidth, OldHeight, x, y); - int nsh = sh - OldHeight+1; - if (nsh <= 0) return; - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, nsh); - DrawBase(); - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh); - - for (int i = 0; i < Controls.Length; i++) - { - if (!Controls[i].Loaded) - { - BlockDraw = true; - Controls[i].LoadToParent(this, Window!); - BlockDraw = false; - } - if (Controls[i].Location.X >= Size.X || - Controls[i].Location.Y >= Size.Y || - Controls[i].Location.X + Controls[i].Size.X < OldWidth || - Controls[i].Location.Y + Controls[i].Size.Y < OldHeight) continue; - - - if (Controls[i] is IParent pp) - { - pp.ResizeDraw(x,y,sx,sy,sw,sh); - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh); - } - else - { - Controls[i].Draw(x,y,sx,sy,sw,sh); - } - } - } - else - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, Size.X, Size.Y, x, y); - } - } public async Task LoadSelectorRoot(SocketCategory Cat) { @@ -89,13 +41,13 @@ public class ChannelSelector : FlowLayout, IChannelAdder } } - private async Task RLOnClicked(IRenderObject arg) + private async Task RLOnClicked(RenderObjectCore arg) { Globals.ms.Controls.Add(new AddChannel(this, CurrentCategory)); TryDraw(); } - private async Task LOnClicked(IRenderObject arg) + private async Task LOnClicked(RenderObjectCore arg) { Globals.ms.Controls.Add(new AddChannel(this, CurrentCategory)); TryDraw(); diff --git a/Luski/GUI/MainScreen/UI/Generic/LuskiFlow.cs b/Luski/GUI/MainScreen/UI/Generic/LuskiFlow.cs index 37ab153..f7925c5 100644 --- a/Luski/GUI/MainScreen/UI/Generic/LuskiFlow.cs +++ b/Luski/GUI/MainScreen/UI/Generic/LuskiFlow.cs @@ -1,6 +1,7 @@ using GraphicsManager.Enums; using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using OpenTK.Mathematics; namespace Luski.GUI.MainScreen.UI.Generic; @@ -9,7 +10,7 @@ public class LuskiFlow : FlowLayout { public override void ParentResize() { - BlockDraw = true; + AddBlockDraw(); for (int i = 0; i < Controls.Length; i++) { if (Controls[i] is IParent parent) @@ -18,12 +19,12 @@ public class LuskiFlow : FlowLayout } } if (Parent is not null) Parent.TryDraw(); - BlockDraw = false; + RemoveBlockDraw(); } - 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) { @@ -42,6 +43,6 @@ public class LuskiFlow : FlowLayout { ForceScrollUpdate(); } - BlockDraw = false; + RemoveBlockDraw(); } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/Generic/MessageFlow.cs b/Luski/GUI/MainScreen/UI/Generic/MessageFlow.cs index 1bc8897..cf1d2ed 100644 --- a/Luski/GUI/MainScreen/UI/Generic/MessageFlow.cs +++ b/Luski/GUI/MainScreen/UI/Generic/MessageFlow.cs @@ -6,60 +6,4 @@ namespace Luski.GUI.MainScreen.UI.Generic; public class MessageFlow : LuskiFlow { - public override void ResizeDraw(int x, int y, int sx, int sy, int sw, int sh) - { - if (LuskiExperiments.GUI.LiveLabelSize.IsEnabled()) - { - if (OldHeight == Size.Y) - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, Size.X, Size.Y, x, y); - } - else if (OldHeight < Size.Y && OldWidth < Size.X) - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, OldWidth, OldHeight, x, y); - int nsh = sh - OldHeight+1; - if (nsh <= 0) return; - int nsw = sw - OldWidth+1; - if (nsw <= 0) return; - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, nsh); - DrawBase(); - GL.Scissor(sx, Window!.CS.Y - sy - sh, nsw, sh); - DrawBase(); - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh); - - for (int i = 0; i < Controls.Length; i++) - { - if (!Controls[i].Loaded) - { - BlockDraw = true; - Controls[i].LoadToParent(this, Window!); - BlockDraw = false; - } - if (Controls[i].Location.X >= Size.X || - Controls[i].Location.Y >= Size.Y || - Controls[i].Location.X + Controls[i].Size.X < OldWidth || - Controls[i].Location.Y + Controls[i].Size.Y < OldHeight) continue; - - - if (Controls[i] is IParent pp) - { - pp.ResizeDraw(x,y,sx,sy,sw,sh); - GL.Scissor(sx, Window!.CS.Y - sy - sh, sw, sh); - } - else - { - Controls[i].Draw(x,y,sx,sy,sw,sh); - } - } - } - else - { - if (!UpdateScissorBox(ref x, ref y, ref sx, ref sy, ref sw, ref sh)) return; - Window!.CopyFromFrontToBack(x, y, Size.X, Size.Y, x, y); - } - } - else base.ResizeDraw(x,y,sx,sy,sw,sh); - } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs b/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs index f9daa15..47644c9 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs @@ -1,5 +1,6 @@ using GraphicsManager.Interfaces; using GraphicsManager.Objects.Core; +using GraphicsManager.Objects.Core.Fonts; using GraphicsManager.Structs; using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; @@ -8,9 +9,18 @@ namespace Luski.GUI.MainScreen.UI.LuskiControls; public class AdvancedGradientLabel : LabelBase { - public AdvancedGradientLabel(FontInteraction fi) : base(fi) { } + public AdvancedGradientLabel(FontInteraction fi) : base(fi) + { + WindowLoaded += OnWindowLoaded; + } - public Color4[] Colors { get; set; } = new[] + private Task OnWindowLoaded(RenderObjectCore arg) + { + Shader = Globals.GradientShader[Window!.Context]; + return Task.CompletedTask; + } + + public Color4[] Colors { get; set; } = new[] { new Color4(255, 255, 255, 255), new Color4(255, 255, 255, 255) @@ -41,14 +51,7 @@ public class AdvancedGradientLabel : LabelBase return new Color4(r, g, b, a); } - public override void LoadToParent(IParent window, IWindow win) - { - if (Loaded) return; - if (Shader is null) Shader = Globals.GradientShader[win.Context]; - base.LoadToParent(window, win); - } - - 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 && Colors.Length > 1) { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/BasicGradientLabel.cs b/Luski/GUI/MainScreen/UI/LuskiControls/BasicGradientLabel.cs index b4b1d94..6f8887f 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/BasicGradientLabel.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/BasicGradientLabel.cs @@ -1,6 +1,7 @@ using GraphicsManager.Interfaces; using GraphicsManager.Objects; using GraphicsManager.Objects.Core; +using GraphicsManager.Objects.Core.Fonts; using GraphicsManager.Structs; using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/CenterFullScreenBase.cs b/Luski/GUI/MainScreen/UI/LuskiControls/CenterFullScreenBase.cs index d25bdbd..683fee7 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/CenterFullScreenBase.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/CenterFullScreenBase.cs @@ -1,13 +1,13 @@ using GraphicsManager.Enums; -using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; namespace Luski.GUI.MainScreen.UI.LuskiControls; public class CenterFullScreenBase : UserControl { - private IRenderObject centerobj; - public CenterFullScreenBase(IRenderObject obj, bool Streach = false) + private RenderObjectCore centerobj; + public CenterFullScreenBase(RenderObjectCore obj, bool Streach = false) { centerobj = obj; if (!Streach) obj.Anchor = ObjectAnchor.Prevent; @@ -15,13 +15,14 @@ public class CenterFullScreenBase : UserControl Controls.Add(obj); base.BackgroundColor = new(0, 0, 0, 130); Anchor = ObjectAnchor.All; + WindowLoaded += OnWindowLoaded; } - public override void LoadToParent(IParent p, IWindow w) + private Task OnWindowLoaded(RenderObjectCore arg) { - base.SetSize(w.CS.X, w.CS.Y); - centerobj.SetLocation((w.CS.X - centerobj.Size.X)/2, (w.CS.Y - centerobj.Size.Y)/2); + base.SetSize(Window!.CS.X, Window!.CS.Y); + centerobj.SetLocation((Window!.CS.X - centerobj.Size.X)/2, (Window!.CS.Y - centerobj.Size.Y)/2); centerobj.ForceDistanceUpdate(this); - base.LoadToParent(p, w); + return Task.CompletedTask; } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/CompressedFlow.cs b/Luski/GUI/MainScreen/UI/LuskiControls/CompressedFlow.cs index c8a588a..ee4e3ce 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/CompressedFlow.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/CompressedFlow.cs @@ -1,5 +1,6 @@ using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.GUI.MainScreen.UI.PublicServers; using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; @@ -17,14 +18,14 @@ public class CompressedFlow : UserControl ChildPadding = new(Padding.X); } - public event Func? SizeUpdateNotIgnored; + public event Func? SizeUpdateNotIgnored; public Vector4i Padding { get; set; } public Vector2i ChildPadding { get; set; } private bool IgnoreNextSizeChange; - private Task OnSizeChanged(IRenderObject arg) + private Task OnSizeChanged(RenderObjectCore arg) { if (IgnoreNextSizeChange) { @@ -41,7 +42,7 @@ public class CompressedFlow : UserControl return Task.CompletedTask; } - private Task ControlsOnControlAdded(int arg1, IRenderObject arg2) + private Task ControlsOnControlAdded(int arg1, RenderObjectCore arg2) { if (arg1 != 0) { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs b/Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs index 45e7f7f..2025db1 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs @@ -23,44 +23,12 @@ public class DropDown : UserControl where TSelection : DropDownOptio set { ip = value; - DropDownContainer.TransferOwners(Globals.ms, value); + DropDownContainer.TransferOwners(Globals.RootWindow, value); } } private bool IsOpen; public event Func? OpenStatusChanged; - - public DropDown(TSelection defaultOption) - { - ip = this; - DropDownContainer = new() - { - Visible = false - }; - Clicked += OnClicked; - WindowLoaded += OnWindowLoaded; - AddOption(defaultOption); - SelectedOption = defaultOption; - } - public DropDown(Texture t, TSelection defaultOption) - :base(t) - { - ip = this; - TextureDisplay = TextureDisplay.HorizontalCenter; - DropDownContainer = new() - { - Visible = false, - Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right - }; - Clicked += OnClicked; - WindowLoaded += OnWindowLoaded; - DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + defaultOption.Size.Y); - DropDownContainer.Controls.Add(defaultOption); - defaultOption.Clicked += OptionOnClicked; - Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context]; - SelectedOption = defaultOption; - } - public void SetSelected(TSelection obj) { SelectedOption = obj; @@ -68,11 +36,11 @@ public class DropDown : UserControl where TSelection : DropDownOptio obj.LoadDisplay.Invoke(); } - public DropDown(Texture t, IRenderObject spacer, TSelection defaultOption) - :base(t) + public DropDown(Texture? InitTexture = null, RenderObjectCore? spacer = null, TSelection? defaultOption = null) + :base(InitTexture) { ip = this; - TextureDisplay = TextureDisplay.HorizontalCenter; + if (InitTexture is not null) TextureDisplay = TextureDisplay.HorizontalCenter; DropDownContainer = new() { Visible = false, @@ -80,35 +48,24 @@ public class DropDown : UserControl where TSelection : DropDownOptio }; Clicked += OnClicked; WindowLoaded += OnWindowLoaded; - DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + spacer.Size.Y); - DropDownContainer.Controls.Add(spacer); - DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + defaultOption.Size.Y); - DropDownContainer.Controls.Add(defaultOption); - defaultOption.Clicked += OptionOnClicked; - Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context]; - SelectedOption = defaultOption; - } - - public DropDown(Texture t, IRenderObject spacer) - :base(t) - { - ip = this; - TextureDisplay = TextureDisplay.HorizontalCenter; - DropDownContainer = new() + if (spacer is not null) { - Visible = false, - Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right - }; - Clicked += OnClicked; - WindowLoaded += OnWindowLoaded; - DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + spacer.Size.Y); - DropDownContainer.Controls.Add(spacer); - Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context]; + DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + spacer.Size.Y); + DropDownContainer.Controls.Add(spacer); + } + + if (defaultOption is not null) + { + AddOption(defaultOption); + SelectedOption = defaultOption; + } + + if (InitTexture is not null) Shader = Rectangle.DefaultAlphaShader[Globals.RootWindow.Context]; } public TSelection SelectedOption { get; private set; } - private Task OnWindowLoaded(IRenderObject arg) + private Task OnWindowLoaded(RenderObjectCore arg) { SelectedOption.LoadDisplay.Invoke(); Window!.MouseDown += WindowOnMouseDown; @@ -117,7 +74,7 @@ public class DropDown : UserControl where TSelection : DropDownOptio private void WindowOnMouseDown(MouseButtonEventArgs obj) { - if (IsOpen && !MouseInside) + if (IsOpen && !MouseInsidePath) { IsOpen = false; DropDownContainer.Visible = IsOpen; @@ -126,15 +83,15 @@ public class DropDown : UserControl where TSelection : DropDownOptio } } - private Task OnClicked(IRenderObject arg) + private Task OnClicked(RenderObjectCore arg) { - BlockDraw = true; + AddBlockDraw(); if (IsOpen) { IsOpen = false; DropDownContainer.Visible = IsOpen; if (OpenStatusChanged is not null) OpenStatusChanged.Invoke(IsOpen); - BlockDraw = false; + RemoveBlockDraw(); TryDraw(); return Task.CompletedTask; } @@ -149,7 +106,7 @@ public class DropDown : UserControl where TSelection : DropDownOptio DropDownContainer.Controls[0].Location = new(0); DropDownParentOverride.Controls.MoveControlToEnd(DropDownContainer); if (OpenStatusChanged is not null) OpenStatusChanged.Invoke(IsOpen); - BlockDraw = false; + RemoveBlockDraw(); TryDraw(); return Task.CompletedTask; } @@ -163,7 +120,7 @@ public class DropDown : UserControl where TSelection : DropDownOptio public event Func? OptionSelected; - private Task OptionOnClicked(IRenderObject arg) + private Task OptionOnClicked(RenderObjectCore arg) { try { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs b/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs index f37863b..64d704e 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs @@ -2,8 +2,8 @@ using System.Diagnostics; using System.Text; using GraphicsManager.Enums; using GraphicsManager.Interfaces; -using GraphicsManager.Objects; using GraphicsManager.Objects.Core; +using GraphicsManager.Objects.Core.Fonts; using GraphicsManager.Structs; using Luski.Enums; using Luski.net.Structures.Public; @@ -16,15 +16,19 @@ namespace Luski.GUI.MainScreen.UI.LuskiControls; public class LuskiLabel : LabelBase { public LuskiLabel() : this(Globals.DefaultFont) { } - public LuskiLabel(FontInteraction fi) : base(fi) { } - public Color4 DefaultColor { get; set; } = Color4.White; - - public override void LoadToParent(IParent window, IWindow win) + + public LuskiLabel(FontInteraction fi) : base(fi) { - if (Loaded) return; - if (Shader is null) Shader = Globals.GradientShader[win.Context]; - base.LoadToParent(window, win); + WindowLoaded += OnWindowLoaded; } + + private Task OnWindowLoaded(RenderObjectCore arg) + { + if (Shader is null) Shader = Globals.GradientShader[Window!.Context]; + return Task.CompletedTask; + } + + public Color4 DefaultColor { get; set; } = Color4.White; float _alpha = 1; protected virtual (Color4,Color4) getGradcols(int Start, int charter, int End, int StartLine, int Line, int EndLine, GradType GT, Color4[] Colors) { @@ -563,7 +567,7 @@ public class LuskiLabel : LabelBase private List Links = new(); - public override void Draw(int x, int y, int sx, int sy, int sw, int sh) + public override void DrawSelf() { if (Visible && Loaded) { @@ -578,7 +582,9 @@ public class LuskiLabel : LabelBase float angle_rad = (float)Math.Atan2(DIR.Y, DIR.X); Matrix4 rotateM = Matrix4.CreateRotationZ(angle_rad); - Matrix4 transOriginM = Matrix4.CreateTranslation(new Vector3(loc_.X + Parent!.IntToWindow(0), loc_.Y + (MaxLineSizes[0].Item1.Y * Scale) + Parent!.IntToWindow(0, true), 0f)); + int y = 0; + if (MaxLineSizes is not null && MaxLineSizes.Count > 0) y = MaxLineSizes[0].Item1.Y; + Matrix4 transOriginM = Matrix4.CreateTranslation(new Vector3(loc_.X + Parent!.IntToWindow(0), loc_.Y + (y * Scale) + Parent!.IntToWindow(0, true), 0f)); float char_x = 0.0f; Matrix4 staticTransform = rotateM * transOriginM; GL.UniformMatrix4(Shader.GetUniformLocation("model"), false, ref staticTransform); diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/MessageCompressedFlow.cs b/Luski/GUI/MainScreen/UI/LuskiControls/MessageCompressedFlow.cs index ad05285..640640e 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/MessageCompressedFlow.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/MessageCompressedFlow.cs @@ -1,6 +1,7 @@ using GraphicsManager.Enums; using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using OpenTK.Mathematics; namespace Luski.GUI.MainScreen.UI.LuskiControls; @@ -17,11 +18,11 @@ public class MessageCompressedFlow : UserControl public Vector4i WallSpacing { get; set; } - public event Func? SizeUpdateNotIgnored; + public event Func? SizeUpdateNotIgnored; private bool IgnoreNextSizeChange; - private Task OnSizeChanged(IRenderObject arg) + private Task OnSizeChanged(RenderObjectCore arg) { if (IgnoreNextSizeChange) { @@ -38,7 +39,7 @@ public class MessageCompressedFlow : UserControl return Task.CompletedTask; } - private Task ControlsOnControlAdded(int arg1, IRenderObject arg2) + private Task ControlsOnControlAdded(int arg1, RenderObjectCore arg2) { if (arg1 != 0) { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/NumberSelector.cs b/Luski/GUI/MainScreen/UI/LuskiControls/NumberSelector.cs index 5200168..79baf20 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/NumberSelector.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/NumberSelector.cs @@ -2,6 +2,7 @@ using System.Numerics; using GraphicsManager.Enums; using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.Enums; using OpenTK.Mathematics; using OpenTK.Windowing.Common; @@ -61,7 +62,9 @@ public class NumberSelector : UserControl where TNumber : INumber : UserControl where TNumber : INumber : UserControl where TNumber : INumber L1.Location.X + L1.Size.X; + L2Default.Visible = value != Default; + RemoveBlockDraw(); progressBar.UpdateProgress(); - if (Loaded && ValueChanged is not null) ValueChanged.Invoke(this); + if (Loaded && BlockEvents == 0 && ValueChanged is not null) ValueChanged.Invoke(this); } } public bool LockToPoints { get; set; } = false; @@ -130,8 +136,8 @@ public class NumberSelector : UserControl where TNumber : INumber : UserControl where TNumber : INumber : UserControl where TNumber : INumber LocalDisabled; + set + { + if (LocalDisabled == value) return; + LocalDisabled = value; + AddBlockDraw(); + if (value) + { + progressBar.ProgressColor = DisabledFillColorL; + progressBar.BackgroundColor = DisabledBackColorL; + RemoveBlockDraw(); + Cursor.BackgroundColor = DisabledCursorColorL; + return; + } + + progressBar.ProgressColor = FillColorL; + progressBar.BackgroundColor = BackColorL; + RemoveBlockDraw(); + Cursor.BackgroundColor = CursorColorL; + } + } + + public Color4 CursorColor + { + get => CursorColorL; + set + { + if (CursorColorL == value) return; + CursorColorL = value; + if (Disabled) return; + Cursor.BackgroundColor = value; + } + } + + public Color4 DisabledCursorColor + { + get => DisabledCursorColorL; + set + { + if (DisabledCursorColorL == value) return; + DisabledCursorColorL = value; + if (!Disabled) return; + Cursor.BackgroundColor = value; + } } - private Task ProgressBarOnClicked(IRenderObject arg) + public Color4 FillColor { + get => FillColorL; + set + { + if (FillColorL == value) return; + FillColorL = value; + if (Disabled) return; + progressBar.ProgressColor = value; + } + } + + public Color4 DisabledFillColor + { + get => DisabledFillColorL; + set + { + if (DisabledFillColorL == value) return; + DisabledFillColorL = value; + if (!Disabled) return; + progressBar.ProgressColor = value; + } + } + + public Color4 BackColor + { + get => BackColorL; + set + { + if (BackColorL == value) return; + BackColorL = value; + if (Disabled) return; + progressBar.BackgroundColor = value; + } + } + + public Color4 DisabledBackColor + { + get => DisabledBackColorL; + set + { + if (DisabledBackColorL == value) return; + DisabledBackColorL = value; + if (!Disabled) return; + progressBar.BackgroundColor = value; + } + } + + private Task OnWindowLoaded(RenderObjectCore arg) + { + Window!.MouseUp += WindowOnMouseUp; + Window!.MouseMove += WindowOnMouseMove; + Cursor.Clicked += CursorOnClicked; + return Task.CompletedTask; + } + + private Task ProgressBarOnClicked(RenderObjectCore arg) + { + if (Disabled) return Task.CompletedTask; Value = progressBar.GetValueFromX((int)Window!.MousePosition.X - progressBar.GetWindowLocation().X) + Min; return Task.CompletedTask; } @@ -180,32 +295,30 @@ public class NumberSelector : UserControl where TNumber : INumber : UserControl where TNumber : INumber : UserControl where TNumber : INumber : UserControl where TSettingsMenu : public PageTab AddPage(TPage Page) where TPage : ISettingsPage { - Page.Location = new(ss.fl.Size.X + 40.ScaleInt(), 0); - Page.Size = new(Globals.ms.CS.X - ss.fl.Size.X - 80.ScaleInt(), Globals.ms.CS.Y); - Page.AllowHoverFromBehind = true; - Page.Anchor = ObjectAnchor.All; + RenderObjectCore roc = (Page as RenderObjectCore)!; + roc.Location = new(ss.fl.Size.X + 40.ScaleInt(), 0); + roc.Size = new(Globals.RootWindow.CS.X - ss.fl.Size.X - 80.ScaleInt(), Globals.RootWindow.CS.Y); + //roc.AllowHoverFromBehind = true; + roc.Anchor = ObjectAnchor.All; Page.BackgroundColor = ss.BackgroundColor; pagest.Add(typeof(TPage)); pages.Add(Page.PageName); - ss.Controls.Add(Page); + ss.Controls.Add(roc); if (Page is PageFlow pbf) pbf.HScrollPixels = Globals.Settings.PerScrollPixels; PageTab cb = new(Page.PageName, ss) { - Page = Page + Page = roc }; Controls.Add(cb); int f = 5.ScaleInt(); cb.Location = new (line.Location.X + f, line.Location.Y - f); line.Location = new(line.Location.X, line.Location.Y + cb.Size.Y + f); Size = new(Size.X, Size.Y + cb.Size.Y + f); - Page.Tag = cb; + roc.Tag = cb; return cb; } @@ -81,7 +83,7 @@ public class SettingsCategory : UserControl where TSettingsMenu : return pagest.Contains(name); } - public void RemovePage(TPage Page) where TPage : ISettingsPage + public void RemovePage(TPage Page) where TPage : RenderObjectCore, ISettingsPage { if (Page.Tag is PageTab cb) { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/SettingsMenuBase/SettingsMenu.cs b/Luski/GUI/MainScreen/UI/LuskiControls/SettingsMenuBase/SettingsMenu.cs index a424d24..3e33af7 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/SettingsMenuBase/SettingsMenu.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/SettingsMenuBase/SettingsMenu.cs @@ -1,6 +1,7 @@ using GraphicsManager.Enums; using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core; using OpenTK.Mathematics; @@ -15,9 +16,9 @@ public class SettingsMenu : UserControl public SettingsMenu(string Name) { base.BackgroundColor = new(34, 34, 34, 255); - base.Size = Globals.ms.ClientSize; - BehindName = Globals.ms.Title; - Globals.ms.Title = Name; + base.Size = Globals.RootWindow.ClientSize; + BehindName = Globals.RootWindow.Title; + Globals.RootWindow.Title = Name; fl = new() { BackgroundColor = new(20, 20, 20, 255), @@ -26,11 +27,11 @@ public class SettingsMenu : UserControl }; Anchor = ObjectAnchor.All; Controls.Add(fl); - Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png")) + Rectangle closebtn = new(Globals.RootWindow.TextureManager.GetTextureResource("close.png")) { - Location = new(Globals.ms.ClientSize.X - 40.ScaleInt(), 8.ScaleInt()), + Location = new(Globals.RootWindow.ClientSize.X - 40.ScaleInt(), 8.ScaleInt()), Size = new(32.ScaleInt()), - Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context], + Shader = Rectangle.DefaultAlphaShader[Globals.RootWindow.Context], BackgroundColor = Color4.Gray, Anchor = ObjectAnchor.Top | ObjectAnchor.Right }; @@ -41,11 +42,11 @@ public class SettingsMenu : UserControl }; closebtn.MouseLeave += _ => { - if (bl) BlockDraw = true; + if (bl) AddBlockDraw(); closebtn.BackgroundColor = Color4.Gray; if (bl) { - BlockDraw = false; + RemoveBlockDraw(); bl = false; } return Task.CompletedTask; @@ -57,12 +58,12 @@ public class SettingsMenu : UserControl private bool bl; - private Task ClosebtnOnClicked(IRenderObject arg) + private Task ClosebtnOnClicked(RenderObjectCore arg) { bl = true; - Globals.ms.Controls.Remove(this, false); - Globals.ms.Title = BehindName; - Globals.ms.DrawFrame(); + Globals.RootWindow.Controls.Remove(this, false); + Globals.RootWindow.Title = BehindName; + Globals.RootWindow.DrawFrame(); return Task.CompletedTask; } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs b/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs index fb6c2c4..e842baf 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs @@ -1,37 +1,38 @@ using System.Timers; using GraphicsManager.Enums; -using GraphicsManager.Interfaces; using GraphicsManager.Objects; using GraphicsManager.Objects.Core; +using GraphicsManager.Objects.Core.Fonts; using OpenTK.Mathematics; using OpenTK.Windowing.Common; using OpenTK.Windowing.Common.Input; using OpenTK.Windowing.GraphicsLibraryFramework; +using Rectangle = GraphicsManager.Objects.Core.Rectangle; using Timer = System.Timers.Timer; namespace Luski.GUI.MainScreen.UI.LuskiControls; public class TextBox : UserControl { - private Label _watermark, _label; - private bool use; - private Rectangle Pointer; - private Timer t; + private readonly Label BackWatermark; + private readonly Label BackLabel; + private readonly Rectangle Pointer; + private readonly Timer t; public int CursorLocation { get; set; } - public TextBox(string defaul = "Textbox.png") - :base(Globals.ms.TextureManager.GetTextureResource(defaul)) + public TextBox(string DefaultTexture = "Textbox.png") + :base(Globals.RootWindow.TextureManager.GetTextureResource(DefaultTexture)) { t = new(500); t.Elapsed += TOnElapsed; - TextureDisplay = TextureDisplay.Center; - _label = new Label(Globals.DefaultFont) + base.TextureDisplay = TextureDisplay.Center; + BackLabel = new Label(Globals.DefaultFont) { HoverMouse = MouseCursor.IBeam, IgnoreHover = true }; - _watermark = new(_label.Font) + BackWatermark = new(BackLabel.Font) { Text = "Text Box", Color = new(128, 128, 128, 255), @@ -41,8 +42,8 @@ public class TextBox : UserControl Pointer = new() { Size = new(1.ScaleInt(), - (int)_label.LineHeight ), - Location = _watermark.Location, + (int)BackLabel.LineHeight ), + Location = BackWatermark.Location, BackgroundColor = Color4.White, Visible = false, IgnoreHover = true @@ -50,13 +51,20 @@ public class TextBox : UserControl IgnoreVisForChildren = true; Controls.Add(Pointer); - Controls.Add(_label); - Controls.Add(_watermark); + Controls.Add(BackLabel); + Controls.Add(BackWatermark); + WindowLoaded += OnWindowLoaded; } - private void TOnElapsed(object? sender, ElapsedEventArgs e) + private Task OnWindowLoaded(RenderObjectCore _) { - Globals.ms.Invoke(() => + Pointer.Location = BackWatermark.Location; + return Task.CompletedTask; + } + + private void TOnElapsed(object? _, ElapsedEventArgs __) + { + Globals.RootWindow.Invoke(() => { Pointer.Visible = !Pointer.Visible; }); @@ -68,47 +76,27 @@ public class TextBox : UserControl public override void UnFocus() { - use = false; + base.UnFocus(); t.Stop(); Pointer.Visible = false; - if (Window is not null && Window.focused == this) - Window.focused = null; } public override void Focus() { - if (Window is not null) - { - if (Window.focused is not null) - { - Window.focused.UnFocus(); - } - t.Start(); - - Window.focused = this; - use = true; - } - } - - public override void LoadToParent(IParent parent, IWindow window) - { - if (Loaded) return; - window.MouseDown += Window_MouseDown; - if (!window.Context.IsCurrent) window.Context.MakeCurrent(); - base.LoadToParent(parent, window); - Pointer.Location = _watermark.Location; + base.Focus(); + if (Window is null) return; + t.Start(); } public override void SendClipEvent(string ClipString) { base.SendClipEvent(ClipString); - if (!use) return; try { Text = Text.Insert(CursorLocation, ClipString); CursorLocation += ClipString.Length; - Vector2i f = _label.GetCharLocation(CursorLocation); - Pointer.Location = _label.Location + new Vector2i(f.X, f.Y); + Vector2i f = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = BackLabel.Location + new Vector2i(f.X, f.Y); Pointer.Visible = true; if (LetterPress is not null) LetterPress.Invoke().Wait(); } @@ -118,7 +106,7 @@ public class TextBox : UserControl } } - public char? PasswordChar { get => _label.PasswordChar; set => _label.PasswordChar = value; } + public char? PasswordChar { get => BackLabel.PasswordChar; set => BackLabel.PasswordChar = value; } private TextLocation tl = TextLocation.TopLeft; @@ -130,23 +118,23 @@ public class TextBox : UserControl tl = value; if (!string.IsNullOrWhiteSpace(Text)) { - _label.Location = value switch + BackLabel.Location = value switch { TextLocation.LineCenter => new(10.ScaleInt(), - ((Size.Y - _label.Size.Y) / 2)), - _ => _label.Location + ((Size.Y - BackLabel.Size.Y) / 2)), + _ => BackLabel.Location }; - _watermark.Location = _label.Location; + BackWatermark.Location = BackLabel.Location; } else { - _watermark.Location = value switch + BackWatermark.Location = value switch { TextLocation.LineCenter => new(10.ScaleInt(), - ((Size.Y - _watermark.Size.Y) / 2)), - _ => _watermark.Location + ((Size.Y - BackWatermark.Size.Y) / 2)), + _ => BackWatermark.Location }; - _label.Location = _watermark.Location; + BackLabel.Location = BackWatermark.Location; } } } @@ -159,53 +147,53 @@ public class TextBox : UserControl if (value == base.Visible) return; if (value) { - if (!string.IsNullOrEmpty(_label.Text)) + if (!string.IsNullOrEmpty(BackLabel.Text)) { - _label.Visible = true; - _watermark.Visible = false; + BackLabel.Visible = true; + BackWatermark.Visible = false; } else { - _label.Visible = false; - _watermark.Visible = true; + BackLabel.Visible = false; + BackWatermark.Visible = true; } } else { - _label.Visible = value; - _watermark.Visible = value; + BackLabel.Visible = value; + BackWatermark.Visible = value; } base.Visible = value; } } - public FontInteraction Font { get => _label.Font; } - public FontInteraction WatermarkFont { get => _watermark.Font; } + public FontInteraction Font { get => BackLabel.Font; } + public FontInteraction WatermarkFont { get => BackWatermark.Font; } - public Color4 TextColor { get => _label.Color; set => _label.Color = value; } - public Color4 WatermarkColor { get => _watermark.Color; set => _watermark.Color = value; } + public Color4 TextColor { get => BackLabel.Color; set => BackLabel.Color = value; } + public Color4 WatermarkColor { get => BackWatermark.Color; set => BackWatermark.Color = value; } public bool AllowMultiLine { get; set; } = true; public string Text { - get => _label.Text; + get => BackLabel.Text; set { - int old = _label.Size.Y; - _label.Text = value; + int old = BackLabel.Size.Y; + BackLabel.Text = value; if (!string.IsNullOrEmpty(value)) { bool f = false; - if (!_label.Visible) + if (!BackLabel.Visible) { f = true; - _label.Visible = true; - _label.Location = TextLocation switch + BackLabel.Visible = true; + BackLabel.Location = TextLocation switch { - TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - _label.Size.Y) / 2)), - _ => _label.Location + TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - BackLabel.Size.Y) / 2)), + _ => BackLabel.Location }; /* _label.Location = TextLocation switch @@ -215,43 +203,35 @@ public class TextBox : UserControl TextLocation.PxLeft => new(Location.X + 5, Location.Y + ((Size.Y - _label.Size.Y) / 2), Location.Z), _ => new(Location.X + 5, Location.Y + 5, Location.Z) };*/ - _watermark.Location = _label.Location; + BackWatermark.Location = BackLabel.Location; } - if (_watermark.Visible) _watermark.Visible = false; - if (!f && TextLocation == TextLocation.LineCenter && old != _label.Size.Y) + if (BackWatermark.Visible) BackWatermark.Visible = false; + if (!f && TextLocation == TextLocation.LineCenter && old != BackLabel.Size.Y) { //_label.Location = new(Location.X + 5, Location.Y + ((Size.Y - _label.TrueHeight) / 2) - (_label.Size.Y - _label.TrueHeight), Location.Z); - _watermark.Location = _label.Location; + BackWatermark.Location = BackLabel.Location; } } else { - if (_label.Visible) _label.Visible = false; - if (!_watermark.Visible) + if (BackLabel.Visible) BackLabel.Visible = false; + if (!BackWatermark.Visible) { - _watermark.Visible = true; - _watermark.Location = TextLocation switch + BackWatermark.Visible = true; + BackWatermark.Location = TextLocation switch { - TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - _watermark.Size.Y) / 2)), - _ => _watermark.Location + TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - BackWatermark.Size.Y) / 2)), + _ => BackWatermark.Location }; - /* - _watermark.Location = TextLocation switch - { - TextLocation.TrueCenterLeft => new(Location.X + 5, Location.Y + ((Size.Y - _watermark.TrueHeight) / 2) - (_watermark.Size.Y - _watermark.TrueHeight), Location.Z), - TextLocation.PostiveTureCenterLeft => new(Location.X + 5, Location.Y + ((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z), - TextLocation.PxLeft => new(Location.X + 5, Location.Y + ((Size.Y - _watermark.Size.Y) / 2), Location.Z), - _ => new(Location.X + 5, Location.Y + 5, Location.Z) - };*/ - _label.Location = _label.Location; + BackLabel.Location = BackLabel.Location; } } - if (_label.Text.Length < CursorLocation) + if (BackLabel.Text.Length < CursorLocation) { - CursorLocation = _label.Text.Length; - var xy = _label.GetCharLocation(CursorLocation); - Pointer.Location = new(_label.Location.X + xy.X, _label.Location.Y + xy.Y); + CursorLocation = BackLabel.Text.Length; + var xy = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = new(BackLabel.Location.X + xy.X, BackLabel.Location.Y + xy.Y); } } } @@ -259,14 +239,14 @@ public class TextBox : UserControl { get { - return _watermark.Text; + return BackWatermark.Text; } set { - _watermark.Text = value; + BackWatermark.Text = value; if (string.IsNullOrEmpty(Text)) { - Pointer.Location = _label.Location; + Pointer.Location = BackLabel.Location; } } } @@ -277,35 +257,34 @@ public class TextBox : UserControl public override void SendKeyEvent(KeyboardKeyEventArgs KeyArgs) { base.SendKeyEvent(KeyArgs); - if (!use) return; if (KeyArgs.Key == Keys.Left && CursorLocation != 0) { CursorLocation--; - var f = _label.GetCharLocation(CursorLocation); - Pointer.Location = _label.Location + new Vector2i(f.X, f.Y); + var f = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = BackLabel.Location + new Vector2i(f.X, f.Y); Pointer.Visible = true; } if (KeyArgs.Key == Keys.Right && CursorLocation != Text.Length) { CursorLocation++; - var f = _label.GetCharLocation(CursorLocation); - Pointer.Location = _label.Location + new Vector2i(f.X, f.Y); + var f = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = BackLabel.Location + new Vector2i(f.X, f.Y); Pointer.Visible = true; } - if (KeyArgs.Key == Keys.CapsLock || KeyArgs.Key == Keys.Menu || KeyArgs.Key == Keys.LeftSuper || KeyArgs.Key == Keys.RightSuper || KeyArgs.Key == Keys.End || KeyArgs.Key == Keys.Home || KeyArgs.Key == Keys.PageDown || KeyArgs.Key == Keys.PageUp || KeyArgs.Key == Keys.Insert || KeyArgs.Key == Keys.Up || KeyArgs.Key == Keys.Down || KeyArgs.Key == Keys.Left || KeyArgs.Key == Keys.Right) return; + if (KeyArgs.Key is Keys.CapsLock or Keys.Menu or Keys.LeftSuper or Keys.RightSuper or Keys.End or Keys.Home or Keys.PageDown or Keys.PageUp or Keys.Insert or Keys.Up or Keys.Down or Keys.Left or Keys.Right) return; if (KeyArgs.Key == Keys.Backspace) { if (!(Text.Length > 0)) return; if (Text[CursorLocation- 1] == '\n') { - Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight); + Size = new(Size.X, Size.Y - (int)BackLabel.Font.PixelHeight); if (OnRemoveLine is not null) OnRemoveLine.Invoke().Wait(); } CursorLocation--; Text = Text.Remove(CursorLocation, 1); if (LetterRemoved is not null) LetterRemoved.Invoke().Wait(); - var f = _label.GetCharLocation(CursorLocation); - Pointer.Location = _label.Location + new Vector2i(f.X, f.Y); + var f = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = BackLabel.Location + new Vector2i(f.X, f.Y); Pointer.Visible = true; } if (KeyArgs.Key == Keys.Delete) @@ -313,7 +292,7 @@ public class TextBox : UserControl if (CursorLocation == Text.Length) return; if (Text[CursorLocation] == '\n') { - Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight); + Size = new(Size.X, Size.Y - (int)BackLabel.Font.PixelHeight); if (OnRemoveLine is not null) OnRemoveLine.Invoke().Wait(); } Text = Text.Remove(CursorLocation, 1); @@ -324,14 +303,14 @@ public class TextBox : UserControl { if (AllowMultiLine && KeyArgs.Shift) { - BlockDraw = true; - Size = new(Size.X, Size.Y + (int)_label.Font.PixelHeight); + AddBlockDraw(); + Size = new(Size.X, Size.Y + (int)BackLabel.Font.PixelHeight); if (OnNewLine is not null) OnNewLine.Invoke().Wait(); - BlockDraw = false; + RemoveBlockDraw(); Text += '\n'; CursorLocation++; - var f = _label.GetCharLocation(CursorLocation); - Pointer.Location = _label.Location + new Vector2i(f.X, f.Y); + var f = BackLabel.GetCharLocation(CursorLocation); + Pointer.Location = BackLabel.Location + new Vector2i(f.X, f.Y); Pointer.Visible = true; } else @@ -342,13 +321,13 @@ public class TextBox : UserControl - if (KeyArgs.Key == Keys.V && KeyArgs.Control && Window is not null) + if (KeyArgs is { Key: Keys.V, Control: true } && Window is not null) { try { SendClipEvent(Window.ClipboardString); - if (LetterPress is not null) LetterPress.Invoke().Wait(); + LetterPress?.Invoke().Wait(); } catch { @@ -357,14 +336,4 @@ public class TextBox : UserControl } if (KeyPress is not null) _ = KeyPress.Invoke(KeyArgs); } - - private void Window_MouseDown(MouseButtonEventArgs e) - { - if (MouseInside && e.Button == MouseButton.Button1) - { - use = true; - Focus(); - } - else UnFocus(); - } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/ToggleSwitch.cs b/Luski/GUI/MainScreen/UI/LuskiControls/ToggleSwitch.cs index dbf7c59..0d500ee 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/ToggleSwitch.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/ToggleSwitch.cs @@ -1,5 +1,6 @@ using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using OpenTK.Mathematics; namespace Luski.GUI.MainScreen.UI.LuskiControls; @@ -7,11 +8,11 @@ namespace Luski.GUI.MainScreen.UI.LuskiControls; public class ToggleSwitch : UserControl { public ToggleSwitch() - :base(Globals.ms.TextureManager.GetTextureResource("Toggle.png")) + :base(Globals.RootWindow.TextureManager.GetTextureResource("Toggle.png")) { base.SetSize(40.ScaleInt(), 24.ScaleInt()); base.BackgroundColor = OffBackgroundColor; - Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context]; + Shader = Rectangle.DefaultAlphaShader[Globals.RootWindow.Context]; Clicked += o => { Value = !Value; @@ -21,13 +22,6 @@ public class ToggleSwitch : UserControl public event Func? ValueChanged; - public override void LoadToParent(IParent Parent, IWindow Window) - { - Value = !Value; - Value = !Value; - base.LoadToParent(Parent, Window); - } - public new Vector2i Size { get => base.Size; diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/UserView.cs b/Luski/GUI/MainScreen/UI/LuskiControls/UserView.cs index 5ed7749..e518dc1 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/UserView.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/UserView.cs @@ -12,7 +12,7 @@ public class UserView : UserControl { public SocketUser User { get; set; } - private UserView(IRenderObject user, SocketUser u, ServerProfile p, Role r, bool offline) + private UserView(RenderObjectCore user, SocketUser u, ServerProfile p, Role r, bool offline) { this.User = u; base.Size = new(244.ScaleInt(), 44.ScaleInt()); diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/VersionDropButton.cs b/Luski/GUI/MainScreen/UI/LuskiControls/VersionDropButton.cs index 47aa38c..fe90075 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/VersionDropButton.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/VersionDropButton.cs @@ -1,5 +1,6 @@ using GraphicsManager.Enums; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using OpenTK.Mathematics; namespace Luski.GUI.MainScreen.UI.LuskiControls; diff --git a/Luski/GUI/MainScreen/UI/LuskiSettings/GlobalSettingsMenu.cs b/Luski/GUI/MainScreen/UI/LuskiSettings/GlobalSettingsMenu.cs index 57f3424..d98a280 100644 --- a/Luski/GUI/MainScreen/UI/LuskiSettings/GlobalSettingsMenu.cs +++ b/Luski/GUI/MainScreen/UI/LuskiSettings/GlobalSettingsMenu.cs @@ -1,5 +1,6 @@ using System.Reflection; using GraphicsManager.Enums; +using GraphicsManager.Objects.Core; using Luski.Classes; using Luski.Classes.Attribs; using Luski.Enums.Strings; @@ -32,23 +33,27 @@ public class GlobalSettingsMenu : SettingsMenu private void LoadPages() { - foreach (PropertyInfo prop in typeof(TFile).GetProperties()) + try { - if (!prop.TryGetAnyAttribute(out SettingInfoAttribute? p)) continue; - if (!categories.ContainsKey(p.Group)) + foreach (PropertyInfo prop in typeof(TFile).GetProperties()) { - categories.Add(p.Group, new SettingsCategory(p.Group, this)); - fl.Controls.Add(categories[p.Group]); - } - - if (!categories[p.Group].HasPage(SettingsPage.Pages[p.Page].Name)) - { - PageTab tab = categories[p.Group].AddPage(p.CreatePage()); - if (First is null) + if (!prop.TryGetAnyAttribute(out SettingInfoAttribute? p)) continue; + if (!categories.ContainsKey(p.Group)) { - First = tab; + categories.Add(p.Group, new SettingsCategory(p.Group, this)); + fl.Controls.Add(categories[p.Group]); } + + if (categories[p.Group].HasPage(SettingsPage.Pages[p.Page].Name)) continue; + PageTab tab = categories[p.Group].AddPage(p.CreatePage()); + First ??= tab; } } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/ExperimentSettings.cs b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/ExperimentSettings.cs index 223f709..42ec808 100644 --- a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/ExperimentSettings.cs +++ b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/ExperimentSettings.cs @@ -1,5 +1,6 @@ using GraphicsManager.Enums; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.Classes; using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core; using Luski.GUI.MainScreen.UI.SettingsPanel; diff --git a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/Updater.cs b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/Updater.cs index 9e07913..1ebb176 100644 --- a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/Updater.cs +++ b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AdvancedSettings/Updater.cs @@ -68,7 +68,7 @@ public class Updater : PageFlow WindowLoaded += _ => { - Globals.ms.ForceUpdate(); + Globals.RootWindow.ForceUpdate(); return Task.CompletedTask; }; } diff --git a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AppSettings/Appearance.cs b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AppSettings/Appearance.cs index 34281b3..542e0ef 100644 --- a/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AppSettings/Appearance.cs +++ b/Luski/GUI/MainScreen/UI/LuskiSettings/Pages/AppSettings/Appearance.cs @@ -1,5 +1,6 @@ using GraphicsManager.Enums; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.Classes; using Luski.GUI.MainScreen.UI.LuskiControls; using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core; @@ -79,7 +80,7 @@ public class Appearance : PageFlow }; ThemeDrop.OpenStatusChanged += b => { - BlockDraw = true; + AddBlockDraw(); Size = new(base.Size.X, base.Size.Y + ( b ? ThemeDrop.DropDownContainer.Size.Y : -1 * ThemeDrop.DropDownContainer.Size.Y)); line!.Location = new(line.Location.X, line.Location.Y + (b ? ThemeDrop.DropDownContainer.Size.Y : -1 * ThemeDrop.DropDownContainer.Size.Y)); @@ -92,7 +93,7 @@ public class Appearance : PageFlow ThemeDrop.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"); } - BlockDraw = false; + RemoveBlockDraw(); return Task.CompletedTask; }; Controls.Add(ThemeDrop); diff --git a/Luski/GUI/MainScreen/UI/PublicServers/AddChannel.cs b/Luski/GUI/MainScreen/UI/PublicServers/AddChannel.cs index d39951e..1a7dfa6 100644 --- a/Luski/GUI/MainScreen/UI/PublicServers/AddChannel.cs +++ b/Luski/GUI/MainScreen/UI/PublicServers/AddChannel.cs @@ -1,6 +1,7 @@ using GraphicsManager.Enums; using GraphicsManager.Interfaces; using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; using Luski.GUI.MainScreen.Interfaces; using Luski.GUI.MainScreen.UI.LuskiControls; using Luski.net.Structures.Public; @@ -67,7 +68,7 @@ public class AddChannel : UserControl Anchor = ObjectAnchor.All; } - private async Task BtnOnClicked(IRenderObject arg) + private async Task BtnOnClicked(RenderObjectCore arg) { SocketChannel chan = await Cat.Server.MakeChannel(Cat, cn.Text, cd.Text); await CA.AddChannel(chan); diff --git a/Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs b/Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs index 5e28220..b6cc910 100644 --- a/Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs +++ b/Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs @@ -21,8 +21,8 @@ public class ChatMessage : UserControl public PublicChat pc; - private IRenderObject LastObject; - public List MessageObjs = new(); + private RenderObjectCore LastObject; + public List MessageObjs = new(); private LabelBase FirstL; public MessageCompressedFlow MCF; @@ -40,7 +40,7 @@ public class ChatMessage : UserControl } - private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, Role r) + private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, RenderObjectCore UserIcon, Role r) { pc = p; @@ -192,7 +192,7 @@ public class ChatMessage : UserControl base.BackgroundColor = new(0,0,0,50); } - private Task MCFOnSizeUpdateNotIgnored(IRenderObject arg) + private Task MCFOnSizeUpdateNotIgnored(RenderObjectCore arg) { base.Size = new(base.Size.X , MCF.Size.Y + MCF.Location.Y); return Task.CompletedTask; @@ -201,7 +201,7 @@ public class ChatMessage : UserControl public async Task AddMessage(SocketMessage msg) { - BlockDraw = true; + AddBlockDraw(); LuskiLabel newLabel; if (!string.IsNullOrWhiteSpace(msg.Context)) { @@ -255,7 +255,7 @@ public class ChatMessage : UserControl }; for (int i = 0; i < msg.Files.Count; i++) { - IRenderObject cem = await ContentEmbed.GetEmbed(this, msg.Files[i], msg.ChannelID); + RenderObjectCore cem = await ContentEmbed.GetEmbed(this, msg.Files[i], msg.ChannelID); cf.Controls.Add(cem); } MCF.Controls.Add(cf); @@ -263,11 +263,11 @@ public class ChatMessage : UserControl Size = new(Size.X , MCF.Size.Y + MCF.Location.Y); - BlockDraw = false; + RemoveBlockDraw(); TryDraw(); } - private Task NewLabelOnClicked(IRenderObject arg) + private Task NewLabelOnClicked(RenderObjectCore arg) { try { @@ -288,7 +288,7 @@ public class ChatMessage : UserControl } readonly List