aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.Frontend/GUI')
-rw-r--r--ShiftOS.Frontend/GUI/Button.cs18
-rw-r--r--ShiftOS.Frontend/GUI/Control.cs7
-rw-r--r--ShiftOS.Frontend/GUI/PictureBox.cs15
3 files changed, 32 insertions, 8 deletions
diff --git a/ShiftOS.Frontend/GUI/Button.cs b/ShiftOS.Frontend/GUI/Button.cs
index 7d6804a..0a0376c 100644
--- a/ShiftOS.Frontend/GUI/Button.cs
+++ b/ShiftOS.Frontend/GUI/Button.cs
@@ -4,6 +4,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
using ShiftOS.Engine;
using ShiftOS.Frontend.GraphicsSubsystem;
@@ -34,15 +35,22 @@ namespace ShiftOS.Frontend.GUI
protected override void OnPaint(GraphicsContext gfx)
{
- var bgCol = SkinEngine.LoadedSkin.ButtonBackgroundColor.ToMonoColor();
+ var bgCol = UIManager.SkinTextures["ButtonBackgroundColor"];
var fgCol = SkinEngine.LoadedSkin.ControlTextColor.ToMonoColor();
if (ContainsMouse)
- bgCol = SkinEngine.LoadedSkin.ButtonHoverColor.ToMonoColor();
+ bgCol = UIManager.SkinTextures["ButtonHoverColor"];
if (MouseLeftDown)
- bgCol = SkinEngine.LoadedSkin.ButtonPressedColor.ToMonoColor();
+ bgCol = UIManager.SkinTextures["ButtonPressedColor"];
+
+ gfx.DrawRectangle(0, 0, Width, Height, fgCol);
+ gfx.DrawRectangle(1, 1, Width - 2, Height - 2, bgCol);
+
+ var measure = gfx.MeasureString(Text, Font);
+
+ var loc = new Vector2((Width - measure.X) / 2, (Height - measure.Y) / 2);
+
+ gfx.DrawString(Text, (int)loc.X, (int)loc.Y, fgCol, Font);
- base.OnPaint(gfx);
- base.OnPaint(gfx);
}
}
}
diff --git a/ShiftOS.Frontend/GUI/Control.cs b/ShiftOS.Frontend/GUI/Control.cs
index 012b2ee..c16792b 100644
--- a/ShiftOS.Frontend/GUI/Control.cs
+++ b/ShiftOS.Frontend/GUI/Control.cs
@@ -364,7 +364,7 @@ namespace ShiftOS.Frontend.GUI
protected virtual void OnPaint(GraphicsContext gfx)
{
- gfx.Clear(Engine.SkinEngine.LoadedSkin.ControlColor.ToMonoColor());
+ gfx.DrawRectangle(0, 0, Width, Height, UIManager.SkinTextures["ControlColor"]);
}
public void SendToBack()
@@ -558,6 +558,7 @@ namespace ShiftOS.Frontend.GUI
{
Click?.Invoke();
Invalidate();
+ MouseUp?.Invoke();
}
if (_leftState == false && ld == true)
{
@@ -565,6 +566,8 @@ namespace ShiftOS.Frontend.GUI
UIManager.FocusedControl = this;
focused?.InvalidateTopLevel();
InvalidateTopLevel();
+ MouseDown?.Invoke();
+
}
_leftState = ld;
_middleState = md;
@@ -631,6 +634,8 @@ namespace ShiftOS.Frontend.GUI
public event Action MouseLeave;
public event Action Click;
public event Action<KeyEvent> KeyEvent;
+ public event Action MouseDown;
+ public event Action MouseUp;
}
public struct Point
diff --git a/ShiftOS.Frontend/GUI/PictureBox.cs b/ShiftOS.Frontend/GUI/PictureBox.cs
index 91735aa..6f60b29 100644
--- a/ShiftOS.Frontend/GUI/PictureBox.cs
+++ b/ShiftOS.Frontend/GUI/PictureBox.cs
@@ -8,12 +8,13 @@ using System.Threading.Tasks;
using ShiftOS.Engine;
using System.Drawing.Imaging;
using ShiftOS.Frontend.GraphicsSubsystem;
+using Microsoft.Xna.Framework.Graphics;
namespace ShiftOS.Frontend.GUI
{
public class PictureBox : Control
{
- private System.Drawing.Image img = null;
+ private Texture2D img = null;
private ImageLayout _layout = ImageLayout.Fit;
public ImageLayout ImageLayout
@@ -28,7 +29,7 @@ namespace ShiftOS.Frontend.GUI
}
}
- public System.Drawing.Image Image
+ public Texture2D Image
{
get
{
@@ -53,6 +54,16 @@ namespace ShiftOS.Frontend.GUI
protected override void OnPaint(GraphicsContext gfx)
{
+ switch (_layout)
+ {
+ case ImageLayout.Stretch:
+ gfx.DrawRectangle(0, 0, Width, Height, Image);
+ break;
+ case ImageLayout.None:
+ gfx.DrawRectangle(0, 0, Image.Width, Image.Height, Image);
+ break;
+ }
+
}
//Again, thanks StackOverflow