Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-7945 pin home button when reducing library size #15692

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ Dynamo.Controls.LacingToVisibilityConverter
Dynamo.Controls.LacingToVisibilityConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LacingToVisibilityConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LacingToVisibilityConverter.LacingToVisibilityConverter() -> void
Dynamo.Controls.LeftMarginConverter
Dynamo.Controls.LeftMarginConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LeftMarginConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LeftMarginConverter.LeftMarginConverter() -> void
Dynamo.Controls.LeftThicknessConverter
Dynamo.Controls.LeftThicknessConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LeftThicknessConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand Down Expand Up @@ -2003,6 +2007,8 @@ Dynamo.ViewModels.DynamoViewModel.LogText.get -> string
Dynamo.ViewModels.DynamoViewModel.MainGuideManager.get -> Dynamo.Wpf.UI.GuidedTour.GuidesManager
Dynamo.ViewModels.DynamoViewModel.MainGuideManager.set -> void
Dynamo.ViewModels.DynamoViewModel.MakeNewHomeWorkspace(object parameter) -> void
Dynamo.ViewModels.DynamoViewModel.MinLeftMarginOffset.get -> double
Dynamo.ViewModels.DynamoViewModel.MinLeftMarginOffset.set -> void
Dynamo.ViewModels.DynamoViewModel.Model.get -> Dynamo.Models.DynamoModel
Dynamo.ViewModels.DynamoViewModel.MutateTestDelegateCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.DynamoViewModel.MutateTestDelegateCommand.set -> void
Expand Down
18 changes: 18 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,24 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
}

/// <summary>
/// A custom converter to 'pin' the location of the Home button in place when the slider goes under a certain value
/// Do not use for other purposes, and please, do not change
/// </summary>
public class LeftMarginConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double offset = (double)value;
return new System.Windows.Thickness(offset * 1, 0, offset * -1, 0);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}

public class PathToFileNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
123 changes: 54 additions & 69 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf">

<ResourceDictionary.MergedDictionaries>
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoColorsAndBrushesDictionaryUri}" />
Expand All @@ -11,45 +10,38 @@
<controls:ToolTipFirstLineOnly x:Key="ToolTipFirstLine" />
<controls:ToolTipAllLinesButFirst x:Key="ToolTipFirstLineNot" />
<controls:WorkspaceTypeConverter x:Key="WorkspaceTypeConverter" />
<controls:WorkspaceBackgroundColorConverter
x:Key="WorkspaceBackgroundColorConverter"
CustomBackgroundColor="{StaticResource WorkspaceBackgroundCustom}"
HomeBackgroundColor="{StaticResource WorkspaceBackgroundHome}" />
<controls:WorkspaceBackgroundBrushConverter
x:Key="WorkspaceBackgroundBrushConverter"
CustomBackgroundBrush="{StaticResource WorkspaceBackgroundCustomBrush}"
HomeBackgroundBrush="{StaticResource WorkspaceBackgroundHomeBrush}" />
<controls:WorkspaceBackgroundColorConverter x:Key="WorkspaceBackgroundColorConverter"
CustomBackgroundColor="{StaticResource WorkspaceBackgroundCustom}"
HomeBackgroundColor="{StaticResource WorkspaceBackgroundHome}" />
<controls:WorkspaceBackgroundBrushConverter x:Key="WorkspaceBackgroundBrushConverter"
CustomBackgroundBrush="{StaticResource WorkspaceBackgroundCustomBrush}"
HomeBackgroundBrush="{StaticResource WorkspaceBackgroundHomeBrush}" />

<controls:MarginConverter x:Key="MarginConverter" />

<controls:BooleanToBrushConverter
x:Key="BooleanToBrushConverter"
FalseBrush="Black"
TrueBrush="#6AC0E7" />
<controls:BooleanToBrushConverter x:Key="BooleanToBrushConverter"
FalseBrush="Black"
TrueBrush="#6AC0E7" />

<controls:BooleanToBrushConverter
x:Key="PortConnectedBooleanToBrushConverter"
FalseBrush="White"
TrueBrush="Black" />
<controls:BooleanToBrushConverter x:Key="PortConnectedBooleanToBrushConverter"
FalseBrush="White"
TrueBrush="Black" />

<controls:BooleanToSelectionColorConverter
x:Key="BooleanToSelectionColorConverter"
False="#444"
True="#6AC0E7" />
<controls:BooleanToSelectionColorConverter x:Key="BooleanToSelectionColorConverter"
False="#444"
True="#6AC0E7" />

<controls:ConnectionStateToColorConverter
x:Key="ConnectionStateToColorConverter"
ExecutionPreview="#F2930C"
None="#444"
Selection="#6AC0E7"
Hover="#808080"/>
<controls:ConnectionStateToColorConverter x:Key="ConnectionStateToColorConverter"
ExecutionPreview="#F2930C"
Hover="#808080"
None="#444"
Selection="#6AC0E7" />

<controls:ConnectionStateToBrushConverter x:Key="ConnectionStateToBrushConverter"
ExecutionPreviewBrush="#F2930C"
SelectionBrush="#6AC0E7"
HoverBrush="#808080"
NoneBrush="#444">
</controls:ConnectionStateToBrushConverter>
NoneBrush="#444"
SelectionBrush="#6AC0E7" />

<controls:ConnectionStateToVisibilityCollapsedConverter x:Key="ConnectionStateToVisibilityCollapsedConverter" />
<controls:AttachmentToPathConverter x:Key="AttachmentToPathConverter" />
Expand Down Expand Up @@ -86,15 +78,15 @@
<controls:AutoLacingToVisibilityConverter x:Key="AutoLacingToVisibilityConverter" />
<controls:LacingToAbbreviationConverter x:Key="LacingToAbbreviationConverter" />
<controls:LacingToTooltipConverter x:Key="LacingToTooltipConverter" />
<controls:NodeWarningConverter x:Key="NodeWarningConverter"/>
<controls:NodeWarningConverter x:Key="NodeWarningConverter" />
<controls:NodeOriginalNameToMarginConverter x:Key="NodeOriginalNameToMarginConverter" />
<controls:BoolToFAIconNameConverter x:Key="BoolToFAIconNameConverter" />
<controls:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<controls:BoolToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<controls:InverseBooleanToVisibilityCollapsedConverter x:Key="InverseBoolToVisibilityCollapsedConverter" />
<controls:EmptyToVisibilityCollapsedConverter x:Key="EmptyToVisibilityCollapsedConverter" />
<controls:ZeroToVisibilityCollapsedConverter x:Key="ZeroToVisibilityCollapsedConverter" />
<controls:EmptyToZeroLengthConverter x:Key="EmptyToZeroLengthConverter"/>
<controls:ZeroToVisibilityCollapsedConverter x:Key="ZeroToVisibilityCollapsedConverter" />
<controls:EmptyToZeroLengthConverter x:Key="EmptyToZeroLengthConverter" />
<controls:NavigationToOpacityConverter x:Key="NavigationToOpacityConverter" />
<controls:ViewButtonClipRectConverter x:Key="ViewButtonClipRectConverter" />
<controls:ZoomToOpacityConverter x:Key="ZoomToOpacityConverter" />
Expand Down Expand Up @@ -131,14 +123,12 @@
<controls:SearchHighlightMarginConverter x:Key="SearchHighlightMarginConverter" />
<controls:ConfidenceScoreFormattingConverter x:Key="ConfidenceScoreFormattingConverter" />
<controls:InOutParamTypeConverter x:Key="InOutParamTypeConverter" />
<controls:NodeTypeToColorConverter
x:Key="NodeTypeToColorConverter"
FalseBrush="#777777"
TrueBrush="#cccccc" />
<controls:BooleanToBrushConverter
x:Key="DescriptionToColorConverter"
FalseBrush="#666666"
TrueBrush="#cccccc" />
<controls:NodeTypeToColorConverter x:Key="NodeTypeToColorConverter"
FalseBrush="#777777"
TrueBrush="#cccccc" />
<controls:BooleanToBrushConverter x:Key="DescriptionToColorConverter"
FalseBrush="#666666"
TrueBrush="#cccccc" />
<controls:GroupFontSizeToEditorEnabledConverter x:Key="GroupFontSizeToEditorEnabledConverter" />
<controls:ElementTypeToShortConverter x:Key="ElementTypeToShortConverter" />
<controls:GroupTitleVisibilityConverter x:Key="GroupTitleVisibilityConverter" />
Expand All @@ -157,35 +147,30 @@
<controls:ClassViewMarginConverter x:Key="ClassViewMarginConverter" />
<controls:ElementGroupToColorConverter x:Key="ElementGroupToColorConverter" />
<controls:RgbaStringToBrushConverter x:Key="RgbaStringToBrushConverter" />
<controls:BooleanToBrushConverter
x:Key="FilterIsSelertedCategoryToBrushConverter"
FalseBrush="{StaticResource FilterCategoryIsNotSelectedColor}"
TrueBrush="{StaticResource CommonSidebarTextColor}" />
<controls:BooleanToBrushConverter
x:Key="FilterIconForegroundConverter"
FalseBrush="{StaticResource LibraryItemHostBackground}"
TrueBrush="{StaticResource FilterIconColor}" />
<controls:BooleanToBrushConverter
x:Key="FilterIsSelertedCategoryForegroundConverter"
FalseBrush="{StaticResource NodeCategoryForeground}"
TrueBrush="{StaticResource NodeNameForeground}" />
<controls:BooleanToBrushConverter
x:Key="CompactLayoutForegroundConverter"
FalseBrush="{StaticResource NodeNameForeground}"
TrueBrush="{StaticResource UnSelectedLayoutForeground}" />
<controls:BooleanToBrushConverter
x:Key="DetailedLayoutForegroundConverter"
FalseBrush="{StaticResource UnSelectedLayoutForeground}"
TrueBrush="{StaticResource NodeNameForeground}" />
<controls:BooleanToBrushConverter
x:Key="PinIconForegroundConverter"
FalseBrush="{StaticResource UnpinnedIconForegroundColor}"
TrueBrush="{StaticResource PinnedIconForegroundColor}" />
<controls:BooleanToBrushConverter x:Key="FilterIsSelertedCategoryToBrushConverter"
FalseBrush="{StaticResource FilterCategoryIsNotSelectedColor}"
TrueBrush="{StaticResource CommonSidebarTextColor}" />
<controls:BooleanToBrushConverter x:Key="FilterIconForegroundConverter"
FalseBrush="{StaticResource LibraryItemHostBackground}"
TrueBrush="{StaticResource FilterIconColor}" />
<controls:BooleanToBrushConverter x:Key="FilterIsSelertedCategoryForegroundConverter"
FalseBrush="{StaticResource NodeCategoryForeground}"
TrueBrush="{StaticResource NodeNameForeground}" />
<controls:BooleanToBrushConverter x:Key="CompactLayoutForegroundConverter"
FalseBrush="{StaticResource NodeNameForeground}"
TrueBrush="{StaticResource UnSelectedLayoutForeground}" />
<controls:BooleanToBrushConverter x:Key="DetailedLayoutForegroundConverter"
FalseBrush="{StaticResource UnSelectedLayoutForeground}"
TrueBrush="{StaticResource NodeNameForeground}" />
<controls:BooleanToBrushConverter x:Key="PinIconForegroundConverter"
FalseBrush="{StaticResource UnpinnedIconForegroundColor}"
TrueBrush="{StaticResource PinnedIconForegroundColor}" />
<controls:NestedGroupsLabelConverter x:Key="NestedGroupsLabelConverter" />
<controls:CollectionHasMoreThanNItemsToBoolConverter x:Key="CollectionHasMoreThanNItemsToBoolConverter" />
<controls:ListHasMoreThanNItemsToVisibilityConverter x:Key="ListHasMoreThanNItemsToVisibilityConverter" />
<controls:ObjectTypeConverter x:Key="ObjectTypeConverter" />
<controls:TextForegroundSaturationColorConverter x:Key="TextForegroundSaturationColorConverter" />
<controls:PortTypeToStringConverter x:Key="PortTypeToStringConverter" />
<controls:BooleanNegationConverter x:Key="BooleanNegationConverter" />
<controls:LeftMarginConverter x:Key="LeftMarginConverter" />
</ResourceDictionary>
17 changes: 17 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,23 @@ public int ConsoleHeight
}
}

private double minLeftMarignOffset;
/// <summary>
/// The
/// </summary>
public double MinLeftMarginOffset
{
get => minLeftMarignOffset;
set
{
if(minLeftMarignOffset != value)
{
minLeftMarignOffset = value;
RaisePropertyChanged(nameof(MinLeftMarginOffset));
}
}
}

/// <summary>
/// Indicates if preview bubbles should be displayed on nodes.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@
<Button Name="HomeButton"
Width="42"
Height="42"
Margin="{Binding MinLeftMarginOffset, Converter={StaticResource LeftMarginConverter}}"
BorderThickness="0"
Click="HomeButton_Click"
Cursor="Hand">
Expand Down
25 changes: 25 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public DynamoView(DynamoViewModel dynamoViewModel)
}

DefaultMinWidth = MinWidth;
PinHomeButton();
}
private void OnRequestCloseHomeWorkSpace()
{
Expand Down Expand Up @@ -2960,6 +2961,8 @@ private void UpdateWorkspaceTabSizes()
{
tabItem.Margin = new System.Windows.Thickness(-leftMargin, 0, leftMargin, 0);
}

PinHomeButton();
}

private void DynamoView_OnDrop(object sender, DragEventArgs e)
Expand Down Expand Up @@ -3085,6 +3088,28 @@ private void TabItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
this.dynamoViewModel.ShowStartPage = false;
}

private void PinHomeButton()
{
const int FirstTabItemMinimumLeftMarginOffset = 230;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants are defined in UpdateWorkspaceTabSizes also, can you put them in the class and remove duplicates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitant to touch the DynamoView class further, but thought about it too. That's now done, but I opted to keep the class variables close to the first place where they are used to reduce clutter.

const int LibraryScrollBarWidth = 15;
const int minimumLeftMarginOffset = FirstTabItemMinimumLeftMarginOffset - LibraryScrollBarWidth;

var parentGrid = (Grid)verticalSplitter.Parent;
var columnWidth = parentGrid.ColumnDefinitions[0].ActualWidth == 0
? dynamoViewModel.LibraryWidth + LibraryScrollBarWidth
: parentGrid.ColumnDefinitions[0].ActualWidth;

// Constrain the position of the HomeButton.
if (columnWidth < minimumLeftMarginOffset)
{
this.dynamoViewModel.MinLeftMarginOffset = minimumLeftMarginOffset - columnWidth;
}
else
{
this.dynamoViewModel.MinLeftMarginOffset = 0;
}
}

public void Dispose()
{
viewExtensionManager.Dispose();
Expand Down
Loading