From e401fdf964b93a599265a337d7502bd91e287e8c Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 13 Aug 2022 17:09:53 +0200 Subject: [PATCH] Editor - Autofit surface on open Data model picker - Expand on double click --- .../DataModelPicker/DataModelPicker.cs | 15 ++++- .../VisualEditor/VisualEditorView.axaml | 2 +- .../VisualEditor/VisualEditorView.axaml.cs | 60 +++++++++++++++++++ .../VisualEditor/VisualEditorViewModel.cs | 7 +++ .../Screens/EnumEqualsNodeCustomView.axaml | 10 ++-- 5 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPicker.cs b/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPicker.cs index bb343bec1..621a96161 100644 --- a/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPicker.cs +++ b/src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPicker.cs @@ -13,6 +13,8 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Data; +using Avalonia.Interactivity; +using Avalonia.LogicalTree; using Avalonia.Threading; using Material.Icons.Avalonia; using ReactiveUI; @@ -129,7 +131,7 @@ public class DataModelPicker : TemplatedControl get => GetValue(DataModelViewModelProperty); private set => SetValue(DataModelViewModelProperty, value); } - + /// /// A list of types to filter the selectable paths on. /// @@ -246,6 +248,13 @@ public class DataModelPicker : TemplatedControl DataModelPath = new DataModelPath(dataModelEvent.DataModelPath); } + private void DataModelTreeViewOnDoubleTapped(object? sender, RoutedEventArgs e) + { + TreeViewItem? treeViewItem = (e.Source as ILogical)?.FindLogicalAncestorOfType(); + if (treeViewItem != null) + treeViewItem.IsExpanded = !treeViewItem.IsExpanded; + } + private void UpdateCurrentPath(bool selectCurrentPath) { if (DataModelPath == null) @@ -278,6 +287,8 @@ public class DataModelPicker : TemplatedControl { if (_dataModelTreeView != null) _dataModelTreeView.SelectionChanged -= DataModelTreeViewOnSelectionChanged; + if (_dataModelTreeView != null) + _dataModelTreeView.DoubleTapped -= DataModelTreeViewOnDoubleTapped; _currentPathIcon = e.NameScope.Find("CurrentPathIcon"); _currentPathDisplay = e.NameScope.Find("CurrentPathDisplay"); @@ -286,6 +297,8 @@ public class DataModelPicker : TemplatedControl if (_dataModelTreeView != null) _dataModelTreeView.SelectionChanged += DataModelTreeViewOnSelectionChanged; + if (_dataModelTreeView != null) + _dataModelTreeView.DoubleTapped += DataModelTreeViewOnDoubleTapped; } #region Overrides of Visual diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml index 2c88bddea..7b79b8273 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml @@ -38,7 +38,7 @@ - +