mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 20:12:23 +00:00
* started refactoring for gui windows * a bit more work on gui windows * fixed some bugs and broken build stuff * fixed some bugs in gui controls * a little code cleanup * got gui dialogs positioning and experimenting with named styles by type * apply control styles directly in the constructor of controls * got everything compiling again * all gui controls have skinnable constructors * rework uniform grid desired size calculations * turns out gui layouts are complicated * include pdb files in nuget packages * fixed a bug in find nearest glyph * custom control styling * added a range constructor overload that takes one value * rethinking control desired size behaviour * made particle emitters more editable at runtime * moved the auto trigger code to the particle effect instead of the emitters * tweaks * changed the particle modifer interface to an abstract base with an optional name * changed the particle modifer interface to an abstract base with an optional name * an attempt at creating a gui combo box * rolled back the nested control experiment * pretty good (but not perfect) combo boxes * tweaks * name property bindings on lists * removed and cleaned up the hacks from the gui combo box * minor combo box styling tweaks * minor bug fix in gui combo box * experiments with data binding * fixed a mistake on the texture region service interface * working on the ability to serialize particles * finished particle serialization * more robust range deserialization * added editor browable attributes * fixed some broken demos * made the particle modifiers editable at runtime * fixed some issues with particle serialization * fixed some issues with interpolators
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
|
|
namespace MonoGame.Extended.Gui.Controls
|
|
{
|
|
public class GuiCheckBox : GuiControl
|
|
{
|
|
public GuiCheckBox()
|
|
{
|
|
}
|
|
|
|
public GuiCheckBox(GuiSkin skin)
|
|
: base(skin)
|
|
{
|
|
}
|
|
|
|
public event EventHandler CheckStateChanged;
|
|
|
|
private bool _isChecked;
|
|
public bool IsChecked
|
|
{
|
|
get { return _isChecked; }
|
|
set
|
|
{
|
|
if (_isChecked != value)
|
|
{
|
|
_isChecked = value;
|
|
CheckedStyle?.ApplyIf(this, _isChecked);
|
|
CheckStateChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|
|
|
|
private GuiControlStyle _checkedStyle;
|
|
public GuiControlStyle CheckedStyle
|
|
{
|
|
get { return _checkedStyle; }
|
|
set
|
|
{
|
|
if (_checkedStyle != value)
|
|
{
|
|
_checkedStyle = value;
|
|
CheckedStyle?.ApplyIf(this, _isChecked);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnPointerUp(IGuiContext context, GuiPointerEventArgs args)
|
|
{
|
|
base.OnPointerUp(context, args);
|
|
|
|
if (IsFocused && BoundingRectangle.Contains(args.Position))
|
|
IsChecked = !IsChecked;
|
|
}
|
|
|
|
protected override void DrawBackground(IGuiContext context, IGuiRenderer renderer, float deltaSeconds)
|
|
{
|
|
var boundingRectangle = BoundingRectangle;
|
|
var checkRectangle = new Rectangle(boundingRectangle.X, boundingRectangle.Y, BackgroundRegion.Width, BackgroundRegion.Height);
|
|
|
|
renderer.DrawRegion(BackgroundRegion, checkRectangle, Color);
|
|
}
|
|
|
|
protected override void DrawForeground(IGuiContext context, IGuiRenderer renderer, float deltaSeconds, TextInfo textInfo)
|
|
{
|
|
textInfo.Position = BoundingRectangle.Location.ToVector2() +
|
|
new Vector2(BackgroundRegion.Width + 5, BackgroundRegion.Height * 0.5f - textInfo.Font.LineHeight * 0.5f);
|
|
|
|
base.DrawForeground(context, renderer, deltaSeconds, textInfo);
|
|
}
|
|
}
|
|
}
|