Skip to content

Commit

Permalink
fix: Reduce visual noise when loading in new properties in the proper…
Browse files Browse the repository at this point in the history
…ty grid
  • Loading branch information
Eideren committed Sep 24, 2024
1 parent 90522b7 commit f97161a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,12 @@ public async Task<GraphViewModel> GenerateSelectionPropertiesAsync(IEnumerable<I

Selection = selectedObjects.ToList();

CanDisplayProperties = false;

ViewModel?.Destroy();

// We set to null now, in case this async method is invoked again while not being finished (otherwise it would dispose twice!)
ViewModel = null;

// No selection, just clean up
if (Selection.Count == 0)
{
ViewModel = null;
FallbackMessage = EmptySelectionFallbackMessage;
return null;
}

string message;
if (!CanDisplaySelectedObjects(Selection, out message))
string message = EmptySelectionFallbackMessage;
if (Selection.Count == 0 || !CanDisplaySelectedObjects(Selection, out message))
{
CanDisplayProperties = false;
ViewModel?.Destroy();
ViewModel = null;
FallbackMessage = message;
return null;
Expand All @@ -147,13 +135,17 @@ public async Task<GraphViewModel> GenerateSelectionPropertiesAsync(IEnumerable<I
if (localToken != currentToken)
return null;

ViewModel?.Destroy();
ViewModel = newViewModel;
CanDisplayProperties = true;
FallbackMessage = "";
}
catch (Exception exception)
{
CanDisplayProperties = false;
FeedbackException(Selection, exception, out message);
FallbackMessage = message;
ViewModel?.Destroy();
ViewModel = null;
}
return ViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private void PrepareItem(object sender, PropertyViewItemEventArgs e)
{
propertyItem.IsExpanded = false;
}
Dispatcher.BeginInvoke(new Action(() => ExpandSingleProperties(e.Container)));

Dispatcher.VerifyAccess();
ExpandSingleProperties(e.Container);
}

private PropertyViewItem GetPropertyItem(string propertyPath)
Expand Down
4 changes: 2 additions & 2 deletions sources/editor/Stride.GameStudio/View/GameStudioWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,6 @@
</DockPanel>
</DockPanel>

<TextBlock Grid.Row="4" Text="{Binding Session.ActiveProperties.FallbackMessage}" HorizontalAlignment="Center" VerticalAlignment="Center"
Visibility="{Binding Session.ActiveProperties.CanDisplayProperties, Converter={sd:Chained {sd:InvertBool}, {sd:VisibleOrCollapsed}}}"/>
<sd:PropertyView x:Name="AssetPropertyView" Grid.Row="4"
ItemsSource="{Binding Session.ActiveProperties.ViewModel.RootNode.Children}"
Visibility="{Binding Session.ActiveProperties.CanDisplayProperties, Converter={sd:VisibleOrCollapsed}}">
Expand Down Expand Up @@ -875,6 +873,8 @@
</i:Interaction.Behaviors>
</sd:PropertyView>

<TextBlock Grid.Row="4" Text="{Binding Session.ActiveProperties.FallbackMessage}" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#99000000"/>

<GridSplitter Grid.Row="5" HorizontalAlignment="Stretch" Height="5" ResizeBehavior="PreviousAndNext"/>

<Border Grid.Row="6" Background="{StaticResource ToolBarBackgroundBrush}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,15 @@ private void ModifySelection([NotNull] ICollection<object> itemsToSelect, [NotNu
return;

allowedSelectionChanges = true;
// Unselect and then select items

// Select and then unselect items to make sure we don't present an empty property grid while it's loading
((NonGenericObservableListWrapper<object>)SelectedItems).AddRange(itemsToSelect);

foreach (var itemToUnSelect in itemsToUnselect)
{
SelectedItems.Remove(itemToUnSelect);
}

((NonGenericObservableListWrapper<object>)SelectedItems).AddRange(itemsToSelect);
allowedSelectionChanges = false;

if (itemsToUnselect.Contains(lastShiftRoot))
Expand Down

0 comments on commit f97161a

Please sign in to comment.