Vector2 single char label
This commit is contained in:
parent
48b2cdf8e7
commit
1c6814fffc
2 changed files with 22 additions and 14 deletions
|
|
@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public NumberEdit ActuallNumberEdit { get; }
|
||||
|
||||
public MHNumberEdit(double startingValue, ThemeConfig theme, double pixelWidth = 0, double pixelHeight = 0, bool allowNegatives = false, bool allowDecimals = false, double minValue = int.MinValue, double maxValue = int.MaxValue, double increment = 1, int tabIndex = 0)
|
||||
public MHNumberEdit(double startingValue, ThemeConfig theme, char singleCharLabel = char.MaxValue, double pixelWidth = 0, double pixelHeight = 0, bool allowNegatives = false, bool allowDecimals = false, double minValue = int.MinValue, double maxValue = int.MaxValue, double increment = 1, int tabIndex = 0)
|
||||
{
|
||||
using (this.LayoutLock())
|
||||
{
|
||||
|
|
@ -48,11 +48,28 @@ namespace MatterHackers.MatterControl
|
|||
this.Border = 1;
|
||||
this.theme = theme;
|
||||
|
||||
double labelWidth = 0;
|
||||
|
||||
if (singleCharLabel != char.MaxValue)
|
||||
{
|
||||
var labelWidget = new TextWidget(singleCharLabel.ToString(), pointSize: theme.DefaultFontSize - 2, textColor: theme.PrimaryAccentColor)
|
||||
{
|
||||
Margin = new BorderDouble(left: 2),
|
||||
HAnchor = HAnchor.Left,
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
labelWidth = labelWidget.Width + labelWidget.Margin.Left;
|
||||
|
||||
this.AddChild(labelWidget);
|
||||
}
|
||||
|
||||
this.ActuallNumberEdit = new NumberEdit(startingValue, 0, 0, theme.DefaultFontSize, pixelWidth, pixelHeight, allowNegatives, allowDecimals, minValue, maxValue, increment, tabIndex)
|
||||
{
|
||||
VAnchor = VAnchor.Bottom,
|
||||
};
|
||||
|
||||
ActuallNumberEdit.Margin = ActuallNumberEdit.Margin.Clone(left: labelWidth + 2);
|
||||
|
||||
var internalWidget = this.ActuallNumberEdit.InternalTextEditWidget;
|
||||
internalWidget.TextColor = theme.EditFieldColors.Inactive.TextColor;
|
||||
internalWidget.FocusChanged += (s, e) =>
|
||||
|
|
|
|||
|
|
@ -74,11 +74,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
double.TryParse(xyValueStrings[0], out double currentXValue);
|
||||
|
||||
xEditWidget = new MHNumberEdit(currentXValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
xEditWidget = new MHNumberEdit(currentXValue, theme, singleCharLabel: 'X', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex,
|
||||
SelectAllOnFocus = true
|
||||
SelectAllOnFocus = true,
|
||||
Margin = theme.ButtonSpacing
|
||||
};
|
||||
xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) =>
|
||||
{
|
||||
|
|
@ -87,16 +88,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
userInitiated: true);
|
||||
};
|
||||
|
||||
container.AddChild(new TextWidget("X:", pointSize: 10, textColor: theme.TextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(5, 0),
|
||||
});
|
||||
container.AddChild(xEditWidget);
|
||||
|
||||
double.TryParse(xyValueStrings[1], out double currentYValue);
|
||||
|
||||
yEditWidget = new MHNumberEdit(currentYValue, theme, allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
yEditWidget = new MHNumberEdit(currentYValue, theme, 'Y', allowNegatives: true, allowDecimals: true, pixelWidth: VectorXYEditWidth, tabIndex: tabIndex)
|
||||
{
|
||||
ToolTipText = this.HelpText,
|
||||
TabIndex = tabIndex + 1,
|
||||
|
|
@ -109,11 +105,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
userInitiated: true);
|
||||
};
|
||||
|
||||
container.AddChild(new TextWidget("Y:", pointSize: 10, textColor: theme.TextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(15, 0, 5, 0),
|
||||
});
|
||||
container.AddChild(yEditWidget);
|
||||
|
||||
this.Content = container;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue