Skip to content

Commit

Permalink
introduce node count threshold for opacity animations on zoom (#15764)
Browse files Browse the repository at this point in the history
Co-authored-by: DimitarVen <[email protected]>
  • Loading branch information
mjkkirschner and dimven-adsk authored Feb 5, 2025
1 parent e70ee1c commit 20d268a
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 135 deletions.
4 changes: 3 additions & 1 deletion src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,8 @@ Dynamo.ViewModels.WorkspaceViewModel.SetZoomCommand.get -> Dynamo.UI.Commands.De
Dynamo.ViewModels.WorkspaceViewModel.ShowAllWiresCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.WorkspaceViewModel.ShowHideAllGeometryPreviewCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.WorkspaceViewModel.ShowInCanvasSearchCommand.get -> Dynamo.UI.Commands.DelegateCommand
Dynamo.ViewModels.WorkspaceViewModel.StopNodeViewOpacityAnimations.get -> bool
Dynamo.ViewModels.WorkspaceViewModel.StopNodeViewOpacityAnimations.set -> void
Dynamo.ViewModels.WorkspaceViewModel.UnpinAllPreviewBubblesTriggered -> Dynamo.ViewModels.ViewEventHandler
Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.ViewModels.Watch3DFullscreenViewModel>
Dynamo.ViewModels.WorkspaceViewModel.Watch3DViewModels.set -> void
Expand Down Expand Up @@ -5216,14 +5218,14 @@ static Dynamo.Wpf.Properties.Resources.PackageStateUnloadedTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageTypeShortString.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibility.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityFilterTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityVersionDownloadMsg.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadNoDependency.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateCompressing.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateCopying.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateError.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateReady.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploaded.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploading.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityVersionDownloadMsg.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUseNewerDynamoMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUseOlderDynamoMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageViewContextMenuLoadText.get -> string
Expand Down
31 changes: 29 additions & 2 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@

namespace Dynamo.Controls
{
/// <summary>
/// selects from one of two styles based on a boolean value.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("ApiDesign",
"RS0016:Add public types and members to the declared API",
Justification = "Converters are not part of the API")]
public class BooleanToStyleConverter : IValueConverter
{
public Style TrueStyle { get; set; }
public Style FalseStyle { get; set; }

public object Convert(object value, Type targetType, object parameter,CultureInfo culture)
{
if (value is bool v && v)
{
return TrueStyle;
}

return FalseStyle;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}

public class ToolTipFirstLineOnly : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Expand All @@ -45,7 +72,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
}

Expand All @@ -60,7 +87,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
}

Expand Down
183 changes: 105 additions & 78 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
xmlns:fa="clr-namespace:FontAwesome5;assembly=FontAwesome5.Net"
xmlns:nodes="clr-namespace:Dynamo.Nodes;assembly=DynamoCoreWpf"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf">
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:conv="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf">

<ResourceDictionary.MergedDictionaries>
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoConvertersDictionaryUri}" />
Expand Down Expand Up @@ -867,9 +868,13 @@
</Style>

<!-- Zoom fade text -->
<Style x:Key="SZoomFadeText" TargetType="{x:Type TextBlock}">
<Style
x:Key="SZoomFadeBase_Animation"
TargetType="{x:Type FrameworkElement}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand All @@ -892,41 +897,41 @@
</Style.Triggers>
</Style>

<!-- Zoom fade label -->
<Style x:Key="SZoomFadeLabel" TargetType="{x:Type Label}">
<Style
x:Key="SZoomFadeBase_Basic"
TargetType="{x:Type FrameworkElement}">
<Setter
Property="Opacity"
Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="1.0"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.0"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<Setter
Property="Opacity"
Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>

<!-- Zoom fade preview -->
<Style x:Key="SZoomFadePreview" TargetType="{x:Type Border}">
<conv:BooleanToStyleConverter
x:Key="SZoomFadeControl"
TrueStyle="{StaticResource SZoomFadeBase_Basic}"
FalseStyle="{StaticResource SZoomFadeBase_Animation}" />

<!-- Zoom fade-in preview -->
<Style
x:Key="SZoomFadeInPreview_Animation"
TargetType="{x:Type FrameworkElement}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.4"
To="0.0"
Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
Expand All @@ -935,7 +940,7 @@
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.7"
To="0.5"
Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
Expand All @@ -944,36 +949,36 @@
</Style.Triggers>
</Style>

<!-- Zoom fade-in preview -->
<Style x:Key="SZoomFadeInPreview" TargetType="{x:Type Border}">
<Style
x:Key="SZoomFadeInPreview_Basic"
TargetType="{x:Type FrameworkElement}">
<Setter
Property="Opacity"
Value="0.5" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.0"
Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.5"
Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<Setter
Property="Opacity"
Value="0.0" />
</DataTrigger>
</Style.Triggers>
</Style>

<!-- Zoom fade-in preview -->
<Style x:Key="SZoomFadeOutPreview" TargetType="{x:Type Border}">
<conv:BooleanToStyleConverter
x:Key="SZoomFadeInPreview"
TrueStyle="{StaticResource SZoomFadeInPreview_Basic}"
FalseStyle="{StaticResource SZoomFadeInPreview_Animation}" />

<!-- Zoom fade-out preview -->
<Style
x:Key="SZoomFadeOutPreview_Animation"
TargetType="{x:Type FrameworkElement}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand All @@ -996,36 +1001,36 @@
</Style.Triggers>
</Style>

<!-- Zoom fade-out framework element -->
<Style x:Key="SZoomFadeOutFrameworkElement" TargetType="{x:Type FrameworkElement}">
<Style
x:Key="SZoomFadeOutPreview_Basic"
TargetType="{x:Type FrameworkElement}">
<Setter
Property="Opacity"
Value="0.0" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="1.0"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity"
To="0.0"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<Setter
Property="Opacity"
Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>

<conv:BooleanToStyleConverter
x:Key="SZoomFadeOutPreview"
TrueStyle="{StaticResource SZoomFadeOutPreview_Basic}"
FalseStyle="{StaticResource SZoomFadeOutPreview_Animation}" />

<!-- Zoom fade-in framework element -->
<Style x:Key="SZoomFadeInFrameworkElement" TargetType="{x:Type FrameworkElement}">
<Style
x:Key="SZoomFadeInControl_Animation"
TargetType="{x:Type FrameworkElement}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}" Value="true">
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand All @@ -1048,6 +1053,28 @@
</Style.Triggers>
</Style>

<Style
x:Key="SZoomFadeInControl_Basic"
TargetType="{x:Type FrameworkElement}">
<Setter
Property="Opacity"
Value="1" />
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=DataContext.Zoom, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource ZoomToBooleanConverter}}"
Value="true">
<Setter
Property="Opacity"
Value="0.0" />
</DataTrigger>
</Style.Triggers>
</Style>

<conv:BooleanToStyleConverter
x:Key="SZoomFadeInControl"
TrueStyle="{StaticResource SZoomFadeInControl_Basic}"
FalseStyle="{StaticResource SZoomFadeInControl_Animation}" />

<Style x:Key="TextButtonStyle" TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Cursor" Value="Hand" />
Expand Down Expand Up @@ -1800,7 +1827,7 @@
FontSize="{TemplateBinding FontSize}"
FontWeight="Bold"
Foreground="{TemplateBinding Foreground}"
Style="{StaticResource SZoomFadeText}"
Style="{Binding Path=DataContext.StopNodeViewOpacityAnimations, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource SZoomFadeControl}}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
</Border>
</Grid>
Expand Down Expand Up @@ -1845,7 +1872,7 @@
FontSize="28px"
FontWeight="Bold"
Foreground="#999999"
Style="{StaticResource SZoomFadeText}"
Style="{Binding Path=DataContext.StopNodeViewOpacityAnimations, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:WorkspaceView}}, Converter={StaticResource SZoomFadeControl}}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
</Border>
</Grid>
Expand Down
7 changes: 4 additions & 3 deletions src/DynamoCoreWpf/UI/Themes/Modern/Ports.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:viewModels="clr-namespace:Dynamo.ViewModels;assembly=DynamoCoreWpf"
xmlns:views="clr-namespace:Dynamo.UI.Views;assembly=DynamoCoreWpf">
xmlns:views="clr-namespace:Dynamo.UI.Views;assembly=DynamoCoreWpf"
xmlns:controlsWpf="clr-namespace:Dynamo.Views;assembly=DynamoCoreWpf">

<!-- Templates
Expand Down Expand Up @@ -125,7 +126,7 @@
FontWeight="Medium"
Foreground="{StaticResource PrimaryCharcoal200Brush}"
IsHitTestVisible="False"
Style="{StaticResource SZoomFadeLabel}" />
Style="{Binding Path=DataContext.StopNodeViewOpacityAnimations, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controlsWpf:WorkspaceView}}, Converter={StaticResource SZoomFadeControl}}" />
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Height" Value="{Binding Path=Height}" />
Expand Down Expand Up @@ -326,7 +327,7 @@
Foreground="Transparent"
IsHitTestVisible="False"
Opacity="0.4"
Style="{StaticResource SZoomFadeText}"
Style="{Binding Path=DataContext.StopNodeViewOpacityAnimations, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controlsWpf:WorkspaceView}}, Converter={StaticResource SZoomFadeControl}}"
Text="{Binding Path=PortName}" />
<dynui:UseLevelSpinner x:Name="useLevelControl"
Width="50"
Expand Down
Loading

0 comments on commit 20d268a

Please sign in to comment.