mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Nodes - Added option to hide cable values until mouseover
Nodes - Only show cable value on first connection
This commit is contained in:
parent
4fbd229846
commit
73794591bc
@ -31,7 +31,10 @@
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
|
||||
<controls:VisualScriptPresenter Grid.Row="1" AvailableNodes="{Binding AvailableNodes}" Script="{Binding DataBinding.Script}" />
|
||||
<controls:VisualScriptPresenter Grid.Row="1"
|
||||
AvailableNodes="{Binding AvailableNodes}"
|
||||
Script="{Binding DataBinding.Script}"
|
||||
AlwaysShowValues="{Binding AlwaysShowValues.Value}"/>
|
||||
<Border Grid.Row="1" Background="{StaticResource MaterialDesignToolBarBackground}"
|
||||
Visibility="{Binding DataBindingEnabled, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="16">
|
||||
|
||||
@ -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<NodeData> AvailableNodes { get; }
|
||||
public PluginSetting<bool> AlwaysShowValues { get; }
|
||||
|
||||
public IDataBinding DataBinding
|
||||
{
|
||||
@ -37,6 +39,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ProfileEditorServiceOnSelectedDataBindingChanged(object sender, EventArgs e)
|
||||
{
|
||||
SubscribeToSelectedDataBinding();
|
||||
|
||||
@ -124,7 +124,11 @@
|
||||
IsChecked="{Binding ShowDataModelValues.Value}"/>
|
||||
<MenuItem Header="Display Full Condition Paths"
|
||||
IsCheckable="True"
|
||||
IsChecked="{Binding ShowFullPaths.Value}"/>
|
||||
IsChecked="{Binding ShowFullPaths.Value}"/>
|
||||
<MenuItem Header="Always Display Cable Values"
|
||||
ToolTip="If enabled, cable values are always shown instead of only on hover"
|
||||
IsCheckable="True"
|
||||
IsChecked="{Binding AlwaysShowValues.Value}"/>
|
||||
<MenuItem Header="Apply All Data Bindings During Edit"
|
||||
ToolTip="If enabled, updates all data bindings instead of only the one you are editing"
|
||||
IsCheckable="True"
|
||||
|
||||
@ -119,6 +119,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
public PluginSetting<bool> StopOnFocusLoss => _settingsService.GetSetting("ProfileEditor.StopOnFocusLoss", true);
|
||||
public PluginSetting<bool> ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
||||
public PluginSetting<bool> AlwaysShowValues => _settingsService.GetSetting("ProfileEditor.AlwaysShowValues", true);
|
||||
public PluginSetting<bool> FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", true);
|
||||
public PluginSetting<bool> 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;
|
||||
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)));
|
||||
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}">
|
||||
<controls:VisualScriptPresenter Script="{TemplateBinding Script}"
|
||||
AvailableNodes="{TemplateBinding AvailableNodes}" />
|
||||
AvailableNodes="{TemplateBinding AvailableNodes}"
|
||||
AlwaysShowValues="{TemplateBinding AlwaysShowValues}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<controls:VisualScriptCablePresenter Cable="{Binding .}" />
|
||||
<controls:VisualScriptCablePresenter Cable="{Binding .}" AlwaysShowValues="{Binding AlwaysShowValues, RelativeSource={RelativeSource AncestorType=controls:VisualScriptPresenter}}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
@ -11,12 +11,10 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
private readonly DataModelNode _node;
|
||||
private BindableCollection<Module> _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<Module>();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user