Merge pull request #3717 from jlewin/master
Move view controls into new View3DWidget toolbar
This commit is contained in:
commit
55b28081c5
9 changed files with 198 additions and 53 deletions
|
|
@ -2250,29 +2250,25 @@ namespace MatterHackers.MatterControl
|
|||
return (slicingSucceeded, gcodeFilePath);
|
||||
}
|
||||
|
||||
internal GuiWidget GetViewOptionButtons(BedConfig sceneContext, PrinterConfig printer, ThemeConfig theme)
|
||||
internal void GetViewOptionButtons(GuiWidget parent, BedConfig sceneContext, PrinterConfig printer, ThemeConfig theme)
|
||||
{
|
||||
var container = new FlowLayoutWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Fit | VAnchor.Center
|
||||
};
|
||||
|
||||
var bedButton = new RadioIconButton(AggContext.StaticData.LoadIcon("bed.png", theme.InvertIcons), theme)
|
||||
{
|
||||
Name = "Bed Button",
|
||||
ToolTipText = "Show Print Bed".Localize(),
|
||||
Checked = sceneContext.RendererOptions.RenderBed,
|
||||
Margin = theme.ButtonSpacing,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
ToggleButton = true,
|
||||
Height = 24,
|
||||
Width = 24,
|
||||
Height = theme.ButtonHeight,
|
||||
Width = theme.ButtonHeight,
|
||||
SiblingRadioButtonList = new List<GuiWidget>()
|
||||
};
|
||||
bedButton.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
sceneContext.RendererOptions.RenderBed = bedButton.Checked;
|
||||
};
|
||||
container.AddChild(bedButton);
|
||||
parent.AddChild(bedButton);
|
||||
|
||||
Func<bool> buildHeightValid = () => sceneContext.BuildHeight > 0;
|
||||
|
||||
|
|
@ -2282,19 +2278,20 @@ namespace MatterHackers.MatterControl
|
|||
ToolTipText = (buildHeightValid()) ? "Show Print Area".Localize() : "Define printer build height to enable",
|
||||
Checked = sceneContext.RendererOptions.RenderBuildVolume,
|
||||
Margin = theme.ButtonSpacing,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
ToggleButton = true,
|
||||
Enabled = buildHeightValid() && printer?.ViewState.ViewMode != PartViewMode.Layers2D,
|
||||
Height = 24,
|
||||
Width = 24,
|
||||
Height = theme.ButtonHeight,
|
||||
Width = theme.ButtonHeight,
|
||||
SiblingRadioButtonList = new List<GuiWidget>()
|
||||
};
|
||||
printAreaButton.CheckedStateChanged += (s, e) =>
|
||||
{
|
||||
sceneContext.RendererOptions.RenderBuildVolume = printAreaButton.Checked;
|
||||
};
|
||||
container.AddChild(printAreaButton);
|
||||
parent.AddChild(printAreaButton);
|
||||
|
||||
this.BindBedOptions(container, bedButton, printAreaButton, sceneContext.RendererOptions);
|
||||
this.BindBedOptions(parent, bedButton, printAreaButton, sceneContext.RendererOptions);
|
||||
|
||||
if (printer != null)
|
||||
{
|
||||
|
|
@ -2307,13 +2304,11 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
printer.ViewState.ViewModeChanged += viewModeChanged;
|
||||
|
||||
container.Closed += (s, e) =>
|
||||
parent.Closed += (s, e) =>
|
||||
{
|
||||
printer.ViewState.ViewModeChanged -= viewModeChanged;
|
||||
};
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
public void BindBedOptions(GuiWidget container, ICheckbox bedButton, ICheckbox printAreaButton, View3DConfig renderOptions)
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.RemoveAllChildren();
|
||||
|
||||
SimpleTabs tabControl = null;
|
||||
|
||||
if (this.ControlIsPinned)
|
||||
{
|
||||
var resizePage = new LeftResizeContainer(theme)
|
||||
|
|
@ -206,6 +207,10 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
this.AddChild(resizePage);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.BackgroundColor = theme.TabBarBackground;
|
||||
}
|
||||
|
||||
foreach (var item in allTabs)
|
||||
{
|
||||
|
|
|
|||
110
MatterControlLib/PartPreviewWindow/DropButton.cs
Normal file
110
MatterControlLib/PartPreviewWindow/DropButton.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
Copyright (c) 2018, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
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
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class DropButton : SimpleButton
|
||||
{
|
||||
private bool menuVisible;
|
||||
|
||||
public DropButton(ThemeConfig theme)
|
||||
: base(theme)
|
||||
{
|
||||
this.AnchorMate = new MatePoint(this)
|
||||
{
|
||||
Mate = new MateOptions(MateEdge.Left, MateEdge.Top),
|
||||
AltMate = new MateOptions(MateEdge.Left, MateEdge.Top)
|
||||
};
|
||||
|
||||
this.PopupMate = new MatePoint()
|
||||
{
|
||||
Mate = new MateOptions(MateEdge.Left, MateEdge.Top),
|
||||
AltMate = new MateOptions(MateEdge.Right, MateEdge.Top)
|
||||
};
|
||||
|
||||
this.AltPopupBounds = default(RectangleDouble);
|
||||
}
|
||||
|
||||
public Func<GuiWidget> PopupContent { get; set; }
|
||||
|
||||
public MatePoint AnchorMate { get; set; }
|
||||
|
||||
public MatePoint PopupMate { get; set; }
|
||||
|
||||
public RectangleDouble AltPopupBounds { get; }
|
||||
|
||||
public override Color BackgroundColor
|
||||
{
|
||||
get => menuVisible ? theme.SlightShade : base.BackgroundColor;
|
||||
set => base.BackgroundColor = value;
|
||||
}
|
||||
|
||||
public override void OnClick(MouseEventArgs mouseEvent)
|
||||
{
|
||||
if (!menuVisible)
|
||||
{
|
||||
var popupContent = this.PopupContent();
|
||||
if (popupContent == null
|
||||
|| popupContent.Children.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.PopupMate.Widget = popupContent;
|
||||
|
||||
if (this.Parents<SystemWindow>().FirstOrDefault() is SystemWindow systemWindow)
|
||||
{
|
||||
menuVisible = true;
|
||||
|
||||
void popupContent_Closed(object sender, EventArgs e)
|
||||
{
|
||||
// Reset menuVisible
|
||||
menuVisible = false;
|
||||
popupContent.Closed -= popupContent_Closed;
|
||||
}
|
||||
|
||||
popupContent.Closed += popupContent_Closed;
|
||||
|
||||
systemWindow.ShowPopup(
|
||||
this.AnchorMate,
|
||||
this.PopupMate,
|
||||
this.AltPopupBounds);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnClick(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,8 +63,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
sectionWidget = new SectionWidget(
|
||||
"Options".Localize(),
|
||||
new GCodeOptionsPanel(sceneContext, printer, theme),
|
||||
theme,
|
||||
ApplicationController.Instance.GetViewOptionButtons(sceneContext, printer, theme))
|
||||
theme)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
toolbar.AddChild(applyButton);
|
||||
|
||||
// put in a remove button
|
||||
var removeButton = new IconButton(AggContext.StaticData.LoadIcon("close.png", 16, 16, theme.InvertIcons), theme)
|
||||
var removeButton = new IconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme)
|
||||
{
|
||||
Margin = theme.ButtonSpacing,
|
||||
ToolTipText = "Delete".Localize(),
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private bool mouseOver = false;
|
||||
private List<TextureData> textureDatas = new List<TextureData>();
|
||||
private WorldView world;
|
||||
ThemeConfig theme;
|
||||
List<ConnectedFaces> connections = new List<ConnectedFaces>();
|
||||
private ThemeConfig theme;
|
||||
private List<ConnectedFaces> connections = new List<ConnectedFaces>();
|
||||
|
||||
public TumbleCubeControl(InteractionLayer interactionLayer, ThemeConfig theme)
|
||||
: base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.Linq;
|
|||
using System.Text.RegularExpressions;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -63,6 +64,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private TreeView treeView;
|
||||
|
||||
private ViewStyleButton modelViewStyleButton;
|
||||
|
||||
private PrinterConfig printer;
|
||||
|
||||
private ThemeConfig theme;
|
||||
|
||||
public Vector3 BedCenter
|
||||
|
|
@ -98,6 +103,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.InteractionLayer.AnchorAll();
|
||||
|
||||
this.viewControls3D = viewControls3D;
|
||||
this.printer = printer;
|
||||
this.theme = theme;
|
||||
this.Name = "View3DWidget";
|
||||
this.BackgroundColor = theme.ActiveTabColor;
|
||||
|
|
@ -165,22 +171,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
modelViewSidePanel.Resized += ModelViewSidePanel_Resized;
|
||||
|
||||
var viewOptionButtons = ApplicationController.Instance.GetViewOptionButtons(sceneContext, printer, theme);
|
||||
viewOptionButtons.AddChild(new ViewStyleButton(sceneContext, theme));
|
||||
|
||||
modelViewSidePanel.AddChild(
|
||||
new SectionWidget(
|
||||
"Options".Localize(),
|
||||
new GuiWidget(),
|
||||
theme,
|
||||
viewOptionButtons,
|
||||
expandingContent: false)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit,
|
||||
BorderColor = Color.Transparent // Disable top border to produce a more flat, dark top edge
|
||||
});
|
||||
|
||||
// add the tree view
|
||||
treeView = new TreeView(theme)
|
||||
{
|
||||
|
|
@ -250,12 +240,49 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
historyAndProperties.Panel2.AddChild(selectedObjectPanel);
|
||||
splitContainer.AddChild(modelViewSidePanel);
|
||||
|
||||
this.InteractionLayer.AddChild(new TumbleCubeControl(this.InteractionLayer, theme)
|
||||
var tumbleCubeControl = new TumbleCubeControl(this.InteractionLayer, theme)
|
||||
{
|
||||
Margin = new BorderDouble(0, 0, 30, 30),
|
||||
Margin = new BorderDouble(0, 0, 10, 35),
|
||||
VAnchor = VAnchor.Top,
|
||||
HAnchor = HAnchor.Right,
|
||||
});
|
||||
};
|
||||
|
||||
this.InteractionLayer.AddChild(tumbleCubeControl);
|
||||
|
||||
var viewOptionsBar = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Right | HAnchor.Fit,
|
||||
VAnchor = VAnchor.Top | VAnchor.Fit,
|
||||
//Margin = new BorderDouble(top: tumbleCubeControl.Height + tumbleCubeControl.Margin.Height + 2),
|
||||
BackgroundColor = theme.MinimalShade
|
||||
};
|
||||
this.InteractionLayer.AddChild(viewOptionsBar);
|
||||
|
||||
var homeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", theme.InvertIcons), theme)
|
||||
{
|
||||
VAnchor = VAnchor.Absolute,
|
||||
ToolTipText = "Reset View".Localize(),
|
||||
Margin = theme.ButtonSpacing
|
||||
};
|
||||
homeButton.Click += (s, e) => viewControls3D.NotifyResetView();
|
||||
viewOptionsBar.AddChild(homeButton);
|
||||
|
||||
modelViewStyleButton = new ViewStyleButton(sceneContext, theme)
|
||||
{
|
||||
ToolTipText = "Model View Style".Localize(),
|
||||
PopupMate = new MatePoint()
|
||||
{
|
||||
Mate = new MateOptions(MateEdge.Left, MateEdge.Top)
|
||||
}
|
||||
};
|
||||
modelViewStyleButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom;
|
||||
modelViewStyleButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Left;
|
||||
|
||||
viewOptionsBar.AddChild(modelViewStyleButton);
|
||||
|
||||
printer.ViewState.ViewModeChanged += this.ViewState_ViewModeChanged;
|
||||
|
||||
ApplicationController.Instance.GetViewOptionButtons(viewOptionsBar, sceneContext, printer, theme);
|
||||
|
||||
UiThread.RunOnIdle(AutoSpin);
|
||||
|
||||
|
|
@ -281,6 +308,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.sceneContext.SceneLoaded += SceneContext_SceneLoaded;
|
||||
}
|
||||
|
||||
private void ViewState_ViewModeChanged(object sender, ViewModeChangedEventArgs e)
|
||||
{
|
||||
this.modelViewStyleButton.Visible = e.ViewMode == PartViewMode.Model;
|
||||
}
|
||||
|
||||
public Dictionary<string, NamedAction> WorkspaceActions { get; set; }
|
||||
|
||||
private void ModelViewSidePanel_Resized(object sender, EventArgs e)
|
||||
|
|
@ -405,6 +437,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Scene.SelectionChanged -= Scene_SelectionChanged;
|
||||
this.InteractionLayer.DrawGlOpaqueContent -= Draw_GlOpaqueContent;
|
||||
this.sceneContext.SceneLoaded -= SceneContext_SceneLoaded;
|
||||
printer.ViewState.ViewModeChanged -= this.ViewState_ViewModeChanged;
|
||||
|
||||
modelViewSidePanel.Resized -= ModelViewSidePanel_Resized;
|
||||
|
||||
if (meshViewerWidget != null)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public NamedAction[] MenuActions { get; private set; }
|
||||
|
||||
internal void NotifyResetView()
|
||||
{
|
||||
this.ResetView.Invoke(this, null);
|
||||
}
|
||||
|
||||
public bool IsPrinterMode { get; }
|
||||
|
||||
public ViewControls3DButtons ActiveButton
|
||||
|
|
@ -163,14 +168,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
this.AddChild(new ToolbarSeparator(theme));
|
||||
|
||||
var homeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", theme.InvertIcons), theme)
|
||||
{
|
||||
ToolTipText = "Reset View".Localize(),
|
||||
Margin = theme.ButtonSpacing
|
||||
};
|
||||
homeButton.Click += (s, e) => ResetView?.Invoke(this, null);
|
||||
AddChild(homeButton);
|
||||
|
||||
var undoButton = new IconButton(AggContext.StaticData.LoadIcon("Undo_grey_16x.png", 16, 16, theme.InvertIcons), theme)
|
||||
{
|
||||
Name = "3D View Undo",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
|
|
@ -38,7 +39,7 @@ using MatterHackers.RenderOpenGl;
|
|||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class ViewStyleButton : PopupButton
|
||||
public class ViewStyleButton : DropButton
|
||||
{
|
||||
private IconButton iconButton;
|
||||
private BedConfig sceneContext;
|
||||
|
|
@ -46,10 +47,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private Dictionary<RenderTypes, ImageBuffer> viewIcons;
|
||||
|
||||
public ViewStyleButton(BedConfig sceneContext, ThemeConfig theme)
|
||||
: base(theme)
|
||||
{
|
||||
this.sceneContext = sceneContext;
|
||||
this.DynamicPopupContent = () => ShowViewOptions(sceneContext, theme);
|
||||
this.AlignToRightEdge = true;
|
||||
this.PopupContent = () => ShowViewOptions(sceneContext, theme);
|
||||
|
||||
viewIcons = new Dictionary<RenderTypes, ImageBuffer>()
|
||||
{
|
||||
|
|
@ -60,7 +61,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
[RenderTypes.Overhang] = AggContext.StaticData.LoadIcon("view_overhang.png", theme.InvertIcons),
|
||||
};
|
||||
|
||||
this.AddChild(iconButton = new IconButton(viewIcons[sceneContext.ViewState.RenderType], theme));
|
||||
this.AddChild(iconButton = new IconButton(viewIcons[sceneContext.ViewState.RenderType], theme)
|
||||
{
|
||||
Selectable = false
|
||||
});
|
||||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
|
||||
|
|
@ -92,6 +96,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
useRadioStyle: true,
|
||||
siblingRadioButtonList: siblingList);
|
||||
|
||||
/*
|
||||
popupMenu.CreateBoolMenuItem(
|
||||
"Outlines".Localize(),
|
||||
viewIcons[RenderTypes.Outlines],
|
||||
|
|
@ -101,7 +106,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
sceneContext.ViewState.RenderType = RenderTypes.Outlines;
|
||||
},
|
||||
useRadioStyle: true,
|
||||
siblingRadioButtonList: siblingList);
|
||||
siblingRadioButtonList: siblingList); */
|
||||
|
||||
popupMenu.CreateBoolMenuItem(
|
||||
"Polygons".Localize(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue