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

introduce node count threshold for opacity animations on zoom #15764

Merged
3 changes: 2 additions & 1 deletion src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3122,6 +3122,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 @@ -5224,7 +5226,6 @@ 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
193 changes: 136 additions & 57 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,36 +897,36 @@
</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 animation style -->
<Style
x:Key="SZoomFadePreview_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 @@ -944,10 +949,36 @@
</Style.Triggers>
</Style>

<Style
x:Key="SZoomFadePreview_Basic"
TargetType="{x:Type FrameworkElement}">
<Setter
Property="Opacity"
Value="0.7" />
<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.4" />
</DataTrigger>
</Style.Triggers>
</Style>

<conv:BooleanToStyleConverter
x:Key="SZoomFadePreview"
TrueStyle="{StaticResource SZoomFadePreview_Basic}"
FalseStyle="{StaticResource SZoomFadePreview_Animation}" />

<!-- Zoom fade-in preview -->
<Style x:Key="SZoomFadeInPreview" TargetType="{x:Type Border}">
<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>
Expand All @@ -970,10 +1001,36 @@
</Style.Triggers>
</Style>

<!-- Zoom fade-in preview -->
<Style x:Key="SZoomFadeOutPreview" 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
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="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.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand All @@ -996,36 +1053,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 +1105,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 +1879,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 +1924,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
Loading