diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index f35fb6761..28f47c247 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -166,7 +166,7 @@ namespace MatterHackers.MatterControl.CustomWidgets SimpleTabs tabControl = null; if (this.ControlIsPinned) { - var resizePage = new ResizeContainer(this) + var resizePage = new LeftResizeContainer() { Width = this.ConstrainedWidth, VAnchor = VAnchor.Stretch, @@ -230,7 +230,7 @@ namespace MatterHackers.MatterControl.CustomWidgets } else // control is floating { - var resizeContainer = new ResizeContainer(this) + var resizeContainer = new LeftResizeContainer() { Width = this.ConstrainedWidth, VAnchor = VAnchor.Stretch, diff --git a/CustomWidgets/ResizeContainer/BottomResizeContainer.cs b/CustomWidgets/ResizeContainer/BottomResizeContainer.cs new file mode 100644 index 000000000..2464067a2 --- /dev/null +++ b/CustomWidgets/ResizeContainer/BottomResizeContainer.cs @@ -0,0 +1,111 @@ +/* +Copyright (c) 2017, Lars Brubaker, 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 MatterHackers.Agg; +using MatterHackers.Agg.UI; + +namespace MatterHackers.MatterControl.CustomWidgets +{ + public class BottomResizeContainer : FlowLayoutWidget + { + private double downHeight = 0; + private bool mouseDownOnBar = false; + private double mouseDownY; + + private int splitterHeight = 10; + + internal BottomResizeContainer() + : base (FlowDirection.TopToBottom) + { + this.HAnchor = HAnchor.Absolute; + this.Cursor = Cursors.HSplit; + } + + public Color SpliterBarColor { get; set; } = ActiveTheme.Instance.TertiaryBackgroundColor; + + public int SplitterHeigt + { + get => splitterHeight; + set + { + if (splitterHeight != value) + { + splitterHeight = value; + this.Padding = new BorderDouble(0, splitterHeight, 0, 0); + } + } + } + + public override void OnDraw(Graphics2D graphics2D) + { + graphics2D.FillRectangle(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Bottom + this.SplitterHeigt, this.SpliterBarColor); + graphics2D.FillRectangle(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Bottom + this.SplitterHeigt, Color.Black); + base.OnDraw(graphics2D); + } + + public override void OnMouseDown(MouseEventArgs mouseEvent) + { + if (mouseEvent.Position.Y < this.SplitterHeigt) + { + mouseDownOnBar = true; + mouseDownY = TransformToScreenSpace(mouseEvent.Position).Y; + downHeight = Height; + } + base.OnMouseDown(mouseEvent); + } + + public override void OnMouseMove(MouseEventArgs mouseEvent) + { + if (mouseDownOnBar) + { + int currentMouseY = (int)TransformToScreenSpace(mouseEvent.Position).Y; + UiThread.RunOnIdle(() => + { + Height = downHeight + mouseDownY - currentMouseY; + }); + } + base.OnMouseMove(mouseEvent); + } + + public override void OnMouseWheel(MouseEventArgs mouseEvent) + { + if(mouseDownOnBar) + { + mouseEvent.WheelDelta = 0; + } + base.OnMouseWheel(mouseEvent); + } + + public override void OnMouseUp(MouseEventArgs mouseEvent) + { + mouseDownOnBar = false; + base.OnMouseUp(mouseEvent); + } + } +} \ No newline at end of file diff --git a/CustomWidgets/ResizeContainer.cs b/CustomWidgets/ResizeContainer/LeftResizeContainer.cs similarity index 94% rename from CustomWidgets/ResizeContainer.cs rename to CustomWidgets/ResizeContainer/LeftResizeContainer.cs index 03b54d564..cc6224b8e 100644 --- a/CustomWidgets/ResizeContainer.cs +++ b/CustomWidgets/ResizeContainer/LeftResizeContainer.cs @@ -32,19 +32,17 @@ using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.CustomWidgets { - public class ResizeContainer : FlowLayoutWidget + public class LeftResizeContainer : FlowLayoutWidget { - private GuiWidget resizeTarget; private double downWidth = 0; private bool mouseDownOnBar = false; private double mouseDownX; private int splitterWidth = 10; - internal ResizeContainer(GuiWidget resizeTarget) + internal LeftResizeContainer() : base (FlowDirection.TopToBottom) { - this.resizeTarget = resizeTarget; this.HAnchor = HAnchor.Absolute; this.Cursor = Cursors.VSplit; } diff --git a/MatterControl.csproj b/MatterControl.csproj index 98575c6fc..51cb77bbe 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -77,6 +77,8 @@ + + @@ -187,7 +189,6 @@ - diff --git a/PartPreviewWindow/PrinterTabPage.cs b/PartPreviewWindow/PrinterTabPage.cs index bab0903f6..4135257d5 100644 --- a/PartPreviewWindow/PrinterTabPage.cs +++ b/PartPreviewWindow/PrinterTabPage.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public SliceLayerSelector LayerScrollbar { get; private set; } internal PrinterConfig printer; private GCodePanel gcodePanel; - internal ResizeContainer gcodeContainer; + internal LeftResizeContainer gcodeContainer; internal PrinterActionsBar printerActionsBar; private DockingTabControl sideBar; private SliceSettingsWidget sliceSettingsWidget; @@ -161,9 +161,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow BackgroundColor = theme.InteractionLayerOverlayColor, }; - var modelViewSidePanel = view3DWidget.Descendants().FirstOrDefault(); + var modelViewSidePanel = view3DWidget.Descendants().FirstOrDefault(); - gcodeContainer = new ResizeContainer(gcodePanel) + gcodeContainer = new LeftResizeContainer() { Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200, VAnchor = VAnchor.Stretch, diff --git a/PartPreviewWindow/SelectedObjectPanel.cs b/PartPreviewWindow/SelectedObjectPanel.cs index 281491128..6c0dd51a5 100644 --- a/PartPreviewWindow/SelectedObjectPanel.cs +++ b/PartPreviewWindow/SelectedObjectPanel.cs @@ -290,7 +290,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow editorPanel.CloseAllChildren(); // Add the tree view container. eventually we may want to make this a stretch container of some type - var treeViewContainer = new GuiWidget() + var treeViewContainer = new BottomResizeContainer() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Absolute diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 7fea601cb..bea2e8d67 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Stretch, }; - modelViewSidePanel = new ResizeContainer(selectedObjectPanel) + modelViewSidePanel = new LeftResizeContainer() { Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200, VAnchor = VAnchor.Stretch, diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index cc7fbfc1b..23cf398f0 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit cc7fbfc1baf618ef49920b73c180595a727f069d +Subproject commit 23cf398f0c750351f66a37f36c09e56f6087c1e5