Brushes - Allow hiding of properties

This commit is contained in:
SpoinkyNL committed 2020-04-21 14:05:30 +02:00
1 parent 8c0d62a00b
commit 5bbd4c7df5
8 files changed
+113 -47

No files matched your search

@@ -45,7 +45,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_layerPropertyViewModels = new List<LayerPropertyViewModel>();
PixelsPerSecond = 31;
}
}
public bool Playing { get; set; }
public bool RepeatAfterLastKeyframe { get; set; }
@@ -79,7 +79,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
base.OnInitialActivate();
}
@@ -87,7 +87,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
_profileEditorService.CurrentTimeChanged -= ProfileEditorServiceOnCurrentTimeChanged;
if (_lastSelectedLayer != null)
{
_lastSelectedLayer.Properties.LayerPropertyRegistered -= LayerOnPropertyRegistered;
@@ -106,7 +106,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
Pause();
base.OnDeactivate();
}
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
{
PopulateProperties(e.ProfileElement);
@@ -14,6 +14,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private readonly IKernel _kernel;
private readonly IProfileEditorService _profileEditorService;
private bool _keyframesEnabled;
private bool _isExpanded;
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, IKernel kernel, IProfileEditorService profileEditorService)
{
@@ -34,7 +35,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public LayerPropertyViewModel Parent { get; }
public List<LayerPropertyViewModel> Children { get; }
public bool IsExpanded { get; set; }
public bool IsExpanded
{
get => _isExpanded;
set
{
_isExpanded = value;
OnExpandedStateChanged();
}
}
public bool KeyframesEnabled
{
@@ -75,5 +84,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_profileEditorService.UpdateSelectedProfileElement();
}
#region Events
public event EventHandler<EventArgs> ExpandedStateChanged;
protected virtual void OnExpandedStateChanged()
{
ExpandedStateChanged?.Invoke(this, EventArgs.Empty);
foreach (var layerPropertyViewModel in Children)
layerPropertyViewModel.OnExpandedStateChanged();
}
#endregion
}
}
@@ -87,6 +87,7 @@
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}">
<Setter Property="IsExpanded" Value="{Binding LayerPropertyViewModel.IsExpanded, Mode=TwoWay}" />
<Setter Property="Visibility" Value="{Binding LayerPropertyViewModel.LayerProperty.IsHidden, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}" />
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources>
@@ -12,7 +12,7 @@
<Border Height="25"
BorderThickness="0,0,0,1"
BorderBrush="{DynamicResource MaterialDesignDivider}"
Visibility="{Binding LayerPropertyViewModel.Parent.IsExpanded, Converter={StaticResource BoolToVisibilityConverter}}">
Visibility="{Binding MustDisplay, Converter={StaticResource BoolToVisibilityConverter}}">
<ItemsControl ItemsSource="{Binding KeyframeViewModels}"
Background="{DynamicResource MaterialDesignToolBarBackground}"
HorizontalAlignment="Left">
@@ -19,12 +19,44 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
PopulateKeyframes();
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);
LayerPropertyViewModel.ExpandedStateChanged += (sender, args) => UpdateMustDisplay();
LayerPropertyViewModel.LayerProperty.VisibilityChanged += (sender, args) => UpdateMustDisplay();
UpdateMustDisplay();
}
public PropertyTimelineViewModel PropertyTimelineViewModel { get; }
public LayerPropertyViewModel LayerPropertyViewModel { get; }
public BindableCollection<PropertyTrackKeyframeViewModel> KeyframeViewModels { get; set; }
public bool MustDisplay { get; set; }
private void UpdateMustDisplay()
{
var expandedTest = LayerPropertyViewModel.Parent;
while (expandedTest != null)
{
if (!expandedTest.IsExpanded)
{
MustDisplay = false;
return;
}
expandedTest = expandedTest.Parent;
}
var visibilityTest = LayerPropertyViewModel.LayerProperty;
while (visibilityTest != null)
{
if (visibilityTest.IsHidden)
{
MustDisplay = false;
return;
}
visibilityTest = visibilityTest.Parent;
}
MustDisplay = true;
}
public void PopulateKeyframes()
{