[GUI] Adding support for parent propegation, the idea of forms and textbox highlighting (#439)

* Adding in changes to deal with custom control types for loading from a GuiScreen, also adding in block text if a width for the element exists.  Adding in Padding to some elements to give the developer some more options in styles.  Adding in some changes to the textbox to deal with selecting a section of text.

* Adding in a few changes to deal with propagation down the GuiControl tree, this was added to most events.  Also, adding in the idea of a form and submit button to deal with keyboard controls when inside of a form.  This gives simalar behavier to how forms work in the browser.

* Adding in the enter key skip for the textbox.
This commit is contained in:
tspayne87
2017-11-21 10:50:24 +10:00
committed by Dylan Wilson
parent 5a7f012bff
commit 46f3f99b39
19 changed files with 614 additions and 106 deletions
@@ -7,12 +7,13 @@ namespace MonoGame.Extended.Gui.Serialization
public class GuiControlJsonConverter : JsonConverter
{
private readonly IGuiSkinService _guiSkinService;
private readonly GuiControlStyleJsonConverter _styleConverter = new GuiControlStyleJsonConverter();
private readonly GuiControlStyleJsonConverter _styleConverter;
private const string _styleProperty = "Style";
public GuiControlJsonConverter(IGuiSkinService guiSkinService)
public GuiControlJsonConverter(IGuiSkinService guiSkinService, params Type[] customControlTypes)
{
_guiSkinService = guiSkinService;
_styleConverter = new GuiControlStyleJsonConverter(customControlTypes);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@@ -19,11 +19,13 @@ namespace MonoGame.Extended.Gui.Serialization
{
private readonly ContentManager _contentManager;
private readonly IGuiSkinService _skinService;
private readonly Type[] _customControlTypes;
public GuiSkinJsonConverter(ContentManager contentManager, IGuiSkinService skinService)
public GuiSkinJsonConverter(ContentManager contentManager, IGuiSkinService skinService, params Type[] customControlTypes)
{
_contentManager = contentManager;
_skinService = skinService;
_customControlTypes = customControlTypes;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@@ -39,7 +41,7 @@ namespace MonoGame.Extended.Gui.Serialization
// TODO: Load this using the ContentManager instead.
using (var stream = TitleContainer.OpenStream(assetName))
{
var skin = GuiSkin.FromStream(_contentManager, stream);
var skin = GuiSkin.FromStream(_contentManager, stream, _customControlTypes);
_skinService.Skin = skin;
return skin;
}