Made a bottom resize container
This commit is contained in:
parent
4ef4ac7a9d
commit
c2bfefbde6
8 changed files with 123 additions and 13 deletions
|
|
@ -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,
|
||||
|
|
|
|||
111
CustomWidgets/ResizeContainer/BottomResizeContainer.cs
Normal file
111
CustomWidgets/ResizeContainer/BottomResizeContainer.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -77,6 +77,8 @@
|
|||
<Compile Include="ApplicationView\LogoSpinner.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizard100PointRadial.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizardMesh.cs" />
|
||||
<Compile Include="CustomWidgets\ResizeContainer\BottomResizeContainer.cs" />
|
||||
<Compile Include="CustomWidgets\ResizeContainer\LeftResizeContainer.cs" />
|
||||
<Compile Include="CustomWidgets\TreeView\TreeNode.cs" />
|
||||
<Compile Include="CustomWidgets\TreeView\TreeView.cs" />
|
||||
<Compile Include="DesignTools\Attributes\ShowSearchFieldAttribute.cs" />
|
||||
|
|
@ -187,7 +189,6 @@
|
|||
<Compile Include="CustomWidgets\PrintingWindow\ExtruderStatusWidget.cs" />
|
||||
<Compile Include="CustomWidgets\PrintingWindow\ProgressDial.cs" />
|
||||
<Compile Include="CustomWidgets\PrintingWindow\TemperatureStatusWidget.cs" />
|
||||
<Compile Include="CustomWidgets\ResizeContainer.cs" />
|
||||
<Compile Include="CustomWidgets\SimpleButton.cs" />
|
||||
<Compile Include="CustomWidgets\NamedAction.cs" />
|
||||
<Compile Include="CustomWidgets\RadioImageWidget.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<ResizeContainer>().FirstOrDefault();
|
||||
var modelViewSidePanel = view3DWidget.Descendants<LeftResizeContainer>().FirstOrDefault();
|
||||
|
||||
gcodeContainer = new ResizeContainer(gcodePanel)
|
||||
gcodeContainer = new LeftResizeContainer()
|
||||
{
|
||||
Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200,
|
||||
VAnchor = VAnchor.Stretch,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit cc7fbfc1baf618ef49920b73c180595a727f069d
|
||||
Subproject commit 23cf398f0c750351f66a37f36c09e56f6087c1e5
|
||||
Loading…
Add table
Add a link
Reference in a new issue