Move static PPE.CreateSettingsRow() to new SettingRow constructor

- Improve reuse and consistency with shared constructor on actual type
This commit is contained in:
John Lewin 2019-05-26 11:08:08 -07:00
parent be8f83d59f
commit df7ea996d1
4 changed files with 22 additions and 25 deletions

View file

@ -201,20 +201,7 @@ namespace MatterHackers.MatterControl.DesignTools
private static GuiWidget CreateSettingsRow(EditableProperty property, UIField field, ThemeConfig theme)
{
return CreateSettingsRow(property.DisplayName.Localize(), property.Description.Localize(), field.Content, theme);
}
public static GuiWidget CreateSettingsRow(string labelText, string toolTipText, GuiWidget guiWidget, ThemeConfig theme)
{
guiWidget.VAnchor |= VAnchor.Center;
var row = new SettingsRow(labelText, toolTipText, theme)
{
Padding = new BorderDouble(right: theme.DefaultContainerPadding)
};
row.AddChild(guiWidget);
return row;
return new SettingsRow(property.DisplayName.Localize(), property.Description.Localize(), field.Content, theme);
}
private static FlowLayoutWidget CreateSettingsColumn(EditableProperty property, UIField field)
@ -409,7 +396,7 @@ namespace MatterHackers.MatterControl.DesignTools
field1.Initialize(0);
field1.SetValue(newDirectionVector);
rowContainer.AddChild(CreateSettingsRow("Axis".Localize(), null, field1.Content, theme));
rowContainer.AddChild(new SettingsRow("Axis".Localize(), null, field1.Content, theme));
// the direction axis
// the distance from the center of the part
@ -816,7 +803,7 @@ namespace MatterHackers.MatterControl.DesignTools
};
theme.ApplyPrimaryActionStyle(detailsLink);
return CreateSettingsRow("Demo Mode".Localize(), null, detailsLink, theme);
return new SettingsRow("Demo Mode".Localize(), null, detailsLink, theme);
}
private void AddWebPageLinkIfRequired(PPEContext context, FlowLayoutWidget editControlsContainer, ThemeConfig theme)
@ -834,7 +821,7 @@ namespace MatterHackers.MatterControl.DesignTools
};
// website row
editControlsContainer.AddChild(CreateSettingsRow("Website".Localize(), null, detailsLink, theme));
editControlsContainer.AddChild(new SettingsRow("Website".Localize(), null, detailsLink, theme));
}
}
}

View file

@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// pillar rows
this.AddChild(
PublicPropertyEditor.CreateSettingsRow(
new SettingsRow(
"Pillar Size".Localize(),
"The width and depth of the support pillars".Localize(),
pillarSizeField.Content,
@ -110,11 +110,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
// overhang row
this.AddChild(PublicPropertyEditor.CreateSettingsRow(
"Overhang Angle".Localize(),
"The angle to generate support for".Localize(),
overHangField.Content,
theme));
this.AddChild(
new SettingsRow(
"Overhang Angle".Localize(),
"The angle to generate support for".Localize(),
overHangField.Content,
theme));
// Button Row
var buttonRow = new FlowLayoutWidget()

View file

@ -258,7 +258,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
// color row
var row = PublicPropertyEditor.CreateSettingsRow("Color".Localize(), null, colorField.Content, theme);
var row = new SettingsRow("Color".Localize(), null, colorField.Content, theme);
// Special top border style for first item in editor
row.Border = new BorderDouble(0, 1);
@ -287,7 +287,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// material row
editorPanel.AddChild(
PublicPropertyEditor.CreateSettingsRow("Material".Localize(), null, materialField.Content, theme));
new SettingsRow("Material".Localize(), null, materialField.Content, theme));
// put in the normal editor
if (selectedItem is ComponentObject3D componentObject

View file

@ -131,6 +131,15 @@ namespace MatterHackers.MatterControl.CustomWidgets
}
}
public SettingsRow(string title, string helpText, GuiWidget guiWidget, ThemeConfig theme)
: this (title, helpText, theme)
{
this.Padding = new BorderDouble(right: theme.DefaultContainerPadding);
guiWidget.VAnchor |= VAnchor.Center;
this.AddChild(guiWidget);
}
public static GuiWidget CreateSettingsLabel(string label, string helpText, Color textColor)
{
return new TextWidget(label, textColor: textColor, pointSize: 10)