public SkinningWeightsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editorParams.DefaultValueGetter = () => new SkinningWeights();
     indexEditors   = new NumericEditBox[4];
     weightsSliders = new ThemedAreaSlider[4];
     foreach (var o in editorParams.Objects)
     {
         var prop = new Property <SkinningWeights>(o, editorParams.PropertyName).Value;
     }
     for (var i = 0; i <= 3; i++)
     {
         indexEditors[i]      = editorParams.NumericEditBoxFactory();
         indexEditors[i].Step = 1;
         weightsSliders[i]    = new ThemedAreaSlider(range: new Vector2(0, 1), labelFormat: "0.00000");
         var wrapper = new Widget {
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchY = 0
             }
         };
         var propertyLabel = new ThemedSimpleText {
             Text       = $"Bone { char.ConvertFromUtf32(65 + i) }",
             VAlignment = VAlignment.Center,
             Padding    = new Thickness {
                 Left = 20
             },
             LayoutCell = new LayoutCell {
                 StretchX = 1.0f
             },
             ForceUncutText = false,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = false
         };
         wrapper.AddNode(propertyLabel);
         wrapper.AddNode(new Widget {
             Layout = new HBoxLayout {
                 Spacing = 4
             },
             LayoutCell = new LayoutCell {
                 StretchX = 2.0f
             },
             Nodes =
             {
                 indexEditors[i],
                 weightsSliders[i]
             }
         });
         ExpandableContent.AddNode(wrapper);
         customWarningsContainer = new Widget {
             Layout = new VBoxLayout()
         };
         ContainerWidget.AddNode(customWarningsContainer);
         var j = i;
         SetLink(i, CoalescedPropertyComponentValue(sw => sw[j].Index), CoalescedPropertyComponentValue(sw => sw[j].Weight));
     }
     CheckWarnings();
 }
Пример #2
0
        public Color4PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ColorBoxButton colorBox;
            var            panel        = new ColorPickerPanel();
            var            currentColor = CoalescedPropertyValue(Color4.White).DistinctUntilChanged();

            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center)
                },
                Nodes =
                {
                    (editor   = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (colorBox = new ColorBoxButton(currentColor)),
                    CreatePipetteButton(),
                    Spacer.HStretch(),
                },
            });
            ExpandableContent.AddNode(panel.Widget);
            panel.Widget.Padding = panel.Widget.Padding + new Thickness(right: 12.0f);
            panel.Widget.Tasks.Add(currentColor.Consume(v => {
                if (panel.Color != v)
                {
                    panel.Color = v;
                }
                Changed?.Invoke();
            }));
            panel.Changed += () => {
                EditorParams.History?.RollbackTransaction();
                SetProperty(panel.Color);
            };
            panel.DragStarted += () => {
                EditorParams.History?.BeginTransaction();
                lastColor = panel.Color;
            };
            panel.DragEnded += () => {
                if (panel.Color != lastColor)
                {
                    EditorParams.History?.CommitTransaction();
                }
                EditorParams.History?.EndTransaction();
            };
            colorBox.Clicked += () => Expanded = !Expanded;
            var currentColorString = currentColor.Select(i => i.ToString(Color4.StringPresentation.Dec));

            editor.Submitted += text => SetComponent(text, currentColorString);
            editor.Tasks.Add(currentColorString.Consume(v => editor.Text = v));
            editor.AddChangeWatcher(() => editor.Text, value => CheckEditorText(value, editor));
        }
 public SkinningWeightsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editorParams.DefaultValueGetter = () => new SkinningWeights();
     indexEditors   = new NumericEditBox[4];
     weigthsEditors = new NumericEditBox[4];
     foreach (var o in editorParams.Objects)
     {
         var prop = new Property <SkinningWeights>(o, editorParams.PropertyName).Value;
     }
     for (var i = 0; i <= 3; i++)
     {
         indexEditors[i]      = editorParams.NumericEditBoxFactory();
         indexEditors[i].Step = 1;
         weigthsEditors[i]    = editorParams.NumericEditBoxFactory();
         var wrapper = new Widget {
             Padding = new Thickness {
                 Left = 20
             },
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchY = 0
             }
         };
         var propertyLabel = new ThemedSimpleText {
             Text           = $"Bone { char.ConvertFromUtf32(65 + i) }",
             VAlignment     = VAlignment.Center,
             LayoutCell     = new LayoutCell(Alignment.LeftCenter, 0),
             ForceUncutText = false,
             MinWidth       = 140,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = true,
             TabTravesable  = new TabTraversable(),
         };
         wrapper.AddNode(propertyLabel);
         wrapper.AddNode(new Widget {
             Layout = new HBoxLayout {
                 DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
             },
             Nodes =
             {
                 indexEditors[i],
                 weigthsEditors[i]
             }
         });
         ExpandableContent.AddNode(wrapper);
         var j = i;
         SetLink(i, CoalescedPropertyComponentValue(sw => sw[j].Index), CoalescedPropertyComponentValue(sw => sw[j].Weight));
     }
 }
Пример #4
0
        public Color4PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ColorBoxButton colorBox;
            var            panel        = new ColorPickerPanel();
            var            currentColor = CoalescedPropertyValue(Color4.White).DistinctUntilChanged();

            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center)
                },
                Nodes =
                {
                    (editor   = editorParams.EditBoxFactory()),
                    new HSpacer(4),
                    (colorBox = new ColorBoxButton(currentColor)),
                    CreatePipetteButton(),
                }
            });
            ExpandableContent.AddNode(panel.Widget);
            panel.Widget.Padding.Right = 12;
            panel.Widget.Tasks.Add(currentColor.Consume(v => panel.Color = v));
            panel.Changed     += () => SetProperty(panel.Color);
            panel.DragStarted += Document.Current.History.BeginTransaction;
            panel.DragEnded   += Document.Current.History.EndTransaction;
            colorBox.Clicked  += () => Expanded = !Expanded;
            var currentColorString = currentColor.Select(i => i.ToString(Color4.StringPresentation.Dec));

            editor.Submitted += text => {
                Color4 newColor;
                if (Color4.TryParse(text, out newColor))
                {
                    SetProperty(newColor);
                }
                else
                {
                    editor.Text = currentColorString.GetValue();
                }
            };
            editor.Tasks.Add(currentColorString.Consume(v => editor.Text = v));
        }
Пример #5
0
        public ColorGradientPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            if (editorParams.Objects.Count() > 1)
            {
                ExpandButton.Visible = false;
                EditorContainer.AddNode(new ThemedSimpleText {
                    Text       = "Unable to edit multiple gradients",
                    VAlignment = VAlignment.Center,
                    LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0),
                });
                return;
            }
            gradientControlWidget = new TransactionalGradientControlWidget(EditorParams.History)
            {
                MinMaxHeight = 35f,
                Height       = 35f,
                LayoutCell   = new LayoutCell(Alignment.LeftCenter),
                Padding      = new Thickness {
                    Right = 5f, Bottom = 5f
                }
            };
            var gradientProperty = CoalescedPropertyValue(new ColorGradient(Color4.White, Color4.Black)).DistinctUntilChanged();

            gradientControlWidget.Gradient = gradientProperty.GetValue();
            ContainerWidget.AddChangeWatcher(gradientProperty, g => gradientControlWidget.Gradient = g);
            gradientControlWidget.SelectionChanged += SelectPoint;
            EditorContainer.AddNode(gradientControlWidget);
            EditorContainer.AddNode(CreatePipetteButton());
            ExpandableContent.Padding = new Thickness {
                Left = 25f, Right = 25f, Top = 5f
            };
            ExpandableContent.AddNode(new Widget {
                Layout = new HBoxLayout {
                    Spacing = 10f
                },
                Nodes =
                {
                    new ThemedSimpleText {
                        Text = nameof(GradientControlPoint.Position), MinWidth = 150
                    },
                    (positionEditor = EditorParams.NumericEditBoxFactory())
                },
                Padding = new Thickness(0, 3f)
            });
            ExpandableContent.AddNode(new Widget {
                Layout = new HBoxLayout {
                    Spacing = 10f
                },
                Nodes =
                {
                    new ThemedSimpleText {
                        Text = nameof(GradientControlPoint.Color), MinWidth = 150
                    },
                    (colorEditor = EditorParams.EditBoxFactory())
                },
                Padding = new Thickness(0, 3f)
            });
            positionEditor.Step       = 0.005f;
            colorEditor.Submitted    += SetColor;
            positionEditor.Submitted += SetPosition;
            colorPanel = new ColorPickerPanel();
            ExpandableContent.AddNode(colorPanel.Widget);
            var padding = colorPanel.Widget.Padding;

            padding.Right                      = 12;
            colorPanel.Widget.Padding          = padding;
            colorPanel.DragStarted            += () => EditorParams.History?.BeginTransaction();
            gradientControlWidget.DragStarted += () => EditorParams.History?.BeginTransaction();
            gradientControlWidget.DragEnded   += () => {
                EditorParams.History?.CommitTransaction();
                EditorParams.History?.EndTransaction();
            };
            colorPanel.DragEnded += () => {
                EditorParams.History?.CommitTransaction();
                EditorParams.History?.EndTransaction();
            };
            colorPanel.Changed += () => {
                EditorParams.History?.RollbackTransaction();
                Core.Operations.SetProperty.Perform(selectedControlPoint, nameof(GradientControlPoint.Color), colorPanel.Color);
            };
            SelectPoint(selectedControlPoint);
        }
Пример #6
0
        public Color4PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ColorBoxButton colorBox;

            panel = new ColorPickerPanel();
            var objects  = EditorParams.Objects.ToList();
            var first    = PropertyValue(objects.First()).GetValue();
            var @default = objects.All(o =>
                                       PropertyValue(o).GetValue().A == first.A) ? new Color4(255, 255, 255, first.A) : Color4.White;
            var currentColor = CoalescedPropertyValue(@default).DistinctUntilChanged();

            panel.Color = currentColor.GetValue().Value;
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center)
                },
                Nodes =
                {
                    (editor   = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (colorBox = new ColorBoxButton(currentColor)),
                    CreatePipetteButton(),
                    Spacer.HStretch(),
                },
            });
            ExpandableContent.AddNode(panel.Widget);
            panel.Widget.Padding += new Thickness(right: 12.0f);
            panel.Widget.Components.GetOrAdd <LateConsumeBehaviour>().Add(currentColor.Consume(v => {
                if (panel.Color != v.Value)
                {
                    panel.Color = v.Value;
                }
                Changed?.Invoke();
            }));
            panel.Changed += () => {
                EditorParams.History?.RollbackTransaction();
                if ((panel.Color.ABGR & 0xFFFFFF) == (previousColor.ABGR & 0xFFFFFF) && panel.Color.A != previousColor.A)
                {
                    SetProperty <Color4>(c => {
                        c.A = panel.Color.A;
                        return(c);
                    });
                }
                else
                {
                    SetProperty(panel.Color);
                }
            };
            panel.DragStarted += () => {
                EditorParams.History?.BeginTransaction();
                previousColor = panel.Color;
            };
            panel.DragEnded += () => {
                if (panel.Color != previousColor || (editorParams.Objects.Skip(1).Any() && SameValues()))
                {
                    EditorParams.History?.CommitTransaction();
                }
                EditorParams.History?.EndTransaction();
            };
            colorBox.Clicked += () => Expanded = !Expanded;
            var currentColorString = currentColor.Select(i => i.Value.ToString(Color4.StringPresentation.Dec));

            editor.Submitted += text => {
                SetComponent(text, currentColorString);
            };
            editor.AddChangeLateWatcher(currentColorString, v => editor.Text = SameValues() ? v : ManyValuesText);
            editor.AddChangeLateWatcher(() => editor.Text, value => CheckEditorText(value, editor));
            ManageManyValuesOnFocusChange(editor, currentColor);
        }