From 0c8ccf5125c512e28fb6f74cd478b622b41cfddf Mon Sep 17 00:00:00 2001 From: Dylan Wilson Date: Mon, 5 Mar 2018 22:06:57 +1000 Subject: [PATCH] dropped the gui prefix on most of the gui stuff --- .../{GuiControlStyle.cs => ControlStyle.cs} | 18 ++-- .../Controls/{GuiButton.cs => Button.cs} | 16 +-- .../Controls/{GuiCanvas.cs => Canvas.cs} | 4 +- .../Controls/{GuiCheckBox.cs => CheckBox.cs} | 10 +- .../Controls/{GuiComboBox.cs => ComboBox.cs} | 6 +- .../Controls/{GuiControl.cs => Control.cs} | 40 ++++---- .../Controls/ControlCollection.cs | 15 +++ .../Controls/{GuiDialog.cs => Dialog.cs} | 10 +- .../Controls/{GuiForm.cs => Form.cs} | 8 +- .../Controls/GuiControlCollection.cs | 15 --- .../Controls/{GuiImage.cs => Image.cs} | 6 +- .../{GuiItemsControl.cs => ItemsControl.cs} | 8 +- .../Controls/{GuiLabel.cs => Label.cs} | 6 +- .../{GuiLayoutControl.cs => LayoutControl.cs} | 8 +- .../Controls/{GuiListBox.cs => ListBox.cs} | 4 +- .../{GuiProgressBar.cs => ProgressBar.cs} | 4 +- .../{GuiStackPanel.cs => StackPanel.cs} | 22 ++--- .../Controls/{GuiSubmit.cs => Submit.cs} | 2 +- .../Controls/{GuiTextBox.cs => TextBox.cs} | 12 +-- .../{GuiUniformGrid.cs => UniformGrid.cs} | 6 +- .../{GuiCursor.cs => Cursor.cs} | 2 +- .../{GuiElement.cs => Element.cs} | 4 +- ...mentCollection.cs => ElementCollection.cs} | 8 +- .../MonoGame.Extended.Gui/GuiOrientation.cs | 4 - .../GuiScreenCollection.cs | 10 -- Source/MonoGame.Extended.Gui/GuiSystem.cs | 52 +++++----- .../GuiWindowCollection.cs | 10 -- .../{GuiLayoutHelper.cs => LayoutHelper.cs} | 10 +- .../MonoGame.Extended.Gui.csproj | 68 ++++++------- Source/MonoGame.Extended.Gui/Orientation.cs | 4 + ...ointerEventArgs.cs => PointerEventArgs.cs} | 12 +-- .../{GuiScreen.cs => Screen.cs} | 42 ++++---- .../MonoGame.Extended.Gui/ScreenCollection.cs | 10 ++ ...mentConverter.cs => AlignmentConverter.cs} | 5 +- ...onConverter.cs => ControlJsonConverter.cs} | 18 ++-- ...verter.cs => ControlStyleJsonConverter.cs} | 16 +-- .../Serialization/GuiJsonSerializer.cs | 4 +- ...nJsonConverter.cs => SkinJsonConverter.cs} | 16 +-- .../{GuiSkin.cs => Skin.cs} | 98 +++++++++---------- .../{GuiWindow.cs => Window.cs} | 8 +- .../MonoGame.Extended.Gui/WindowCollection.cs | 10 ++ 41 files changed, 314 insertions(+), 317 deletions(-) rename Source/MonoGame.Extended.Gui/{GuiControlStyle.cs => ControlStyle.cs} (87%) rename Source/MonoGame.Extended.Gui/Controls/{GuiButton.cs => Button.cs} (91%) rename Source/MonoGame.Extended.Gui/Controls/{GuiCanvas.cs => Canvas.cs} (87%) rename Source/MonoGame.Extended.Gui/Controls/{GuiCheckBox.cs => CheckBox.cs} (91%) rename Source/MonoGame.Extended.Gui/Controls/{GuiComboBox.cs => ComboBox.cs} (96%) rename Source/MonoGame.Extended.Gui/Controls/{GuiControl.cs => Control.cs} (90%) create mode 100644 Source/MonoGame.Extended.Gui/Controls/ControlCollection.cs rename Source/MonoGame.Extended.Gui/Controls/{GuiDialog.cs => Dialog.cs} (77%) rename Source/MonoGame.Extended.Gui/Controls/{GuiForm.cs => Form.cs} (84%) delete mode 100644 Source/MonoGame.Extended.Gui/Controls/GuiControlCollection.cs rename Source/MonoGame.Extended.Gui/Controls/{GuiImage.cs => Image.cs} (61%) rename Source/MonoGame.Extended.Gui/Controls/{GuiItemsControl.cs => ItemsControl.cs} (97%) rename Source/MonoGame.Extended.Gui/Controls/{GuiLabel.cs => Label.cs} (56%) rename Source/MonoGame.Extended.Gui/Controls/{GuiLayoutControl.cs => LayoutControl.cs} (71%) rename Source/MonoGame.Extended.Gui/Controls/{GuiListBox.cs => ListBox.cs} (93%) rename Source/MonoGame.Extended.Gui/Controls/{GuiProgressBar.cs => ProgressBar.cs} (94%) rename Source/MonoGame.Extended.Gui/Controls/{GuiStackPanel.cs => StackPanel.cs} (77%) rename Source/MonoGame.Extended.Gui/Controls/{GuiSubmit.cs => Submit.cs} (60%) rename Source/MonoGame.Extended.Gui/Controls/{GuiTextBox.cs => TextBox.cs} (97%) rename Source/MonoGame.Extended.Gui/Controls/{GuiUniformGrid.cs => UniformGrid.cs} (92%) rename Source/MonoGame.Extended.Gui/{GuiCursor.cs => Cursor.cs} (89%) rename Source/MonoGame.Extended.Gui/{GuiElement.cs => Element.cs} (96%) rename Source/MonoGame.Extended.Gui/{GuiElementCollection.cs => ElementCollection.cs} (89%) delete mode 100644 Source/MonoGame.Extended.Gui/GuiOrientation.cs delete mode 100644 Source/MonoGame.Extended.Gui/GuiScreenCollection.cs delete mode 100644 Source/MonoGame.Extended.Gui/GuiWindowCollection.cs rename Source/MonoGame.Extended.Gui/{GuiLayoutHelper.cs => LayoutHelper.cs} (89%) create mode 100644 Source/MonoGame.Extended.Gui/Orientation.cs rename Source/MonoGame.Extended.Gui/{GuiPointerEventArgs.cs => PointerEventArgs.cs} (72%) rename Source/MonoGame.Extended.Gui/{GuiScreen.cs => Screen.cs} (67%) create mode 100644 Source/MonoGame.Extended.Gui/ScreenCollection.cs rename Source/MonoGame.Extended.Gui/Serialization/{GuiAlignmentConverter.cs => AlignmentConverter.cs} (90%) rename Source/MonoGame.Extended.Gui/Serialization/{GuiControlJsonConverter.cs => ControlJsonConverter.cs} (65%) rename Source/MonoGame.Extended.Gui/Serialization/{GuiControlStyleJsonConverter.cs => ControlStyleJsonConverter.cs} (87%) rename Source/MonoGame.Extended.Gui/Serialization/{GuiSkinJsonConverter.cs => SkinJsonConverter.cs} (69%) rename Source/MonoGame.Extended.Gui/{GuiSkin.cs => Skin.cs} (51%) rename Source/MonoGame.Extended.Gui/{GuiWindow.cs => Window.cs} (73%) create mode 100644 Source/MonoGame.Extended.Gui/WindowCollection.cs diff --git a/Source/MonoGame.Extended.Gui/GuiControlStyle.cs b/Source/MonoGame.Extended.Gui/ControlStyle.cs similarity index 87% rename from Source/MonoGame.Extended.Gui/GuiControlStyle.cs rename to Source/MonoGame.Extended.Gui/ControlStyle.cs index 7341bc6f..1593da38 100644 --- a/Source/MonoGame.Extended.Gui/GuiControlStyle.cs +++ b/Source/MonoGame.Extended.Gui/ControlStyle.cs @@ -7,21 +7,21 @@ using MonoGame.Extended.Gui.Controls; namespace MonoGame.Extended.Gui { - public class GuiControlStyle : IDictionary + public class ControlStyle : IDictionary { private readonly Dictionary> _previousStates = new Dictionary>(); - public GuiControlStyle() - : this(typeof(GuiElement)) + public ControlStyle() + : this(typeof(Element)) { } - public GuiControlStyle(Type targetType) + public ControlStyle(Type targetType) : this(targetType.FullName, targetType) { } - public GuiControlStyle(string name, Type targetType) + public ControlStyle(string name, Type targetType) { Name = name; TargetType = targetType; @@ -33,7 +33,7 @@ namespace MonoGame.Extended.Gui private readonly Dictionary _setters; - public void ApplyIf(GuiControl control, bool predicate) + public void ApplyIf(Control control, bool predicate) { if (predicate) Apply(control); @@ -41,7 +41,7 @@ namespace MonoGame.Extended.Gui Revert(control); } - public void Apply(GuiControl control) + public void Apply(Control control) { _previousStates[control.Id] = _setters .ToDictionary(i => i.Key, i => TargetType.GetRuntimeProperty(i.Key)?.GetValue(control)); @@ -49,7 +49,7 @@ namespace MonoGame.Extended.Gui ChangePropertyValues(control, _setters); } - public void Revert(GuiControl control) + public void Revert(Control control) { if (_previousStates.ContainsKey(control.Id) && _previousStates[control.Id] != null) ChangePropertyValues(control, _previousStates[control.Id]); @@ -57,7 +57,7 @@ namespace MonoGame.Extended.Gui _previousStates[control.Id] = null; } - private static void ChangePropertyValues(GuiControl control, Dictionary setters) + private static void ChangePropertyValues(Control control, Dictionary setters) { var targetType = control.GetType(); diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiButton.cs b/Source/MonoGame.Extended.Gui/Controls/Button.cs similarity index 91% rename from Source/MonoGame.Extended.Gui/Controls/GuiButton.cs rename to Source/MonoGame.Extended.Gui/Controls/Button.cs index 990b0d4e..8052adb5 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiButton.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Button.cs @@ -4,9 +4,9 @@ using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Gui.Controls { - public class GuiButton : GuiControl + public class Button : Control { - public GuiButton() + public Button() { } @@ -46,8 +46,8 @@ namespace MonoGame.Extended.Gui.Controls } } - private GuiControlStyle _pressedStyle; - public GuiControlStyle PressedStyle + private ControlStyle _pressedStyle; + public ControlStyle PressedStyle { get { return _pressedStyle; } set @@ -62,7 +62,7 @@ namespace MonoGame.Extended.Gui.Controls private bool _isPointerDown; - public override bool OnPointerDown(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerDown(IGuiContext context, PointerEventArgs args) { if (IsEnabled) { @@ -72,7 +72,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerDown(context, args); } - public override bool OnPointerUp(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerUp(IGuiContext context, PointerEventArgs args) { _isPointerDown = false; @@ -86,7 +86,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerUp(context, args); } - public override bool OnPointerEnter(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerEnter(IGuiContext context, PointerEventArgs args) { if (IsEnabled && _isPointerDown) IsPressed = true; @@ -94,7 +94,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerEnter(context, args); } - public override bool OnPointerLeave(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerLeave(IGuiContext context, PointerEventArgs args) { if (IsEnabled) IsPressed = false; diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiCanvas.cs b/Source/MonoGame.Extended.Gui/Controls/Canvas.cs similarity index 87% rename from Source/MonoGame.Extended.Gui/Controls/GuiCanvas.cs rename to Source/MonoGame.Extended.Gui/Controls/Canvas.cs index bea7182f..e6c16c6a 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiCanvas.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Canvas.cs @@ -2,9 +2,9 @@ namespace MonoGame.Extended.Gui.Controls { - public class GuiCanvas : GuiLayoutControl + public class Canvas : LayoutControl { - public GuiCanvas() + public Canvas() { } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiCheckBox.cs b/Source/MonoGame.Extended.Gui/Controls/CheckBox.cs similarity index 91% rename from Source/MonoGame.Extended.Gui/Controls/GuiCheckBox.cs rename to Source/MonoGame.Extended.Gui/Controls/CheckBox.cs index d2a2c943..55e4f61e 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiCheckBox.cs +++ b/Source/MonoGame.Extended.Gui/Controls/CheckBox.cs @@ -3,9 +3,9 @@ using Microsoft.Xna.Framework; namespace MonoGame.Extended.Gui.Controls { - public class GuiCheckBox : GuiControl + public class CheckBox : Control { - public GuiCheckBox() + public CheckBox() { } @@ -27,8 +27,8 @@ namespace MonoGame.Extended.Gui.Controls } } - private GuiControlStyle _checkedStyle; - public GuiControlStyle CheckedStyle + private ControlStyle _checkedStyle; + public ControlStyle CheckedStyle { get { return _checkedStyle; } set @@ -41,7 +41,7 @@ namespace MonoGame.Extended.Gui.Controls } } - public override bool OnPointerUp(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerUp(IGuiContext context, PointerEventArgs args) { if (IsFocused && BoundingRectangle.Contains(args.Position)) IsChecked = !IsChecked; diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiComboBox.cs b/Source/MonoGame.Extended.Gui/Controls/ComboBox.cs similarity index 96% rename from Source/MonoGame.Extended.Gui/Controls/GuiComboBox.cs rename to Source/MonoGame.Extended.Gui/Controls/ComboBox.cs index 3c2672fd..c8a807b9 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiComboBox.cs +++ b/Source/MonoGame.Extended.Gui/Controls/ComboBox.cs @@ -5,9 +5,9 @@ using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Gui.Controls { - public class GuiComboBox : GuiItemsControl + public class ComboBox : ItemsControl { - public GuiComboBox() + public ComboBox() { } @@ -23,7 +23,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnKeyPressed(context, args); } - public override bool OnPointerDown(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerDown(IGuiContext context, PointerEventArgs args) { IsOpen = !IsOpen; return base.OnPointerDown(context, args); diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiControl.cs b/Source/MonoGame.Extended.Gui/Controls/Control.cs similarity index 90% rename from Source/MonoGame.Extended.Gui/Controls/GuiControl.cs rename to Source/MonoGame.Extended.Gui/Controls/Control.cs index 558aa4f7..dce23b4f 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiControl.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Control.cs @@ -10,15 +10,15 @@ using System.Linq; namespace MonoGame.Extended.Gui.Controls { - public abstract class GuiControl : GuiElement, IMovable, ISizable, IRectangular + public abstract class Control : Element, IMovable, ISizable, IRectangular { - protected GuiControl() + protected Control() { Color = Color.White; TextColor = Color.White; IsEnabled = true; IsVisible = true; - Controls = new GuiControlCollection(this) + Controls = new ControlCollection(this) { ItemAdded = x => UpdateRootIsLayoutRequired(), ItemRemoved = x => UpdateRootIsLayoutRequired() @@ -26,10 +26,10 @@ namespace MonoGame.Extended.Gui.Controls Origin = Vector2.Zero; } - private GuiSkin _skin; + private Skin _skin; [EditorBrowsable(EditorBrowsableState.Never)] - public GuiSkin Skin + public Skin Skin { get { return _skin; } set @@ -71,7 +71,7 @@ namespace MonoGame.Extended.Gui.Controls public BitmapFont Font { get; set; } public Color TextColor { get; set; } public Vector2 TextOffset { get; set; } - public GuiControlCollection Controls { get; } + public ControlCollection Controls { get; } public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Centre; public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Centre; public HorizontalAlignment HorizontalTextAlignment { get; set; } = HorizontalAlignment.Centre; @@ -129,7 +129,7 @@ namespace MonoGame.Extended.Gui.Controls var buttonSize = Size2.Empty; - var guiButton = this as GuiButton; + var guiButton = this as Button; if (guiButton?.IconRegion != null) { buttonSize = guiButton.IconRegion.Size; @@ -166,10 +166,10 @@ namespace MonoGame.Extended.Gui.Controls } public bool IsVisible { get; set; } - public GuiControlStyle HoverStyle { get; set; } + public ControlStyle HoverStyle { get; set; } - private GuiControlStyle _disabledStyle; - public GuiControlStyle DisabledStyle + private ControlStyle _disabledStyle; + public ControlStyle DisabledStyle { get { return _disabledStyle; } set @@ -187,11 +187,11 @@ namespace MonoGame.Extended.Gui.Controls public virtual bool OnFocus(IGuiContext context) { return true; } public virtual bool OnUnfocus(IGuiContext context) { return true; } - public virtual bool OnPointerDown(IGuiContext context, GuiPointerEventArgs args) { return true; } - public virtual bool OnPointerMove(IGuiContext context, GuiPointerEventArgs args) { return true; } - public virtual bool OnPointerUp(IGuiContext context, GuiPointerEventArgs args) { return true; } + public virtual bool OnPointerDown(IGuiContext context, PointerEventArgs args) { return true; } + public virtual bool OnPointerMove(IGuiContext context, PointerEventArgs args) { return true; } + public virtual bool OnPointerUp(IGuiContext context, PointerEventArgs args) { return true; } - public virtual bool OnPointerEnter(IGuiContext context, GuiPointerEventArgs args) + public virtual bool OnPointerEnter(IGuiContext context, PointerEventArgs args) { if (IsEnabled && !_isHovering) { @@ -201,7 +201,7 @@ namespace MonoGame.Extended.Gui.Controls return true; } - public virtual bool OnPointerLeave(IGuiContext context, GuiPointerEventArgs args) + public virtual bool OnPointerLeave(IGuiContext context, PointerEventArgs args) { if (IsEnabled && _isHovering) { @@ -222,19 +222,19 @@ namespace MonoGame.Extended.Gui.Controls DrawForeground(context, renderer, deltaSeconds, GetTextInfo(context, CreateBoxText(Text, Font ?? context.DefaultFont, Width), BoundingRectangle, HorizontalTextAlignment, VerticalTextAlignment)); } - public bool HasParent(GuiControl control) + public bool HasParent(Control control) { return Parent != null && (Parent == control || Parent.HasParent(control)); } protected List FindControls() - where T : GuiControl + where T : Control { return FindControls(Controls); } - protected List FindControls(GuiControlCollection controls) - where T : GuiControl + protected List FindControls(ControlCollection controls) + where T : Control { var results = new List(); foreach (var control in controls) @@ -249,7 +249,7 @@ namespace MonoGame.Extended.Gui.Controls { var font = Font ?? context.DefaultFont; var textSize = font.GetStringRectangle(text ?? string.Empty, Vector2.Zero).Size; - var destinationRectangle = GuiLayoutHelper.AlignRectangle(horizontalAlignment, verticalAlignment, textSize, targetRectangle); + var destinationRectangle = LayoutHelper.AlignRectangle(horizontalAlignment, verticalAlignment, textSize, targetRectangle); var textPosition = destinationRectangle.Location.ToVector2(); var textInfo = new TextInfo(text, font, textPosition, textSize, TextColor, clippingRectangle ?? ClippingRectangle); return textInfo; diff --git a/Source/MonoGame.Extended.Gui/Controls/ControlCollection.cs b/Source/MonoGame.Extended.Gui/Controls/ControlCollection.cs new file mode 100644 index 00000000..6135b4c2 --- /dev/null +++ b/Source/MonoGame.Extended.Gui/Controls/ControlCollection.cs @@ -0,0 +1,15 @@ +namespace MonoGame.Extended.Gui.Controls +{ + public class ControlCollection : ElementCollection + { + public ControlCollection() + : base(null) + { + } + + public ControlCollection(Control parent) + : base(parent) + { + } + } +} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiDialog.cs b/Source/MonoGame.Extended.Gui/Controls/Dialog.cs similarity index 77% rename from Source/MonoGame.Extended.Gui/Controls/GuiDialog.cs rename to Source/MonoGame.Extended.Gui/Controls/Dialog.cs index ee810f0b..08258d35 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiDialog.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Dialog.cs @@ -3,18 +3,18 @@ using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Gui.Controls { - public class GuiDialog : GuiLayoutControl + public class Dialog : LayoutControl { - public GuiDialog() + public Dialog() { HorizontalAlignment = HorizontalAlignment.Centre; VerticalAlignment = VerticalAlignment.Centre; } public Thickness Padding { get; set; } - public GuiScreen Owner { get; private set; } + public Screen Owner { get; private set; } - public void Show(GuiScreen owner) + public void Show(Screen owner) { Owner = owner; Owner.Controls.Add(this); @@ -27,7 +27,7 @@ namespace MonoGame.Extended.Gui.Controls protected override Size2 CalculateDesiredSize(IGuiContext context, Size2 availableSize) { - var sizes = Controls.Select(control => GuiLayoutHelper.GetSizeWithMargins(control, context, availableSize)).ToArray(); + var sizes = Controls.Select(control => LayoutHelper.GetSizeWithMargins(control, context, availableSize)).ToArray(); var width = sizes.Max(s => s.Width); var height = sizes.Max(s => s.Height); return new Size2(width, height) + Padding.Size; diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiForm.cs b/Source/MonoGame.Extended.Gui/Controls/Form.cs similarity index 84% rename from Source/MonoGame.Extended.Gui/Controls/GuiForm.cs rename to Source/MonoGame.Extended.Gui/Controls/Form.cs index 0890c325..357b1c96 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiForm.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Form.cs @@ -4,9 +4,9 @@ using Microsoft.Xna.Framework.Input; namespace MonoGame.Extended.Gui.Controls { - public class GuiForm : GuiStackPanel + public class Form : StackPanel { - public GuiForm() + public Form() { } @@ -14,7 +14,7 @@ namespace MonoGame.Extended.Gui.Controls { if (args.Key == Keys.Tab) { - var controls = FindControls(); + var controls = FindControls(); var index = controls.IndexOf(context.FocusedControl); if (index > -1) { @@ -27,7 +27,7 @@ namespace MonoGame.Extended.Gui.Controls if (args.Key == Keys.Enter) { - var controls = FindControls(); + var controls = FindControls(); if (controls.Count > 0) { var submit = controls.FirstOrDefault(); diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiControlCollection.cs b/Source/MonoGame.Extended.Gui/Controls/GuiControlCollection.cs deleted file mode 100644 index 6bf874f7..00000000 --- a/Source/MonoGame.Extended.Gui/Controls/GuiControlCollection.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace MonoGame.Extended.Gui.Controls -{ - public class GuiControlCollection : GuiElementCollection - { - public GuiControlCollection() - : base(null) - { - } - - public GuiControlCollection(GuiControl parent) - : base(parent) - { - } - } -} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiImage.cs b/Source/MonoGame.Extended.Gui/Controls/Image.cs similarity index 61% rename from Source/MonoGame.Extended.Gui/Controls/GuiImage.cs rename to Source/MonoGame.Extended.Gui/Controls/Image.cs index 715e40b6..ac6e100c 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiImage.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Image.cs @@ -2,13 +2,13 @@ namespace MonoGame.Extended.Gui.Controls { - public class GuiImage : GuiControl + public class Image : Control { - public GuiImage() + public Image() { } - public GuiImage(TextureRegion2D image) + public Image(TextureRegion2D image) { BackgroundRegion = image; } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiItemsControl.cs b/Source/MonoGame.Extended.Gui/Controls/ItemsControl.cs similarity index 97% rename from Source/MonoGame.Extended.Gui/Controls/GuiItemsControl.cs rename to Source/MonoGame.Extended.Gui/Controls/ItemsControl.cs index 00b1eeeb..12dffbe3 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiItemsControl.cs +++ b/Source/MonoGame.Extended.Gui/Controls/ItemsControl.cs @@ -7,9 +7,9 @@ using MonoGame.Extended.Input.InputListeners; namespace MonoGame.Extended.Gui.Controls { - public abstract class GuiItemsControl : GuiControl + public abstract class ItemsControl : Control { - protected GuiItemsControl() + protected ItemsControl() { } @@ -71,7 +71,7 @@ namespace MonoGame.Extended.Gui.Controls SelectedIndex--; } - public override bool OnPointerDown(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerDown(IGuiContext context, PointerEventArgs args) { var contentRectangle = GetContentRectangle(context); @@ -90,7 +90,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerDown(context, args); } - protected virtual void OnItemClicked(IGuiContext context, GuiPointerEventArgs args) { } + protected virtual void OnItemClicked(IGuiContext context, PointerEventArgs args) { } protected TextInfo GetItemTextInfo(IGuiContext context, Rectangle itemRectangle, object item, Rectangle? clippingRectangle) { diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiLabel.cs b/Source/MonoGame.Extended.Gui/Controls/Label.cs similarity index 56% rename from Source/MonoGame.Extended.Gui/Controls/GuiLabel.cs rename to Source/MonoGame.Extended.Gui/Controls/Label.cs index 1be563a2..37b90aff 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiLabel.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Label.cs @@ -1,12 +1,12 @@ namespace MonoGame.Extended.Gui.Controls { - public class GuiLabel : GuiControl + public class Label : Control { - public GuiLabel() + public Label() { } - public GuiLabel(string text = null) + public Label(string text = null) { Text = text ?? string.Empty; } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiLayoutControl.cs b/Source/MonoGame.Extended.Gui/Controls/LayoutControl.cs similarity index 71% rename from Source/MonoGame.Extended.Gui/Controls/GuiLayoutControl.cs rename to Source/MonoGame.Extended.Gui/Controls/LayoutControl.cs index f10d62f8..75bf4bc1 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiLayoutControl.cs +++ b/Source/MonoGame.Extended.Gui/Controls/LayoutControl.cs @@ -3,9 +3,9 @@ using Microsoft.Xna.Framework; namespace MonoGame.Extended.Gui.Controls { - public abstract class GuiLayoutControl : GuiControl + public abstract class LayoutControl : Control { - protected GuiLayoutControl() + protected LayoutControl() { HorizontalAlignment = HorizontalAlignment.Stretch; VerticalAlignment = VerticalAlignment.Stretch; @@ -19,9 +19,9 @@ namespace MonoGame.Extended.Gui.Controls public abstract void Layout(IGuiContext context, RectangleF rectangle); - protected static void PlaceControl(IGuiContext context, GuiControl control, float x, float y, float width, float height) + protected static void PlaceControl(IGuiContext context, Control control, float x, float y, float width, float height) { - GuiLayoutHelper.PlaceControl(context, control, x, y, width, height); + LayoutHelper.PlaceControl(context, control, x, y, width, height); } } } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiListBox.cs b/Source/MonoGame.Extended.Gui/Controls/ListBox.cs similarity index 93% rename from Source/MonoGame.Extended.Gui/Controls/GuiListBox.cs rename to Source/MonoGame.Extended.Gui/Controls/ListBox.cs index e0009bde..b35c47ec 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiListBox.cs +++ b/Source/MonoGame.Extended.Gui/Controls/ListBox.cs @@ -3,9 +3,9 @@ using Microsoft.Xna.Framework; namespace MonoGame.Extended.Gui.Controls { - public class GuiListBox : GuiItemsControl + public class ListBox : ItemsControl { - public GuiListBox() + public ListBox() { } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiProgressBar.cs b/Source/MonoGame.Extended.Gui/Controls/ProgressBar.cs similarity index 94% rename from Source/MonoGame.Extended.Gui/Controls/GuiProgressBar.cs rename to Source/MonoGame.Extended.Gui/Controls/ProgressBar.cs index ef271972..34611deb 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiProgressBar.cs +++ b/Source/MonoGame.Extended.Gui/Controls/ProgressBar.cs @@ -4,9 +4,9 @@ using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Gui.Controls { - public class GuiProgressBar : GuiControl + public class ProgressBar : Control { - public GuiProgressBar() + public ProgressBar() { } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiStackPanel.cs b/Source/MonoGame.Extended.Gui/Controls/StackPanel.cs similarity index 77% rename from Source/MonoGame.Extended.Gui/Controls/GuiStackPanel.cs rename to Source/MonoGame.Extended.Gui/Controls/StackPanel.cs index 78309674..55f04b0f 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiStackPanel.cs +++ b/Source/MonoGame.Extended.Gui/Controls/StackPanel.cs @@ -2,15 +2,15 @@ namespace MonoGame.Extended.Gui.Controls { - public class GuiStackPanel : GuiLayoutControl + public class StackPanel : LayoutControl { - public GuiStackPanel() + public StackPanel() { HorizontalAlignment = HorizontalAlignment.Centre; VerticalAlignment = VerticalAlignment.Centre; } - public GuiOrientation Orientation { get; set; } = GuiOrientation.Vertical; + public Orientation Orientation { get; set; } = Orientation.Vertical; public Thickness Padding { get; set; } public int Spacing { get; set; } = 0; @@ -21,15 +21,15 @@ namespace MonoGame.Extended.Gui.Controls foreach (var control in Controls) { - var desiredSize = GuiLayoutHelper.GetSizeWithMargins(control, context, availableSize); + var desiredSize = LayoutHelper.GetSizeWithMargins(control, context, availableSize); switch (Orientation) { - case GuiOrientation.Horizontal: + case Orientation.Horizontal: width += desiredSize.Width; height = desiredSize.Height > height ? desiredSize.Height : height; break; - case GuiOrientation.Vertical: + case Orientation.Vertical: width = desiredSize.Width > width ? desiredSize.Width : width; height += desiredSize.Height; break; @@ -39,8 +39,8 @@ namespace MonoGame.Extended.Gui.Controls } - width += Padding.Left + Padding.Right + (Orientation == GuiOrientation.Horizontal ? (Controls.Count - 1) * Spacing : 0); - height += Padding.Top + Padding.Bottom + (Orientation == GuiOrientation.Vertical ? (Controls.Count - 1) * Spacing : 0); + width += Padding.Left + Padding.Right + (Orientation == Orientation.Horizontal ? (Controls.Count - 1) * Spacing : 0); + height += Padding.Top + Padding.Bottom + (Orientation == Orientation.Vertical ? (Controls.Count - 1) * Spacing : 0); return new Size2(width, height); } @@ -53,18 +53,18 @@ namespace MonoGame.Extended.Gui.Controls foreach (var control in Controls) { - var desiredSize = GuiLayoutHelper.GetSizeWithMargins(control, context, availableSize); + var desiredSize = LayoutHelper.GetSizeWithMargins(control, context, availableSize); switch (Orientation) { - case GuiOrientation.Vertical: + case Orientation.Vertical: control.VerticalAlignment = VerticalAlignment.Top; PlaceControl(context, control, 0f, y, Width, desiredSize.Height); y += desiredSize.Height + Spacing; availableSize.Height -= desiredSize.Height; break; - case GuiOrientation.Horizontal: + case Orientation.Horizontal: control.HorizontalAlignment = HorizontalAlignment.Left; PlaceControl(context, control, x, 0f, desiredSize.Width, Height); diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiSubmit.cs b/Source/MonoGame.Extended.Gui/Controls/Submit.cs similarity index 60% rename from Source/MonoGame.Extended.Gui/Controls/GuiSubmit.cs rename to Source/MonoGame.Extended.Gui/Controls/Submit.cs index f203ae7c..fdc80919 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiSubmit.cs +++ b/Source/MonoGame.Extended.Gui/Controls/Submit.cs @@ -1,6 +1,6 @@ namespace MonoGame.Extended.Gui.Controls { - public class GuiSubmit : GuiButton + public class Submit : Button { } } diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs b/Source/MonoGame.Extended.Gui/Controls/TextBox.cs similarity index 97% rename from Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs rename to Source/MonoGame.Extended.Gui/Controls/TextBox.cs index e1479d78..b6b29bbc 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs +++ b/Source/MonoGame.Extended.Gui/Controls/TextBox.cs @@ -7,9 +7,9 @@ using MonoGame.Extended.BitmapFonts; namespace MonoGame.Extended.Gui.Controls { - public class GuiTextBox : GuiControl + public class TextBox : Control { - public GuiTextBox(string text = null) + public TextBox(string text = null) { Text = text ?? string.Empty; } @@ -31,7 +31,7 @@ namespace MonoGame.Extended.Gui.Controls return new Size2(Width + Padding.Left + Padding.Right, (Height <= 0.0f ? font.LineHeight + 2 : Height) + Padding.Top + Padding.Bottom); } - public override bool OnPointerDown(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerDown(IGuiContext context, PointerEventArgs args) { SelectionStart = FindNearestGlyphIndex(context, args.Position); _isCaretVisible = true; @@ -43,7 +43,7 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerDown(context, args); } - public override bool OnPointerMove(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerMove(IGuiContext context, PointerEventArgs args) { if (_startSelectionBox) { @@ -71,14 +71,14 @@ namespace MonoGame.Extended.Gui.Controls return base.OnPointerMove(context, args); } - public override bool OnPointerLeave(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerLeave(IGuiContext context, PointerEventArgs args) { _startSelectionBox = false; return base.OnPointerLeave(context, args); } - public override bool OnPointerUp(IGuiContext context, GuiPointerEventArgs args) + public override bool OnPointerUp(IGuiContext context, PointerEventArgs args) { _startSelectionBox = false; diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiUniformGrid.cs b/Source/MonoGame.Extended.Gui/Controls/UniformGrid.cs similarity index 92% rename from Source/MonoGame.Extended.Gui/Controls/GuiUniformGrid.cs rename to Source/MonoGame.Extended.Gui/Controls/UniformGrid.cs index 1a989a84..2c31b51d 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiUniformGrid.cs +++ b/Source/MonoGame.Extended.Gui/Controls/UniformGrid.cs @@ -3,9 +3,9 @@ using System.Linq; namespace MonoGame.Extended.Gui.Controls { - public class GuiUniformGrid : GuiLayoutControl + public class UniformGrid : LayoutControl { - public GuiUniformGrid() + public UniformGrid() { } @@ -60,7 +60,7 @@ namespace MonoGame.Extended.Gui.Controls var maxCellWidth = availableSize.Width / columns; var maxCellHeight = availableSize.Height / rows; var sizes = Controls - .Select(control => GuiLayoutHelper.GetSizeWithMargins(control, context, new Size2(maxCellWidth, maxCellHeight))) + .Select(control => LayoutHelper.GetSizeWithMargins(control, context, new Size2(maxCellWidth, maxCellHeight))) .ToArray(); var maxControlWidth = sizes.Length == 0 ? 0 : sizes.Max(s => s.Width); var maxControlHeight = sizes.Length == 0 ? 0 : sizes.Max(s => s.Height); diff --git a/Source/MonoGame.Extended.Gui/GuiCursor.cs b/Source/MonoGame.Extended.Gui/Cursor.cs similarity index 89% rename from Source/MonoGame.Extended.Gui/GuiCursor.cs rename to Source/MonoGame.Extended.Gui/Cursor.cs index dcfa72a1..638baecd 100644 --- a/Source/MonoGame.Extended.Gui/GuiCursor.cs +++ b/Source/MonoGame.Extended.Gui/Cursor.cs @@ -3,7 +3,7 @@ using MonoGame.Extended.TextureAtlases; namespace MonoGame.Extended.Gui { - public class GuiCursor + public class Cursor { public TextureRegion2D TextureRegion { get; set; } public Color Color { get; set; } = Color.White; diff --git a/Source/MonoGame.Extended.Gui/GuiElement.cs b/Source/MonoGame.Extended.Gui/Element.cs similarity index 96% rename from Source/MonoGame.Extended.Gui/GuiElement.cs rename to Source/MonoGame.Extended.Gui/Element.cs index e4dd0b44..31fa9fe6 100644 --- a/Source/MonoGame.Extended.Gui/GuiElement.cs +++ b/Source/MonoGame.Extended.Gui/Element.cs @@ -21,7 +21,7 @@ namespace MonoGame.Extended.Gui public string ViewProperty { get; } } - public abstract class GuiElement + public abstract class Element { public string Name { get; set; } public Vector2 Position { get; set; } @@ -93,7 +93,7 @@ namespace MonoGame.Extended.Gui public abstract void Draw(IGuiContext context, IGuiRenderer renderer, float deltaSeconds); } - public abstract class GuiElement : GuiElement, IRectangular + public abstract class Element : Element, IRectangular where TParent : IRectangular { [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/Source/MonoGame.Extended.Gui/GuiElementCollection.cs b/Source/MonoGame.Extended.Gui/ElementCollection.cs similarity index 89% rename from Source/MonoGame.Extended.Gui/GuiElementCollection.cs rename to Source/MonoGame.Extended.Gui/ElementCollection.cs index 1d39ab60..009161db 100644 --- a/Source/MonoGame.Extended.Gui/GuiElementCollection.cs +++ b/Source/MonoGame.Extended.Gui/ElementCollection.cs @@ -5,9 +5,9 @@ using MonoGame.Extended.Gui.Controls; namespace MonoGame.Extended.Gui { - public abstract class GuiElementCollection : IList + public abstract class ElementCollection : IList where TParent : class, IRectangular - where TChild : GuiElement + where TChild : Element { private readonly TParent _parent; private readonly List _list = new List(); @@ -15,7 +15,7 @@ namespace MonoGame.Extended.Gui public Action ItemAdded { get; set; } public Action ItemRemoved { get; set; } - protected GuiElementCollection(TParent parent) + protected ElementCollection(TParent parent) { _parent = parent; } @@ -67,7 +67,7 @@ namespace MonoGame.Extended.Gui public int Count => _list.Count; - public bool IsReadOnly => ((ICollection)_list).IsReadOnly; + public bool IsReadOnly => ((ICollection)_list).IsReadOnly; public int IndexOf(TChild item) { diff --git a/Source/MonoGame.Extended.Gui/GuiOrientation.cs b/Source/MonoGame.Extended.Gui/GuiOrientation.cs deleted file mode 100644 index 027381cd..00000000 --- a/Source/MonoGame.Extended.Gui/GuiOrientation.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace MonoGame.Extended.Gui -{ - public enum GuiOrientation { Horizontal, Vertical } -} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/GuiScreenCollection.cs b/Source/MonoGame.Extended.Gui/GuiScreenCollection.cs deleted file mode 100644 index 10bb1479..00000000 --- a/Source/MonoGame.Extended.Gui/GuiScreenCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MonoGame.Extended.Gui -{ - public class GuiScreenCollection : GuiElementCollection - { - public GuiScreenCollection(GuiSystem parent) - : base(parent) - { - } - } -} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/GuiSystem.cs b/Source/MonoGame.Extended.Gui/GuiSystem.cs index f3137dba..3ccc3ba4 100644 --- a/Source/MonoGame.Extended.Gui/GuiSystem.cs +++ b/Source/MonoGame.Extended.Gui/GuiSystem.cs @@ -12,9 +12,9 @@ namespace MonoGame.Extended.Gui { BitmapFont DefaultFont { get; } Vector2 CursorPosition { get; } - GuiControl FocusedControl { get; } + Control FocusedControl { get; } - void SetFocus(GuiControl focusedControl); + void SetFocus(Control focusedControl); } public class GuiSystem : IGuiContext, IRectangular @@ -25,23 +25,23 @@ namespace MonoGame.Extended.Gui private readonly TouchListener _touchListener; private readonly KeyboardListener _keyboardListener; - private GuiControl _preFocusedControl; + private Control _preFocusedControl; - public GuiSystem(ViewportAdapter viewportAdapter, IGuiRenderer renderer, GuiSkin defaultSkin) + public GuiSystem(ViewportAdapter viewportAdapter, IGuiRenderer renderer, Skin defaultSkin) { _viewportAdapter = viewportAdapter; _renderer = renderer; _mouseListener = new MouseListener(viewportAdapter); - _mouseListener.MouseDown += (s, e) => OnPointerDown(GuiPointerEventArgs.FromMouseArgs(e)); - _mouseListener.MouseMoved += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromMouseArgs(e)); - _mouseListener.MouseUp += (s, e) => OnPointerUp(GuiPointerEventArgs.FromMouseArgs(e)); + _mouseListener.MouseDown += (s, e) => OnPointerDown(PointerEventArgs.FromMouseArgs(e)); + _mouseListener.MouseMoved += (s, e) => OnPointerMoved(PointerEventArgs.FromMouseArgs(e)); + _mouseListener.MouseUp += (s, e) => OnPointerUp(PointerEventArgs.FromMouseArgs(e)); _mouseListener.MouseWheelMoved += (s, e) => FocusedControl?.OnScrolled(e.ScrollWheelDelta); _touchListener = new TouchListener(viewportAdapter); - _touchListener.TouchStarted += (s, e) => OnPointerDown(GuiPointerEventArgs.FromTouchArgs(e)); - _touchListener.TouchMoved += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromTouchArgs(e)); - _touchListener.TouchEnded += (s, e) => OnPointerUp(GuiPointerEventArgs.FromTouchArgs(e)); + _touchListener.TouchStarted += (s, e) => OnPointerDown(PointerEventArgs.FromTouchArgs(e)); + _touchListener.TouchMoved += (s, e) => OnPointerMoved(PointerEventArgs.FromTouchArgs(e)); + _touchListener.TouchEnded += (s, e) => OnPointerUp(PointerEventArgs.FromTouchArgs(e)); _keyboardListener = new KeyboardListener(); _keyboardListener.KeyTyped += (sender, args) => PropagateDown(FocusedControl, x => x.OnKeyTyped(this, args)); @@ -50,11 +50,11 @@ namespace MonoGame.Extended.Gui DefaultSkin = defaultSkin; } - public GuiControl FocusedControl { get; private set; } - public GuiControl HoveredControl { get; private set; } + public Control FocusedControl { get; private set; } + public Control HoveredControl { get; private set; } - private GuiScreen _activeScreen; - public GuiScreen ActiveScreen + private Screen _activeScreen; + public Screen ActiveScreen { get { return _activeScreen; } set @@ -73,11 +73,11 @@ namespace MonoGame.Extended.Gui public Vector2 CursorPosition { get; set; } - public GuiSkin DefaultSkin { get; } + public Skin DefaultSkin { get; } public BitmapFont DefaultFont => DefaultSkin?.DefaultFont; - private void InitializeScreen(GuiScreen screen) + private void InitializeScreen(Screen screen) { screen.Layout(this, BoundingRectangle); } @@ -117,7 +117,7 @@ namespace MonoGame.Extended.Gui _renderer.End(); } - private void DrawWindows(GuiWindowCollection windows, float deltaSeconds) + private void DrawWindows(WindowCollection windows, float deltaSeconds) { foreach (var window in windows) { @@ -126,7 +126,7 @@ namespace MonoGame.Extended.Gui } } - private void DrawChildren(GuiControlCollection controls, float deltaSeconds) + private void DrawChildren(ControlCollection controls, float deltaSeconds) { foreach (var control in controls.Where(c => c.IsVisible)) { @@ -140,7 +140,7 @@ namespace MonoGame.Extended.Gui DrawChildren(childControl.Controls, deltaSeconds); } - private void OnPointerDown(GuiPointerEventArgs args) + private void OnPointerDown(PointerEventArgs args) { if (ActiveScreen == null || !ActiveScreen.IsVisible) return; @@ -149,7 +149,7 @@ namespace MonoGame.Extended.Gui PropagateDown(HoveredControl, x => x.OnPointerDown(this, args)); } - private void OnPointerUp(GuiPointerEventArgs args) + private void OnPointerUp(PointerEventArgs args) { if (ActiveScreen == null || !ActiveScreen.IsVisible) return; @@ -165,7 +165,7 @@ namespace MonoGame.Extended.Gui PropagateDown(HoveredControl, x => x.OnPointerUp(this, args)); } - private void OnPointerMoved(GuiPointerEventArgs args) + private void OnPointerMoved(PointerEventArgs args) { CursorPosition = args.Position.ToVector2(); @@ -188,7 +188,7 @@ namespace MonoGame.Extended.Gui } } - public void SetFocus(GuiControl focusedControl) + public void SetFocus(Control focusedControl) { if (FocusedControl != focusedControl) { @@ -214,7 +214,7 @@ namespace MonoGame.Extended.Gui /// /// The control we want to check against /// A function to check if the propagation should resume, if returns false it will continue down the tree. - private static void PropagateDown(GuiControl control, Func predicate) + private static void PropagateDown(Control control, Func predicate) { while(control != null && predicate(control)) { @@ -222,7 +222,7 @@ namespace MonoGame.Extended.Gui } } - private GuiControl FindControlAtPoint(Point point) + private Control FindControlAtPoint(Point point) { if (ActiveScreen == null || !ActiveScreen.IsVisible) return null; @@ -230,9 +230,9 @@ namespace MonoGame.Extended.Gui return FindControlAtPoint(ActiveScreen.Controls, point); } - private GuiControl FindControlAtPoint(GuiControlCollection controls, Point point) + private Control FindControlAtPoint(ControlCollection controls, Point point) { - var topMostControl = (GuiControl) null; + var topMostControl = (Control) null; for (var i = controls.Count - 1; i >= 0; i--) { diff --git a/Source/MonoGame.Extended.Gui/GuiWindowCollection.cs b/Source/MonoGame.Extended.Gui/GuiWindowCollection.cs deleted file mode 100644 index d79b4919..00000000 --- a/Source/MonoGame.Extended.Gui/GuiWindowCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MonoGame.Extended.Gui -{ - public class GuiWindowCollection : GuiElementCollection - { - public GuiWindowCollection(GuiScreen parent) - : base(parent) - { - } - } -} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/GuiLayoutHelper.cs b/Source/MonoGame.Extended.Gui/LayoutHelper.cs similarity index 89% rename from Source/MonoGame.Extended.Gui/GuiLayoutHelper.cs rename to Source/MonoGame.Extended.Gui/LayoutHelper.cs index 725bd2a0..6f52c2d0 100644 --- a/Source/MonoGame.Extended.Gui/GuiLayoutHelper.cs +++ b/Source/MonoGame.Extended.Gui/LayoutHelper.cs @@ -7,14 +7,14 @@ namespace MonoGame.Extended.Gui public enum HorizontalAlignment { Left, Right, Centre, Stretch } public enum VerticalAlignment { Top, Bottom, Centre, Stretch } - public static class GuiLayoutHelper + public static class LayoutHelper { - public static Size2 GetSizeWithMargins(GuiControl control, IGuiContext context, Size2 availableSize) + public static Size2 GetSizeWithMargins(Control control, IGuiContext context, Size2 availableSize) { return control.GetDesiredSize(context, availableSize) + control.Margin.Size; } - public static void PlaceControl(IGuiContext context, GuiControl control, float x, float y, float width, float height) + public static void PlaceControl(IGuiContext context, Control control, float x, float y, float width, float height) { var rectangle = new Rectangle((int)x, (int)y, (int)width, (int)height); var availableSize = new Size2(width, height); @@ -24,11 +24,11 @@ namespace MonoGame.Extended.Gui control.Position = new Vector2(control.Margin.Left + alignedRectangle.X, control.Margin.Top + alignedRectangle.Y); control.Size = alignedRectangle.Size - control.Margin.Size; - var layoutControl = control as GuiLayoutControl; + var layoutControl = control as LayoutControl; layoutControl?.Layout(context, new RectangleF(x, y, width, height)); } - public static void PlaceWindow(IGuiContext context, GuiWindow window, float x, float y, float width, float height) + public static void PlaceWindow(IGuiContext context, Window window, float x, float y, float width, float height) { var rectangle = new Rectangle((int)x, (int)y, (int)width, (int)height); var availableSize = new Size2(width, height); diff --git a/Source/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj b/Source/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj index 5b0fb2e1..fab7add7 100644 --- a/Source/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj +++ b/Source/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj @@ -38,44 +38,44 @@ bin\Release\MonoGame.Extended.Gui.XML - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - + + + + - - - + + + - + diff --git a/Source/MonoGame.Extended.Gui/Orientation.cs b/Source/MonoGame.Extended.Gui/Orientation.cs new file mode 100644 index 00000000..a12599ff --- /dev/null +++ b/Source/MonoGame.Extended.Gui/Orientation.cs @@ -0,0 +1,4 @@ +namespace MonoGame.Extended.Gui +{ + public enum Orientation { Horizontal, Vertical } +} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/GuiPointerEventArgs.cs b/Source/MonoGame.Extended.Gui/PointerEventArgs.cs similarity index 72% rename from Source/MonoGame.Extended.Gui/GuiPointerEventArgs.cs rename to Source/MonoGame.Extended.Gui/PointerEventArgs.cs index ca44a825..ee6dd32f 100644 --- a/Source/MonoGame.Extended.Gui/GuiPointerEventArgs.cs +++ b/Source/MonoGame.Extended.Gui/PointerEventArgs.cs @@ -4,9 +4,9 @@ using MonoGame.Extended.Input.InputListeners; namespace MonoGame.Extended.Gui { - public class GuiPointerEventArgs : EventArgs + public class PointerEventArgs : EventArgs { - private GuiPointerEventArgs() + private PointerEventArgs() { } @@ -16,9 +16,9 @@ namespace MonoGame.Extended.Gui public int ScrollWheelValue { get; private set; } public TimeSpan Time { get; private set; } - public static GuiPointerEventArgs FromMouseArgs(MouseEventArgs args) + public static PointerEventArgs FromMouseArgs(MouseEventArgs args) { - return new GuiPointerEventArgs + return new PointerEventArgs { Position = args.Position, Button = args.Button, @@ -28,9 +28,9 @@ namespace MonoGame.Extended.Gui }; } - public static GuiPointerEventArgs FromTouchArgs(TouchEventArgs args) + public static PointerEventArgs FromTouchArgs(TouchEventArgs args) { - return new GuiPointerEventArgs + return new PointerEventArgs { Position = args.Position, Button = MouseButton.Left, diff --git a/Source/MonoGame.Extended.Gui/GuiScreen.cs b/Source/MonoGame.Extended.Gui/Screen.cs similarity index 67% rename from Source/MonoGame.Extended.Gui/GuiScreen.cs rename to Source/MonoGame.Extended.Gui/Screen.cs index 299be11e..a66bc081 100644 --- a/Source/MonoGame.Extended.Gui/GuiScreen.cs +++ b/Source/MonoGame.Extended.Gui/Screen.cs @@ -9,14 +9,14 @@ using Newtonsoft.Json; namespace MonoGame.Extended.Gui { - public class GuiScreenRoot : GuiControl { } + public class ScreenRoot : Control { } - public class GuiScreen : GuiElement, IDisposable + public class Screen : Element, IDisposable { - public GuiScreen() + public Screen() { - Controls = new GuiControlCollection { ItemAdded = c => _isLayoutRequired = true }; - Windows = new GuiWindowCollection(this) { ItemAdded = w => _isLayoutRequired = true }; + Controls = new ControlCollection { ItemAdded = c => _isLayoutRequired = true }; + Windows = new WindowCollection(this) { ItemAdded = w => _isLayoutRequired = true }; } public virtual void Dispose() @@ -24,10 +24,10 @@ namespace MonoGame.Extended.Gui } [JsonProperty(Order = 1)] - public GuiControlCollection Controls { get; set; } + public ControlCollection Controls { get; set; } [JsonIgnore] - public GuiWindowCollection Windows { get; } + public WindowCollection Windows { get; } public new float Width { get; private set; } public new float Height { get; private set; } @@ -51,13 +51,13 @@ namespace MonoGame.Extended.Gui } public T FindControl(string name) - where T : GuiControl + where T : Control { return FindControl(Controls, name); } - private static T FindControl(GuiControlCollection controls, string name) - where T : GuiControl + private static T FindControl(ControlCollection controls, string name) + where T : Control { foreach (var control in controls) { @@ -82,10 +82,10 @@ namespace MonoGame.Extended.Gui Height = rectangle.Height; foreach (var control in Controls) - GuiLayoutHelper.PlaceControl(context, control, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); + LayoutHelper.PlaceControl(context, control, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); foreach (var window in Windows) - GuiLayoutHelper.PlaceWindow(context, window, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); + LayoutHelper.PlaceWindow(context, window, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); _isLayoutRequired = false; foreach (var control in Controls) control.IsLayoutRequired = false; @@ -96,21 +96,21 @@ namespace MonoGame.Extended.Gui renderer.DrawRectangle(BoundingRectangle, Color.Green); } - public static GuiScreen FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes) + public static Screen FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes) { - return FromStream(contentManager, stream, customControlTypes); + return FromStream(contentManager, stream, customControlTypes); } public static TScreen FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes) - where TScreen : GuiScreen + where TScreen : Screen { - var skinService = new GuiSkinService(); + var skinService = new SkinService(); var serializer = new GuiJsonSerializer(contentManager, customControlTypes) { Converters = { - new GuiSkinJsonConverter(contentManager, skinService, customControlTypes), - new GuiControlJsonConverter(skinService, customControlTypes) + new SkinJsonConverter(contentManager, skinService, customControlTypes), + new ControlJsonConverter(skinService, customControlTypes) } }; @@ -122,16 +122,16 @@ namespace MonoGame.Extended.Gui } } - public static GuiScreen FromFile(ContentManager contentManager, string path, params Type[] customControlTypes) + public static Screen FromFile(ContentManager contentManager, string path, params Type[] customControlTypes) { using (var stream = TitleContainer.OpenStream(path)) { - return FromStream(contentManager, stream, customControlTypes); + return FromStream(contentManager, stream, customControlTypes); } } public static TScreen FromFile(ContentManager contentManager, string path, params Type[] customControlTypes) - where TScreen : GuiScreen + where TScreen : Screen { using (var stream = TitleContainer.OpenStream(path)) { diff --git a/Source/MonoGame.Extended.Gui/ScreenCollection.cs b/Source/MonoGame.Extended.Gui/ScreenCollection.cs new file mode 100644 index 00000000..4fb8e9bf --- /dev/null +++ b/Source/MonoGame.Extended.Gui/ScreenCollection.cs @@ -0,0 +1,10 @@ +namespace MonoGame.Extended.Gui +{ + public class ScreenCollection : ElementCollection + { + public ScreenCollection(GuiSystem parent) + : base(parent) + { + } + } +} \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/Serialization/GuiAlignmentConverter.cs b/Source/MonoGame.Extended.Gui/Serialization/AlignmentConverter.cs similarity index 90% rename from Source/MonoGame.Extended.Gui/Serialization/GuiAlignmentConverter.cs rename to Source/MonoGame.Extended.Gui/Serialization/AlignmentConverter.cs index 4caf5aad..defea24a 100644 --- a/Source/MonoGame.Extended.Gui/Serialization/GuiAlignmentConverter.cs +++ b/Source/MonoGame.Extended.Gui/Serialization/AlignmentConverter.cs @@ -3,10 +3,7 @@ using Newtonsoft.Json; namespace MonoGame.Extended.Gui.Serialization { - /// - /// This converter handles the different spellings of Center. - /// - public class GuiAlignmentConverter : JsonConverter + public class AlignmentConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { diff --git a/Source/MonoGame.Extended.Gui/Serialization/GuiControlJsonConverter.cs b/Source/MonoGame.Extended.Gui/Serialization/ControlJsonConverter.cs similarity index 65% rename from Source/MonoGame.Extended.Gui/Serialization/GuiControlJsonConverter.cs rename to Source/MonoGame.Extended.Gui/Serialization/ControlJsonConverter.cs index fccc7416..8d670b2e 100644 --- a/Source/MonoGame.Extended.Gui/Serialization/GuiControlJsonConverter.cs +++ b/Source/MonoGame.Extended.Gui/Serialization/ControlJsonConverter.cs @@ -4,16 +4,16 @@ using Newtonsoft.Json; namespace MonoGame.Extended.Gui.Serialization { - public class GuiControlJsonConverter : JsonConverter + public class ControlJsonConverter : JsonConverter { private readonly IGuiSkinService _guiSkinService; - private readonly GuiControlStyleJsonConverter _styleConverter; + private readonly ControlStyleJsonConverter _styleConverter; private const string _styleProperty = "Style"; - public GuiControlJsonConverter(IGuiSkinService guiSkinService, params Type[] customControlTypes) + public ControlJsonConverter(IGuiSkinService guiSkinService, params Type[] customControlTypes) { _guiSkinService = guiSkinService; - _styleConverter = new GuiControlStyleJsonConverter(customControlTypes); + _styleConverter = new ControlStyleJsonConverter(customControlTypes); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) @@ -23,15 +23,15 @@ namespace MonoGame.Extended.Gui.Serialization public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var skin = _guiSkinService.Skin; - var style = (GuiControlStyle) _styleConverter.ReadJson(reader, objectType, existingValue, serializer); + var style = (ControlStyle) _styleConverter.ReadJson(reader, objectType, existingValue, serializer); var template = GetControlTemplate(style); var control = skin.Create(style.TargetType, template); object childControls; - if (style.TryGetValue(nameof(GuiControl.Controls), out childControls)) + if (style.TryGetValue(nameof(Control.Controls), out childControls)) { - var controlCollection = childControls as GuiControlCollection; + var controlCollection = childControls as ControlCollection; if (controlCollection != null) { @@ -46,10 +46,10 @@ namespace MonoGame.Extended.Gui.Serialization public override bool CanConvert(Type objectType) { - return objectType == typeof(GuiControl); + return objectType == typeof(Control); } - private static string GetControlTemplate(GuiControlStyle style) + private static string GetControlTemplate(ControlStyle style) { object template; diff --git a/Source/MonoGame.Extended.Gui/Serialization/GuiControlStyleJsonConverter.cs b/Source/MonoGame.Extended.Gui/Serialization/ControlStyleJsonConverter.cs similarity index 87% rename from Source/MonoGame.Extended.Gui/Serialization/GuiControlStyleJsonConverter.cs rename to Source/MonoGame.Extended.Gui/Serialization/ControlStyleJsonConverter.cs index d3d7a8ac..c258304b 100644 --- a/Source/MonoGame.Extended.Gui/Serialization/GuiControlStyleJsonConverter.cs +++ b/Source/MonoGame.Extended.Gui/Serialization/ControlStyleJsonConverter.cs @@ -9,26 +9,26 @@ using Newtonsoft.Json; namespace MonoGame.Extended.Gui.Serialization { - public class GuiControlStyleJsonConverter : JsonConverter + public class ControlStyleJsonConverter : JsonConverter { private readonly Dictionary _controlTypes; private const string _typeProperty = "Type"; private const string _nameProperty = "Name"; - public GuiControlStyleJsonConverter(params Type[] customControlTypes) + public ControlStyleJsonConverter(params Type[] customControlTypes) { - _controlTypes = typeof(GuiControl) + _controlTypes = typeof(Control) .GetTypeInfo() .Assembly .ExportedTypes .Concat(customControlTypes) - .Where(t => t.GetTypeInfo().IsSubclassOf(typeof(GuiControl))) + .Where(t => t.GetTypeInfo().IsSubclassOf(typeof(Control))) .ToDictionary(t => t.Name); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - var style = (GuiControlStyle)value; + var style = (ControlStyle)value; var dictionary = new Dictionary { [_typeProperty] = style.TargetType.Name }; foreach (var keyValuePair in style) @@ -42,11 +42,11 @@ namespace MonoGame.Extended.Gui.Serialization var dictionary = serializer.Deserialize>(reader); var name = dictionary.GetValueOrDefault(_nameProperty) as string; var typeName = dictionary.GetValueOrDefault(_typeProperty) as string; - var targetType = typeName != null ? _controlTypes[typeName] : typeof(GuiControl); + var targetType = typeName != null ? _controlTypes[typeName] : typeof(Control); var properties = targetType .GetRuntimeProperties() .ToDictionary(p => p.Name); - var style = new GuiControlStyle(name, targetType); + var style = new ControlStyle(name, targetType); foreach (var keyValuePair in dictionary.Where(i => i.Key != _typeProperty)) { @@ -77,7 +77,7 @@ namespace MonoGame.Extended.Gui.Serialization public override bool CanConvert(Type objectType) { - return objectType == typeof(GuiControlStyle); + return objectType == typeof(ControlStyle); } } } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/Serialization/GuiJsonSerializer.cs b/Source/MonoGame.Extended.Gui/Serialization/GuiJsonSerializer.cs index 37d49124..419a855c 100644 --- a/Source/MonoGame.Extended.Gui/Serialization/GuiJsonSerializer.cs +++ b/Source/MonoGame.Extended.Gui/Serialization/GuiJsonSerializer.cs @@ -16,11 +16,11 @@ namespace MonoGame.Extended.Gui.Serialization Converters.Add(new ColorJsonConverter()); Converters.Add(new ThicknessJsonConverter()); Converters.Add(new ContentManagerJsonConverter(contentManager, font => font.Name)); - Converters.Add(new GuiControlStyleJsonConverter(customControlTypes)); + Converters.Add(new ControlStyleJsonConverter(customControlTypes)); Converters.Add(new GuiTextureAtlasJsonConverter(contentManager, textureRegionService)); Converters.Add(new GuiNinePatchRegion2DJsonConverter(textureRegionService)); Converters.Add(new TextureRegion2DJsonConverter(textureRegionService)); - Converters.Add(new GuiAlignmentConverter()); + Converters.Add(new AlignmentConverter()); ContractResolver = new ShortNameJsonContractResolver(); Formatting = Formatting.Indented; } diff --git a/Source/MonoGame.Extended.Gui/Serialization/GuiSkinJsonConverter.cs b/Source/MonoGame.Extended.Gui/Serialization/SkinJsonConverter.cs similarity index 69% rename from Source/MonoGame.Extended.Gui/Serialization/GuiSkinJsonConverter.cs rename to Source/MonoGame.Extended.Gui/Serialization/SkinJsonConverter.cs index 39c0a3ff..c167e9fd 100644 --- a/Source/MonoGame.Extended.Gui/Serialization/GuiSkinJsonConverter.cs +++ b/Source/MonoGame.Extended.Gui/Serialization/SkinJsonConverter.cs @@ -7,21 +7,21 @@ namespace MonoGame.Extended.Gui.Serialization { public interface IGuiSkinService { - GuiSkin Skin { get; set; } + Skin Skin { get; set; } } - public class GuiSkinService : IGuiSkinService + public class SkinService : IGuiSkinService { - public GuiSkin Skin { get; set; } + public Skin Skin { get; set; } } - public class GuiSkinJsonConverter : JsonConverter + public class SkinJsonConverter : JsonConverter { private readonly ContentManager _contentManager; private readonly IGuiSkinService _skinService; private readonly Type[] _customControlTypes; - public GuiSkinJsonConverter(ContentManager contentManager, IGuiSkinService skinService, params Type[] customControlTypes) + public SkinJsonConverter(ContentManager contentManager, IGuiSkinService skinService, params Type[] customControlTypes) { _contentManager = contentManager; _skinService = skinService; @@ -41,18 +41,18 @@ namespace MonoGame.Extended.Gui.Serialization // TODO: Load this using the ContentManager instead. using (var stream = TitleContainer.OpenStream(assetName)) { - var skin = GuiSkin.FromStream(_contentManager, stream, _customControlTypes); + var skin = Skin.FromStream(_contentManager, stream, _customControlTypes); _skinService.Skin = skin; return skin; } } - throw new InvalidOperationException($"{nameof(GuiSkinJsonConverter)} can only convert from a string"); + throw new InvalidOperationException($"{nameof(SkinJsonConverter)} can only convert from a string"); } public override bool CanConvert(Type objectType) { - return objectType == typeof(GuiSkin); + return objectType == typeof(Skin); } } } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/GuiSkin.cs b/Source/MonoGame.Extended.Gui/Skin.cs similarity index 51% rename from Source/MonoGame.Extended.Gui/GuiSkin.cs rename to Source/MonoGame.Extended.Gui/Skin.cs index f88cdaca..abff2a5f 100644 --- a/Source/MonoGame.Extended.Gui/GuiSkin.cs +++ b/Source/MonoGame.Extended.Gui/Skin.cs @@ -14,14 +14,14 @@ using Newtonsoft.Json; namespace MonoGame.Extended.Gui { - public class GuiSkin + public class Skin { - public GuiSkin() + public Skin() { TextureAtlases = new List(); Fonts = new List(); NinePatches = new List(); - Styles = new KeyedCollection(s => s.Name ?? s.TargetType.Name); + Styles = new KeyedCollection(s => s.Name ?? s.TargetType.Name); } [JsonProperty(Order = 0)] @@ -40,19 +40,19 @@ namespace MonoGame.Extended.Gui public BitmapFont DefaultFont => Fonts.FirstOrDefault(); [JsonProperty(Order = 5)] - public GuiCursor Cursor { get; set; } + public Cursor Cursor { get; set; } [JsonProperty(Order = 6)] - public KeyedCollection Styles { get; private set; } + public KeyedCollection Styles { get; private set; } - public GuiControlStyle GetStyle(string name) + public ControlStyle GetStyle(string name) { return Styles[name]; } - public GuiControlStyle GetStyle(Type controlType) + public ControlStyle GetStyle(Type controlType) { - GuiControlStyle controlStyle = null; + ControlStyle controlStyle = null; while (controlStyle == null && controlType != null) { @@ -63,7 +63,7 @@ namespace MonoGame.Extended.Gui return controlStyle; } - public static GuiSkin FromFile(ContentManager contentManager, string path, params Type[] customControlTypes) + public static Skin FromFile(ContentManager contentManager, string path, params Type[] customControlTypes) { using (var stream = TitleContainer.OpenStream(path)) { @@ -71,26 +71,26 @@ namespace MonoGame.Extended.Gui } } - public static GuiSkin FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes) + public static Skin FromStream(ContentManager contentManager, Stream stream, params Type[] customControlTypes) { var skinSerializer = new GuiJsonSerializer(contentManager, customControlTypes); using (var streamReader = new StreamReader(stream)) using (var jsonReader = new JsonTextReader(streamReader)) { - return skinSerializer.Deserialize(jsonReader); + return skinSerializer.Deserialize(jsonReader); } } public T Create(string template, string name = null, string text = null) - where T : GuiControl, new() + where T : Control, new() { return Create(template, Vector2.Zero, name, text); } public T Create(string template, Vector2 position, string name = null, string text = null) - where T : GuiControl, new() + where T : Control, new() { var control = new T(); GetStyle(template).Apply(control); @@ -101,7 +101,7 @@ namespace MonoGame.Extended.Gui } public T Create(string template, Action onCreate) - where T : GuiControl, new() + where T : Control, new() { var control = new T(); GetStyle(template).Apply(control); @@ -109,9 +109,9 @@ namespace MonoGame.Extended.Gui return control; } - public GuiControl Create(Type type, string template) + public Control Create(Type type, string template) { - var control = (GuiControl)Activator.CreateInstance(type); + var control = (Control)Activator.CreateInstance(type); if (template != null) GetStyle(template).Apply(control); @@ -119,59 +119,59 @@ namespace MonoGame.Extended.Gui return control; } - public static GuiSkin FromDefault(BitmapFont font) + public static Skin FromDefault(BitmapFont font) { - var skin = new GuiSkin + var skin = new Skin { Fonts = { font }, Styles = { - new GuiControlStyle(typeof(GuiControl)) + new ControlStyle(typeof(Control)) { - {nameof(GuiControl.Color), new Color(51, 51, 55)}, - {nameof(GuiControl.BorderColor), new Color(67, 67, 70)}, - {nameof(GuiControl.BorderThickness), 1}, - {nameof(GuiControl.TextColor), new Color(241, 241, 241)}, - {nameof(GuiStackPanel.Padding), new Thickness(5)} + {nameof(Control.Color), new Color(51, 51, 55)}, + {nameof(Control.BorderColor), new Color(67, 67, 70)}, + {nameof(Control.BorderThickness), 1}, + {nameof(Control.TextColor), new Color(241, 241, 241)}, + {nameof(StackPanel.Padding), new Thickness(5)} }, - new GuiControlStyle(typeof(GuiComboBox)) + new ControlStyle(typeof(ComboBox)) { - {nameof(GuiControl.Color), new Color(51, 51, 55)}, - {nameof(GuiControl.BorderColor), new Color(67, 67, 70)}, - {nameof(GuiControl.BorderThickness), 1}, - {nameof(GuiControl.TextColor), new Color(241, 241, 241)}, - {nameof(GuiStackPanel.Padding), new Thickness(5)}, - {nameof(GuiComboBox.DropDownColor) , new Color(51, 51, 55)} + {nameof(Control.Color), new Color(51, 51, 55)}, + {nameof(Control.BorderColor), new Color(67, 67, 70)}, + {nameof(Control.BorderThickness), 1}, + {nameof(Control.TextColor), new Color(241, 241, 241)}, + {nameof(StackPanel.Padding), new Thickness(5)}, + {nameof(ComboBox.DropDownColor) , new Color(51, 51, 55)} }, - new GuiControlStyle(typeof(GuiLabel)) + new ControlStyle(typeof(Label)) { - {nameof(GuiControl.Color), Color.Transparent}, - {nameof(GuiControl.TextColor), Color.White} + {nameof(Control.Color), Color.Transparent}, + {nameof(Control.TextColor), Color.White} }, - new GuiControlStyle(typeof(GuiTextBox)) + new ControlStyle(typeof(TextBox)) { - {nameof(GuiControl.Color), Color.LightGray}, - {nameof(GuiControl.TextColor), Color.Black}, - {nameof(GuiControl.BorderColor), new Color(67, 67, 70)}, + {nameof(Control.Color), Color.LightGray}, + {nameof(Control.TextColor), Color.Black}, + {nameof(Control.BorderColor), new Color(67, 67, 70)}, }, - new GuiControlStyle(typeof(GuiButton)) + new ControlStyle(typeof(Button)) { - {nameof(GuiControl.Color), new Color(51, 51, 55)}, - {nameof(GuiControl.BorderColor), new Color(67, 67, 70)}, - {nameof(GuiControl.BorderThickness), 1}, - {nameof(GuiControl.TextColor), new Color(241, 241, 241)}, + {nameof(Control.Color), new Color(51, 51, 55)}, + {nameof(Control.BorderColor), new Color(67, 67, 70)}, + {nameof(Control.BorderThickness), 1}, + {nameof(Control.TextColor), new Color(241, 241, 241)}, { - nameof(GuiControl.HoverStyle), - new GuiControlStyle + nameof(Control.HoverStyle), + new ControlStyle { - {nameof(GuiButton.Color), new Color(62, 62, 64)} + {nameof(Button.Color), new Color(62, 62, 64)} } }, { - nameof(GuiButton.PressedStyle), - new GuiControlStyle + nameof(Button.PressedStyle), + new ControlStyle { - {nameof(GuiButton.Color), new Color(0, 122, 204)} + {nameof(Button.Color), new Color(0, 122, 204)} } } } diff --git a/Source/MonoGame.Extended.Gui/GuiWindow.cs b/Source/MonoGame.Extended.Gui/Window.cs similarity index 73% rename from Source/MonoGame.Extended.Gui/GuiWindow.cs rename to Source/MonoGame.Extended.Gui/Window.cs index c983e4b1..c1baa373 100644 --- a/Source/MonoGame.Extended.Gui/GuiWindow.cs +++ b/Source/MonoGame.Extended.Gui/Window.cs @@ -4,14 +4,14 @@ using MonoGame.Extended.Gui.Controls; namespace MonoGame.Extended.Gui { - public class GuiWindow : GuiElement + public class Window : Element { - public GuiWindow(GuiScreen parent) + public Window(Screen parent) { Parent = parent; } - public GuiControlCollection Controls { get; } = new GuiControlCollection(); + public ControlCollection Controls { get; } = new ControlCollection(); public void Show() { @@ -36,7 +36,7 @@ namespace MonoGame.Extended.Gui public void Layout(IGuiContext context, RectangleF rectangle) { foreach (var control in Controls) - GuiLayoutHelper.PlaceControl(context, control, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); + LayoutHelper.PlaceControl(context, control, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } } } \ No newline at end of file diff --git a/Source/MonoGame.Extended.Gui/WindowCollection.cs b/Source/MonoGame.Extended.Gui/WindowCollection.cs new file mode 100644 index 00000000..5a56e429 --- /dev/null +++ b/Source/MonoGame.Extended.Gui/WindowCollection.cs @@ -0,0 +1,10 @@ +namespace MonoGame.Extended.Gui +{ + public class WindowCollection : ElementCollection + { + public WindowCollection(Screen parent) + : base(parent) + { + } + } +} \ No newline at end of file