public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; this.ContentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.AddChild(this.ContentPanel); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; this.AddChild(scrollable); var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.TabBodyBackground, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("fa-check_16.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var applyButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply operation and make permanent".Localize(), Enabled = scene.SelectedItem?.CanApply == true }; applyButton.Click += (s, e) => { this.item.Apply(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => applyButton.Enabled = scene.SelectedItem?.CanApply == true; toolbar.AddChild(applyButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("close.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Remove operation from parts".Localize() }; removeButton.Click += (s, e) => { var rootSelection = scene.SelectedItemRoot; item.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; if (item != rootSelection) { scene.SelectedItem = rootSelection; } }; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme); overflowButton.Enabled = scene.SelectedItem != null; scene.SelectionChanged += (s, e) => overflowButton.Enabled = scene.SelectedItem != null; overflowButton.PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120); overflowButton.DynamicPopupContent = () => { return(ApplicationController.Instance.GetActionMenuForSceneItem(item, sceneContext.Scene)); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "editorPanel", Padding = new BorderDouble(right: theme.DefaultContainerPadding + 1) }; // Wrap editorPanel with scrollable container var scrollableWidget = new ScrollableWidget(true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; scrollableWidget.AddChild(editorPanel); scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch; scrollableWidget.Padding = new BorderDouble(right: theme.DefaultContainerPadding * .8); editorSectionWidget = new ResizableSectionWidget("Editor", sceneContext.ViewState.SelectedObjectEditorHeight, scrollableWidget, theme, serializationKey: UserSettingsKey.EditorPanelExpanded, rightAlignedContent: toolbar, defaultExpansion: true) { VAnchor = VAnchor.Fit, }; editorSectionWidget.Resized += (s, e) => { sceneContext.ViewState.SelectedObjectEditorHeight = editorSectionWidget.ResizeContainer.Height; }; int topBottom = theme.DefaultContainerPadding / 2; editorSectionWidget.ResizeContainer.Padding = new BorderDouble(left: theme.DefaultContainerPadding, top: topBottom, bottom: topBottom + editorSectionWidget.ResizeContainer.SplitterHeight); this.ContentPanel.AddChild(editorSectionWidget); var colorSection = new SectionWidget( "Color".Localize(), new ColorSwatchSelector(scene, theme, buttonSize: 16, buttonSpacing: new BorderDouble(1, 1, 0, 0)) { Margin = new BorderDouble(left: 10) }, theme, serializationKey: UserSettingsKey.ColorPanelExpanded) { Name = "Color Panel", }; this.ContentPanel.AddChild(colorSection); var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, serializationKey: UserSettingsKey.MaterialsPanelExpanded) { Name = "Materials Panel", }; this.ContentPanel.AddChild(materialsSection); // Enforce panel padding in sidebar foreach (var sectionWidget in this.ContentPanel.Children <SectionWidget>()) { // Special case for editorResizeWrapper due to ResizeContainer if (sectionWidget is ResizableSectionWidget resizableSectionWidget) { // Apply padding to ResizeContainer not wrapper //resizableSectionWidget.ResizeContainer.Padding = new BorderDouble(10, 10, 10, 0); } else { sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0); sectionWidget.ExpandableWhenDisabled = true; sectionWidget.Enabled = false; } } }
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; this.ContentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var scrollable = new ScrollableWidget(true) { Name = "editorPanel", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; scrollable.AddChild(this.ContentPanel); scrollable.ScrollArea.HAnchor = HAnchor.Stretch; this.AddChild(scrollable); var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.TabBodyBackground, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("fa-check_16.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var applyButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply operation and make permanent".Localize() }; applyButton.Click += (s, e) => { this.item.Apply(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => applyButton.Enabled = scene.SelectedItem?.CanApply == true; toolbar.AddChild(applyButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("close.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Remove operation from parts".Localize() }; removeButton.Click += (s, e) => { item.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; scene.SelectionChanged += (s, e) => removeButton.Enabled = scene.SelectedItem?.CanRemove == true; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme); overflowButton.PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120); overflowButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var menuItem = popupMenu.CreateMenuItem("Rename"); menuItem.Click += (s, e) => { DialogWindow.Show( new InputBoxPage( "Rename Item".Localize(), "Name".Localize(), item.Name, "Enter New Name Here".Localize(), "Rename".Localize(), (newName) => { item.Name = newName; editorSectionWidget.Text = newName; })); }; popupMenu.CreateHorizontalLine(); if (true) //allowOperations) { var selectedItemType = item.GetType(); var selectedItem = item; foreach (var nodeOperation in ApplicationController.Instance.Graph.Operations) { foreach (var type in nodeOperation.MappedTypes) { if (type.IsAssignableFrom(selectedItemType) && (nodeOperation.IsVisible?.Invoke(selectedItem) != false) && nodeOperation.IsEnabled?.Invoke(selectedItem) != false) { var button = popupMenu.CreateMenuItem(nodeOperation.Title, nodeOperation.IconCollector?.Invoke()?.CreateScaledImage(16, 16)); button.Click += (s, e) => { nodeOperation.Operation(selectedItem, sceneContext.Scene).ConfigureAwait(false); }; } } } } return(popupMenu); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = new BorderDouble(top: 10) }; // 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, rightAlignedContent: toolbar, defaultExpansion: true) { VAnchor = VAnchor.Fit, }; editorSectionWidget.Resized += (s, e) => { sceneContext.ViewState.SelectedObjectEditorHeight = editorSectionWidget.ResizeContainer.Height; }; this.ContentPanel.AddChild(editorSectionWidget); var colorSection = new SectionWidget( "Color".Localize(), new ColorSwatchSelector(scene, theme, buttonSize: 16, buttonSpacing: new BorderDouble(1, 1, 0, 0)) { Margin = new BorderDouble(left: 10) }, theme, serializationKey: UserSettingsKey.ColorPanelExpanded) { Name = "Color Panel", }; this.ContentPanel.AddChild(colorSection); var materialsSection = new SectionWidget("Materials".Localize(), new MaterialControls(scene, theme), theme, serializationKey: UserSettingsKey.MaterialsPanelExpanded) { Name = "Materials Panel", }; this.ContentPanel.AddChild(materialsSection); // Enforce panel padding in sidebar foreach (var sectionWidget in this.ContentPanel.Children <SectionWidget>()) { // Special case for editorResizeWrapper due to ResizeContainer if (sectionWidget is ResizableSectionWidget resizableSectionWidget) { // Apply padding to ResizeContainer not wrapper resizableSectionWidget.ResizeContainer.Padding = new BorderDouble(10, 10, 10, 0); } else { sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0); sectionWidget.ExpandableWhenDisabled = true; sectionWidget.Enabled = false; } } }
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.view3DWidget = view3DWidget; 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 a make permanent button var icon = AggContext.StaticData.LoadIcon("noun_766157.png", 16, 16, theme.InvertIcons).SetPreMultiply(); flattenButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Flatten".Localize(), Enabled = true }; flattenButton.Click += (s, e) => { if (this.item.CanFlatten) { var item = this.item; using (new SelectionMaintainer(view3DWidget.Scene)) { item.Flatten(view3DWidget.Scene.UndoBuffer); } } else { // try to ungroup it sceneContext.Scene.UngroupSelection(); } }; toolbar.AddChild(flattenButton); // put in a remove button removeButton = new IconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Delete".Localize(), Enabled = scene.SelectedItem != null }; removeButton.Click += (s, e) => { var item = this.item; using (new SelectionMaintainer(view3DWidget.Scene)) { item.Remove(view3DWidget.Scene.UndoBuffer); } }; toolbar.AddChild(removeButton); primaryActionsPanel = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Center | VAnchor.Fit }; toolbar.AddChild(primaryActionsPanel); overflowButton = new OverflowBar.OverflowMenuButton(theme) { Enabled = scene.SelectedItem != null, }; overflowButton.DynamicPopupContent = () => { var remainingOperations = ApplicationController.Instance.Graph.Operations.Values.Except(primaryActions); return(ApplicationController.Instance.GetActionMenuForSceneItem(item, sceneContext.Scene, false, remainingOperations)); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "editorPanel", Padding = new BorderDouble(right: theme.DefaultContainerPadding + 1) }; // 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; editorPanel.Padding = new BorderDouble(theme.DefaultContainerPadding, 0); // Register listeners scene.SelectionChanged += Scene_SelectionChanged; }
public SelectedObjectPanel(View3DWidget view3DWidget, BedConfig sceneContext, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Top | VAnchor.Fit; this.Padding = 0; this.view3DWidget = view3DWidget; this.theme = theme; this.sceneContext = sceneContext; var toolbar = new LeftClipFlowLayoutWidget() { BackgroundColor = theme.ActiveTabColor, Padding = theme.ToolbarPadding, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit }; var scene = sceneContext.Scene; // put in a make permanent button var icon = AggContext.StaticData.LoadIcon("noun_766157.png", 16, 16, theme.InvertIcons).SetPreMultiply(); var flattenButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Flatten".Localize(), Enabled = scene.SelectedItem?.CanFlatten == true }; flattenButton.Click += (s, e) => { this.item.Flatten(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; }; toolbar.AddChild(flattenButton); // put in a remove button var removeButton = new IconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Delete".Localize(), Enabled = scene.SelectedItem != null }; removeButton.Click += (s, e) => { var rootSelection = scene.SelectedItemRoot; var removeItem = item; removeItem.Remove(view3DWidget.Scene.UndoBuffer); scene.SelectedItem = null; // Only restore the root selection if it wasn't the item removed if (removeItem != rootSelection) { scene.SelectedItem = rootSelection; } }; toolbar.AddChild(removeButton); var overflowButton = new OverflowBar.OverflowMenuButton(theme) { Enabled = scene.SelectedItem != null, PopupBorderColor = ApplicationController.Instance.MenuTheme.GetBorderColor(120) }; overflowButton.DynamicPopupContent = () => { return(ApplicationController.Instance.GetActionMenuForSceneItem(item, sceneContext.Scene, false)); }; toolbar.AddChild(overflowButton); editorPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Name = "editorPanel", Padding = new BorderDouble(right: theme.DefaultContainerPadding + 1) }; // 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("Editor", scrollableWidget, theme, toolbar, expandingContent: false, defaultExpansion: true, setContentVAnchor: false) { VAnchor = VAnchor.Stretch }; this.AddChild(editorSectionWidget); this.ContentPanel = editorPanel; editorPanel.Padding = new BorderDouble(theme.DefaultContainerPadding, 0); scene.SelectionChanged += (s, e) => { if (editorPanel.Children.FirstOrDefault()?.DescendantsAndSelf <SectionWidget>().FirstOrDefault() is SectionWidget firstSectionWidget) { firstSectionWidget.Margin = firstSectionWidget.Margin.Clone(top: 0); } var selectedItem = scene.SelectedItem; flattenButton.Enabled = selectedItem?.CanFlatten == true; removeButton.Enabled = selectedItem != null; overflowButton.Enabled = selectedItem != null; }; }
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 var icon = StaticData.Instance.LoadIcon("apply.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(); flattenButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply".Localize(), Enabled = true }; flattenButton.Click += (s, e) => { if (this.item.CanFlatten) { var item = this.item; using (new SelectionMaintainer(view3DWidget.Scene)) { item.Flatten(view3DWidget.Scene.UndoBuffer); } } else { // try to ungroup it sceneContext.Scene.UngroupSelection(); } }; toolbar.AddChild(flattenButton); // put in a remove button removeButton = new IconButton(StaticData.Instance.LoadIcon("cancel.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Cancel".Localize(), Enabled = scene.SelectedItem != null }; removeButton.Click += (s, e) => { var item = this.item; using (new SelectionMaintainer(view3DWidget.Scene)) { item.Remove(view3DWidget.Scene.UndoBuffer); } }; toolbar.AddChild(removeButton); overflowButton = new OverflowBar.OverflowMenuButton(theme) { Enabled = scene.SelectedItem != null, }; overflowButton.ToolTipText = "Selected Object Options".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; }