From 6b71d70e0a5c4ee1f5070321bc656d2782179eaf Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 25 Oct 2018 14:43:21 -0700 Subject: [PATCH 1/3] Fix typo --- MatterControlLib/CustomWidgets/DockingTabControl.cs | 4 ++-- .../ResizeContainer/VerticalResizeContainer.cs | 10 ++++++---- MatterControlLib/PartPreviewWindow/PrinterTabPage.cs | 2 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 2 +- MatterControlLib/PartPreviewWindow/ViewControls3D.cs | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) 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/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..bcd71ac5b 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -544,7 +544,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var verticalResizeContainer = new VerticalResizeContainer(theme, GrabBarSide.Right) { - BackgroundColor = theme.TabBarBackground, + BackgroundColor = Color.Red, Padding = new BorderDouble(0, 0, theme.DefaultContainerPadding / 2, 0), MinimumSize = new Vector2(120, 50), Height = libraryPopup.TransformToScreenSpace(libraryPopup.Position).Y, From ffd99782aee60024634a32121533eb120a46a3a0 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 25 Oct 2018 15:31:31 -0700 Subject: [PATCH 2/3] Fix colors and padding for Add Content panel - Issue MatterHackers/MCCentral#4367 Colors should match - Issue MatterHackers/MCCentral#4368 Subtle alignment issues with splitter bar and content --- .../PartPreviewWindow/PopupButton.cs | 22 +++++++++---------- .../PartPreviewWindow/ViewControls3D.cs | 8 ++++--- 2 files changed, 15 insertions(+), 15 deletions(-) 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/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index bcd71ac5b..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 = Color.Red, - 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, }; From b6dcc983a0bb35c38230eaa2513c8dba65468670 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 25 Oct 2018 17:38:58 -0700 Subject: [PATCH 3/3] Add resizable favorites bar - Issue MatterHackers/MCCentral#4362 --- .../Library/Widgets/ListView/IconListView.cs | 17 +++++- .../PartPreviewWindow/PartTabPage.cs | 49 ++++++++++++++++-- .../SettingsManagement/UserSettings.cs | 1 + StaticData/Icons/collapse.png | Bin 0 -> 1061 bytes StaticData/Icons/expand.png | Bin 0 -> 1073 bytes 5 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 StaticData/Icons/collapse.png create mode 100644 StaticData/Icons/expand.png 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/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 0000000000000000000000000000000000000000..91368833fd20ef672c0c4eabd39bd5ab41471c62 GIT binary patch literal 1061 zcmeAS@N?(olHy`uVBq!ia0y~yU=RXf4mJh`hOl#e;S3Cn(wQL}FfdWk9d zNvV1jxdjX$U}IlVkeHmETB4AYnx2_wtMq>NekFy>6kDZmQ(pt$0_W6>OpmIf)Zi+= zkmRcDWXlvKdpjE(M#Slr*a#7dNQpqLegSrHqo20xNy}^73-Ma$~*xqI7*jOG`_A z10#JSBi*8uG~MFLypqHU-MnIDkP#3wTvCgZi!uvJGV}8kKxQT;<(HP&DkJCPK_K{uNAl<+0_OmNzGG=W0R_NZ^Wo{R``p?e#wRM(RuLA%X9!R_DVHvP8Zet1EmW{<=_GQ%8Tf z^2`&j?7s)<7rF;;HWs>l^!5f$LpK3^;T{8@hB&rVz6Xo@~PA??+20Xn@>*?yV>}eH>1+P)LYwQ>Lb0w4cCP;X0$KMUJpoCO|{#S9GG!XV7ZFl&wk0|TRq zr;B5VMeo_mYyFrVMcN*ga|=1Ls&MFZu@%ZNItr**m}qK#;p2FyRmIP%n_$2ZByfe{ zn=s39UWE-D0$V!#CeOS%^XRt~XDw%^e>%&5CQ5W?m^fI=CB8_UYcfd zNI*02WDT- zXNonRJ^2gc8|L_Xk8F*teb(iqdHZ}@`S9%T0~@<{@bWC`aG$i!OHgaWH0zxr*QS)n z-ck0P?=#O;rugvL`ND?Qm-`n8-Du`l-{7YiB~mPSgOP1gozUk87th80Wz^(q(z|x( R+Z<5t_H^}gS?83{1OO5LrIi2x literal 0 HcmV?d00001 diff --git a/StaticData/Icons/expand.png b/StaticData/Icons/expand.png new file mode 100644 index 0000000000000000000000000000000000000000..2813767ff4bffe4f8c70b4637b1e1ee5a7eace00 GIT binary patch literal 1073 zcmeAS@N?(olHy`uVBq!ia0y~yU=RXf4mJh`hOl#e;S3Cn(wQL}FfdWk9d zNvV1jxdjX$U}IlVkeHmETB4AYnx2_wtMq>NekFy>6kDZmQ(pt$0_W6>OpmIf)Zi+= zkmRcDWXlvKdpjE(M#Slr*a#7dNQpqLegSrHqo20xNy}^73-Ma$~*xqI7*jOG`_A z10#JSBi*8uG~MFLypqHU-MnIDkP#3wTvCgZi!uvJGV}8kKxQT;<(HP&DkJCPK_K{uNAl<+0_OmNzGG=W0R_NZ^Wo{R``p?e#wRM(RuLA%X9!R_DVHvP8Zet1EmW{<=_GQ%8Tf z^2`&j?7s)<7rF;;HWs>l^!5f$LpK3^;T{8@hB&rVz6Xo@~PA??+20Xn@>*?yV>}eH>1+P)LYwQ>Lb0w4cCP;X0$KMUJpoCO|{#S9GG!XV7ZFl&wk0|TRh zr;B5VMeo^5YyFrVMcN*2zrBRRBy9)lff~6$5022Uf7I?Ua+Y6=R`}z^A|aqMLFBYL z2S?t5NJn0#rbQiow^MiDzSTF&()#(#;xzWO+z@tQ&)14AQL~oa{iEhttk{yqq3C=0 z%W@8{N5`BW$W=_+GRt|@0p0>u8_y_>7M0M3#XIJ)=M~>D+93Gc`+&3Hv>WeSSA;k1 zWmrCQj*|}KhFZ=yqKO|DG-pPruJ*dcc+Tjf{({8ax|)oAjemVkNe68IJ26G^wz%q4 z-CO^3SH7vb5taAF=t9I*R?EE`7c6;u