From d7bfc4c35533e560accce2f64862dedeae8a342b Mon Sep 17 00:00:00 2001 From: Martin Misol Monzo Date: Wed, 26 Aug 2020 11:09:12 -0400 Subject: [PATCH] Make side panel handles size to content The handles for size panels were using a fixed size, which was not enough to fit some translated texts. The handles are now allowed to size to content by doing some extra gimnastics to rotate them in the right way. --- src/DynamoCoreWpf/Views/Core/DynamoView.xaml | 39 ++++++------ .../Views/Core/DynamoView.xaml.cs | 60 ++++++++++++++----- 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml index 49cddf1906d..07ce25892ed 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml @@ -1516,7 +1516,7 @@ VerticalAlignment="Top" Margin="0,310,0,0"> @@ -1635,7 +1640,7 @@ - + diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs index 0f143dc7f83..c30aff38598 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs @@ -120,7 +120,7 @@ public DynamoView(DynamoViewModel dynamoViewModel) LocationChanged += DynamoView_LocationChanged; // Apply appropriate expand/collapse library button state depending on initial width - updateCollapseIcon(); + UpdateLibraryCollapseIcon(); // Check that preference bounds are actually within one // of the available monitors. @@ -1780,25 +1780,40 @@ private void SlideWindowToIncludeTab(int tabSelected) } } - private void Button_MouseEnter(object sender, MouseEventArgs e) + private void LibraryHandle_MouseEnter(object sender, MouseEventArgs e) { Grid g = (Grid)sender; StackPanel sp = (StackPanel)(g.Children[0]); TextBlock tb = (TextBlock)(sp.Children[0]); - var bc = new BrushConverter(); - tb.Foreground = (Brush)bc.ConvertFrom("#cccccc"); Image collapseIcon = (Image)sp.Children[1]; - // When hovered swap appropriate expand/collapse button state + UpdateHandleHoveredStyle(tb, collapseIcon); + } + + private void UpdateHandleHoveredStyle(TextBlock text, Image icon) + { + var bc = new BrushConverter(); + text.Foreground = (Brush)bc.ConvertFrom("#cccccc"); + if (LibraryCollapsed || ExtensionsCollapsed) { Uri imageUri; imageUri = new Uri(@"pack://application:,,,/DynamoCoreWpf;component/UI/Images/expand_hover.png"); BitmapImage hover = new BitmapImage(imageUri); - collapseIcon.Source = hover; + icon.Source = hover; } } + private void ExtensionHandle_MouseEnter(object sender, MouseEventArgs e) + { + Grid g = (Grid)sender; + StackPanel sp = (StackPanel)(g.Children[0]); + TextBlock tb = (TextBlock)(sp.Children[1]); + Image collapseIcon = (Image)sp.Children[0]; + + UpdateHandleHoveredStyle(tb, collapseIcon); + } + private bool libraryCollapsed; private bool extensionsCollapsed; @@ -1842,7 +1857,7 @@ public bool ExtensionsCollapsed } // Check if library is collapsed or expanded and apply appropriate button state - private void updateCollapseIcon() + private void UpdateLibraryCollapseIcon() { if (LibraryCollapsed) { @@ -1882,7 +1897,7 @@ private void OnCollapsedLeftSidebarClick(object sender, EventArgs e) LeftExtensionsViewColumn.Width = new GridLength(0, GridUnitType.Star); } - updateCollapseIcon(); + UpdateLibraryCollapseIcon(); } private void OnCollapsedRightSidebarClick(object sender, EventArgs e) @@ -1898,24 +1913,39 @@ private void OnCollapsedRightSidebarClick(object sender, EventArgs e) } // TODO: Maynot need this depending on tab design - updateCollapseIcon(); + UpdateLibraryCollapseIcon(); } - private void Button_MouseLeave(object sender, MouseEventArgs e) + private void LibraryHandle_MouseLeave(object sender, MouseEventArgs e) { Grid g = (Grid)sender; StackPanel sp = (StackPanel)(g.Children[0]); TextBlock tb = (TextBlock)(sp.Children[0]); - var bc = new BrushConverter(); - tb.Foreground = (Brush)bc.ConvertFromString("#aaaaaa"); Image collapseIcon = (Image)sp.Children[1]; + UpdateHandleUnhoveredStyle(tb, collapseIcon); + UpdateLibraryCollapseIcon(); + } + + private void UpdateHandleUnhoveredStyle(TextBlock text, Image icon) + { + var bc = new BrushConverter(); + text.Foreground = (Brush)bc.ConvertFromString("#aaaaaa"); + Uri imageUri; imageUri = new Uri(@"pack://application:,,,/DynamoCoreWpf;component/UI/Images/expand_normal.png"); BitmapImage hover = new BitmapImage(imageUri); - collapseIcon.Source = hover; + icon.Source = hover; + } + + private void ExtensionHandle_MouseLeave(object sender, MouseEventArgs e) + { + Grid g = (Grid)sender; + StackPanel sp = (StackPanel)(g.Children[0]); + TextBlock tb = (TextBlock)(sp.Children[1]); + Image collapseIcon = (Image)sp.Children[0]; - updateCollapseIcon(); + UpdateHandleUnhoveredStyle(tb, collapseIcon); } private double restoreWidth = 0; @@ -2004,7 +2034,7 @@ private void WorkspaceTabs_SizeChanged(object sender, SizeChangedEventArgs e) ToggleWorkspaceTabVisibility(WorkspaceTabs.SelectedIndex); // When workspace is resized apply appropriate library expand/collapse icon - updateCollapseIcon(); + UpdateLibraryCollapseIcon(); } private void DynamoView_OnDrop(object sender, DragEventArgs e)