|
@@ -8,35 +8,15 @@ namespace PixiEditor.Views.UserControls.Layers;
|
|
|
|
|
|
internal partial class LayersManager : UserControl
|
|
|
{
|
|
|
+ public static readonly DependencyProperty ActiveDocumentProperty =
|
|
|
+ DependencyProperty.Register(nameof(ActiveDocument), typeof(DocumentViewModel), typeof(LayersManager), new(null));
|
|
|
|
|
|
- public static readonly DependencyProperty SelectedItemProperty =
|
|
|
- DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(LayersManager), new PropertyMetadata(0));
|
|
|
- public object SelectedItem
|
|
|
+ public DocumentViewModel ActiveDocument
|
|
|
{
|
|
|
- get { return (object)GetValue(SelectedItemProperty); }
|
|
|
- set { SetValue(SelectedItemProperty, value); }
|
|
|
+ get => (DocumentViewModel)GetValue(ActiveDocumentProperty);
|
|
|
+ set => SetValue(ActiveDocumentProperty, value);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static readonly DependencyProperty OpacityInputEnabledProperty =
|
|
|
- DependencyProperty.Register(nameof(OpacityInputEnabled), typeof(bool), typeof(LayersManager), new PropertyMetadata(false));
|
|
|
-
|
|
|
- public bool OpacityInputEnabled
|
|
|
- {
|
|
|
- get { return (bool)GetValue(OpacityInputEnabledProperty); }
|
|
|
- set { SetValue(OpacityInputEnabledProperty, value); }
|
|
|
- }
|
|
|
-
|
|
|
- public static readonly DependencyProperty StructureRootProperty =
|
|
|
- DependencyProperty.Register(nameof(StructureRoot), typeof(FolderViewModel), typeof(LayersManager), new(null));
|
|
|
-
|
|
|
- public FolderViewModel StructureRoot
|
|
|
- {
|
|
|
- get => (FolderViewModel)GetValue(StructureRootProperty);
|
|
|
- set => SetValue(StructureRootProperty, value);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public LayersManager()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -53,45 +33,6 @@ internal partial class LayersManager : UserControl
|
|
|
}
|
|
|
*/
|
|
|
}
|
|
|
- /*
|
|
|
- private void HandleGroupOpacityChange(GuidStructureItem group, float value)
|
|
|
- {
|
|
|
- if (LayerCommandsViewModel.Owner?.BitmapManager?.ActiveDocument != null)
|
|
|
- {
|
|
|
- var doc = LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument;
|
|
|
-
|
|
|
- if (group.Opacity == value)
|
|
|
- return;
|
|
|
-
|
|
|
- var processArgs = new object[] { group.GroupGuid, value };
|
|
|
- var reverseProcessArgs = new object[] { group.GroupGuid, group.Opacity };
|
|
|
-
|
|
|
- ChangeGroupOpacityProcess(processArgs);
|
|
|
-
|
|
|
- LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.LayerStructure.ExpandParentGroups(group);
|
|
|
-
|
|
|
- doc.UndoManager.AddUndoChange(
|
|
|
- new Change(
|
|
|
- ChangeGroupOpacityProcess,
|
|
|
- reverseProcessArgs,
|
|
|
- ChangeGroupOpacityProcess,
|
|
|
- processArgs,
|
|
|
- $"Change {group.Name} opacity"), false);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void ChangeGroupOpacityProcess(object[] processArgs)
|
|
|
- {
|
|
|
- if (processArgs.Length > 0 && processArgs[0] is Guid groupGuid && processArgs[1] is float opacity)
|
|
|
- {
|
|
|
- var structure = LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument.LayerStructure;
|
|
|
- var group = structure.GetGroupByGuid(groupGuid);
|
|
|
- group.Opacity = opacity;
|
|
|
- var layers = structure.GetGroupLayers(group);
|
|
|
- layers.ForEach(x => x.Opacity = x.Opacity); // This might seems stupid, but it raises property changed, without setting any value. This is used to trigger converters that use group opacity
|
|
|
- numberInput.Value = opacity * 100;
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
private void LayerGroup_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|
|
{
|
|
@@ -106,76 +47,12 @@ internal partial class LayersManager : UserControl
|
|
|
|
|
|
private void NumberInput_LostFocus(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- float val = numberInput.Value / 100f;
|
|
|
-
|
|
|
- object item = SelectedItem;
|
|
|
- /*
|
|
|
- if (item is Layer || item is LayerStructureItemContainer)
|
|
|
- {
|
|
|
- Layer layer = null;
|
|
|
-
|
|
|
- if (item is Layer lr)
|
|
|
- {
|
|
|
- layer = lr;
|
|
|
- }
|
|
|
- else if (item is LayerStructureItemContainer container)
|
|
|
- {
|
|
|
- layer = container.Layer;
|
|
|
- }
|
|
|
-
|
|
|
- HandleLayerOpacityChange(val, layer);
|
|
|
- }
|
|
|
- else if (item is LayerGroup group)
|
|
|
- {
|
|
|
- HandleGroupOpacityChange(group.StructureData, val);
|
|
|
- }
|
|
|
- else if (item is LayerGroupControl groupControl)
|
|
|
- {
|
|
|
- HandleGroupOpacityChange(groupControl.GroupData, val);
|
|
|
- }
|
|
|
- */
|
|
|
- ShortcutController.UnblockShortcutExecutionAll();
|
|
|
- }
|
|
|
- /*
|
|
|
- private void HandleLayerOpacityChange(float val, Layer layer)
|
|
|
- {
|
|
|
- float oldOpacity = layer.Opacity;
|
|
|
- if (oldOpacity == val)
|
|
|
+ if (ActiveDocument?.SelectedStructureMember is null)
|
|
|
return;
|
|
|
+ ActiveDocument.SetMemberOpacity(ActiveDocument.SelectedStructureMember.GuidValue, numberInput.Value / 100f);
|
|
|
|
|
|
- var doc = LayerCommandsViewModel.Owner.BitmapManager.ActiveDocument;
|
|
|
-
|
|
|
- doc.RaisePropertyChange(nameof(doc.LayerStructure));
|
|
|
-
|
|
|
- layer.OpacityUndoTriggerable = val;
|
|
|
-
|
|
|
- doc.LayerStructure.ExpandParentGroups(layer.GuidValue);
|
|
|
-
|
|
|
- doc.RaisePropertyChange(nameof(doc.LayerStructure));
|
|
|
-
|
|
|
- UndoManager undoManager = doc.UndoManager;
|
|
|
-
|
|
|
-
|
|
|
- undoManager.AddUndoChange(
|
|
|
- new Change(
|
|
|
- UpdateNumberInputLayerOpacityProcess,
|
|
|
- new object[] { oldOpacity },
|
|
|
- UpdateNumberInputLayerOpacityProcess,
|
|
|
- new object[] { val }));
|
|
|
- undoManager.SquashUndoChanges(2);
|
|
|
- }
|
|
|
-
|
|
|
- private void UpdateNumberInputLayerOpacityProcess(object[] args)
|
|
|
- {
|
|
|
- if (args.Length > 0 && args[0] is float opacity)
|
|
|
- {
|
|
|
- numberInput.Value = opacity * 100;
|
|
|
- }
|
|
|
- }
|
|
|
- */
|
|
|
- private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
|
- {
|
|
|
- //SetInputOpacity(SelectedItem);
|
|
|
+ // does anyone know why this is here?
|
|
|
+ ShortcutController.UnblockShortcutExecutionAll();
|
|
|
}
|
|
|
|
|
|
private void Grid_Drop(object sender, DragEventArgs e)
|
|
@@ -222,9 +99,4 @@ internal partial class LayersManager : UserControl
|
|
|
{
|
|
|
((Border)sender).BorderBrush = Brushes.Transparent;
|
|
|
}
|
|
|
-
|
|
|
- private void SelectActiveItem(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
|
- {
|
|
|
- SelectedItem = sender;
|
|
|
- }
|
|
|
}
|