2015-02-26 13:28:36 -08:00
|
|
|
|
/*
|
2023-03-10 17:15:55 -08:00
|
|
|
|
Copyright (c) 2023, Lars Brubaker, John Lewin
|
2015-02-26 13:28:36 -08:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2015-02-26 13:28:36 -08:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2015-02-26 13:28:36 -08:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2015-02-26 13:28:36 -08:00
|
|
|
|
|
|
|
|
|
|
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
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2015-02-26 13:28:36 -08:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-06-08 08:41:15 -07:00
|
|
|
|
using JsonPath;
|
2017-03-15 16:17:06 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2018-02-17 19:03:33 -08:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2015-02-26 13:28:36 -08:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2017-10-18 14:56:10 -07:00
|
|
|
|
using MatterHackers.DataConverters3D;
|
2021-05-21 14:24:45 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
2017-03-15 16:17:06 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
2017-11-15 09:24:56 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2018-01-30 11:50:22 -08:00
|
|
|
|
using MatterHackers.MatterControl.DesignTools;
|
2018-12-12 09:38:04 -08:00
|
|
|
|
using MatterHackers.MatterControl.DesignTools.Operations;
|
2018-02-17 19:03:33 -08:00
|
|
|
|
using MatterHackers.MatterControl.Library;
|
2018-10-06 15:09:01 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2023-03-10 17:15:55 -08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2023-11-01 15:13:25 -07:00
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
2023-03-10 17:15:55 -08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2018-06-08 08:41:15 -07:00
|
|
|
|
using static JsonPath.JsonPathContext.ReflectionValueSystem;
|
2015-02-26 13:28:36 -08:00
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
2015-02-26 13:28:36 -08:00
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
public class SelectedObjectPanel : FlowLayoutWidget, IContentStore
|
|
|
|
|
|
{
|
|
|
|
|
|
private IObject3D item = new Object3D();
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ThemeConfig theme;
|
|
|
|
|
|
private readonly ISceneContext sceneContext;
|
|
|
|
|
|
private readonly SectionWidget editorSectionWidget;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly GuiWidget editorPanel;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly string editorTitle = "Properties".Localize();
|
|
|
|
|
|
|
|
|
|
|
|
public SelectedObjectPanel(View3DWidget view3DWidget, ISceneContext sceneContext, ThemeConfig theme)
|
|
|
|
|
|
: base(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
this.VAnchor = VAnchor.Top | VAnchor.Fit;
|
|
|
|
|
|
this.Padding = 0;
|
|
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
this.sceneContext = sceneContext;
|
|
|
|
|
|
|
|
|
|
|
|
var toolbar = new LeftClipFlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = theme.BackgroundColor,
|
|
|
|
|
|
Padding = theme.ToolbarPadding,
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
scene = sceneContext.Scene;
|
|
|
|
|
|
|
|
|
|
|
|
// put in the container for dynamic actions
|
|
|
|
|
|
primaryActionsPanel = new FlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Center | VAnchor.Fit
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
toolbar.AddChild(primaryActionsPanel);
|
|
|
|
|
|
|
|
|
|
|
|
// put in a make permanent button
|
2023-10-03 16:17:01 -07:00
|
|
|
|
var icon = StaticData.Instance.LoadIcon("apply.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply();
|
2023-03-10 17:15:55 -08:00
|
|
|
|
applyButton = new ThemedIconButton(icon, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
|
|
|
|
|
ToolTipText = "Apply".Localize(),
|
|
|
|
|
|
Enabled = true
|
|
|
|
|
|
};
|
|
|
|
|
|
applyButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.item.CanApply)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = this.item;
|
|
|
|
|
|
using (new SelectionMaintainer(view3DWidget.Scene))
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Apply(view3DWidget.Scene.UndoBuffer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// try to ungroup it
|
|
|
|
|
|
sceneContext.Scene.UngroupSelection();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
toolbar.AddChild(applyButton);
|
|
|
|
|
|
|
|
|
|
|
|
// put in a remove button
|
2023-10-03 16:17:01 -07:00
|
|
|
|
cancelButton = new ThemedIconButton(StaticData.Instance.LoadIcon("cancel.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(), theme)
|
2023-03-10 17:15:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
|
|
|
|
|
ToolTipText = "Cancel".Localize(),
|
|
|
|
|
|
Enabled = scene.SelectedItem != null
|
|
|
|
|
|
};
|
|
|
|
|
|
cancelButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = this.item;
|
|
|
|
|
|
using (new SelectionMaintainer(view3DWidget.Scene))
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Cancel(view3DWidget.Scene.UndoBuffer);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
toolbar.AddChild(cancelButton);
|
|
|
|
|
|
|
|
|
|
|
|
overflowButton = new PopupMenuButton("Action".Localize(), theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Enabled = scene.SelectedItem != null,
|
|
|
|
|
|
DrawArrow = true,
|
|
|
|
|
|
};
|
|
|
|
|
|
overflowButton.ToolTipText = "Object Actions".Localize();
|
|
|
|
|
|
overflowButton.DynamicPopupContent = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return ApplicationController.Instance.GetModifyMenu(view3DWidget.sceneContext);
|
|
|
|
|
|
};
|
|
|
|
|
|
toolbar.AddChild(overflowButton);
|
|
|
|
|
|
|
|
|
|
|
|
editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
Name = "editorPanel",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 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 SectionWidget(editorTitle, scrollableWidget, theme, toolbar, expandingContent: false, defaultExpansion: true, setContentVAnchor: false)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Stretch
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(editorSectionWidget);
|
|
|
|
|
|
|
|
|
|
|
|
this.ContentPanel = editorPanel;
|
|
|
|
|
|
|
|
|
|
|
|
// Register listeners
|
|
|
|
|
|
scene.SelectionChanged += Scene_SelectionChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public GuiWidget ContentPanel { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private readonly JsonPathContext pathGetter = new JsonPathContext();
|
|
|
|
|
|
private readonly ThemedIconButton applyButton;
|
|
|
|
|
|
private readonly ThemedIconButton cancelButton;
|
|
|
|
|
|
private readonly PopupMenuButton overflowButton;
|
|
|
|
|
|
private readonly InteractiveScene scene;
|
|
|
|
|
|
private readonly FlowLayoutWidget primaryActionsPanel;
|
|
|
|
|
|
|
|
|
|
|
|
public void SetActiveItem(ISceneContext sceneContext)
|
|
|
|
|
|
{
|
2023-11-01 15:13:25 -07:00
|
|
|
|
int tabIndex = 0;
|
2023-03-10 17:15:55 -08:00
|
|
|
|
var selectedItem = sceneContext?.Scene?.SelectedItem;
|
|
|
|
|
|
if (this.item == selectedItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.item = selectedItem;
|
|
|
|
|
|
editorPanel.CloseChildren();
|
|
|
|
|
|
|
|
|
|
|
|
// Allow caller to clean up with passing null for selectedItem
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
editorSectionWidget.Text = editorTitle;
|
|
|
|
|
|
// show any variables that are on the scene
|
|
|
|
|
|
|
2023-04-27 11:45:58 -07:00
|
|
|
|
// and return before showing a properties panel for the selected part (no selection)
|
2023-03-10 17:15:55 -08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var selectedItemType = selectedItem.GetType();
|
|
|
|
|
|
|
|
|
|
|
|
primaryActionsPanel.RemoveChildren();
|
|
|
|
|
|
|
|
|
|
|
|
// Get primary actions for selected item
|
|
|
|
|
|
var primaryOperations = new List<SceneOperation>();
|
|
|
|
|
|
|
|
|
|
|
|
// first check if the item implements IPrimaryOperationsSpecifier
|
|
|
|
|
|
if (selectedItem is IPrimaryOperationsSpecifier primaryOperatinsSpecifier)
|
|
|
|
|
|
{
|
|
|
|
|
|
primaryOperations = primaryOperatinsSpecifier.GetOperations().ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
// if not check if it is a 3D object
|
|
|
|
|
|
else if (selectedItemType == typeof(Object3D))
|
|
|
|
|
|
{
|
|
|
|
|
|
primaryOperations.Add(SceneOperations.ById("Scale"));
|
|
|
|
|
|
primaryOperations.Add(SceneOperations.ById("Mirror"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Loop over primary actions creating a button for each
|
|
|
|
|
|
foreach (var primaryAction in primaryOperations)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Run visible/enable rules on actions, conditionally add/enable as appropriate
|
|
|
|
|
|
var button = new ThemedIconButton(primaryAction.Icon(theme), theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Name = namedAction.Title + " Button",
|
|
|
|
|
|
ToolTipText = primaryAction.Title,
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
|
|
|
|
|
BackgroundColor = theme.ToolbarButtonBackground,
|
|
|
|
|
|
HoverColor = theme.ToolbarButtonHover,
|
|
|
|
|
|
MouseDownColor = theme.ToolbarButtonDown,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
button.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
primaryAction.Action.Invoke(sceneContext);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
primaryActionsPanel.AddChild(button);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (primaryActionsPanel.Children.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
// add in a separator from the apply and cancel buttons
|
|
|
|
|
|
primaryActionsPanel.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
editorSectionWidget.Text = selectedItem.Name ?? selectedItemType.Name;
|
|
|
|
|
|
|
2023-10-27 16:54:35 -07:00
|
|
|
|
HashSet<Func<ThemeConfig, UndoBuffer, IObjectEditor>> mappedEditors = ApplicationController.Instance.EditorExtensions.GetEditorsForType(selectedItemType);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
|
|
|
|
|
|
var undoBuffer = sceneContext.Scene.UndoBuffer;
|
|
|
|
|
|
|
|
|
|
|
|
void GetNextSelectionColor(Action<Color> setColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
var scene = sceneContext.Scene;
|
|
|
|
|
|
var startingSelection = scene.SelectedItem;
|
|
|
|
|
|
CancellationTokenSource cancellationToken = null;
|
|
|
|
|
|
|
|
|
|
|
|
void SelectionChanged(object s, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var selection = scene.SelectedItem;
|
|
|
|
|
|
if (selection != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
setColor?.Invoke(selection.WorldColor());
|
|
|
|
|
|
scene.SelectionChanged -= SelectionChanged;
|
|
|
|
|
|
cancellationToken?.Cancel();
|
|
|
|
|
|
scene.SelectedItem = startingSelection;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var durationSeconds = 20;
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.Tasks.Execute("Select an object to copy its color".Localize(),
|
|
|
|
|
|
null,
|
|
|
|
|
|
(progress, cancellationTokenIn) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
cancellationToken = cancellationTokenIn;
|
|
|
|
|
|
var time = UiThread.CurrentTimerMs;
|
|
|
|
|
|
while (UiThread.CurrentTimerMs < time + durationSeconds * 1000
|
|
|
|
|
|
&& !cancellationToken.IsCancellationRequested)
|
|
|
|
|
|
{
|
|
|
|
|
|
Thread.Sleep(30);
|
|
|
|
|
|
progress?.Invoke((UiThread.CurrentTimerMs - time) / 1000.0 / durationSeconds, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
scene.SelectionChanged -= SelectionChanged;
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
scene.SelectionChanged += SelectionChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(selectedItem.GetType().GetCustomAttributes(typeof(HideMeterialAndColor), true).FirstOrDefault() is HideMeterialAndColor))
|
|
|
|
|
|
{
|
2023-11-01 15:13:25 -07:00
|
|
|
|
AddMaterialAndColorSelector(sceneContext, selectedItem, undoBuffer, ref tabIndex);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var rows = new SafeList<SettingsRow>();
|
|
|
|
|
|
|
|
|
|
|
|
// put in the normal editor
|
|
|
|
|
|
if (selectedItem is ComponentObject3D componentObject
|
|
|
|
|
|
&& componentObject.Finalized)
|
|
|
|
|
|
{
|
2023-11-01 15:13:25 -07:00
|
|
|
|
AddComponentEditor(selectedItem, undoBuffer, rows, componentObject, ref tabIndex);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item != null
|
2023-10-27 16:54:35 -07:00
|
|
|
|
&& ApplicationController.Instance.EditorExtensions.GetEditorsForType(item.GetType())?.FirstOrDefault() is Func<ThemeConfig, UndoBuffer, IObjectEditor> editorFactory)
|
2022-04-29 17:33:29 -07:00
|
|
|
|
{
|
2023-10-27 16:54:35 -07:00
|
|
|
|
ShowObjectEditor((editorFactory.Invoke(theme, undoBuffer), item, item.Name), selectedItem);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-11-01 15:13:25 -07:00
|
|
|
|
void AddMaterialAndColorSelector(ISceneContext sceneContext, IObject3D selectedItem, UndoBuffer undoBuffer, ref int tabIndex)
|
2023-03-10 17:15:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
var firstDetectedColor = selectedItem.VisibleMeshes()?.FirstOrDefault()?.WorldColor();
|
|
|
|
|
|
var worldColor = Color.White;
|
|
|
|
|
|
if (firstDetectedColor != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
worldColor = firstDetectedColor.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// put in a color edit field
|
|
|
|
|
|
var colorField = new ColorField(theme, worldColor, GetNextSelectionColor, true);
|
2023-11-01 15:13:25 -07:00
|
|
|
|
colorField.Initialize(ref tabIndex);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
colorField.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectedItem.Color != colorField.Color)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (colorField.Color == Color.Transparent)
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.AddAndDo(new ChangeColor(selectedItem, colorField.Color, PrintOutputTypes.Default));
|
|
|
|
|
|
}
|
2022-05-27 17:44:03 -07:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
undoBuffer.AddAndDo(new ChangeColor(selectedItem, colorField.Color, PrintOutputTypes.Solid));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ColorButton holeButton = null;
|
|
|
|
|
|
var solidButton = colorField.Content.Descendants<ColorButton>().FirstOrDefault();
|
|
|
|
|
|
GuiWidget otherContainer = null;
|
|
|
|
|
|
TextWidget otherText = null;
|
|
|
|
|
|
GuiWidget holeContainer = null;
|
|
|
|
|
|
GuiWidget solidContainer = null;
|
|
|
|
|
|
void SetOtherOutputSelection(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
otherText.Text = text;
|
|
|
|
|
|
otherContainer.Visible = true;
|
|
|
|
|
|
holeContainer.BackgroundOutlineWidth = 0;
|
|
|
|
|
|
holeButton.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
|
|
|
|
|
|
solidContainer.BackgroundOutlineWidth = 0;
|
|
|
|
|
|
solidButton.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var scaledButtonSize = 24 * GuiWidget.DeviceScale;
|
|
|
|
|
|
void SetButtonStates()
|
2022-05-07 18:38:51 -07:00
|
|
|
|
{
|
2022-05-26 15:56:55 -07:00
|
|
|
|
switch (selectedItem.OutputType)
|
2022-05-07 20:00:07 -07:00
|
|
|
|
{
|
|
|
|
|
|
case PrintOutputTypes.Hole:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
holeContainer.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
holeButton.BackgroundOutlineWidth = 2;
|
|
|
|
|
|
holeButton.BackgroundRadius = scaledButtonSize / 2 - 1;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
2023-03-10 17:15:55 -08:00
|
|
|
|
solidContainer.BackgroundOutlineWidth = 0;
|
|
|
|
|
|
solidButton.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
solidButton.BackgroundRadius = scaledButtonSize / 2;
|
|
|
|
|
|
otherContainer.Visible = false;
|
|
|
|
|
|
break;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
|
|
|
|
|
case PrintOutputTypes.Default:
|
|
|
|
|
|
case PrintOutputTypes.Solid:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
holeContainer.BackgroundOutlineWidth = 0;
|
|
|
|
|
|
holeButton.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
holeButton.BackgroundRadius = scaledButtonSize / 2;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
2023-03-10 17:15:55 -08:00
|
|
|
|
solidContainer.BackgroundOutlineWidth = 1;
|
|
|
|
|
|
solidButton.BackgroundOutlineWidth = 2;
|
|
|
|
|
|
solidButton.BackgroundRadius = scaledButtonSize / 2 - 1;
|
|
|
|
|
|
otherContainer.Visible = false;
|
|
|
|
|
|
break;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
|
|
|
|
|
case PrintOutputTypes.Support:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
SetOtherOutputSelection("Support".Localize());
|
|
|
|
|
|
break;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
|
|
|
|
|
case PrintOutputTypes.WipeTower:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
SetOtherOutputSelection("Wipe Tower".Localize());
|
|
|
|
|
|
break;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
|
|
|
|
|
|
case PrintOutputTypes.Fuzzy:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
SetOtherOutputSelection("Fuzzy".Localize());
|
|
|
|
|
|
break;
|
2022-05-07 20:00:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-07 18:38:51 -07:00
|
|
|
|
|
2023-03-10 17:15:55 -08:00
|
|
|
|
void SetToSolid()
|
2022-05-07 18:38:51 -07:00
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
// make sure the render mode is set to shaded or outline
|
|
|
|
|
|
switch (sceneContext.ViewState.RenderType)
|
2022-05-12 18:15:07 -07:00
|
|
|
|
{
|
|
|
|
|
|
case RenderOpenGl.RenderTypes.Shaded:
|
|
|
|
|
|
case RenderOpenGl.RenderTypes.Outlines:
|
2023-03-10 17:15:55 -08:00
|
|
|
|
case RenderOpenGl.RenderTypes.Polygons:
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
// make sure the render mode is set to outline
|
|
|
|
|
|
sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Outlines;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var currentOutputType = selectedItem.OutputType;
|
|
|
|
|
|
if (currentOutputType != PrintOutputTypes.Solid && currentOutputType != PrintOutputTypes.Default)
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.AddAndDo(new ChangeColor(selectedItem, colorField.Color, PrintOutputTypes.Solid));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetButtonStates();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
solidButton.Parent.MouseDown += (s, e) => SetToSolid();
|
|
|
|
|
|
|
|
|
|
|
|
var colorRow = new SettingsRow("Output".Localize(), null, colorField.Content, theme)
|
2022-05-10 08:29:08 -07:00
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
// Special top border style for first item in editor
|
|
|
|
|
|
Border = new BorderDouble(0, 1)
|
|
|
|
|
|
};
|
|
|
|
|
|
editorPanel.AddChild(colorRow);
|
|
|
|
|
|
|
|
|
|
|
|
// put in a hole button
|
|
|
|
|
|
holeButton = new ColorButton(Color.DarkGray)
|
2022-05-07 18:38:51 -07:00
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
Margin = new BorderDouble(5, 0, 11, 0),
|
|
|
|
|
|
Width = scaledButtonSize,
|
|
|
|
|
|
Height = scaledButtonSize,
|
|
|
|
|
|
BackgroundRadius = scaledButtonSize / 2,
|
|
|
|
|
|
BackgroundOutlineWidth = 1,
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
DisabledColor = theme.MinimalShade,
|
|
|
|
|
|
BorderColor = theme.TextColor,
|
|
|
|
|
|
ToolTipText = "Convert to Hole".Localize(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
GuiWidget NewTextContainer(string text)
|
2022-05-07 20:00:07 -07:00
|
|
|
|
{
|
2023-03-10 17:15:55 -08:00
|
|
|
|
var textWidget = new TextWidget(text.Localize(), pointSize: theme.FontSize10, textColor: theme.TextColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(5, 4, 5, 5),
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
|
|
|
|
|
};
|
2018-10-06 15:09:01 -07:00
|
|
|
|
|
2023-03-10 17:15:55 -08:00
|
|
|
|
var container = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(5, 0),
|
|
|
|
|
|
VAnchor = VAnchor.Fit | VAnchor.Center,
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
BackgroundRadius = 3,
|
|
|
|
|
|
BackgroundOutlineWidth = 1,
|
|
|
|
|
|
BorderColor = theme.PrimaryAccentColor,
|
|
|
|
|
|
Selectable = true,
|
|
|
|
|
|
};
|
2021-06-04 07:13:34 -07:00
|
|
|
|
|
2023-03-10 17:15:55 -08:00
|
|
|
|
container.AddChild(textWidget);
|
|
|
|
|
|
|
|
|
|
|
|
return container;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var buttonRow = solidButton.Parents<FlowLayoutWidget>().FirstOrDefault();
|
|
|
|
|
|
solidContainer = NewTextContainer("Solid");
|
|
|
|
|
|
buttonRow.AddChild(solidContainer, 0);
|
|
|
|
|
|
|
|
|
|
|
|
buttonRow.AddChild(holeButton, 0);
|
|
|
|
|
|
holeContainer = NewTextContainer("Hole");
|
|
|
|
|
|
buttonRow.AddChild(holeContainer, 0);
|
|
|
|
|
|
|
|
|
|
|
|
otherContainer = NewTextContainer("");
|
|
|
|
|
|
buttonRow.AddChild(otherContainer, 0);
|
|
|
|
|
|
|
|
|
|
|
|
otherText = otherContainer.Children.First() as TextWidget;
|
|
|
|
|
|
|
|
|
|
|
|
void SetToHole()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectedItem.OutputType != PrintOutputTypes.Hole)
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.AddAndDo(new MakeHole(selectedItem));
|
|
|
|
|
|
}
|
|
|
|
|
|
SetButtonStates();
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
holeButton.Click += (s, e) => SetToHole();
|
|
|
|
|
|
holeContainer.Click += (s, e) => SetToHole();
|
|
|
|
|
|
solidContainer.Click += (s, e) => SetToSolid();
|
|
|
|
|
|
|
|
|
|
|
|
SetButtonStates();
|
|
|
|
|
|
void SelectedItemOutputChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetButtonStates();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
selectedItem.Invalidated += SelectedItemOutputChanged;
|
|
|
|
|
|
Closed += (s, e) => selectedItem.Invalidated -= SelectedItemOutputChanged;
|
|
|
|
|
|
|
|
|
|
|
|
// put in a material edit field
|
|
|
|
|
|
var materialField = new MaterialIndexField(sceneContext.Printer, theme, selectedItem.MaterialIndex);
|
2023-11-01 15:13:25 -07:00
|
|
|
|
materialField.Initialize(ref tabIndex);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
materialField.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectedItem.MaterialIndex != materialField.MaterialIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.AddAndDo(new ChangeMaterial(selectedItem, materialField.MaterialIndex));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
materialField.Content.MouseDown += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Materials)
|
|
|
|
|
|
{
|
|
|
|
|
|
// make sure the render mode is set to material
|
|
|
|
|
|
sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Materials;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// material row
|
|
|
|
|
|
editorPanel.AddChild(new SettingsRow("Material".Localize(), null, materialField.Content, theme));
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}
|
2022-05-07 20:00:07 -07:00
|
|
|
|
}
|
2017-10-18 18:18:10 -07:00
|
|
|
|
|
2023-11-01 15:13:25 -07:00
|
|
|
|
private void AddComponentEditor(IObject3D selectedItem, UndoBuffer undoBuffer, SafeList<SettingsRow> rows, ComponentObject3D componentObject, ref int tabIndex)
|
2022-03-21 15:41:57 -07:00
|
|
|
|
{
|
2023-10-27 10:40:57 -07:00
|
|
|
|
var context = new EditorContext();
|
|
|
|
|
|
PropertyEditor.AddUnlockLinkIfRequired(selectedItem, editorPanel, theme);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
var editorList = componentObject.SurfacedEditors;
|
2022-03-21 15:41:57 -07:00
|
|
|
|
for (var editorIndex = 0; editorIndex < editorList.Count; editorIndex++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// if it is a reference to a sheet cell
|
|
|
|
|
|
if (editorList[editorIndex].StartsWith("!"))
|
|
|
|
|
|
{
|
|
|
|
|
|
AddSheetCellEditor(undoBuffer, componentObject, editorList, editorIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
else // parse it as a path to an object
|
|
|
|
|
|
{
|
|
|
|
|
|
// Get the named property via reflection
|
|
|
|
|
|
// Selector example: '$.Children<CylinderObject3D>'
|
|
|
|
|
|
var match = pathGetter.Select(componentObject, editorList[editorIndex]).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
//// - Add editor row for each
|
|
|
|
|
|
foreach (var instance in match)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (instance is IObject3D object3D)
|
|
|
|
|
|
{
|
2023-10-27 16:54:35 -07:00
|
|
|
|
if (ApplicationController.Instance.EditorExtensions.GetEditorsForType(object3D.GetType())?.FirstOrDefault() is Func<ThemeConfig, UndoBuffer, IObjectEditor> editorFactory)
|
2022-03-21 15:41:57 -07:00
|
|
|
|
{
|
2023-10-27 16:54:35 -07:00
|
|
|
|
ShowObjectEditor((editorFactory.Invoke(theme, undoBuffer), object3D, object3D.Name), selectedItem);
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (JsonPathContext.ReflectionValueSystem.LastMemberValue is ReflectionTarget reflectionTarget)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (reflectionTarget.Source is IObject3D editedChild)
|
|
|
|
|
|
{
|
2023-10-27 10:40:57 -07:00
|
|
|
|
context.Item = editedChild;
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-10-27 10:40:57 -07:00
|
|
|
|
context.Item = item;
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var editableProperty = new EditableProperty(reflectionTarget.PropertyInfo, reflectionTarget.Source);
|
|
|
|
|
|
|
2023-10-27 16:54:35 -07:00
|
|
|
|
var propertyEditor = new PropertyEditor(theme, undoBuffer);
|
2023-11-01 15:13:25 -07:00
|
|
|
|
var editor = propertyEditor.CreatePropertyEditor(editableProperty, undoBuffer, context, theme, ref tabIndex);
|
2022-03-21 15:41:57 -07:00
|
|
|
|
if (editor != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
editorPanel.AddChild(editor);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Init with custom 'UpdateControls' hooks
|
2023-10-27 10:40:57 -07:00
|
|
|
|
(context.Item as IPropertyGridModifier)?.UpdateControls(new PublicPropertyChange(context, "Update_Button"));
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Enforce panel padding
|
|
|
|
|
|
foreach (var sectionWidget in editorPanel.Descendants<SectionWidget>())
|
|
|
|
|
|
{
|
|
|
|
|
|
sectionWidget.Margin = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddSheetCellEditor(UndoBuffer undoBuffer, ComponentObject3D componentObject, List<string> editorList, int editorIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
var firtSheet = componentObject.Descendants<SheetObject3D>().FirstOrDefault();
|
|
|
|
|
|
if (firtSheet != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var (cellId, cellData) = componentObject.DecodeContent(editorIndex);
|
|
|
|
|
|
var cell = firtSheet.SheetData[cellId];
|
|
|
|
|
|
if (cell != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// create an expresion editor
|
2022-11-26 15:28:01 -08:00
|
|
|
|
var field = new TextField(theme)
|
2022-03-21 15:41:57 -07:00
|
|
|
|
{
|
2022-11-26 15:28:01 -08:00
|
|
|
|
Name = cellId + " Field",
|
2022-03-21 15:41:57 -07:00
|
|
|
|
};
|
2023-11-01 15:13:25 -07:00
|
|
|
|
int tabIndex = 0;
|
|
|
|
|
|
field.Initialize(ref tabIndex);
|
2022-11-26 15:28:01 -08:00
|
|
|
|
field.SetValue(cellData, false);
|
2023-03-10 17:15:55 -08:00
|
|
|
|
field.ClearUndoHistory();
|
|
|
|
|
|
field.Content.HAnchor = HAnchor.Stretch;
|
2022-03-21 15:41:57 -07:00
|
|
|
|
|
|
|
|
|
|
var doOrUndoing = false;
|
|
|
|
|
|
field.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!doOrUndoing)
|
|
|
|
|
|
{
|
|
|
|
|
|
var oldValue = componentObject.DecodeContent(editorIndex).cellData;
|
|
|
|
|
|
var newValue = field.Value;
|
|
|
|
|
|
undoBuffer.AddAndDo(new UndoRedoActions(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
doOrUndoing = true;
|
2023-03-10 17:15:55 -08:00
|
|
|
|
editorList[editorIndex] = "!" + cellId + "," + oldValue;
|
|
|
|
|
|
var expression = new StringOrExpression(oldValue);
|
|
|
|
|
|
cell.Expression = expression.Value(componentObject).ToString();
|
|
|
|
|
|
componentObject.Invalidate(InvalidateType.SheetUpdated);
|
2022-03-21 15:41:57 -07:00
|
|
|
|
doOrUndoing = false;
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
doOrUndoing = true;
|
2023-03-10 17:15:55 -08:00
|
|
|
|
editorList[editorIndex] = "!" + cellId + "," + newValue;
|
|
|
|
|
|
var expression = new StringOrExpression(newValue);
|
|
|
|
|
|
cell.Expression = expression.Value(componentObject).ToString();
|
|
|
|
|
|
componentObject.Invalidate(InvalidateType.SheetUpdated);
|
|
|
|
|
|
doOrUndoing = false;
|
2022-03-21 15:41:57 -07:00
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-03-22 15:54:19 -07:00
|
|
|
|
var row = new SettingsRow(cell.Name == null ? cellId : cell.Name.Replace("_", " "), null, field.Content, theme);
|
2022-03-21 15:41:57 -07:00
|
|
|
|
editorPanel.AddChild(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-16 07:46:44 -07:00
|
|
|
|
private class OperationButton : ThemedTextButton
|
2023-03-10 17:15:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
private readonly SceneOperation sceneOperation;
|
|
|
|
|
|
private readonly ISceneContext sceneContext;
|
|
|
|
|
|
|
|
|
|
|
|
public OperationButton(SceneOperation sceneOperation, ISceneContext sceneContext, ThemeConfig theme)
|
|
|
|
|
|
: base(sceneOperation.Title, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.sceneOperation = sceneOperation;
|
|
|
|
|
|
this.sceneContext = sceneContext;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void EnsureAvailablity()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Enabled = sceneOperation.IsEnabled?.Invoke(sceneContext) != false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-23 14:04:47 -07:00
|
|
|
|
private void ShowObjectEditor((IObjectEditor editor, IObject3D item, string displayName) scopeItem, IObject3D rootSelection)
|
2023-03-10 17:15:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
var selectedItem = scopeItem.item;
|
|
|
|
|
|
|
|
|
|
|
|
var editorWidget = scopeItem.editor.Create(selectedItem, sceneContext.Scene.UndoBuffer, theme);
|
|
|
|
|
|
editorWidget.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
editorWidget.VAnchor = VAnchor.Fit;
|
|
|
|
|
|
|
|
|
|
|
|
if (scopeItem.item != rootSelection
|
2023-10-27 10:40:57 -07:00
|
|
|
|
&& scopeItem.editor is PropertyEditor)
|
2023-03-10 17:15:55 -08:00
|
|
|
|
{
|
|
|
|
|
|
editorWidget.Padding = new BorderDouble(10, 10, 10, 0);
|
|
|
|
|
|
|
|
|
|
|
|
// EditOutline section
|
|
|
|
|
|
var sectionWidget = new SectionWidget(
|
|
|
|
|
|
scopeItem.displayName ?? "Unknown",
|
|
|
|
|
|
editorWidget,
|
|
|
|
|
|
theme);
|
|
|
|
|
|
|
|
|
|
|
|
theme.ApplyBoxStyle(sectionWidget, margin: 0);
|
|
|
|
|
|
|
|
|
|
|
|
editorWidget = sectionWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
editorWidget.Padding = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
editorPanel.AddChild(editorWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task Save(ILibraryItem item, IObject3D content)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.item.Parent.Children.Modify(children =>
|
|
|
|
|
|
{
|
|
|
|
|
|
children.Remove(this.item);
|
|
|
|
|
|
children.Add(content);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnClosed(EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
scene.SelectionChanged -= Scene_SelectionChanged;
|
|
|
|
|
|
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Scene_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (editorPanel.Children.FirstOrDefault()?.DescendantsAndSelf<SectionWidget>().FirstOrDefault() is SectionWidget firstSectionWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
firstSectionWidget.Margin = firstSectionWidget.Margin.Clone(top: 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var selectedItem = scene.SelectedItem;
|
|
|
|
|
|
|
|
|
|
|
|
applyButton.Enabled = selectedItem != null
|
|
|
|
|
|
&& (selectedItem is GroupObject3D
|
|
|
|
|
|
|| (selectedItem.GetType() == typeof(Object3D) && selectedItem.Children.Any())
|
|
|
|
|
|
|| selectedItem.CanApply);
|
|
|
|
|
|
cancelButton.Enabled = selectedItem != null;
|
|
|
|
|
|
overflowButton.Enabled = selectedItem != null;
|
|
|
|
|
|
if (selectedItem == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
primaryActionsPanel.RemoveChildren();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|