From dc0c2851569937e5ac019f2ca66f9937445d1dcf Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 26 May 2017 00:59:47 -0700 Subject: [PATCH] Adjust ViewControls colors to account for new potentially dark bgcolor --- PartPreviewWindow/ViewControls2D.cs | 98 +++++++++-------------------- PartPreviewWindow/ViewControls3D.cs | 43 ++++++------- PartPreviewWindow/ViewGcodeBasic.cs | 8 +-- 3 files changed, 52 insertions(+), 97 deletions(-) diff --git a/PartPreviewWindow/ViewControls2D.cs b/PartPreviewWindow/ViewControls2D.cs index c4af00b5a..19af7d10f 100644 --- a/PartPreviewWindow/ViewControls2D.cs +++ b/PartPreviewWindow/ViewControls2D.cs @@ -27,31 +27,20 @@ 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; -using System.IO; -using MatterHackers.Localizations; using System; -using MatterHackers.Agg.PlatformAbstract; +using System.IO; +using MatterHackers.Agg; using MatterHackers.Agg.ImageProcessing; +using MatterHackers.Agg.PlatformAbstract; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { public class ViewControlsBase : FlowLayoutWidget { - protected int buttonHeight; - - public ViewControlsBase() - { - if (UserSettings.Instance.IsTouchScreen) - { - buttonHeight = 40; - } - else - { - buttonHeight = 20; - } - } + protected int buttonHeight = UserSettings.Instance.IsTouchScreen ? 40 : 20; + protected const int overlayAlpha = 50; } public class ViewControls2D : ViewControlsBase @@ -63,27 +52,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public event EventHandler ResetView; - public ViewControls2D() + public ViewControls2D(TextImageButtonFactory buttonFactory) { - if (UserSettings.Instance.IsTouchScreen) - { - buttonHeight = 40; - } - else - { - buttonHeight = 0; - } - - TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); - iconTextImageButtonFactory.AllowThemeToAdjustImage = false; - iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; - - BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); - iconTextImageButtonFactory.FixedHeight = buttonHeight * GuiWidget.DeviceScale; - iconTextImageButtonFactory.FixedWidth = buttonHeight * GuiWidget.DeviceScale; - + this.BackgroundColor = new RGBA_Bytes(0, 0, 0, overlayAlpha); string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png"); - resetViewButton = iconTextImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath,32,32).InvertLightness()); + resetViewButton = buttonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath, 32, 32).InvertLightness()); resetViewButton.ToolTipText = "Reset View".Localize(); AddChild(resetViewButton); resetViewButton.Click += (sender, e) => @@ -92,20 +65,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); - translateButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath,32,32)); - translateButton.ToolTipText = "Move".Localize(); - translateButton.Margin = new BorderDouble(3); + translateButton = buttonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath, 32, 32)); + translateButton.ToolTipText = "Move".Localize(); + translateButton.Margin = new BorderDouble(3); AddChild(translateButton); string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); - scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath,32,32)); - scaleButton.ToolTipText = "Zoom".Localize(); - scaleButton.Margin = new BorderDouble(3); + scaleButton = buttonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath, 32, 32)); + scaleButton.ToolTipText = "Zoom".Localize(); + scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); Margin = new BorderDouble(5); - HAnchor |= Agg.UI.HAnchor.ParentLeft; - VAnchor = Agg.UI.VAnchor.ParentTop; + HAnchor |= HAnchor.ParentLeft; + VAnchor = VAnchor.ParentTop; translateButton.Checked = true; } } @@ -117,29 +90,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private static bool userChangedTo3DThisRun = false; - public ViewControlsToggle() + public ViewControlsToggle(TextImageButtonFactory buttonFactory) { - TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); - iconTextImageButtonFactory.AllowThemeToAdjustImage = false; - iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; + this.BackgroundColor = new RGBA_Bytes(0, 0, 0, overlayAlpha); - BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); - - iconTextImageButtonFactory.FixedHeight = buttonHeight * GuiWidget.DeviceScale; - iconTextImageButtonFactory.FixedWidth = buttonHeight * GuiWidget.DeviceScale; - - string select2dIconPath = Path.Combine("ViewTransformControls", "2d.png"); - twoDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select2dIconPath); + twoDimensionButton = buttonFactory.GenerateRadioButton("", Path.Combine("ViewTransformControls", "2d.png")); twoDimensionButton.Margin = new BorderDouble(3); - AddChild(twoDimensionButton); + this.AddChild(twoDimensionButton); - string select3dIconPath = Path.Combine("ViewTransformControls", "3d.png"); - threeDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select3dIconPath); + threeDimensionButton = buttonFactory.GenerateRadioButton("", Path.Combine("ViewTransformControls", "3d.png")); threeDimensionButton.Margin = new BorderDouble(3); + threeDimensionButton.Click += (sender, e) => + { + userChangedTo3DThisRun = true; + }; if (!UserSettings.Instance.IsTouchScreen) { - AddChild(threeDimensionButton); + this.AddChild(threeDimensionButton); if (UserSettings.Instance.get("LayerViewDefault") == "3D Layer" && @@ -159,13 +127,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow twoDimensionButton.Checked = true; } - threeDimensionButton.Click += (sender, e) => - { - userChangedTo3DThisRun = true; - }; - Margin = new BorderDouble(5, 5, 200, 5); - HAnchor |= Agg.UI.HAnchor.ParentRight; - VAnchor = Agg.UI.VAnchor.ParentTop; + this.Margin = new BorderDouble(5, 5, 200, 5); + this.HAnchor |= HAnchor.ParentRight; + this.VAnchor = VAnchor.ParentTop; } } } \ No newline at end of file diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index ec63392f5..2221bacbf 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014, Lars Brubaker +Copyright (c) 2017, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,20 +27,14 @@ 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; -using MatterHackers.MeshVisualizer; -using MatterHackers.VectorMath; using System; using System.IO; -using MatterHackers.Localizations; -using MatterHackers.Agg.PlatformAbstract; -using MatterHackers.Agg.ImageProcessing; -using System.Collections.Generic; -using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.RenderOpenGl; -using MatterHackers.MatterControl.CustomWidgets; using System.Linq; +using MatterHackers.Agg; +using MatterHackers.Agg.ImageProcessing; +using MatterHackers.Agg.PlatformAbstract; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { @@ -57,8 +51,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public ViewControls3DButtons TransformMode { get; set; } } - public class ViewControls3D : FlowLayoutWidget + public class ViewControls3D : ViewControlsBase { + public event EventHandler ResetView; + public event EventHandler TransformStateChanged; + + internal OverflowDropdown OverflowButton; + private GuiWidget partSelectSeparator; private Button resetViewButton; @@ -69,12 +68,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private EventHandler unregisterEvents; - internal OverflowDropdown OverflowButton; - - public event EventHandler ResetView; - - public event EventHandler TransformStateChanged; - + private ViewControls3DButtons activeTransformState = ViewControls3DButtons.Rotate; + public bool PartSelectVisible { get { return partSelectSeparator.Visible; } @@ -85,8 +80,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private ViewControls3DButtons activeTransformState = ViewControls3DButtons.Rotate; - public ViewControls3DButtons ActiveButton { get @@ -124,6 +117,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public ViewControls3D(TextImageButtonFactory buttonFactory) { + this.BackgroundColor = new RGBA_Bytes(0, 0, 0, overlayAlpha); + this.HAnchor |= HAnchor.ParentLeft; + this.VAnchor = VAnchor.ParentTop; + string iconPath; iconPath = Path.Combine("ViewTransformControls", "reset.png"); @@ -181,11 +178,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow OverflowButton.Margin = 3; AddChild(OverflowButton); - HAnchor |= Agg.UI.HAnchor.ParentLeft; - VAnchor = Agg.UI.VAnchor.ParentTop; - rotateButton.Checked = true; - BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); } public override void OnClosed(ClosedEventArgs e) diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 769281490..72c637e90 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -303,7 +303,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow meshViewerWidget.Visible = false; meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent); - viewControls2D = new ViewControls2D(); + viewControls2D = new ViewControls2D(ApplicationController.Instance.Theme.ViewControlsButtonFactory); viewControls2D.Visible = false; AddChild(viewControls2D); @@ -319,7 +319,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewControls3D.ActiveButton = ViewControls3DButtons.Rotate; - viewControlsToggle = new ViewControlsToggle(); + viewControlsToggle = new ViewControlsToggle(ApplicationController.Instance.Theme.ViewControlsButtonFactory); viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight; AddChild(viewControlsToggle); viewControlsToggle.Visible = false; @@ -575,9 +575,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private GuiWidget GetEstimatedMassInfo() { FlowLayoutWidget estimatedMassInfo = new FlowLayoutWidget(FlowDirection.TopToBottom); - string massLabel = "Estimated Mass".Localize(); - string massLabelFull = string.Format("{0}:", massLabel); - estimatedMassInfo.AddChild(new TextWidget(massLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); + estimatedMassInfo.AddChild(new TextWidget("Estimated Mass".Localize() + ":", pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); massTextWidget = new TextWidget("", pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor) { AutoExpandBoundsToText = true,