diff --git a/MatterControlLib/CustomWidgets/DockingTabControl.cs b/MatterControlLib/CustomWidgets/DockingTabControl.cs index 21e6f6583..76e896dab 100644 --- a/MatterControlLib/CustomWidgets/DockingTabControl.cs +++ b/MatterControlLib/CustomWidgets/DockingTabControl.cs @@ -183,7 +183,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { Width = this.ConstrainedWidth, VAnchor = VAnchor.Stretch, - SpliterBarColor = theme.SplitterBackground, + SplitterBarColor = theme.SplitterBackground, SplitterWidth = theme.SplitterWidth, MinimumSize = new Vector2(this.MinDockingWidth, 0) }; @@ -255,7 +255,7 @@ namespace MatterHackers.MatterControl.CustomWidgets VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Right, BackgroundColor = theme.ActiveTabColor, - SpliterBarColor = theme.SplitterBackground, + SplitterBarColor = theme.SplitterBackground, SplitterWidth = theme.SplitterWidth, }; resizeContainer.AddChild(new DockingWindowContent(this, item.widget, item.text, theme) diff --git a/MatterControlLib/CustomWidgets/ResizeContainer/VerticalResizeContainer.cs b/MatterControlLib/CustomWidgets/ResizeContainer/VerticalResizeContainer.cs index 936d9057f..006430147 100644 --- a/MatterControlLib/CustomWidgets/ResizeContainer/VerticalResizeContainer.cs +++ b/MatterControlLib/CustomWidgets/ResizeContainer/VerticalResizeContainer.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.grabSide = grabSide; this.HAnchor = HAnchor.Absolute; this.SplitterWidth = theme.SplitterWidth; - this.SpliterBarColor = theme.SplitterBackground; + this.SplitterBarColor = theme.SplitterBackground; } public override Cursors Cursor @@ -71,7 +71,7 @@ namespace MatterHackers.MatterControl.CustomWidgets set => base.Cursor = value; } - public Color SpliterBarColor { get; set; } + public Color SplitterBarColor { get; set; } public int SplitterWidth { @@ -81,6 +81,7 @@ namespace MatterHackers.MatterControl.CustomWidgets if (_splitterWidth != value) { _splitterWidth = value; + if (grabSide == GrabBarSide.Left) { this.Padding = new BorderDouble(_splitterWidth, 0, 0, 0); @@ -89,6 +90,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { this.Padding = new BorderDouble(0, 0, _splitterWidth, 0); } + this.MinimumSize = new VectorMath.Vector2(_splitterWidth, 0); } } @@ -103,11 +105,11 @@ namespace MatterHackers.MatterControl.CustomWidgets { if (grabSide == GrabBarSide.Left) { - graphics2D.FillRectangle(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Left + this.SplitterWidth, LocalBounds.Top, this.SpliterBarColor); + graphics2D.FillRectangle(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Left + this.SplitterWidth, LocalBounds.Top, this.SplitterBarColor); } else { - graphics2D.FillRectangle(LocalBounds.Right - this.SplitterWidth, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Top, this.SpliterBarColor); + graphics2D.FillRectangle(LocalBounds.Right - this.SplitterWidth, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Top, this.SplitterBarColor); } base.OnDraw(graphics2D); diff --git a/MatterControlLib/Library/Widgets/ListView/IconListView.cs b/MatterControlLib/Library/Widgets/ListView/IconListView.cs index 1a47677ae..a5bf4d0ed 100644 --- a/MatterControlLib/Library/Widgets/ListView/IconListView.cs +++ b/MatterControlLib/Library/Widgets/ListView/IconListView.cs @@ -67,6 +67,16 @@ namespace MatterHackers.MatterControl.CustomWidgets } public override void OnBoundsChanged(EventArgs e) + { + if (!reloading) + { + this.LayoutIcons(); + } + + base.OnBoundsChanged(e); + } + + private void LayoutIcons() { int currentWidth = (int)this.Size.X; if (reflownWidth != currentWidth) @@ -101,8 +111,6 @@ namespace MatterHackers.MatterControl.CustomWidgets } } } - - base.OnBoundsChanged(e); } private int RecomputeFlowValues(int leftRightItemMargin) @@ -185,13 +193,18 @@ namespace MatterHackers.MatterControl.CustomWidgets this.CloseAllChildren(); } + private bool reloading = false; + public void BeginReload() { + reloading = true; columnCount = RecomputeFlowValues(1); } public void EndReload() { + reloading = false; + this.LayoutIcons(); } } diff --git a/MatterControlLib/PartPreviewWindow/PartTabPage.cs b/MatterControlLib/PartPreviewWindow/PartTabPage.cs index 1ee1e8a66..aba343812 100644 --- a/MatterControlLib/PartPreviewWindow/PartTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PartTabPage.cs @@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Linq; using MatterHackers.Agg; +using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; @@ -131,21 +132,59 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer }; + var leftBar = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + VAnchor = VAnchor.Stretch + }; + favoritesBarAndView3DWidget.AddChild(leftBar); + + bool expanded = UserSettings.Instance.get(UserSettingsKey.FavoritesBarExpansion) != "0"; + favoritesBar = new LibraryListView(favoritesBarContext, theme) { Name = "LibraryView", // Drop containers ContainerFilter = (container) => false, BackgroundColor = theme.ActiveTabColor, - ListContentView = new IconListView(theme, 22), Border = new BorderDouble(top: 1, right: 1), BorderColor = theme.BorderColor20, HAnchor = HAnchor.Absolute, - Width = 33, - AllowContextMenu = false - }; + VAnchor = VAnchor.Fit | VAnchor.Top, + AllowContextMenu = false, - favoritesBarAndView3DWidget.AddChild(favoritesBar); + // restore to state for favorites bar size + Width = expanded ? 55 : 33, + ListContentView = new IconListView(theme, expanded ? 48 : 24), + }; + leftBar.AddChild(favoritesBar); + + leftBar.AddChild(new VerticalSpacer()); + + var expandedImage = AggContext.StaticData.LoadIcon("expand.png", 18, 18, theme.InvertIcons); + var collapsedImage = AggContext.StaticData.LoadIcon("collapse.png", 18, 18, theme.InvertIcons); + + var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme) + { + HAnchor = HAnchor.Center, + VAnchor = VAnchor.Absolute, + Margin = new BorderDouble(bottom: 4) + }; + expandBarButton.Click += (s, e) => UiThread.RunOnIdle(() => + { + expanded = !expanded; + + UserSettings.Instance.set(UserSettingsKey.FavoritesBarExpansion, expanded ? "1" : "0"); + + favoritesBar.ListContentView = new IconListView(theme, expanded ? 48 : 24); + favoritesBar.Width = expanded ? 55 : 33; + expandBarButton.SetIcon(expanded ? collapsedImage : expandedImage); + expandBarButton.Invalidate(); + + favoritesBar.Reload().ConfigureAwait(false); + }); + + leftBar.AddChild(expandBarButton); + favoritesBarAndView3DWidget.AddChild(view3DWidget); toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget); diff --git a/MatterControlLib/PartPreviewWindow/PopupButton.cs b/MatterControlLib/PartPreviewWindow/PopupButton.cs index c13a46b9c..42c93736f 100644 --- a/MatterControlLib/PartPreviewWindow/PopupButton.cs +++ b/MatterControlLib/PartPreviewWindow/PopupButton.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2017, Lars Brubaker, John Lewin +Copyright (c) 20178 Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,6 +37,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public Color HoverColor { get; set; } = new Color(0, 0, 0, 40); + public Color OpenColor { get; set; } = new Color(0, 0, 0, 40); + public event EventHandler PopupWindowClosed; public event EventHandler BeforePopup; public event EventHandler ConfigurePopup; @@ -44,7 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow protected GuiWidget buttonView; private bool menuVisibileAtMouseDown = false; - private bool menuVisible = false; + protected bool menuVisible = false; private PopupWidget popupWidget; public PopupButton() @@ -70,6 +72,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public Color PopupBorderColor { get; set; } = Color.Transparent; + public override Color BackgroundColor + { + get => menuVisible ? this.OpenColor : base.BackgroundColor; + set => base.BackgroundColor = value; + } + public override void OnMouseDown(MouseEventArgs mouseEvent) { // Store the menu state at the time of mousedown @@ -87,16 +95,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow base.OnClick(mouseEvent); } - public override void OnDraw(Graphics2D graphics2D) - { - if (menuVisible) - { - graphics2D.FillRectangle(this.LocalBounds, HoverColor); - } - - base.OnDraw(graphics2D); - } - public void ShowPopup() { if (PopupLayoutEngine == null) diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index 4429d0053..dbdee9351 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -166,7 +166,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Width = printer?.ViewState.SelectedObjectPanelWidth ?? 200, VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Absolute, - SpliterBarColor = theme.SplitterBackground, + SplitterBarColor = theme.SplitterBackground, SplitterWidth = theme.SplitterWidth, Visible = false, }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index c0467e49d..69c29e8c8 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -163,7 +163,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Absolute, BackgroundColor = theme.InteractionLayerOverlayColor, - SpliterBarColor = theme.SplitterBackground, + SplitterBarColor = theme.SplitterBackground, SplitterWidth = theme.SplitterWidth, MinimumSize = new Vector2(theme.SplitterWidth, 0) }; diff --git a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index 65972b555..00f45356f 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -527,8 +527,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Fit, }; - PopupMenuButton libraryPopup = null; + var openColor = theme.ResolveColor(theme.ActiveTabColor, theme.SlightShade); + PopupMenuButton libraryPopup = null; libraryPopup = new PopupMenuButton(buttonView, theme) { MakeScrollable = false, @@ -544,10 +545,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var verticalResizeContainer = new VerticalResizeContainer(theme, GrabBarSide.Right) { - BackgroundColor = theme.TabBarBackground, - Padding = new BorderDouble(0, 0, theme.DefaultContainerPadding / 2, 0), + BackgroundColor = openColor, MinimumSize = new Vector2(120, 50), Height = libraryPopup.TransformToScreenSpace(libraryPopup.Position).Y, + SplitterBarColor = theme.SlightShade, }; double.TryParse(UserSettings.Instance.get(UserSettingsKey.PopupLibraryWidth), out double controlWidth); @@ -607,6 +608,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow BackgroundColor = theme.ToolbarButtonBackground, HoverColor = theme.ToolbarButtonHover, MouseDownColor = theme.ToolbarButtonDown, + OpenColor = openColor, DrawArrow = true, Margin = theme.ButtonSpacing, }; diff --git a/MatterControlLib/SettingsManagement/UserSettings.cs b/MatterControlLib/SettingsManagement/UserSettings.cs index 451c458a8..65bf82b2a 100644 --- a/MatterControlLib/SettingsManagement/UserSettings.cs +++ b/MatterControlLib/SettingsManagement/UserSettings.cs @@ -68,6 +68,7 @@ namespace MatterHackers.MatterControl public const string SelectedObjectEditorHeight = nameof(SelectedObjectEditorHeight); public const string SelectionTreeViewPanelExpanded = nameof(SelectionTreeViewPanelExpanded); public const string ThemeName = nameof(ThemeName); + public const string FavoritesBarExpansion= nameof(FavoritesBarExpansion); } public class UserSettings diff --git a/StaticData/Icons/collapse.png b/StaticData/Icons/collapse.png new file mode 100644 index 000000000..91368833f Binary files /dev/null and b/StaticData/Icons/collapse.png differ diff --git a/StaticData/Icons/expand.png b/StaticData/Icons/expand.png new file mode 100644 index 000000000..2813767ff Binary files /dev/null and b/StaticData/Icons/expand.png differ