Skip to content

Commit

Permalink
Version 0.4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Mar 7, 2017
1 parent ccfecea commit 9041a36
Show file tree
Hide file tree
Showing 16 changed files with 454 additions and 180 deletions.
4 changes: 2 additions & 2 deletions Myra.Content.Pipeline/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
4 changes: 2 additions & 2 deletions Myra.Editor/Myra.Editor.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Myra.Editor</id>
<version>0.3.9.7</version>
<version>0.4.0.0</version>
<title>Myra.Editor</title>
<authors>MyraTeam</authors>
<owners>MyraTeam</owners>
Expand All @@ -13,7 +13,7 @@
<copyright>Copyright 2017</copyright>
<tags>gamedev monogame</tags>
<dependencies>
<dependency id="Myra" version="0.3.9.7" />
<dependency id="Myra" version="0.4.0.0" />
</dependencies>
</metadata>
<files>
Expand Down
6 changes: 3 additions & 3 deletions Myra.Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Myra.Editor")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyCopyright("Copyright © 2016-2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
186 changes: 97 additions & 89 deletions Myra.Editor/UI/PropertyGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,76 @@ public override void SetValue(object obj, object value)
}
}

private class SubGrid : GridBased
{
private readonly ImageButton _mark;

public ImageButton Mark
{
get { return _mark; }
}

public SubGrid(PropertyGrid parent, object value, string header, string category, Record parentProperty)
{
ColumnSpacing = 2;
RowSpacing = 2;

ColumnsProportions.Add(new Proportion(ProportionType.Auto));
ColumnsProportions.Add(new Proportion(ProportionType.Fill));
RowsProportions.Add(new Proportion(ProportionType.Auto));
RowsProportions.Add(new Proportion(ProportionType.Auto));

var propertyGrid = new PropertyGrid(parent.PropertyGridStyle, category)
{
Object = value,
Visible = false,
HorizontalAlignment = HorizontalAlignment.Stretch,
GridPositionX = 1,
GridPositionY = 1,
ColorChangeHandler = parent.ColorChangeHandler,
_parentGrid = parent,
_parentProperty = parentProperty
};

// Mark
_mark = new ImageButton(parent.PropertyGridStyle.MarkStyle)
{
Toggleable = true,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center
};

Widgets.Add(_mark);

_mark.Down += (sender, args) =>
{
propertyGrid.Visible = true;
parent._expandedCategories.Add(category);
};

_mark.Up += (sender, args) =>
{
propertyGrid.Visible = false;
parent._expandedCategories.Remove(category);
};

var label = new TextBlock(parent.PropertyGridStyle.LabelStyle)
{
Text = header,
GridPositionX = 1
};

label.DoubleClick += (sender, args) =>
{
_mark.IsPressed = !_mark.IsPressed;
};

Widgets.Add(label);

Widgets.Add(propertyGrid);
}
}

private PropertyGrid _parentGrid;
private Record _parentProperty;
private readonly Dictionary<string, List<Record>> _records = new Dictionary<string, List<Record>>();
Expand Down Expand Up @@ -121,7 +191,7 @@ public object Object

public Func<Color?, Color?> ColorChangeHandler { get; set; }

public event EventHandler<GenericEventArgs<string>> PropertyChanged;
public event EventHandler<GenericEventArgs<string>> PropertyChanged;

public PropertyGrid(TreeStyle style, string category)
{
Expand All @@ -144,7 +214,6 @@ public PropertyGrid(string category) : this(DefaultAssets.UIStylesheet.TreeStyle

public PropertyGrid() : this(DefaultCategoryName)
{

}

private void FireChanged(string name)
Expand All @@ -161,69 +230,6 @@ private static void UpdateLabelCount(TextBlock textBlock, int count)
textBlock.Text = string.Format("{0} Items", count);
}

private Grid CreateSubGrid(object value, string header, string category, Record parentProperty)
{
var subGrid = new Grid
{
ColumnSpacing = 2,
RowSpacing = 2
};

subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));
subGrid.RowsProportions.Add(new Proportion(ProportionType.Auto));
subGrid.RowsProportions.Add(new Proportion(ProportionType.Auto));

var propertyGrid = new PropertyGrid(PropertyGridStyle, category)
{
Object = value,
Visible = false,
HorizontalAlignment = HorizontalAlignment.Stretch,
GridPositionX = 1,
GridPositionY = 1,
ColorChangeHandler = ColorChangeHandler,
_parentGrid = this,
_parentProperty = parentProperty
};

// Mark
var mark = new ImageButton(PropertyGridStyle.MarkStyle)
{
Toggleable = true,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center
};

subGrid.Widgets.Add(mark);

mark.Down += (sender, args) =>
{
propertyGrid.Visible = true;
};

mark.Up += (sender, args) =>
{
propertyGrid.Visible = false;
};

var label = new TextBlock(PropertyGridStyle.LabelStyle)
{
Text = header,
GridPositionX = 1
};

label.DoubleClick += (sender, args) =>
{
mark.IsPressed = !mark.IsPressed;
};

subGrid.Widgets.Add(label);

subGrid.Widgets.Add(propertyGrid);

return subGrid;
}

private void FillSubGrid(ref int y, IReadOnlyList<Record> records)
{
for (var i = 0; i < records.Count; ++i)
Expand Down Expand Up @@ -266,9 +272,9 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)

valueWidget = cb;
}
else if (propertyType == typeof(bool))
else if (propertyType == typeof (bool))
{
var isChecked = (bool)value;
var isChecked = (bool) value;
var cb = new CheckBox
{
IsPressed = isChecked
Expand Down Expand Up @@ -297,27 +303,27 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)
valueWidget = cb;

}
else if (propertyType == typeof(Color) || propertyType == typeof(Color?))
else if (propertyType == typeof (Color) || propertyType == typeof (Color?))
{
var subGrid = new Grid
{
ColumnSpacing = 8,
HorizontalAlignment = HorizontalAlignment.Stretch
};

var isColor = propertyType == typeof(Color);
var isColor = propertyType == typeof (Color);

subGrid.ColumnsProportions.Add(new Proportion());
subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));

var color = Color.Transparent;
if (isColor)
{
color = (Color)value;
color = (Color) value;
}
else if (value != null)
{
color = ((Color?)value).Value;
color = ((Color?) value).Value;
}

var sprite = Sprite.CreateSolidColorRect(color);
Expand Down Expand Up @@ -375,7 +381,7 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)

valueWidget = subGrid;
}
else if (propertyType.IsAssignableFrom(typeof(Drawable)))
else if (propertyType.IsAssignableFrom(typeof (Drawable)))
{
}
else if (propertyType.IsEnum)
Expand Down Expand Up @@ -408,8 +414,8 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)

valueWidget = cb;
}
else if (propertyType.IsNumericType() ||
(propertyType.IsNullablePrimitive() && propertyType.GetNullableType().IsNumericType()))
else if (propertyType.IsNumericType() ||
(propertyType.IsNullablePrimitive() && propertyType.GetNullableType().IsNumericType()))
{
var numericType = propertyType;
if (propertyType.IsNullablePrimitive())
Expand All @@ -421,7 +427,7 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)
{
Integer = numericType.IsNumericInteger(),
Nullable = propertyType.IsNullablePrimitive(),
Value = value != null ? (float)Convert.ChangeType(value, typeof (float)) : default(float?)
Value = value != null ? (float) Convert.ChangeType(value, typeof (float)) : default(float?)
};

if (record.HasSetter)
Expand Down Expand Up @@ -476,7 +482,7 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)

valueWidget = spinButton;
}
else if (propertyType == typeof(string) || propertyType.IsPrimitive || propertyType.IsNullablePrimitive())
else if (propertyType == typeof (string) || propertyType.IsPrimitive || propertyType.IsNullablePrimitive())
{
var tf = new TextField
{
Expand Down Expand Up @@ -542,15 +548,15 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)

valueWidget = tf;
}
else if (typeof(IList).IsAssignableFrom(propertyType))
else if (typeof (IList).IsAssignableFrom(propertyType))
{
var it = propertyType.FindGenericType(typeof(ICollection<>));
var it = propertyType.FindGenericType(typeof (ICollection<>));
if (it != null)
{
var itemType = it.GenericTypeArguments[0];
if (value != null)
{
var items = (IList)value;
var items = (IList) value;

var subGrid = new Grid
{
Expand Down Expand Up @@ -606,10 +612,11 @@ private void FillSubGrid(ref int y, IReadOnlyList<Record> records)
// Subgrid
if (value != null)
{
var subGrid = CreateSubGrid(value, record.Name, DefaultCategoryName, record);

subGrid.GridSpanX = 2;
subGrid.GridPositionY = y;
var subGrid = new SubGrid(this, value, record.Name, DefaultCategoryName, record)
{
GridSpanX = 2,
GridPositionY = y
};

Widgets.Add(subGrid);

Expand Down Expand Up @@ -772,24 +779,25 @@ private void Rebuild()
continue;
}

var subGrid = CreateSubGrid(Object, category.Key, category.Key, null);

subGrid.GridSpanX = 2;
subGrid.GridPositionY = y;
var subGrid = new SubGrid(this, Object, category.Key, category.Key, null)
{
GridSpanX = 2,
GridPositionY = y
};

Widgets.Add(subGrid);

if (_expandedCategories.Contains(category.Key))
{
// mark.IsPressed = true;
subGrid.Mark.IsPressed = true;
}

var rp = new Proportion(ProportionType.Auto);
RowsProportions.Add(rp);

y++;
}
}
}

public void ApplyPropertyGridStyle(TreeStyle style)
{
Expand Down
Loading

0 comments on commit 9041a36

Please sign in to comment.