Improved selected object editor panel
issue: MatterHackers/MCCentral#3536 Consider if Object3D items should have coupling to MatterControl
This commit is contained in:
parent
01eeff3544
commit
91ff0d4a88
3 changed files with 37 additions and 15 deletions
|
|
@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.CustomWidgets
|
||||
{
|
||||
|
|
@ -49,6 +50,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.SpliterBarColor = theme.SplitterBackground;
|
||||
}
|
||||
|
||||
public event EventHandler Resized;
|
||||
public Color SpliterBarColor { get; set; }
|
||||
|
||||
public int SplitterHeight
|
||||
|
|
@ -65,6 +67,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual void OnResized(EventArgs e)
|
||||
{
|
||||
this.Resized?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
graphics2D.FillRectangle(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Bottom + this.SplitterHeight, this.SpliterBarColor);
|
||||
|
|
@ -106,6 +113,13 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
public override void OnMouseUp(MouseEventArgs mouseEvent)
|
||||
{
|
||||
var mouseUpY = TransformToScreenSpace(mouseEvent.Position).Y;
|
||||
if (mouseDownOnBar
|
||||
&& mouseUpY != mouseDownY)
|
||||
{
|
||||
OnResized(null);
|
||||
}
|
||||
|
||||
mouseDownOnBar = false;
|
||||
base.OnMouseUp(mouseEvent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private ThemeConfig theme;
|
||||
private BedConfig sceneContext;
|
||||
private View3DWidget view3DWidget;
|
||||
private SectionWidget editorSection;
|
||||
private SectionWidget selectedObjectEditorSection;
|
||||
private TextButton editButton;
|
||||
|
||||
private GuiWidget editorPanel;
|
||||
private InlineTitleEdit inlineTitleEdit;
|
||||
private BottomResizeContainer editorColumn;
|
||||
private BottomResizeContainer selectedObjectEditorColumn;
|
||||
|
||||
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
|
|
@ -85,7 +85,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
this.AddChild(scrollable);
|
||||
|
||||
editorColumn = new BottomResizeContainer(theme)
|
||||
selectedObjectEditorColumn = new BottomResizeContainer(theme)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
|
|
@ -98,7 +98,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
editorColumn.AddChild(toolbar);
|
||||
selectedObjectEditorColumn.AddChild(toolbar);
|
||||
|
||||
selectedObjectEditorColumn.Resized += (s, e) =>
|
||||
{
|
||||
sceneContext.ViewState.SelectedObjectEditorHeight = selectedObjectEditorColumn.Height;
|
||||
};
|
||||
|
||||
var scene = sceneContext.Scene;
|
||||
|
||||
|
|
@ -178,8 +183,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
scene.SelectionChanged += (s, e) => removeButton.Enabled = scene.SelectedItem?.CanRemove == true;
|
||||
toolbar.AddChild(removeButton);
|
||||
|
||||
|
||||
// Add container used to host the current specialized editor for the selection
|
||||
editorColumn.AddChild(editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
selectedObjectEditorColumn.AddChild(editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
|
|
@ -195,18 +201,26 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
};
|
||||
|
||||
editorSection = new SectionWidget("Editor", editorColumn, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true, setContentVAnchor: false)
|
||||
var selectedObjectEditorColumnBody = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
|
||||
selectedObjectEditorColumnBody.AddChild(selectedObjectEditorColumn);
|
||||
|
||||
selectedObjectEditorSection = new SectionWidget("Editor", selectedObjectEditorColumnBody, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, defaultExpansion: true)
|
||||
{
|
||||
VAnchor = VAnchor.Fit,
|
||||
};
|
||||
|
||||
// TODO: Replace hackery with practical solution
|
||||
if (editorSection.Children.FirstOrDefault() is ExpandCheckboxButton checkbox)
|
||||
if (selectedObjectEditorSection.Children.FirstOrDefault() is ExpandCheckboxButton checkbox)
|
||||
{
|
||||
checkbox.ReplaceChild(checkbox.Children[1], inlineTitleEdit);
|
||||
}
|
||||
|
||||
this.ContentPanel.AddChild(editorSection);
|
||||
this.ContentPanel.AddChild(selectedObjectEditorSection);
|
||||
|
||||
var colorSection = new SectionWidget(
|
||||
"Color".Localize(),
|
||||
|
|
@ -400,11 +414,5 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
children.Add(content);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
sceneContext.ViewState.SelectedObjectEditorHeight = editorColumn.Height;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit b9b5f59042a6404dd99a61a9e295f072ab6f915b
|
||||
Subproject commit b19589fc2ebfa4db00f691c8421cb718aef32145
|
||||
Loading…
Add table
Add a link
Reference in a new issue