Merge pull request #2316 from jlewin/design_tools
Consolidate and reuse theme factories
This commit is contained in:
commit
8bfd13cf37
7 changed files with 63 additions and 172 deletions
|
|
@ -170,29 +170,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
// Extrude buttons {{
|
||||
|
||||
var moveButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = 20 * GuiWidget.DeviceScale,
|
||||
FixedWidth = 30 * GuiWidget.DeviceScale,
|
||||
FontSize = 8,
|
||||
Margin = new BorderDouble(2, 0),
|
||||
CheckedBorderColor = buttonFactory.normalTextColor,
|
||||
|
||||
Normal = new ButtonOptionSection()
|
||||
{
|
||||
TextColor = buttonFactory.normalTextColor,
|
||||
FillColor = buttonFactory.normalFillColor,
|
||||
},
|
||||
Hover = new ButtonOptionSection()
|
||||
{
|
||||
FillColor = buttonFactory.hoverFillColor,
|
||||
},
|
||||
Pressed = new ButtonOptionSection()
|
||||
{
|
||||
FillColor = buttonFactory.pressedFillColor,
|
||||
TextColor = buttonFactory.pressedTextColor
|
||||
}
|
||||
});
|
||||
var moveButtonFactory = ApplicationController.Instance.Theme.MicroButtonMenu;
|
||||
|
||||
var buttonContainer = new FlowLayoutWidget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public TextImageButtonFactory DisableableControlBase { get; private set; }
|
||||
public TextImageButtonFactory HomingButtons { get; private set; }
|
||||
public TextImageButtonFactory MicroButton { get; private set; }
|
||||
public TextImageButtonFactory MicroButtonMenu { get; private set; }
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
|
|
@ -139,13 +141,17 @@ namespace MatterHackers.MatterControl
|
|||
options.Margin = new BorderDouble(8, 0);
|
||||
}));
|
||||
|
||||
this.MenuButtonFactory = new TextImageButtonFactory(commonOptions.Clone(options =>
|
||||
var commonGray = commonOptions.Clone(options =>
|
||||
{
|
||||
options.Normal.TextColor = RGBA_Bytes.Black;
|
||||
options.Normal.FillColor = RGBA_Bytes.LightGray;
|
||||
options.Hover.TextColor = RGBA_Bytes.Black;
|
||||
options.Pressed.TextColor = RGBA_Bytes.Black;
|
||||
options.Pressed.FillColor = RGBA_Bytes.LightGray;
|
||||
});
|
||||
|
||||
this.MenuButtonFactory = new TextImageButtonFactory(commonGray.Clone(options =>
|
||||
{
|
||||
options.Margin = new BorderDouble(8, 0);
|
||||
}));
|
||||
|
||||
|
|
@ -166,6 +172,25 @@ namespace MatterHackers.MatterControl
|
|||
options.CheckedBorderColor = RGBA_Bytes.White;
|
||||
}));
|
||||
|
||||
this.MicroButton = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = 20 * GuiWidget.DeviceScale,
|
||||
FixedWidth = 30 * GuiWidget.DeviceScale,
|
||||
FontSize = 8,
|
||||
Margin = 0,
|
||||
CheckedBorderColor = ActiveTheme.Instance.PrimaryTextColor
|
||||
});
|
||||
|
||||
this.MicroButtonMenu = new TextImageButtonFactory(commonGray.Clone(options =>
|
||||
{
|
||||
options.FixedHeight = 20 * GuiWidget.DeviceScale;
|
||||
options.FixedWidth = 30 * GuiWidget.DeviceScale;
|
||||
options.FontSize = 8;
|
||||
options.Margin = 0;
|
||||
options.BorderWidth = 1;
|
||||
options.CheckedBorderColor = RGBA_Bytes.Black;
|
||||
}));
|
||||
|
||||
#region PartPreviewWidget
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,23 +8,6 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public class SplitButtonFactory
|
||||
{
|
||||
public BorderDouble Margin = new BorderDouble(0, 0);
|
||||
public RGBA_Bytes normalFillColor = new RGBA_Bytes(0, 0, 0, 0);
|
||||
public RGBA_Bytes hoverFillColor = new RGBA_Bytes(0, 0, 0, 50);
|
||||
public RGBA_Bytes pressedFillColor = new RGBA_Bytes(0, 0, 0, 0);
|
||||
public RGBA_Bytes disabledFillColor = new RGBA_Bytes(255, 255, 255, 50);
|
||||
|
||||
public RGBA_Bytes normalBorderColor = new RGBA_Bytes(255, 255, 255, 0);
|
||||
public RGBA_Bytes hoverBorderColor = new RGBA_Bytes(0, 0, 0, 0);
|
||||
public RGBA_Bytes pressedBorderColor = new RGBA_Bytes(0, 0, 0, 0);
|
||||
public RGBA_Bytes disabledBorderColor = new RGBA_Bytes(0, 0, 0, 0);
|
||||
public RGBA_Bytes checkedBorderColor = new RGBA_Bytes(255, 255, 255, 0);
|
||||
|
||||
public RGBA_Bytes normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
public RGBA_Bytes hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
public RGBA_Bytes pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
public RGBA_Bytes disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
public int fontSize = 12;
|
||||
public double borderWidth = 1;
|
||||
public bool invertImageLocation = false;
|
||||
|
|
@ -32,30 +15,32 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public double FixedHeight = 30 * GuiWidget.DeviceScale;
|
||||
|
||||
public ButtonFactoryOptions Options { get; set; } = ApplicationController.Instance.Theme.ButtonFactory.Options;
|
||||
|
||||
public SplitButton Generate(List<NamedAction> actions, Direction direction = Direction.Down, string imageName = null)
|
||||
{
|
||||
var menuFactory = new DropDownMenuFactory()
|
||||
{
|
||||
normalFillColor = this.normalFillColor,
|
||||
hoverFillColor = this.hoverFillColor,
|
||||
pressedFillColor = this.pressedFillColor,
|
||||
normalBorderColor = this.normalBorderColor,
|
||||
hoverBorderColor = this.hoverBorderColor,
|
||||
pressedBorderColor = this.pressedBorderColor,
|
||||
disabledBorderColor = this.disabledBorderColor,
|
||||
normalTextColor = this.normalTextColor,
|
||||
hoverTextColor = this.hoverTextColor,
|
||||
pressedTextColor = this.pressedTextColor,
|
||||
disabledTextColor = this.disabledTextColor,
|
||||
normalFillColor = this.Options.Normal.FillColor,
|
||||
hoverFillColor = this.Options.Hover.FillColor,
|
||||
pressedFillColor = this.Options.Pressed.FillColor,
|
||||
normalBorderColor = this.Options.Normal.BorderColor,
|
||||
hoverBorderColor = this.Options.Hover.BorderColor,
|
||||
pressedBorderColor = this.Options.Pressed.BorderColor,
|
||||
disabledBorderColor = this.Options.Disabled.BorderColor,
|
||||
normalTextColor = this.Options.Normal.TextColor,
|
||||
hoverTextColor = this.Options.Hover.TextColor,
|
||||
pressedTextColor = this.Options.Pressed.TextColor,
|
||||
disabledTextColor = this.Options.Disabled.TextColor,
|
||||
FixedWidth = 20,
|
||||
};
|
||||
|
||||
DropDownMenu menu = menuFactory.Generate(actions: actions.Skip(1).ToList(), direction: direction);
|
||||
menu.Height = FixedHeight;
|
||||
menu.BorderColor = normalBorderColor;
|
||||
menu.HoverArrowColor = this.hoverTextColor;
|
||||
menu.NormalArrowColor = this.normalTextColor;
|
||||
menu.BackgroundColor = normalFillColor;
|
||||
menu.BorderColor = this.Options.Normal.BorderColor;
|
||||
menu.HoverArrowColor = this.Options.Hover.TextColor;
|
||||
menu.NormalArrowColor = this.Options.Normal.TextColor;
|
||||
menu.BackgroundColor = this.Options.Normal.FillColor;
|
||||
menu.Margin = new BorderDouble();
|
||||
|
||||
// TODO: Why?
|
||||
|
|
@ -66,26 +51,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
var primaryAction = actions[0];
|
||||
|
||||
var buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = this.FixedHeight,
|
||||
|
||||
Normal = new ButtonOptionSection()
|
||||
{
|
||||
|
||||
FillColor = this.normalFillColor,
|
||||
TextColor = this.normalTextColor,
|
||||
BorderColor = this.normalBorderColor,
|
||||
},
|
||||
Hover = new ButtonOptionSection()
|
||||
{
|
||||
TextColor = this.hoverTextColor,
|
||||
FillColor = this.hoverFillColor,
|
||||
BorderColor = this.hoverBorderColor
|
||||
},
|
||||
|
||||
BorderWidth = 1,
|
||||
});
|
||||
var buttonFactory = ApplicationController.Instance.Theme.SmallMarginButtonFactory;
|
||||
|
||||
Button button = buttonFactory.Generate(primaryAction.Title, normalImageName: imageName, centerText: true);
|
||||
button.Name = $"{primaryAction.Title} Button";
|
||||
|
|
|
|||
|
|
@ -27,79 +27,42 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class SplitButton : FlowLayoutWidget
|
||||
{
|
||||
private DropDownMenu altChoices;
|
||||
|
||||
private Button DefaultButton { get; }
|
||||
|
||||
public SplitButton(string buttonText, Direction direction = Direction.Down)
|
||||
: base(FlowDirection.LeftToRight)
|
||||
{
|
||||
HAnchor = HAnchor.FitToChildren;
|
||||
VAnchor = VAnchor.FitToChildren;
|
||||
|
||||
this.DefaultButton = CreateDefaultButton(buttonText);
|
||||
this.DefaultButton.VAnchor = VAnchor.ParentCenter;
|
||||
var button = ApplicationController.Instance.Theme.ButtonFactory.Generate(buttonText, centerText: true);
|
||||
button.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
altChoices = CreateDropDown(direction);
|
||||
AddChild(button);
|
||||
|
||||
AddChild(this.DefaultButton);
|
||||
AddChild(altChoices);
|
||||
AddChild(new DropDownMenu("", direction)
|
||||
{
|
||||
VAnchor = VAnchor.ParentCenter,
|
||||
MenuAsWideAsItems = false,
|
||||
AlignToRightEdge = true,
|
||||
Height = button.Height
|
||||
});
|
||||
}
|
||||
|
||||
public SplitButton(Button button, DropDownMenu menu)
|
||||
public SplitButton(Button button, DropDownMenu altChoices)
|
||||
: base(FlowDirection.LeftToRight)
|
||||
{
|
||||
HAnchor = HAnchor.FitToChildren;
|
||||
VAnchor = VAnchor.FitToChildren;
|
||||
|
||||
this.DefaultButton = button;
|
||||
this.DefaultButton.VAnchor = VAnchor.ParentCenter;
|
||||
button.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
altChoices = menu;
|
||||
|
||||
AddChild(this.DefaultButton);
|
||||
AddChild(button);
|
||||
AddChild(altChoices);
|
||||
}
|
||||
|
||||
private DropDownMenu CreateDropDown(Direction direction)
|
||||
{
|
||||
return new DropDownMenu("", direction)
|
||||
{
|
||||
VAnchor = VAnchor.ParentCenter,
|
||||
MenuAsWideAsItems = false,
|
||||
AlignToRightEdge = true,
|
||||
Height = this.DefaultButton.Height
|
||||
};
|
||||
}
|
||||
|
||||
private Button CreateDefaultButton(string buttonText)
|
||||
{
|
||||
var buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = 30 * GuiWidget.DeviceScale,
|
||||
Normal = new ButtonOptionSection()
|
||||
{
|
||||
FillColor = RGBA_Bytes.White,
|
||||
TextColor = RGBA_Bytes.Black,
|
||||
BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200),
|
||||
},
|
||||
Hover = new ButtonOptionSection()
|
||||
{
|
||||
TextColor = RGBA_Bytes.Black,
|
||||
FillColor = new RGBA_Bytes(255, 255, 255, 200),
|
||||
BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200)
|
||||
},
|
||||
BorderWidth = 1,
|
||||
});
|
||||
|
||||
return buttonFactory.Generate(buttonText, centerText: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,8 +54,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
private static CreateFolderWindow createFolderWindow = null;
|
||||
private static RenameItemWindow renameItemWindow = null;
|
||||
private ExportToFolderFeedbackWindow exportingWindow = null;
|
||||
private TextImageButtonFactory textImageButtonFactory;
|
||||
private TextImageButtonFactory editButtonFactory;
|
||||
|
||||
private Button addToLibraryButton;
|
||||
private Button createFolderButton;
|
||||
|
|
@ -79,26 +77,6 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground;
|
||||
this.AnchorAll();
|
||||
|
||||
textImageButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
BorderWidth = 0,
|
||||
|
||||
Normal = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Hover = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Pressed = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Disabled = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.TabLabelUnselected, FillColor = new RGBA_Bytes() }
|
||||
});
|
||||
|
||||
editButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
Normal = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Hover = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Disabled = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.TabLabelUnselected, FillColor = new RGBA_Bytes() },
|
||||
Pressed = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
BorderWidth = 0,
|
||||
Margin = new BorderDouble(10, 0)
|
||||
});
|
||||
|
||||
var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
|
||||
libraryView = new ListView(ApplicationController.Instance.Library)
|
||||
|
|
@ -266,6 +244,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
private void AddLibraryButtonElements()
|
||||
{
|
||||
var textImageButtonFactory = ApplicationController.Instance.Theme.SmallMarginButtonFactory;
|
||||
|
||||
buttonPanel.RemoveAllChildren();
|
||||
|
||||
// the add button
|
||||
|
|
|
|||
|
|
@ -95,14 +95,7 @@ namespace MatterHackers.MatterControl
|
|||
//setMoveDistanceControl.AddChild(buttonsLabel);
|
||||
|
||||
{
|
||||
var buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = 20 * GuiWidget.DeviceScale,
|
||||
FixedWidth = 30 * GuiWidget.DeviceScale,
|
||||
FontSize = 8,
|
||||
Margin = new BorderDouble(0),
|
||||
CheckedBorderColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
});
|
||||
var buttonFactory = ApplicationController.Instance.Theme.MicroButton;
|
||||
|
||||
FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();
|
||||
|
||||
|
|
@ -501,14 +494,7 @@ namespace MatterHackers.MatterControl
|
|||
//setMoveDistanceControl.AddChild(buttonsLabel);
|
||||
|
||||
{
|
||||
var buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
FixedHeight = 20 * GuiWidget.DeviceScale,
|
||||
FixedWidth = 30 * GuiWidget.DeviceScale,
|
||||
FontSize = 8,
|
||||
Margin = 0,
|
||||
CheckedBorderColor = ActiveTheme.Instance.PrimaryTextColor
|
||||
});
|
||||
var buttonFactory = ApplicationController.Instance.Theme.MicroButton;
|
||||
|
||||
var moveRadioButtons = new FlowLayoutWidget();
|
||||
RadioButton oneButton = buttonFactory.GenerateRadioButton("1");
|
||||
|
|
|
|||
|
|
@ -84,14 +84,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
textColor = ActiveTheme.Instance.SecondaryAccentColor
|
||||
};
|
||||
|
||||
var buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions()
|
||||
{
|
||||
Normal = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Hover = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Disabled = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
Pressed = new ButtonOptionSection() { TextColor = ActiveTheme.Instance.PrimaryTextColor },
|
||||
BorderWidth = 0
|
||||
});
|
||||
var buttonFactory = ApplicationController.Instance.Theme.ButtonFactory;
|
||||
|
||||
FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue