diff --git a/GraphicsManager/FPSWindow.cs b/GraphicsManager/FPSWindow.cs
index cd8899a..a7a0ba9 100755
--- a/GraphicsManager/FPSWindow.cs
+++ b/GraphicsManager/FPSWindow.cs
@@ -47,6 +47,8 @@ public class FPSWindow : GameWindow , IWindow
ClientRectangle = new Box2i(num, num2, num + Size.X, num2 + Size.Y);
}
+
+ public Vector2i CS { get; private set; } = new(0, 0);
public Matrix4 WindowSizeMatrix { get; private set; }
diff --git a/GraphicsManager/GraphicsManager.csproj b/GraphicsManager/GraphicsManager.csproj
index 1a5603a..0e2981d 100644
--- a/GraphicsManager/GraphicsManager.csproj
+++ b/GraphicsManager/GraphicsManager.csproj
@@ -10,7 +10,7 @@
False
https://git.jacobtech.com/JacobTech.com/GraphicsManager
git
- 1.0.9-alpha66
+ 1.0.9-alpha81
diff --git a/GraphicsManager/Interfaces/IRenderObject.cs b/GraphicsManager/Interfaces/IRenderObject.cs
index 2efc1cc..0ba326c 100755
--- a/GraphicsManager/Interfaces/IRenderObject.cs
+++ b/GraphicsManager/Interfaces/IRenderObject.cs
@@ -1,6 +1,7 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using OpenTK.Mathematics;
+using OpenTK.Windowing.Common;
using OpenTK.Windowing.Common.Input;
namespace GraphicsManager.Interfaces;
@@ -21,6 +22,8 @@ public interface IRenderObject
public void Clean();
public void Focus();
public void UnFocus();
+ public void SendKeyEvent(KeyboardKeyEventArgs KeyArgs);
+ public void SendClipEvent(string Text);
public Vector2i Size { get; set; }
public Vector3i Location { get; set; }
public Vector2 SizeAsFloat { get; }
diff --git a/GraphicsManager/Interfaces/IWindow.cs b/GraphicsManager/Interfaces/IWindow.cs
index d9284b0..ef5e47d 100644
--- a/GraphicsManager/Interfaces/IWindow.cs
+++ b/GraphicsManager/Interfaces/IWindow.cs
@@ -11,7 +11,7 @@ public interface IWindow : IParent
public bool ShowMissingChar { get; }
public Matrix4 WindowSizeMatrix { get; }
- public Vector2i ClientSize { get; }
+ public Vector2i CS { get; }
public event Action MouseDown;
diff --git a/GraphicsManager/Objects/Core/ParentBase.cs b/GraphicsManager/Objects/Core/ParentBase.cs
index 153faa4..4ecd509 100644
--- a/GraphicsManager/Objects/Core/ParentBase.cs
+++ b/GraphicsManager/Objects/Core/ParentBase.cs
@@ -83,7 +83,7 @@ public abstract class ParentBase : Rectangle, IParent
nh = Size.Y;
}
if (nw == 0 || nh == 0) return;
- GL.Scissor(nx, Window!.ClientSize.Y - ny - nh, nw, nh);
+ GL.Scissor(nx, Window!.CS.Y - ny - nh, nw, nh);
base.Draw(nx,ny,nw,nh);
IEnumerable needload = Controls.Where(a => a.Loaded == false);
@@ -100,7 +100,7 @@ public abstract class ParentBase : Rectangle, IParent
for (int i = 0; i < Controls.Length; i++)
{
if (Controls[i].Location.X > Size.X || Controls[i].Location.Y > Size.Y) continue;
- GL.Scissor(nx, Window!.ClientSize.Y - ny - nh, nw, nh);
+ GL.Scissor(nx, Window!.CS.Y - ny - nh, nw, nh);
Controls[i].Draw(nx, ny, nw, nh);
}
}
diff --git a/GraphicsManager/Objects/Core/Shader.cs b/GraphicsManager/Objects/Core/Shader.cs
index c072cf9..b8d8e43 100755
--- a/GraphicsManager/Objects/Core/Shader.cs
+++ b/GraphicsManager/Objects/Core/Shader.cs
@@ -114,6 +114,12 @@ public class Shader : IDisposable
GL.UseProgram(Handle);
GL.UniformMatrix4(_uniformLocations[name], true, ref data);
}
+
+ public void SetMatrixF4(string name, Matrix4 data)
+ {
+ GL.UseProgram(Handle);
+ GL.UniformMatrix4(_uniformLocations[name], false, ref data);
+ }
public void Use()
{
diff --git a/GraphicsManager/Objects/FlowLayout.cs b/GraphicsManager/Objects/FlowLayout.cs
index ad8ee4f..903adef 100644
--- a/GraphicsManager/Objects/FlowLayout.cs
+++ b/GraphicsManager/Objects/FlowLayout.cs
@@ -226,7 +226,7 @@ public class FlowLayout : ParentBase, IFlow
}
Timer t;
- private int dist = 0;
+ private int dist;
private void WindowOnMouseWheel(MouseWheelEventArgs obj)
{
@@ -245,7 +245,7 @@ public class FlowLayout : ParentBase, IFlow
public uint HScrollPixels { get; set; } = 30;
- private uint ScrollValueBackEnd { get; set; } = 0;
+ private uint ScrollValueBackEnd { get; set; }
public event Func? FlowUpdate;
@@ -283,7 +283,7 @@ public class FlowLayout : ParentBase, IFlow
}
}
- private uint ss = 0;
+ private uint ss;
public uint ScrollSum
{
@@ -293,7 +293,7 @@ public class FlowLayout : ParentBase, IFlow
ss = value;
}
}
- private bool scroleip = false;
+ private bool scroleip;
private void TOnElapsed(object? sender, ElapsedEventArgs e)
{
try
@@ -301,7 +301,7 @@ public class FlowLayout : ParentBase, IFlow
if (!scroleip && dist != 0)
{
scroleip = true;
- var n = ScrollValue - dist;
+ long n = ScrollValue - dist;
if (n < 0) n = 0;
if (n > MaxScrollValue) n = MaxScrollValue;
Window!.Invoke(() =>ScrollValue = (uint)n);
diff --git a/GraphicsManager/Objects/Label.cs b/GraphicsManager/Objects/Label.cs
index c37231d..33ddd5b 100755
--- a/GraphicsManager/Objects/Label.cs
+++ b/GraphicsManager/Objects/Label.cs
@@ -314,7 +314,17 @@ public class Label : ILabel
max_x = (xrel + w);
}
}
- return new((int)max_x, (int)(lines * LineHeight) + (int)(lines * Font.ExtraLinePixels));
+ return new((int)char_x, (int)(lines * LineHeight) + (int)(lines * Font.ExtraLinePixels));
+ }
+
+ public virtual void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
+ {
+
+ }
+
+ public virtual void SendClipEvent(string ClipString)
+ {
+
}
public void Clean()
@@ -349,11 +359,9 @@ public class Label : ILabel
Shader.Use();
GL.Enable(EnableCap.Blend);
GL.Uniform4(Shader.GetUniformLocation("textColor"), Color);
- Matrix4 projectionM = Matrix4.CreateOrthographicOffCenter(0, Window!.Size.X, Window!.Size.Y, 0, -1.0f, 1.0f);
- projectionM = this.Window.WindowSizeMatrix;
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
GL.BlendFunc(0, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
- GL.UniformMatrix4(1, false, ref projectionM);
+ Shader.SetMatrixF4("projection", Window.WindowSizeMatrix);
GL.BindVertexArray(VAO);
diff --git a/GraphicsManager/Objects/RainbowLabel.cs b/GraphicsManager/Objects/RainbowLabel.cs
index 1b3e6c9..ca73060 100755
--- a/GraphicsManager/Objects/RainbowLabel.cs
+++ b/GraphicsManager/Objects/RainbowLabel.cs
@@ -302,6 +302,16 @@ public class RainbowLabel : ILabel
}
}
}
+ }
+
+ public virtual void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
+ {
+
+ }
+
+ public virtual void SendClipEvent(string ClipString)
+ {
+
}
public void ForceDistanceUpdate()
{
diff --git a/GraphicsManager/Objects/Rectangle.cs b/GraphicsManager/Objects/Rectangle.cs
index a7fe5e1..6fd5305 100755
--- a/GraphicsManager/Objects/Rectangle.cs
+++ b/GraphicsManager/Objects/Rectangle.cs
@@ -93,6 +93,15 @@ public class Rectangle : ITextureObject
}
public Action? OnDrawAction;
+ public virtual void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
+ {
+
+ }
+
+ public virtual void SendClipEvent(string ClipString)
+ {
+
+ }
//public Action? OnDrawExitAction;
public virtual void Draw(int x, int y, int w, int h)
diff --git a/GraphicsManager/Resources/Textures/BadChar.png b/GraphicsManager/Resources/Textures/BadChar.png
new file mode 100644
index 0000000..36b2ef3
Binary files /dev/null and b/GraphicsManager/Resources/Textures/BadChar.png differ
diff --git a/GraphicsManager/Window.cs b/GraphicsManager/Window.cs
index 7a656a2..c20d3a4 100755
--- a/GraphicsManager/Window.cs
+++ b/GraphicsManager/Window.cs
@@ -76,6 +76,15 @@ public class Window : NativeWindow , IWindow
last = WindowState;
WindowSizeMatrix = Matrix4.CreateOrthographicOffCenter(0.0f, Size.X, Size.Y, 0, 1, -1);
KeyDown += OnKeyDownn;
+ TextInput += OnTextInputEvent;
+ }
+
+ private void OnTextInputEvent(TextInputEventArgs obj)
+ {
+ if (focused is not null)
+ {
+ focused.SendClipEvent(obj.AsString);
+ }
}
private WindowState last;
@@ -84,6 +93,10 @@ public class Window : NativeWindow , IWindow
public bool CustomF11 = true;
private unsafe void OnKeyDownn(KeyboardKeyEventArgs obj)
{
+ if (focused is not null)
+ {
+ focused.SendKeyEvent(obj);
+ }
if (obj.Key != Keys.F11 || WindowBorder == WindowBorder.Fixed) return;
if (CustomF11)
{
@@ -136,91 +149,14 @@ public class Window : NativeWindow , IWindow
public Color4 BackgroundColor { get; set; } = new Color4(0, 0, 0, 255);
public ControlList Controls { get; } = new();
-#region Cool Math Things
- public float[] RctToFloat(int x, int y, int Width, int Height, bool hasTexture = false, float z = 0.0f)
- {
- if (hasTexture)
- {
- return new float[20] {
- IntToFloat(x + Width), IntToFloat(y, true), z, 1.0f, 1.0f,// top r
- IntToFloat(x + Width), IntToFloat(y + Height, true), z, 1.0f, 0.0f,//b r
- IntToFloat(x), IntToFloat(y + Height, true), z, 0.0f, 0.0f,//bot l
- IntToFloat(x), IntToFloat(y, true), z, 0.0f, 1.0f// top l
- };
- }
- else
- {
- return new float[12] {
- IntToFloat(x + Width), IntToFloat(y, true), z,// top r
- IntToFloat(x + Width), IntToFloat(y + Height, true), z, //b r
- IntToFloat(x), IntToFloat(y + Height, true), z, //bot l
- IntToFloat(x), IntToFloat(y, true), z,// top l
- };
- }
- }
- public Vector3 PointToVector(float x, float y, float z = 0.0f)
- {
- return new Vector3(IntToFloat(x), IntToFloat(y, true), z);
- }
+ public Vector2i CS { get; private set; } = new(0, 0);
- public float IntToFloat(float p, bool Invert = false)
- {
- float Size = (Invert ? this.Size.Y : this.Size.X);
- double half = Math.Round((double)Size / (double)2, 1);
- double Per = Math.Round((double)1 / half, 15);
- if (p == half) return 0.0f;
- if (Invert)
- {
- if (p > half) return (float)(((double)(p - half) * Per) * -1);
- else return (float)(1 - (p * Per));
- }
- else
- {
- if (p > half) return (float)((double)(p - half) * Per);
- else return (float)((1 - (p * Per)) * -1);
- }
- }
-
public float IntToWindow(float p, bool Y = false)
{
return p;
}
-
- public float FloatToInt(float p, bool Invert = false)
- {
- float Size = (Invert ? this.Size.Y : this.Size.X);
- double half = Math.Round((double)Size / (double)2, 15);
- if (p == 0) return (int)half;
- if (Invert)
- {
- if (p < 0)
- {
- p *= -1;
- p++;
- return (float)(half * p);
- }
- else
- {
- return (float)(half - (p * half));
- }
- }
- else
- {
- if (p < 0)
- {
- p *= -1;
- p++;
- return (float)(Size - (half * p));
- }
- else
- {
- return (float)(p * half + half);
- }
- }
- }
-#endregion
-
+
public void ForceUpdate(ResizeEventArgs e)
{
BlockDraw = true;
@@ -237,7 +173,7 @@ public class Window : NativeWindow , IWindow
int ly = (top ? Controls[i].Location.Y : Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
int sy = (bottom ? Size.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
int sx = (right ? Size.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
- if (Controls[i].Size.X != sx || Controls[i].Size.Y != sy) Controls[i].Size = new(sx, sy);
+ Controls[i].Size = new(sx, sy);
Controls[i].Location = new(lx, ly, Controls[i].Location.Z);
if (Controls[i] is IParent parent)
{
@@ -256,7 +192,8 @@ public class Window : NativeWindow , IWindow
if (e.Width == 0 && e.Height == 0 && WindowState != WindowState.Fullscreen) return;
WindowSizeMatrix = Matrix4.CreateOrthographicOffCenter(0.0f, e.Width, e.Height, 0, 1, -1);
- GL.Viewport(0, 0, e.Width, e.Height);
+ GL.Viewport(0, 0, e.Width, e.Height);
+ CS = e.Size;
ForceUpdate(e);
}
@@ -442,13 +379,13 @@ public class Window : NativeWindow , IWindow
}
BlockDraw = false;
}
- GL.Scissor(0,0,Size.X, Size.Y);
+ GL.Scissor(0,0,CS.X, CS.Y);
GL.Clear(ClearBufferMask.ColorBufferBit);
for (int i = 0; i < Controls.Length; i++)
{
if (!Controls[i].Loaded) continue;
- GL.Scissor(0, 0, Size.X, Size.Y);
- Controls[i].Draw(0,0,Size.X, ClientSize.Y);
+ GL.Scissor(0, 0, CS.X, CS.Y);
+ Controls[i].Draw(0,0,CS.X, CS.Y);
}
Context.SwapBuffers();