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

Resize Nodes #12009

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/DynamoCore/Configuration/Configurations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class Configurations
/// <summary>
/// Generic Constants
/// </summary>
public static readonly double PortHeightInPixels = 41 ;
public static readonly double PortHeightInPixels = 34;

/// <summary>
/// Canvas Control
Expand Down
33 changes: 33 additions & 0 deletions src/DynamoCore/Graph/Nodes/NodeCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Xml;
using Dynamo.Configuration;
using Dynamo.Engine;
using Dynamo.Graph.Nodes.CustomNodes;
using Dynamo.Library;
using ProtoCore;

Expand Down Expand Up @@ -572,5 +573,37 @@ private static bool HasPathInformation(string fileNameOrPath)

return indexOfSeparator >= 0;
}

/// <summary>
/// Returns the icon path for a ZeroTouch node
/// </summary>
/// <returns></returns>
internal static string GetFunctionDescriptorIconName(FunctionDescriptor functionDescriptor)
{
string name = NormalizeAsResourceName(functionDescriptor.QualifiedName);

if (string.IsNullOrEmpty(name))
{
name = NormalizeAsResourceName(functionDescriptor.FunctionName);
}

// Usual case.
if (!functionDescriptor.IsOverloaded)
{
return name;
}

// Case for overloaded methods.
if (name == functionDescriptor.QualifiedName)
{
return TypedParametersToString(functionDescriptor);
}

// Some nodes contain names with invalid symbols like %, <, >, etc. In this
// case the value of "FunctionDescriptor.Name" property should be used. For
// an example, "DynamoUnits.SUnit.%" to be renamed as "DynamoUnits.SUnit.mod".
string shortName = NormalizeAsResourceName(functionDescriptor.FunctionName);
return TypedParametersToString(functionDescriptor, name + shortName);
}
}
}
2 changes: 1 addition & 1 deletion src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public abstract class NodeModel : ModelBase, IRenderPackageSource<NodeModel>, ID

#endregion

internal const double HeaderHeight = 55;
internal const double HeaderHeight = 46;

#region public members

Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCore/Graph/Nodes/PortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public Point2D Center
double halfHeight = Height * 0.5;

double offset = Owner.GetPortVerticalOffset(this);
double y = Owner.Y + NodeModel.HeaderHeight + 5 + halfHeight + offset;
double y = Owner.Y + NodeModel.HeaderHeight + halfHeight + offset + 9;

switch (PortType)
{
Expand All @@ -179,7 +179,7 @@ public Point2D Center
// Special case because code block outputs are smaller than regular outputs.
// This ensures the output port of the first code block output aligns with
// the first input port of any node.
return new Point2D(Owner.X + Owner.Width, y + 12.8);
return new Point2D(Owner.X + Owner.Width, y + 9);
}
return new Point2D(Owner.X + Owner.Width, y);
}
Expand Down
28 changes: 1 addition & 27 deletions src/DynamoCore/Search/SearchElements/ZeroTouchSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor)

}

iconName = GetIconName();
iconName = Graph.Nodes.Utilities.GetFunctionDescriptorIconName(functionDescriptor);
}

protected override NodeModel ConstructNewNodeModel()
Expand All @@ -109,31 +109,5 @@ protected override NodeModel ConstructNewNodeModel()
return new DSVarArgFunction(functionDescriptor);
return new DSFunction(functionDescriptor);
}

private string GetIconName()
{
string name = Graph.Nodes.Utilities.NormalizeAsResourceName(functionDescriptor.QualifiedName);

if (string.IsNullOrEmpty(name))
name = Graph.Nodes.Utilities.NormalizeAsResourceName(functionDescriptor.FunctionName);

// Usual case.
if (!functionDescriptor.IsOverloaded)
return name;

// Case for overloaded methods.
if (name == functionDescriptor.QualifiedName)
{
return Graph.Nodes.Utilities.TypedParametersToString(functionDescriptor);
}
else
{
// Some nodes contain names with invalid symbols like %, <, >, etc. In this
// case the value of "FunctionDescriptor.Name" property should be used. For
// an example, "DynamoUnits.SUnit.%" to be renamed as "DynamoUnits.SUnit.mod".
string shortName = Graph.Nodes.Utilities.NormalizeAsResourceName(functionDescriptor.FunctionName);
return Graph.Nodes.Utilities.TypedParametersToString(functionDescriptor, name + shortName);
}
}
}
}
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Controls/DynamoTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public DynamoTextBox(string initialText)
FontSize = 16;
LostFocus += OnLostFocus;
LostKeyboardFocus += OnLostFocus;
Padding = new Thickness(7);
Padding = new Thickness(5, 3, 5, 3);
base.Text = initialText;
Pending = false;
Style = (Style)SharedDictionaryManager.DynamoModernDictionary["SZoomFadeTextBox"];
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,8 @@ public class NodeOriginalNameToMarginConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string originalName = value.ToString();
if (originalName == "Code Block") return new Thickness(0, 22, 0, 0);
return new Thickness(0, 8, 0, 8);
if (originalName == "Code Block") return new Thickness(0, 13, 0, 0);
return new Thickness(0, 3, 0, 5);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
Binary file modified src/DynamoCoreWpf/UI/Images/more-vertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 45 additions & 27 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,6 @@
</Style>

<Style x:Key="SNodeTextButton" TargetType="{x:Type Button}">
<Setter Property="MinWidth" Value="41px" />
<Setter Property="Height" Value="34px" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
Expand All @@ -831,19 +829,15 @@
HorizontalAlignment="Stretch"
Background="#4D4D4D"
CornerRadius="4">
<Grid x:Name="inner">
<Label x:Name="text"
Margin="0,1,0,0"
Padding="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"
FontSize="17px"
FontWeight="Bold"
Style="{StaticResource SZoomFadeLabel}" />
</Grid>
<TextBlock x:Name="text"
Margin="0,1,0,0"
Padding="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"
FontSize="17px"
FontWeight="Bold"
Style="{StaticResource SZoomFadeText}" />
</Border>
</Grid>
<ControlTemplate.Triggers>
Expand All @@ -859,15 +853,39 @@
<Setter TargetName="text" Property="Foreground" Value="{StaticResource Blue300Brush}" />
</Trigger>

<DataTrigger Binding="{Binding ElementName=text, Path=Content}" Value="+">
<Setter TargetName="text" Property="FontSize" Value="24px" />
<Setter TargetName="roundedBorder" Property="CornerRadius" Value="4,0,0,4" />
<Setter TargetName="roundedBorder" Property="Margin" Value="0,0,0.5,0" />
<DataTrigger Binding="{Binding ElementName=text, Path=Text}" Value="+">
<Setter TargetName="text"
Property="FontSize"
Value="28px" />
<Setter TargetName="text"
Property="Margin"
Value="1,3,0,0" />
<Setter TargetName="container"
Property="Height"
Value="22px" />
<Setter TargetName="container"
Property="Width"
Value="22px" />
<Setter TargetName="roundedBorder"
Property="CornerRadius"
Value="4,0,0,4" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=text, Path=Content}" Value="-">
<Setter TargetName="text" Property="FontSize" Value="24px" />
<Setter TargetName="roundedBorder" Property="CornerRadius" Value="0,4,4,0" />
<Setter TargetName="roundedBorder" Property="Margin" Value="0.5,0,0,0" />
<DataTrigger Binding="{Binding ElementName=text, Path=Text}" Value="-">
<Setter TargetName="text"
Property="FontSize"
Value="28px" />
<Setter TargetName="text"
Property="Margin"
Value="0,3,1,0" />
<Setter TargetName="container"
Property="Height"
Value="22px" />
<Setter TargetName="container"
Property="Width"
Value="22px" />
<Setter TargetName="roundedBorder"
Property="CornerRadius"
Value="0,4,4,0" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Expand Down Expand Up @@ -944,7 +962,7 @@
</Style>

<ControlTemplate x:Key="RefreshComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid Height="35px"
<Grid Height="29px"
HorizontalAlignment="Stretch"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -995,8 +1013,8 @@
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="MinWidth" Value="300px" />
<Setter Property="Margin" Value="-10,0,0,0" />
<Setter Property="Height" Value="35px" />
<Setter Property="Margin" Value="-6,0,0,0" />
<Setter Property="Height" Value="29px" />
<Setter Property="Foreground" Value="#DCDCDC" />
<Setter Property="FontSize" Value="16px" />
<Setter Property="Template">
Expand All @@ -1018,7 +1036,7 @@
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
IsHitTestVisible="False" />
<TextBox x:Name="PART_EditableTextBox"
Margin="0,0,25,0"
Margin="0,0,25,4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Focusable="True"
Expand Down
12 changes: 6 additions & 6 deletions src/DynamoCoreWpf/UI/Themes/Modern/Ports.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="{Binding PortBackgroundColor, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Height" Value="35px" />
<Setter Property="Height" Value="29px" />
<Setter Property="BorderBrush" Value="{Binding PortBorderBrushColor, UpdateSourceTrigger=PropertyChanged}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=PortType}" Value="{x:Static nodes:PortType.Input}">
Expand Down Expand Up @@ -204,7 +204,7 @@
<!-- Blue marker that appears to the left side of an input port, indicating it's using its default value. -->
<Rectangle x:Name="usingDefaultValueMarker"
Width="6px"
Height="35px"
Height="29px"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="{StaticResource PortUsingDefaultValueMarkerColor}"
Expand All @@ -221,7 +221,7 @@
UseLayoutRounding="true">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Height" Value="35px" />
<Setter Property="Height" Value="29px" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=PortType}" Value="{x:Static nodes:PortType.Input}">
<Setter Property="CornerRadius" Value="0,11,11,0" />
Expand Down Expand Up @@ -289,15 +289,15 @@
This is the UseLevelsSpinner and UseLevelsControl.
-->
<DockPanel Name="interactionControlsDockPanel"
Height="35px"
Height="29px"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FlowDirection="LeftToRight"
IsHitTestVisible="True"
Visibility="{Binding Path=UseLevelVisibility}">
<Rectangle x:Name="useLevelArrowHighlightOverlay"
Width="15"
Height="31px"
Height="15px"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
IsHitTestVisible="True"
Expand Down Expand Up @@ -488,7 +488,7 @@
</DockPanel>
<Grid.Style>
<Style>
<Setter Property="Grid.Height" Value="41px" />
<Setter Property="Grid.Height" Value="35px" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsPortCondensed}" Value="True">
<Setter Property="Grid.Height" Value="{Binding Source={x:Static configuration:Configurations.CodeBlockOutputPortHeightInPixels}}" />
Expand Down
14 changes: 10 additions & 4 deletions src/DynamoCoreWpf/ViewModels/Search/SearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Windows;
using System.Windows.Media;
using Dynamo.Configuration;
using Dynamo.Engine;
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Nodes.ZeroTouch;
using Dynamo.Interfaces;
Expand Down Expand Up @@ -1198,8 +1199,14 @@ internal bool TryGetNodeIcon(NodeViewModel nodeViewModel, out ImageSource iconSo
{
// For ZeroTouch nodes
case DSFunction dsFunction:
nodeTypeName = dsFunction.Controller.Definition.QualifiedName;
assemblyLocation = dsFunction.Controller.Definition.Assembly;
FunctionDescriptor functionDescriptor = dsFunction.Controller.Definition;
assemblyLocation = functionDescriptor.Assembly;
nodeTypeName = Graph.Nodes.Utilities.GetFunctionDescriptorIconName(functionDescriptor);
break;
// For DSVarArgFunctions like String.Concat
case DSVarArgFunction dsVarArgFunction:
nodeTypeName = dsVarArgFunction.Controller.Definition.QualifiedName;
assemblyLocation = dsVarArgFunction.Controller.Definition.Assembly;
break;
// For NodeModel nodes
case NodeModel nodeModel:
Expand All @@ -1217,8 +1224,7 @@ internal bool TryGetNodeIcon(NodeViewModel nodeViewModel, out ImageSource iconSo
IconWarehouse currentWarehouse = iconServices.GetForAssembly(assemblyLocation);
if (currentWarehouse is null) return false;

string iconName = nodeTypeName + Configurations.SmallIconPostfix;
iconSource = currentWarehouse.LoadIconInternal(iconName);
iconSource = currentWarehouse.LoadIconInternal(nodeTypeName + Configurations.SmallIconPostfix);
return !(iconSource is null);
}

Expand Down
Loading