Improving property editor layout

This commit is contained in:
LarsBrubaker 2020-05-18 21:47:35 -07:00
parent bf40aa3dc0
commit 4f969addb4
4 changed files with 45 additions and 24 deletions

View file

@ -27,31 +27,30 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using ClipperLib;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Image.ThresholdFunctions;
using MatterHackers.Agg.Transform;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
using MatterHackers.MarchingSquares;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Polygon = System.Collections.Generic.List<ClipperLib.IntPoint>;
using Polygons = System.Collections.Generic.List<System.Collections.Generic.List<ClipperLib.IntPoint>>;
namespace MatterHackers.MatterControl.DesignTools
{
using MatterHackers.Agg.Image.ThresholdFunctions;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath;
using System.ComponentModel.DataAnnotations;
using Polygon = List<IntPoint>;
using Polygons = List<List<IntPoint>>;
public class ImageToPathObject3D : Object3D, IPathObject, IEditorDraw
{
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
@ -64,12 +63,22 @@ namespace MatterHackers.MatterControl.DesignTools
Name = "Image to Path".Localize();
}
public enum ThresholdFunctions { Silhouette, Intensity, Alpha, Hue }
public enum ThresholdFunctions
{
Silhouette,
Intensity,
Alpha,
Hue
}
[EnumRename("Alpha", "Transparency")]
public ThresholdFunctions FeatureDetector
{
get { return _featureDetector; }
get
{
return _featureDetector;
}
set
{
if (value != _featureDetector)
@ -126,6 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
_histogramDisplayCache = new ImageBuffer(_histogramRawCache);
}
UpdateHistogramDisplay();
return _histogramDisplayCache;
@ -155,6 +165,7 @@ namespace MatterHackers.MatterControl.DesignTools
[Range(0, 1, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
public double RangeStart { get; set; } = .1;
[Range(0, 1, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
public double RangeEnd { get; set; } = 1;

View file

@ -509,7 +509,11 @@ namespace MatterHackers.MatterControl.DesignTools
else if (propertyValue is ImageBuffer imageBuffer)
{
rowContainer = CreateSettingsColumn(property);
rowContainer.AddChild(new ImageWidget(imageBuffer));
rowContainer.AddChild(new ImageWidget(imageBuffer)
{
HAnchor = HAnchor.Left,
Margin = new BorderDouble(0, 3)
});
}
#if !__ANDROID__
else if (propertyValue is List<string> stringList)
@ -532,7 +536,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
if (readOnly)
{
var valueField = new WrappedTextWidget(intValue.ToString(),
var valueField = new TextWidget(intValue.ToString(),
textColor: theme.TextColor,
pointSize: 10);
@ -582,11 +586,12 @@ namespace MatterHackers.MatterControl.DesignTools
{
if (readOnly)
{
var valueField = new TextWidget(stringValue, textColor: theme.TextColor, pointSize: 10);
rowContainer = new SettingsRow(property.DisplayName.Localize(),
property.Description.Localize(),
valueField,
theme);
rowContainer = new WrappedTextWidget(stringValue,
textColor: theme.TextColor,
pointSize: 10)
{
Margin = 5
};
}
else // normal edit row
{
@ -633,7 +638,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
field = new EnumDisplayField(property, enumDisplayAttribute, theme)
{
InitialValue = propertyValue.ToString()
InitialValue = propertyValue.ToString(),
};
if (enumDisplayAttribute.Mode == EnumDisplayAttribute.PresentationMode.Tabs)

View file

@ -183,6 +183,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,
Margin = new BorderDouble(8, 5)
};
imageSection.ContentPanel.AddChild(row);
@ -191,6 +192,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
Checked = imageObject.Invert,
Margin = new BorderDouble(0),
VAnchor = VAnchor.Center,
};
invertCheckbox.CheckedStateChanged += (s, e) =>
{

View file

@ -82,7 +82,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private void AddTabs(IEnumerable<(string Key, string Value)> enumItems)
{
var menuRow = new FlowLayoutWidget();
var menuRow = new FlowLayoutWidget()
{
Margin = 5
};
int index = 0;
foreach (var enumItem in enumItems)