diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsView.xaml index 90da2f349..52fa0286f 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsView.xaml @@ -31,7 +31,10 @@ - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs index a2b4d0846..85b601c4e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs @@ -13,13 +13,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings private readonly IProfileEditorService _profileEditorService; private IDataBinding _dataBinding; - public DataBindingsViewModel(IProfileEditorService profileEditorService, INodeService nodeService) + public DataBindingsViewModel(IProfileEditorService profileEditorService, INodeService nodeService, ISettingsService settingsService) { _profileEditorService = profileEditorService; AvailableNodes = nodeService.AvailableNodes.ToList(); + AlwaysShowValues = settingsService.GetSetting("ProfileEditor.AlwaysShowValues", true); } public List AvailableNodes { get; } + public PluginSetting AlwaysShowValues { get; } public IDataBinding DataBinding { @@ -37,6 +39,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings } } + private void ProfileEditorServiceOnSelectedDataBindingChanged(object sender, EventArgs e) { SubscribeToSelectedDataBinding(); diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.xaml b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.xaml index c7cf110cf..bb2739781 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.xaml @@ -124,7 +124,11 @@ IsChecked="{Binding ShowDataModelValues.Value}"/> + IsChecked="{Binding ShowFullPaths.Value}"/> + StopOnFocusLoss => _settingsService.GetSetting("ProfileEditor.StopOnFocusLoss", true); public PluginSetting ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false); public PluginSetting ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", true); + public PluginSetting AlwaysShowValues => _settingsService.GetSetting("ProfileEditor.AlwaysShowValues", true); public PluginSetting FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", true); public PluginSetting AlwaysApplyDataBindings => _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true); @@ -194,6 +195,7 @@ namespace Artemis.UI.Screens.ProfileEditor StopOnFocusLoss.AutoSave = true; ShowDataModelValues.AutoSave = true; ShowFullPaths.AutoSave = true; + AlwaysShowValues.AutoSave = true; FocusSelectedLayer.AutoSave = true; AlwaysApplyDataBindings.AutoSave = true; @@ -208,6 +210,7 @@ namespace Artemis.UI.Screens.ProfileEditor StopOnFocusLoss.AutoSave = false; ShowDataModelValues.AutoSave = false; ShowFullPaths.AutoSave = false; + AlwaysShowValues.AutoSave = false; FocusSelectedLayer.AutoSave = false; AlwaysApplyDataBindings.AutoSave = false; diff --git a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptCablePresenter.cs b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptCablePresenter.cs index 22bfdcf07..d534e4979 100644 --- a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptCablePresenter.cs +++ b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptCablePresenter.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.ComponentModel; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -24,6 +25,7 @@ namespace Artemis.VisualScripting.Editor.Controls #region Properties & Fields private Path _path; + private Border _valueBorder; #endregion @@ -56,6 +58,15 @@ namespace Artemis.VisualScripting.Editor.Controls set => SetValue(ValuePositionProperty, value); } + public static readonly DependencyProperty AlwaysShowValuesProperty = DependencyProperty.Register( + "AlwaysShowValues", typeof(bool), typeof(VisualScriptCablePresenter), new PropertyMetadata(default(bool), AlwaysShowValuesChanged)); + + public bool AlwaysShowValues + { + get => (bool) GetValue(AlwaysShowValuesProperty); + set => SetValue(AlwaysShowValuesProperty, value); + } + #endregion #region Methods @@ -63,9 +74,15 @@ namespace Artemis.VisualScripting.Editor.Controls public override void OnApplyTemplate() { _path = GetTemplateChild(PART_PATH) as Path ?? throw new NullReferenceException($"The Path '{PART_PATH}' is missing."); - _path.MouseDown += OnPathMouseDown; - + _valueBorder = GetTemplateChild("PART_ValueDisplay") as Border ?? throw new NullReferenceException("The Border 'PART_ValueDisplay' is missing."); + + _path.MouseEnter += (_, _) => UpdateValueVisibility(); + _path.MouseLeave += (_, _) => UpdateValueVisibility(); + _valueBorder.MouseEnter += (_, _) => UpdateValueVisibility(); + _valueBorder.MouseLeave += (_, _) => UpdateValueVisibility(); Unloaded += OnUnloaded; + + UpdateValueVisibility(); } private void OnUnloaded(object sender, RoutedEventArgs e) @@ -112,6 +129,26 @@ namespace Artemis.VisualScripting.Editor.Controls UpdateValuePosition(); } + private static void AlwaysShowValuesChanged(DependencyObject d, DependencyPropertyChangedEventArgs args) + { + if (d is not VisualScriptCablePresenter presenter) return; + + presenter.UpdateValueVisibility(); + } + + private void UpdateValueVisibility() + { + if (_valueBorder == null) + return; + + if (AlwaysShowValues && Cable.From.Connections.LastOrDefault() == Cable) + _valueBorder.Visibility = Visibility.Visible; + else if (_valueBorder.IsMouseOver || _path.IsMouseOver) + _valueBorder.Visibility = Visibility.Visible; + else + _valueBorder.Visibility = Visibility.Collapsed; + } + private void OnPinPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(VisualScriptPin.AbsolutePosition)) diff --git a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptEditor.cs b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptEditor.cs index 8af40eb0b..f4c963902 100644 --- a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptEditor.cs +++ b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptEditor.cs @@ -27,6 +27,15 @@ namespace Artemis.VisualScripting.Editor.Controls set => SetValue(AvailableNodesProperty, value); } + public static readonly DependencyProperty AlwaysShowValuesProperty = DependencyProperty.Register( + "AlwaysShowValues", typeof(bool), typeof(VisualScriptEditor), new PropertyMetadata(default(bool))); + + public bool AlwaysShowValues + { + get => (bool)GetValue(AlwaysShowValuesProperty); + set => SetValue(AlwaysShowValuesProperty, value); + } + #endregion } } diff --git a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs index 0b939b2a3..1e3a468ad 100644 --- a/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs +++ b/src/Artemis.VisualScripting/Editor/Controls/VisualScriptPresenter.cs @@ -114,6 +114,15 @@ namespace Artemis.VisualScripting.Editor.Controls set => SetValue(AvailableNodesProperty, value); } + public static readonly DependencyProperty AlwaysShowValuesProperty = DependencyProperty.Register( + "AlwaysShowValues", typeof(bool), typeof(VisualScriptPresenter), new PropertyMetadata(default(bool))); + + public bool AlwaysShowValues + { + get => (bool)GetValue(AlwaysShowValuesProperty); + set => SetValue(AlwaysShowValuesProperty, value); + } + public static readonly DependencyProperty CreateNodeCommandProperty = DependencyProperty.Register( "CreateNodeCommand", typeof(ICommand), typeof(VisualScriptPresenter), new PropertyMetadata(default(ICommand))); diff --git a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptEditor.xaml b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptEditor.xaml index 227d14b7a..09f5b5a6f 100644 --- a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptEditor.xaml +++ b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptEditor.xaml @@ -8,7 +8,8 @@ BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> + AvailableNodes="{TemplateBinding AvailableNodes}" + AlwaysShowValues="{TemplateBinding AlwaysShowValues}"/> diff --git a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptPresenter.xaml b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptPresenter.xaml index eb9341488..265423dd5 100644 --- a/src/Artemis.VisualScripting/Editor/Styles/VisualScriptPresenter.xaml +++ b/src/Artemis.VisualScripting/Editor/Styles/VisualScriptPresenter.xaml @@ -70,7 +70,7 @@ - + diff --git a/src/Artemis.VisualScripting/Nodes/CustomViewModels/DataModelNodeCustomViewModel.cs b/src/Artemis.VisualScripting/Nodes/CustomViewModels/DataModelNodeCustomViewModel.cs index eb3f10cca..44db086bd 100644 --- a/src/Artemis.VisualScripting/Nodes/CustomViewModels/DataModelNodeCustomViewModel.cs +++ b/src/Artemis.VisualScripting/Nodes/CustomViewModels/DataModelNodeCustomViewModel.cs @@ -11,12 +11,10 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels private readonly DataModelNode _node; private BindableCollection _modules; - public DataModelNodeCustomViewModel(DataModelNode node, ISettingsService settingsService, IPluginManagementService test) : base(node) + public DataModelNodeCustomViewModel(DataModelNode node, ISettingsService settingsService) : base(node) { _node = node; - var tessst = test.GetFeaturesOfType(); - ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true); ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false); } @@ -38,7 +36,7 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels if (ReferenceEquals(_node.DataModelPath, value)) return; - _node.DataModelPath.Dispose(); + _node.DataModelPath?.Dispose(); _node.DataModelPath = value; _node.DataModelPath.Save(); diff --git a/src/Artemis.VisualScripting/Nodes/DataModelNode.cs b/src/Artemis.VisualScripting/Nodes/DataModelNode.cs index dbbb0ded9..850a71cef 100644 --- a/src/Artemis.VisualScripting/Nodes/DataModelNode.cs +++ b/src/Artemis.VisualScripting/Nodes/DataModelNode.cs @@ -45,7 +45,9 @@ namespace Artemis.VisualScripting.Nodes if (Output == null) UpdateOutputPin(false); - Output.Value = DataModelPath.GetValue() ?? Output.Type.GetDefault(); + object pathValue = DataModelPath.GetValue(); + if (pathValue != null) + Output.Value = pathValue; } }