Skip to content

Commit

Permalink
Cherry-Picking the ColorPicker to the 2.18 (#13932)
Browse files Browse the repository at this point in the history
* Dyn 5716 color picker improvements (#13919)

* Color Picker UI improvements

* Updating documentation

* Fixing pixels

* Update the gif doc (#13930)
  • Loading branch information
jesusalvino authored Apr 24, 2023
1 parent bcf3f72 commit 0ac6595
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 18 additions & 17 deletions src/DynamoCoreWpf/Views/Core/CustomColorPicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid Grid.Row="0" Margin="0,0,0,-15">
<Grid x:Name="titleGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="7*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="0,20,0,20"
Margin="-4,5,0,20"
Padding="2"
Background="Transparent"
FontFamily="{StaticResource ArtifaktElementRegular}"
Expand All @@ -320,15 +320,15 @@
Grid.Column="1"
Width="12"
Height="12"
Margin="0,0,0,10"
Margin="0,-8,0,10"
Click="CustomColorsCloseButton_Click"
Style="{StaticResource PopupCloseButtonStyle}" />
</Grid>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="420" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="420"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand All @@ -337,6 +337,7 @@

<!-- Contains all the colors in a Canvas -->
<Border
Margin="0,0,5,0"
Background="{StaticResource CheckerBrush}"
BorderBrush="DarkGray"
BorderThickness="1"
Expand Down Expand Up @@ -415,7 +416,7 @@
x:Name="PART_HexadecimalTextBox"
Grid.Column="1"
MinHeight="22"
Margin="2,0,2,0"
Margin="2,0,5,0"
VerticalAlignment="Center"
FontFamily="{StaticResource ArtifaktElementRegular}"
Style="{StaticResource ColorCanvasTextBoxStyle}" />
Expand All @@ -426,7 +427,7 @@
<Border
Grid.RowSpan="2"
Grid.Column="1"
Margin="4,-8,0,0"
Margin="7,-8,0,0"
ClipToBounds="False">
<xctk:ColorSpectrumSlider x:Name="PART_SpectrumSlider" VerticalAlignment="Stretch" />
</Border>
Expand Down Expand Up @@ -642,7 +643,7 @@
<!-- Normal Colors Window -->
<Grid
x:Name="gridNormalColorSelection"
Margin="20"
Margin="21,10,20,10"
HorizontalAlignment="Left"
Background="Transparent"
Visibility="{Binding Path=IsCustomColorSelectionEnabled, Converter={StaticResource InverseBooleanToVisibilityCollapsedConverter}}">
Expand All @@ -659,18 +660,16 @@
<Grid Grid.Row="0">
<Grid x:Name="titleCustomColorsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="0,10,0,10"
Padding="2"
Background="Transparent"
Margin="0"
FontFamily="{StaticResource ArtifaktElementRegular}"
FontSize="20"
FontWeight="Bold"
Foreground="Black"
Text="{x:Static p:Resources.CustomColorPickerTitle}" />
Text="{x:Static p:Resources.CustomColorPickerTitle}"/>
<Button
Name="NormalColorsCloseButton"
Grid.Column="1"
Expand All @@ -695,6 +694,7 @@
Margin="0,10,0,0"
Padding="2"
Background="Transparent"
FontSize="14"
FontFamily="{StaticResource ArtifaktElementRegular}"
Foreground="Black"
Text="{x:Static p:Resources.CustomColorPickerBasicColors}" />
Expand All @@ -719,10 +719,11 @@
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Margin="0,10,0,0"
Margin="0,10,0,-9"
Padding="2"
Background="Transparent"
FontFamily="{StaticResource ArtifaktElementRegular}"
FontSize="14"
Foreground="Black"
Text="{x:Static p:Resources.CustomColorPickerCustomColors}" />

Expand All @@ -741,7 +742,7 @@
<Button
x:Name="DefineColorBtn"
MaxWidth="200"
Margin="2,0,0,0"
Margin="3,0,0,0"
Padding="10"
HorizontalAlignment="Left"
Click="DefineColorBtn_Click"
Expand All @@ -761,7 +762,7 @@

<!-- Buttons -->
<Grid Grid.Row="5" HorizontalAlignment="Right">
<Grid Margin="10,10,0,0">
<Grid Margin="10,7,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
Expand Down
16 changes: 16 additions & 0 deletions src/Libraries/CoreNodeModelsWpf/ColorPaletteViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Dynamo.Wpf
internal class ColorPaletteViewModel : NotificationObject
{
private SolidColorBrush selectedColor;
private string selectedColorValue;
private bool isColorPickerShown;

/// <summary>
Expand All @@ -23,6 +24,21 @@ public SolidColorBrush SelectedColor
RaisePropertyChanged(nameof(SelectedColor));
}
}
/// <summary>
/// This property will contain the selected color value in the CustomColorPicker popup
/// </summary>
public string SelectedColorValue
{
get
{
return selectedColorValue;
}
set
{
selectedColorValue = value;
RaisePropertyChanged(nameof(SelectedColorValue));
}
}

/// <summary>
/// When the Color Picker is opened this value will have true otherwise will be false, this helps to control the arrow color in the ToggleButton
Expand Down
6 changes: 5 additions & 1 deletion src/Libraries/CoreNodeModelsWpf/Controls/ColorPalette.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
Height="25"
Click="ColorToggleButton_Click"
IsChecked="{Binding IsColorPickerShown}"
Style="{StaticResource CustomColorToggle}" />
Style="{StaticResource CustomColorToggle}">
<ToggleButton.ToolTip>
<ToolTip Content="{Binding SelectedColorValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</ToggleButton.ToolTip>
</ToggleButton>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void ColorPaletteNode_PropertyChanged(object sender, PropertyChangedEven
if (!isSameColor)
{
colorPaletteViewModel.SelectedColor = new SolidColorBrush(convertedModelColor);
colorPaletteViewModel.SelectedColorValue = colorPaletteViewModel.SelectedColor.ToString();
}
}
}
Expand Down

0 comments on commit 0ac6595

Please sign in to comment.