Merge pull request #3460 from jlewin/design_tools

Remove scrollable from ResizableSectionWidget, wrap in caller
This commit is contained in:
johnlewin 2018-06-23 08:29:28 -07:00 committed by GitHub
commit 3962d188a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 21 deletions

View file

@ -35,6 +35,7 @@ using MatterHackers.Agg.Font;
using MatterHackers.Agg.Image; using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform; using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.ImageProcessing;
using MatterHackers.VectorMath; using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.CustomWidgets namespace MatterHackers.MatterControl.CustomWidgets
@ -160,6 +161,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
return content?.Children.Where((c) => c is TreeNode).Count() ?? 0; return content?.Children.Where((c) => c is TreeNode).Count() ?? 0;
} }
public bool AlwaysExpandable
{
get => expandWidget.AlwaysExpandable;
set => expandWidget.AlwaysExpandable = value;
}
public override void OnDraw(Graphics2D graphics2D) public override void OnDraw(Graphics2D graphics2D)
{ {
if (isDirty) if (isDirty)
@ -421,10 +428,21 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.AddChild(imageButton); this.AddChild(imageButton);
} }
private bool _alwaysExpandable;
public bool AlwaysExpandable
{
get => _alwaysExpandable;
set
{
imageButton.SetIcon((_expanded) ? arrowDown : arrowRight);
_alwaysExpandable = value;
}
}
private bool? _expandable = null; private bool? _expandable = null;
public bool Expandable public bool Expandable
{ {
get => _expandable == true; get => _expandable == true || this.AlwaysExpandable;
set set
{ {
if (_expandable != value) if (_expandable != value)

View file

@ -28,7 +28,6 @@ either expressed or implied, of the FreeBSD Project.
*/ */
using System; using System;
using MatterHackers.Agg;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.CustomWidgets;
@ -41,7 +40,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public event EventHandler Resized; public event EventHandler Resized;
public ResizableSectionWidget(string sectionTitle, double initialHeight, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true) public ResizableSectionWidget(string sectionTitle, double initialHeight, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true)
: base(sectionTitle, new GuiWidget(), theme, rightAlignedContent, headingPointSize, expanded, expanded, serializationKey, defaultExpansion, setContentVAnchor) : base(sectionTitle, new GuiWidget(), theme, rightAlignedContent, headingPointSize, expandingContent, expanded, serializationKey, defaultExpansion, setContentVAnchor)
{ {
this.VAnchor = VAnchor.Fit; this.VAnchor = VAnchor.Fit;
@ -51,29 +50,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
VAnchor = VAnchor.Absolute, VAnchor = VAnchor.Absolute,
Height = initialHeight Height = initialHeight
}; };
this.ResizeContainer.Resized += (s, e) => this.ResizeContainer.Resized += (s, e) =>
{ {
this.Resized?.Invoke(this, null); this.Resized?.Invoke(this, null);
}; };
this.ResizeContainer.AddChild(sectionContent);
// Add container used to host the current specialized editor for the selection
var scrollableWidget = new ScrollableWidget(true)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
scrollableWidget.AddChild(sectionContent);
scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch;
this.ResizeContainer.AddChild(scrollableWidget);
// A wrapping container to fix resize quirks - GuiWidget with H:Stretch V:Fit that can be hidden and shown and allow the ResizeContainer can keep it's size // A wrapping container to fix resize quirks - GuiWidget with H:Stretch V:Fit that can be hidden and shown and allow the ResizeContainer can keep it's size
var resizeWrapper = new GuiWidget() var resizeWrapper = new GuiWidget()
{ {
HAnchor = HAnchor.Stretch, HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit, VAnchor = VAnchor.Fit,
Name = "editorRootContainer" Visible = checkbox.Checked
}; };
resizeWrapper.AddChild(this.ResizeContainer); resizeWrapper.AddChild(this.ResizeContainer);

View file

@ -10,7 +10,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
/// </summary> /// </summary>
public class SectionWidget : FlowLayoutWidget, IIgnoredPopupChild public class SectionWidget : FlowLayoutWidget, IIgnoredPopupChild
{ {
private ExpandCheckboxButton checkbox; protected ExpandCheckboxButton checkbox;
private bool setContentVAnchor; private bool setContentVAnchor;
public SectionWidget(string sectionTitle, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true) public SectionWidget(string sectionTitle, GuiWidget sectionContent, ThemeConfig theme, GuiWidget rightAlignedContent = null, int headingPointSize = -1, bool expandingContent = true, bool expanded = true, string serializationKey = null, bool defaultExpansion = false, bool setContentVAnchor = true)

View file

@ -186,7 +186,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
} }
}; };
editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, editorPanel, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true) // Wrap editorPanel with scrollable container
var scrollableWidget = new ScrollableWidget(true)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
scrollableWidget.AddChild(editorPanel);
scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch;
editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, scrollableWidget, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true)
{ {
VAnchor = VAnchor.Fit, VAnchor = VAnchor.Fit,
}; };

View file

@ -187,7 +187,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
HAnchor = HAnchor.Left | HAnchor.Fit, HAnchor = HAnchor.Left | HAnchor.Fit,
VAnchor = VAnchor.Top | VAnchor.Fit, VAnchor = VAnchor.Top | VAnchor.Fit,
Margin = new BorderDouble(left: 30, top: 2) Margin = new BorderDouble(left: 18),
}; };
treeView.AfterSelect += (s, e) => treeView.AfterSelect += (s, e) =>
{ {
@ -198,8 +198,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
} }
selectedObjectPanel.SetActiveItem((IObject3D)treeView.SelectedNode.Tag); selectedObjectPanel.SetActiveItem((IObject3D)treeView.SelectedNode.Tag);
}; };
treeView.ScrollArea.ChildAdded += (s, e) =>
{
if (e is GuiWidgetEventArgs childEventArgs
&& childEventArgs.Child is TreeNode treeNode)
{
treeNode.AlwaysExpandable = true;
}
};
var treeSection = new ResizableSectionWidget("Design History".Localize(), sceneContext.ViewState.SceneTreeHeight, treeView, theme, expanded: false); var treeSection = new ResizableSectionWidget("Design History".Localize(), sceneContext.ViewState.SceneTreeHeight, treeView, theme, serializationKey: UserSettingsKey.SelectionTreeViewPanelExpanded);
treeSection.Resized += (s, e) => treeSection.Resized += (s, e) =>
{ {
sceneContext.ViewState.SceneTreeHeight = treeSection.ResizeContainer.Height; sceneContext.ViewState.SceneTreeHeight = treeSection.ResizeContainer.Height;
@ -1220,7 +1228,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (this.Parent != null) if (this.Parent != null)
{ {
rootNode.Padding = rootNode.Padding.Clone(left: 8, top: 8);
assigningTreeNode = true; assigningTreeNode = true;
treeView.SelectedNode = rootNode; treeView.SelectedNode = rootNode;

View file

@ -60,6 +60,7 @@ namespace MatterHackers.MatterControl
public const string ActiveThemeName = nameof(ActiveThemeName); public const string ActiveThemeName = nameof(ActiveThemeName);
public const string SceneTreeHeight = nameof(SceneTreeHeight); public const string SceneTreeHeight = nameof(SceneTreeHeight);
public const string SelectedObjectEditorHeight = nameof(SelectedObjectEditorHeight); public const string SelectedObjectEditorHeight = nameof(SelectedObjectEditorHeight);
public const string SelectionTreeViewPanelExpanded = nameof(SelectionTreeViewPanelExpanded);
} }
public class UserSettings public class UserSettings