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

1642 - hint-text wrapping #268

Merged
merged 2 commits into from
Nov 24, 2024
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
110 changes: 65 additions & 45 deletions WpfDataUi/Controls/AngleSelectorDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,80 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:decorators="clr-namespace:WpfDataUiCore.Decorators"
mc:Ignorable="d"
>
<Grid DragOver="Grid_DragOver_1" x:Name="MainGrid">
<Grid.ContextMenu>
<ContextMenu></ContextMenu>
</Grid.ContextMenu>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label x:Name="Label" Grid.Column="0" VerticalAlignment="Center">TitleText</Label>
<Canvas Grid.Column="1" Width="40" Height="40" Margin="6">
<Ellipse Grid.Column="0" Width="40" Height="40" Stroke="Gray" MouseMove="Ellipse_MouseMove_1" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown_1">
<Ellipse.Fill>
<LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1">
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="LightGray" Offset="1.0" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Line x:Name="Line" Canvas.Left="20" Canvas.Top="20" X1="0" Y1="0" X2="22" Y2="0"
<StackPanel>

<Grid DragOver="Grid_DragOver_1" x:Name="TopRowGrid">
<Grid.ContextMenu>
<ContextMenu></ContextMenu>
</Grid.ContextMenu>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<Label x:Name="Label" Grid.Column="0" VerticalAlignment="Center">TitleText</Label>
<Canvas Grid.Column="1" Width="40" Height="40" Margin="6">
<Ellipse Grid.Column="0" Width="40" Height="40" Stroke="Gray" MouseMove="Ellipse_MouseMove_1" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown_1">
<Ellipse.Fill>
<LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1">
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="LightGray" Offset="1.0" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Line x:Name="Line" Canvas.Left="20" Canvas.Top="20" X1="0" Y1="0" X2="22" Y2="0"
StrokeThickness="3" StrokeEndLineCap="Triangle" RenderTransformOrigin="0,0" MouseMove="Ellipse_MouseMove_1">
<Line.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="{Binding Path=NegativeAngle}"/>
<TranslateTransform/>
</TransformGroup>
</Line.RenderTransform>
<Line.Stroke>
<SolidColorBrush Color="Black"></SolidColorBrush>


</Line.Stroke>

</Line>
<Ellipse Name="CenterPoint" Grid.Column="0" Width="4" Height="4" Fill="Gray" Canvas.Left="18" Canvas.Top="18" />
<Line.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="{Binding Path=NegativeAngle}"/>
<TranslateTransform/>
</TransformGroup>
</Line.RenderTransform>
<Line.Stroke>
<SolidColorBrush Color="Black"></SolidColorBrush>


</Canvas>
<Grid Grid.Column="2">
<Grid>
<TextBox x:Name="TextBox" MinWidth="50" Height="24"
</Line.Stroke>

</Line>
<Ellipse Name="CenterPoint" Grid.Column="0" Width="4" Height="4" Fill="Gray" Canvas.Left="18" Canvas.Top="18" />

</Canvas>
<Grid Grid.Column="2">
<Grid>
<TextBox x:Name="TextBox" MinWidth="50" Height="24"
PreviewKeyDown="TextBox_PreviewKeyDown_1"
LostFocus="TextBox_LostFocus_1"
Margin="0,0,13,0"
/>
<decorators:NoSizeDecorator>
<TextBlock IsHitTestVisible="False"
<decorators:NoSizeDecorator>
<TextBlock IsHitTestVisible="False"
VerticalAlignment="Center"
Foreground="Gray"
Margin="3,0,16,0" x:Name="PlaceholderText" ></TextBlock>
</decorators:NoSizeDecorator>
</decorators:NoSizeDecorator>
</Grid>
<Label Content="&#186;" Height="32" HorizontalAlignment="Right"></Label>
</Grid>
<Label Content="&#186;" Height="32" HorizontalAlignment="Right"></Label>
</Grid>
</Grid>
<TextBlock x:Name="HintTextBlock"
Padding="8,1,0,4"
Grid.Row="2"
Grid.ColumnSpan="3"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
Margin="0,0,-4,0"
FontSize="10" Text="This is a property description. But what if it is longer?"/>

</StackPanel>
</UserControl>
7 changes: 5 additions & 2 deletions WpfDataUi/Controls/AngleSelectorDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public AngleSelectorDisplay()

mTextBoxLogic = new TextBoxDisplayLogic(this, this.TextBox);

this.RefreshContextMenu(MainGrid.ContextMenu);
this.RefreshContextMenu(TopRowGrid.ContextMenu);

// do we have to refresh the context menu? We do in the TextBoxDisplay
}
Expand Down Expand Up @@ -275,7 +275,10 @@ public void Refresh(bool forceRefreshEvenIfFocused = false)

this.Label.Content = InstanceMember.DisplayName;

this.RefreshContextMenu(MainGrid.ContextMenu);
this.RefreshContextMenu(TopRowGrid.ContextMenu);

HintTextBlock.Visibility = !string.IsNullOrEmpty(InstanceMember?.DetailText) ? Visibility.Visible : Visibility.Collapsed;
HintTextBlock.Text = InstanceMember?.DetailText;

if (InstanceMember.IsDefault)
{
Expand Down
4 changes: 2 additions & 2 deletions WpfDataUi/Controls/CheckBoxDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<TextBlock x:Name="HintTextBlock"
Padding="8,0,0,0" Grid.Row="1"
TextWrapping="Wrap"
HorizontalAlignment="Stretch"
MaxWidth="{Binding ElementName=CheckBox, Path=ActualWidth}"
Margin="0,0,-4,0"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
FontSize="10">
This is a property description.
</TextBlock>
Expand Down
41 changes: 26 additions & 15 deletions WpfDataUi/Controls/ComboBoxDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,40 @@ private void CreateLayout()
Grid.SetColumn(ComboBox, 1);
Grid.Children.Add(ComboBox);

var isUsingBinding = false;

HintTextBlock = new TextBlock
{
Name="DetailTextBlock",
VerticalAlignment = VerticalAlignment.Center,
TextWrapping = TextWrapping.Wrap,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness(8, 1, 0, 4),
FontSize = 10,
MaxWidth = 250
Padding = new Thickness(8, 1, 0, 4),
Margin = new Thickness(0, 0, -4, 0),
FontSize = 10
};

// This is an attempt to make the hint text block only take as much space as the top
// grid. I can't get it to work, even though it works with the TextBoxDisplay. Therefore, we'll just give the
// a reasonable max width.
//var binding = new Binding()
//{
// ElementName = "TopRowGrid",
// Path = new PropertyPath("ActualWidth"),
// Mode = BindingMode.OneWay
//};

//HintTextBlock.SetBinding(TextBlock.WidthProperty, binding);
// More info here: https://github.com/vchelaru/FlatRedBall/issues/1618
if(!isUsingBinding)
{
HintTextBlock.MaxWidth = 250;
}
else
{
// This is an attempt to make the hint text block only take as much space as the top
// grid. I can't get it to work, even though it works with the TextBoxDisplay. Therefore, we'll just give the
// a reasonable max width.
var binding = new Binding()
{
ElementName = "TopRowGrid",
Path = new PropertyPath("ActualWidth"),
Mode = BindingMode.OneWay
};


HintTextBlock.SetBinding(TextBlock.WidthProperty, binding);
// More info here: https://github.com/vchelaru/FlatRedBall/issues/1618
}


stackPanel.Children.Add(HintTextBlock);

Expand Down
65 changes: 39 additions & 26 deletions WpfDataUi/Controls/FileSelectionDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,52 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Name="FirstColumn" Width="{Binding FirstGridLength}"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<TextBlock x:Name="Label" MinWidth="100" TextWrapping="Wrap" VerticalAlignment="Center">Property Label:</TextBlock>

<TextBox Grid.Column="1" x:Name="TextBox"
<Grid x:Name="TopRowGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="FirstColumn" Width="{Binding FirstGridLength}"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>

<TextBlock x:Name="Label" MinWidth="100" TextWrapping="Wrap" VerticalAlignment="Center">Property Label:</TextBlock>

<TextBox Grid.Column="1" x:Name="TextBox"
Margin="0,0,51,0" LostFocus="TextBox_LostFocus_1"
MinWidth="60" VerticalAlignment="Center">
<TextBox.ContextMenu>
<ContextMenu>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
<Button Width="24"
<TextBox.ContextMenu>
<ContextMenu>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
<Button Width="24"
Click="Button_Click_1" VerticalAlignment="Center"
>...</Button>
<Button Grid.Column="2"
<Button Grid.Column="2"
Width="24"
Height="20"
Margin="1,0,0,0" Click="ViewInExplorerClicked">
<Image Source="/WpfDataUi;component/Content/Icons/OpenFolder.png"></Image>
</Button>
</StackPanel>
<Image Source="/WpfDataUi;component/Content/Icons/OpenFolder.png"></Image>
</Button>

</StackPanel>

</Grid>
</Grid>
<TextBlock x:Name="HintTextBlock"
Padding="8,1,0,4"
Grid.Row="2"
Grid.ColumnSpan="3"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
Margin="0,0,-4,0"
FontSize="10" Text="This is a property description. But what if it is longer?"/>
</StackPanel>
</UserControl>
2 changes: 2 additions & 0 deletions WpfDataUi/Controls/FileSelectionDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public void Refresh(bool forceRefreshEvenIfFocused = false)

mTextBoxLogic.RefreshDisplay();

HintTextBlock.Visibility = !string.IsNullOrEmpty(InstanceMember?.DetailText) ? Visibility.Visible : Visibility.Collapsed;
HintTextBlock.Text = InstanceMember?.DetailText;

this.Label.Text = InstanceMember.DisplayName;
this.RefreshContextMenu(TextBox.ContextMenu);
Expand Down
26 changes: 14 additions & 12 deletions WpfDataUi/Controls/NullableBoolDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
<ContextMenu></ContextMenu>
</GroupBox.ContextMenu>
<StackPanel>
<RadioButton x:Name="TrueRadioButton" Checked="TrueRadioButton_Checked">True</RadioButton>
<RadioButton x:Name="FalseRadioButton" Checked="FalseRadioButton_Checked">False</RadioButton>
<RadioButton x:Name="NullRadioButton" Checked="NullRadioButton_Checked">None</RadioButton>

<Grid x:Name="TopRowGrid">
<StackPanel>
<RadioButton x:Name="TrueRadioButton" Checked="TrueRadioButton_Checked">True</RadioButton>
<RadioButton x:Name="FalseRadioButton" Checked="FalseRadioButton_Checked">False</RadioButton>
<RadioButton x:Name="NullRadioButton" Checked="NullRadioButton_Checked">None</RadioButton>
</StackPanel>
</Grid>
<TextBlock x:Name="HintTextBlock"
Padding="8,1,8,0"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="{Binding ElementName=TopRowGrid, Path=ActualWidth, Mode=OneWay}"
FontSize="10" Text="This is a property description. But what if it is longer?" />


Padding="8,1,8,0"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
Margin="0,0,-4,0"
FontSize="10" Text="This is a property description. But what if it is longer?" />
</StackPanel>
</GroupBox>
</UserControl>
3 changes: 2 additions & 1 deletion WpfDataUi/Controls/SliderDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="{Binding ElementName=TopRowGrid, Path=ActualWidth, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
Margin="0,0,-4,0"
FontSize="10">This is the bottommost text</TextBlock>
</Grid>
</UserControl>
7 changes: 2 additions & 5 deletions WpfDataUi/Controls/TextBoxDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,13 @@
<StackPanel x:Name="AfterTextBoxUi" Orientation="Horizontal" Grid.Column="2" VerticalAlignment="Stretch">
</StackPanel>
</Grid>
<!--Vic says: If this is really long, it extends the entire control horizontally rather than wrapping. I don't know how to control this.
In Gum we would just mark this Width as RelativeToParent and be done with it-->
<TextBlock x:Name="HintTextBlock"
Padding="8,1,0,4"
Grid.Row="2"
Grid.ColumnSpan="3"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="{Binding ElementName=TopRowGrid, Path=ActualWidth, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=TopRowGrid}"
Margin="0,0,-4,0"
FontSize="10" Text="This is a property description. But what if it is longer?"/>


Expand Down
Loading