Merge pull request #2453 from jlewin/design_tools
Add disabled overlay to temperature controls
This commit is contained in:
commit
48ec03349f
7 changed files with 89 additions and 32 deletions
|
|
@ -34,10 +34,11 @@ using MatterHackers.Agg.Platform;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
{
|
||||
internal class TemperatureWidgetBase : PopupButton
|
||||
internal abstract class TemperatureWidgetBase : PopupButton
|
||||
{
|
||||
protected TextWidget CurrentTempIndicator;
|
||||
private TextWidget goalTempIndicator;
|
||||
|
|
@ -55,6 +56,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
protected virtual int ActualTemperature { get; }
|
||||
protected virtual int TargetTemperature { get; }
|
||||
|
||||
private DisableablePanel disableablePanel;
|
||||
|
||||
public TemperatureWidgetBase(PrinterConfig printer, string textValue)
|
||||
{
|
||||
this.printer = printer;
|
||||
|
|
@ -105,6 +108,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
Margin = new BorderDouble(left: 5)
|
||||
};
|
||||
container.AddChild(DirectionIndicator);
|
||||
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
disableablePanel.Enabled = printer.Connection.PrinterIsConnected;
|
||||
|
||||
}, ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected void DisplayCurrentTemperature()
|
||||
|
|
@ -131,7 +140,18 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected virtual void SetTargetTemperature(double targetTemp) { }
|
||||
|
||||
protected virtual GuiWidget GetPopupContent() { return null; }
|
||||
protected abstract GuiWidget GetPopupContent();
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
// Wrap popup content in a DisableablePanel
|
||||
disableablePanel = new DisableablePanel(this.GetPopupContent(), printer.Connection.PrinterIsConnected, alpha: 140);
|
||||
|
||||
// Set as popup
|
||||
this.PopupContent = disableablePanel;
|
||||
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.ImageWidget.Image = icon;
|
||||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
printer.Connection.BedTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,8 +185,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.DisplayCurrentTemperature();
|
||||
this.ToolTipText = "Current extruder temperature".Localize();
|
||||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
printer.Connection.HotendTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
|
|||
63
CustomWidgets/DisableablePanel.cs
Normal file
63
CustomWidgets/DisableablePanel.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright (c) 2017, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
public class DisableablePanel : GuiWidget
|
||||
{
|
||||
private GuiWidget disableOverlay;
|
||||
|
||||
public DisableablePanel(GuiWidget widgetToWrap, bool enabled = false, int alpha = 200)
|
||||
{
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
|
||||
this.AddChild(widgetToWrap);
|
||||
|
||||
disableOverlay = new GuiWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Visible = !enabled,
|
||||
BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.TertiaryBackgroundColor, alpha)
|
||||
};
|
||||
this.AddChild(disableOverlay);
|
||||
}
|
||||
|
||||
public override bool Enabled
|
||||
{
|
||||
get => !disableOverlay.Visible;
|
||||
set => disableOverlay.Visible = !value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +143,7 @@
|
|||
<Compile Include="CustomWidgets\RadioImageWidget.cs" />
|
||||
<Compile Include="CustomWidgets\RadioPanelWidget.cs" />
|
||||
<Compile Include="CustomWidgets\ValueDisplayInfo.cs" />
|
||||
<Compile Include="CustomWidgets\DisableablePanel.cs" />
|
||||
<Compile Include="Utilities\InspectForm.cs" Condition="'$(Configuration)' == 'Debug'">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
public class SliceSettingsWidget : FlowLayoutWidget
|
||||
public partial class SliceSettingsWidget : FlowLayoutWidget
|
||||
{
|
||||
private TabControl primaryTabControl;
|
||||
internal PresetsToolbar settingsControlBar;
|
||||
|
|
@ -720,7 +720,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
else
|
||||
{
|
||||
return new DisabledOverlay(settingsRow);
|
||||
return new DisableablePanel(settingsRow);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -735,29 +735,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
};
|
||||
}
|
||||
|
||||
private class DisabledOverlay : GuiWidget
|
||||
{
|
||||
private GuiWidget disableOverlay;
|
||||
|
||||
public DisabledOverlay(GuiWidget widgetToWrap)
|
||||
{
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
|
||||
this.AddChild(widgetToWrap);
|
||||
|
||||
disableOverlay = new GuiWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.TertiaryBackgroundColor, 200)
|
||||
};
|
||||
this.AddChild(disableOverlay);
|
||||
}
|
||||
|
||||
public override bool Enabled { get => !disableOverlay.Visible; set => disableOverlay.Visible = value; }
|
||||
}
|
||||
|
||||
public static GuiWidget CreateQuickMenu(SliceSettingData settingData, SettingsContext settingsContext, GuiWidget content, InternalTextEditWidget internalTextWidget)
|
||||
{
|
||||
string sliceSettingValue =settingsContext.GetValue(settingData.SlicerConfigName);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit b8d0bb50813391957d437a5f5f868c3e1ea0651b
|
||||
Subproject commit a5eec3a5312cf09bee903113628cc8a63ec62a27
|
||||
Loading…
Add table
Add a link
Reference in a new issue