Merge pull request #3179 from jlewin/design_tools

Make SectionWidget collapsable when disabled
This commit is contained in:
johnlewin 2018-04-12 09:18:47 -07:00 committed by GitHub
commit 2f6659f68a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 22 deletions

View file

@ -817,7 +817,8 @@ namespace MatterHackers.MatterControl.PrintLibrary
IsEnabled = (selectedListItems, listView) =>
{
return listView.SelectedItems.Count == 1
&& selectedListItems.FirstOrDefault()?.Model is ILibraryAsset;
&& selectedListItems.FirstOrDefault()?.Model is ILibraryAsset libraryAsset
&& libraryAsset.ContentType == "mcx";
}
});
}

View file

@ -1,4 +1,5 @@
using MatterHackers.Agg;
using System;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
@ -109,6 +110,24 @@ namespace MatterHackers.MatterControl.CustomWidgets
public int BorderRadius { get; set; } = 0;
public bool ExpandableWhenDisabled { get; set; }
public override bool Enabled
{
get => (this.ExpandableWhenDisabled) ? true: base.Enabled;
set
{
if (this.ExpandableWhenDisabled)
{
this.ContentPanel.Enabled = value;
}
else
{
base.Enabled = value;
}
}
}
public override void OnDrawBackground(Graphics2D graphics2D)
{
if (this.BorderRadius > 0)

View file

@ -55,7 +55,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
private IObject3D item = new Object3D();
private FlowLayoutWidget scrollableContent;
private ThemeConfig theme;
private View3DWidget view3DWidget;
private InteractiveScene scene;
@ -88,7 +87,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
scrollableContent = new FlowLayoutWidget(FlowDirection.TopToBottom)
this.ContentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,
@ -101,13 +100,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
VAnchor = VAnchor.Stretch,
};
scrollable.AddChild(scrollableContent);
scrollable.AddChild(this.ContentPanel);
scrollable.ScrollArea.HAnchor = HAnchor.Stretch;
this.AddChild(scrollable);
// Add heading separator
scrollableContent.AddChild(new HorizontalLine(25)
this.ContentPanel.AddChild(new HorizontalLine(25)
{
Margin = new BorderDouble(0)
});
@ -211,7 +210,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
});
editorSection = new SectionWidget("Editor", editorColumn, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true);
scrollableContent.AddChild(editorSection);
this.ContentPanel.AddChild(editorSection);
var colorSection = new SectionWidget(
"Color".Localize(),
@ -224,33 +223,36 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
Name = "Color Panel",
};
scrollableContent.AddChild(colorSection);
this.ContentPanel.AddChild(colorSection);
var mirrorSection = new SectionWidget("Mirror".Localize(), new MirrorControls(scene, theme), theme, serializationKey: UserSettingsKey.MirrorPanelExpanded)
{
Name = "Mirror Panel",
};
scrollableContent.AddChild(mirrorSection);
this.ContentPanel.AddChild(mirrorSection);
var scaleSection = new SectionWidget("Scale".Localize(), new ScaleControls(scene, theme), theme, serializationKey: UserSettingsKey.ScalePanelExpanded)
{
Name = "Scale Panel",
};
scrollableContent.AddChild(scaleSection);
this.ContentPanel.AddChild(scaleSection);
var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, serializationKey: UserSettingsKey.MaterialsPanelExpanded)
{
Name = "Materials Panel",
};
scrollableContent.AddChild(materialsSection);
this.ContentPanel.AddChild(materialsSection);
// Enforce panel padding in sidebar
foreach(var sectionWidget in scrollableContent.Children<SectionWidget>())
foreach(var sectionWidget in this.ContentPanel.Children<SectionWidget>())
{
sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0);
sectionWidget.ExpandableWhenDisabled = true;
}
}
public GuiWidget ContentPanel { get; set; }
private static Type componentAttribute = typeof(IObject3DComponentAttribute);
private static Type componentType = typeof(IObject3DComponent);
private static Type iobject3DType = typeof(IObject3D);

View file

@ -1120,7 +1120,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void Scene_SelectionChanged(object sender, EventArgs e)
{
selectedObjectPanel.Enabled = scene.HasSelection;
foreach (var child in selectedObjectPanel.ContentPanel.Children)
{
child.Enabled = scene.HasSelection;
}
if (!scene.HasSelection)
{

View file

@ -67,7 +67,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
HAnchor = HAnchor.Absolute,
VAnchor = VAnchor.Fit | VAnchor.Center,
Width = settingData.ShowAsOverride ? 50 * GuiWidget.DeviceScale : 5,
Width = 50 * GuiWidget.DeviceScale,
DebugShowBounds = debugLayout
});
@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
HAnchor = HAnchor.Absolute,
VAnchor = VAnchor.Fit | VAnchor.Center,
Width = settingData.ShowAsOverride ? 20 * GuiWidget.DeviceScale : 5,
Width = 20 * GuiWidget.DeviceScale,
DebugShowBounds = debugLayout
};
this.AddChild(restoreArea);

View file

@ -479,11 +479,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
HAnchor = HAnchor.Stretch,
};
topToBottomSettings.AddChild(new HorizontalLine(20));
HorizontalLine lastLine = null;
GuiWidget settingsRow = null;
bool firstRow = true;
foreach (SliceSettingData settingData in subGroup.Settings)
{
@ -496,6 +493,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
settingsRow = CreateItemRow(settingData);
if (firstRow)
{
// First row needs top and bottom border
settingsRow.Border = new BorderDouble(0, 1);
firstRow = false;
}
this.settingsRows.Add((settingsRow, settingData));
topToBottomSettings.AddChild(settingsRow);
@ -508,9 +513,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
settingsRow.BorderColor = Color.Transparent;
}
lastLine?.Close();
return (topToBottomSettings.Children.Count == 1) ? null : topToBottomSettings;
return (topToBottomSettings.Children.Any()) ? topToBottomSettings : null;
}
private static bool CheckIfShouldBeShown(SliceSettingData settingData, SettingsContext settingsContext)