Fix bed menu spacing, background color, add support for non-gradient bg
This commit is contained in:
parent
0a1c95d9f3
commit
0869d580be
2 changed files with 25 additions and 22 deletions
|
|
@ -52,29 +52,34 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
}
|
||||
|
||||
public int GradientDistance { get; set; } = 5;
|
||||
|
||||
public override void OnDrawBackground(Graphics2D graphics2D)
|
||||
{
|
||||
if (gradientBackground != null)
|
||||
{
|
||||
graphics2D.Render(gradientBackground, this.LocalBounds.Left, 0);
|
||||
}
|
||||
|
||||
//base.OnDrawBackground(graphics2D);
|
||||
else
|
||||
{
|
||||
base.OnDrawBackground(graphics2D);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
base.OnLoad(args);
|
||||
|
||||
int gradientDistance = 5;
|
||||
if (this.GradientDistance > 0)
|
||||
{
|
||||
gradientBackground = agg_basics.TrasparentToColorGradientX(
|
||||
(int)this.LocalBounds.Width + this.GradientDistance,
|
||||
(int)this.LocalBounds.Height,
|
||||
this.BackgroundColor,
|
||||
this.GradientDistance);
|
||||
|
||||
gradientBackground = agg_basics.TrasparentToColorGradientX(
|
||||
(int)this.LocalBounds.Width + gradientDistance,
|
||||
(int)this.LocalBounds.Height,
|
||||
this.BackgroundColor,
|
||||
gradientDistance);
|
||||
|
||||
gradientBackground.SetRecieveBlender(new BlenderPreMultBGRA());
|
||||
gradientBackground.SetRecieveBlender(new BlenderPreMultBGRA());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -160,12 +160,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
string iconPath;
|
||||
|
||||
var commonMargin = theme.ButtonSpacing;
|
||||
var commonMargin = theme.ButtonSpacing;
|
||||
|
||||
double height = theme.ButtonFactory.Options.FixedHeight;
|
||||
|
||||
this.AddChild(CreateBedMenu(sceneContext, theme));
|
||||
|
||||
this.AddChild(new VerticalLine(50)
|
||||
{
|
||||
Margin = 4
|
||||
});
|
||||
|
||||
var homeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", IconColor.Theme), theme)
|
||||
{
|
||||
ToolTipText = "Reset View".Localize(),
|
||||
|
|
@ -413,7 +418,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
buttonView.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon((IsPrinterMode) ? "bed.png" : "cube.png", IconColor.Theme))
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = theme.ButtonSpacing,
|
||||
Margin = theme.ButtonSpacing.Clone(left: 10),
|
||||
});
|
||||
|
||||
var buttonText = (IsPrinterMode) ? "Bed".Localize() : "Part".Localize();
|
||||
|
|
@ -426,20 +431,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
Name = "Bed Options Menu",
|
||||
DynamicPopupContent = () => theme.CreatePopupMenu(this.BedMenuActions(sceneContext)),
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
GradientDistance = -1,
|
||||
DrawArrow = true,
|
||||
AlignToRightEdge = true,
|
||||
Margin = new BorderDouble(right: theme.ButtonSpacing.Left),
|
||||
Margin = theme.ButtonSpacing,
|
||||
};
|
||||
|
||||
// HACK: Fix left padding to improve style. Ideally fix this in the underlying button
|
||||
var firstChild = overflowMenu.Children.First();
|
||||
firstChild.Margin = firstChild.Margin.Clone(left: 8);
|
||||
|
||||
overflowMenu.Load += (s, e) =>
|
||||
{
|
||||
var firstBackgroundColor = this.Parents<GuiWidget>().Where(p => p.BackgroundColor.Alpha0To1 == 1).FirstOrDefault()?.BackgroundColor;
|
||||
overflowMenu.BackgroundColor = firstBackgroundColor ?? Color.Transparent;
|
||||
};
|
||||
return overflowMenu;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue