Example #1
0
        public QuaternionPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory())
                }
            });
            var current = CoalescedPropertyValue();

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, current.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, current.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, current.GetValue());
            editorX.AddChangeWatcher(current, v => {
                var ea       = v.ToEulerAngles() * Mathf.RadToDeg;
                editorX.Text = RoundAngle(ea.X).ToString();
                editorY.Text = RoundAngle(ea.Y).ToString();
                editorZ.Text = RoundAngle(ea.Z).ToString();
            });
        }
Example #2
0
 protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
 {
     ContainerWidget.AddNode(new Widget {
         Layout = new HBoxLayout(),
         Nodes  =
         {
             (editor         = editorParams.EditBoxFactory()),
             new HSpacer(4),
             (button         = new ThemedButton {
                 Text        = "...",
                 MinMaxWidth =                             20,
                 LayoutCell  = new LayoutCell(Alignment.Center)
             })
         }
     });
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Submitted += text => AssignAsset(AssetPath.CorrectSlashes(text));
     button.Clicked   += () => {
         var dlg = new FileDialog {
             AllowedFileTypes = allowedFileTypes,
             Mode             = FileDialogMode.Open,
             InitialDirectory = Directory.Exists(LastOpenedDirectory) ? LastOpenedDirectory : Project.Current.GetSystemDirectory(Document.Current.Path),
         };
         if (dlg.RunModal())
         {
             SetFilePath(dlg.FileName);
             LastOpenedDirectory = Project.Current.GetSystemDirectory(dlg.FileName);
         }
     };
 }
 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();
 }
Example #4
0
 public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1;
     editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0;
     ContainerWidget.AddNode(editor);
     editor.Submitted += SetProperty;
     editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v);
 }
Example #5
0
 public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.IsReadOnly = true;
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     ContainerWidget.AddNode(editor);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v =>
                             editor.Text = v == null ?
                                           "RenderTexture (null)" :
                                           $"RenderTexture ({v.ImageSize.Width}x{v.ImageSize.Height})"
                             );
 }
Example #6
0
 public BooleanPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     checkBox = new ThemedCheckBox {
         LayoutCell = new LayoutCell(Alignment.LeftCenter)
     };
     ContainerWidget.AddNode(checkBox);
     checkBox.Changed += args => {
         if (args.ChangedByUser)
         {
             SetProperty(args.Value);
         }
     };
     checkBox.AddChangeWatcher(CoalescedPropertyValue(), v => checkBox.Checked = v);
 }
Example #7
0
 public AnchorsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     group = new Widget {
         Layout = new HBoxLayout {
             CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
         }
     };
     ContainerWidget.AddNode(group);
     firstButton = AddButton(Anchors.Left, "Anchor to the left");
     AddButton(Anchors.Right, "Anchor to the right");
     AddButton(Anchors.Top, "Anchor to the top");
     AddButton(Anchors.Bottom, "Anchor to the bottom");
     AddButton(Anchors.CenterH, "Anchor to the center horizontally");
     AddButton(Anchors.CenterV, "Anchor to the center vertically");
 }
Example #8
0
        public NodeReferencePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            var propName = editorParams.PropertyName;

            if (propName.EndsWith("Ref"))
            {
                PropertyLabel.Text = propName.Substring(0, propName.Length - 3);
            }
            editor            = editorParams.EditBoxFactory();
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(editor);
            editor.Submitted += text => {
                SetProperty(new NodeReference <T>(text));
            };
            editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v?.Id);
        }
Example #9
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            ContainerWidget.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                float newValue;
                if (float.TryParse(text, out newValue))
                {
                    SetProperty(newValue);
                }

                editor.Text = current.GetValue().ToString();
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString());
        }
Example #10
0
        public NumericRangePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (medEditor  = editorParams.NumericEditBoxFactory()),
                    (dispEditor = editorParams.NumericEditBoxFactory()),
                }
            });
            var currentMed  = CoalescedPropertyComponentValue(v => v.Median);
            var currentDisp = CoalescedPropertyComponentValue(v => v.Dispersion);

            medEditor.Submitted  += text => SetComponent(editorParams, 0, medEditor, currentMed.GetValue());
            dispEditor.Submitted += text => SetComponent(editorParams, 1, dispEditor, currentDisp.GetValue());
            medEditor.AddChangeWatcher(currentMed, v => medEditor.Text    = v.ToString());
            dispEditor.AddChangeWatcher(currentDisp, v => dispEditor.Text = v.ToString());
        }
Example #11
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory())
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString());
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString());
        }
Example #12
0
        public IntPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor             = editorParams.EditBoxFactory();
            editor.MinMaxWidth = 80;
            editor.LayoutCell  = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                int newValue;
                if (int.TryParse(text, out newValue))
                {
                    SetProperty(newValue);
                }
                else
                {
                    editor.Text = current.GetValue().ToString();
                }
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString());
        }
Example #13
0
 public TriggerPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     comboBox = new ThemedComboBox {
         LayoutCell = new LayoutCell(Alignment.Center)
     };
     ContainerWidget.AddNode(comboBox);
     comboBox.Changed += ComboBox_Changed;
     if (editorParams.Objects.Count == 1)
     {
         var node = (Node)editorParams.Objects[0];
         foreach (var a in node.Animations)
         {
             foreach (var m in a.Markers.Where(i => i.Action != MarkerAction.Jump && !string.IsNullOrEmpty(i.Id)))
             {
                 var id = a.Id != null ? m.Id + '@' + a.Id : m.Id;
                 comboBox.Items.Add(new DropDownList.Item(id));
             }
         }
     }
     comboBox.AddChangeWatcher(CoalescedPropertyValue(), v => comboBox.Text = v);
 }
Example #14
0
        public EnumPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            Selector            = editorParams.DropDownListFactory();
            Selector.LayoutCell = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(Selector);
            var propType      = editorParams.PropertyInfo.PropertyType;
            var fields        = propType.GetFields(BindingFlags.Public | BindingFlags.Static);
            var allowedFields = fields.Where(f => !Attribute.IsDefined(f, typeof(TangerineIgnoreAttribute)));

            foreach (var field in allowedFields)
            {
                Selector.Items.Add(new CommonDropDownList.Item(field.Name, field.GetValue(null)));
            }
            Selector.Changed += a => {
                if (a.ChangedByUser)
                {
                    SetProperty((T)Selector.Items[a.Index].Value);
                }
            };
            Selector.AddChangeWatcher(CoalescedPropertyValue(), v => Selector.Value = v);
        }
Example #15
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));
        }
Example #16
0
            public BlendingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
            {
                editor             = editorParams.NumericEditBoxFactory();
                editor.Step        = 1f;
                editor.MinMaxWidth = 80;
                editor.LayoutCell  = new LayoutCell(Alignment.Center);
                ContainerWidget.AddNode(editor);
                var current = CoalescedPropertyValue();

                editor.Submitted += text => {
                    int newValue;
                    if (int.TryParse(text, out newValue))
                    {
                        SetProperty(new BlendingOption(newValue));
                    }
                    else
                    {
                        editor.Text = current.GetValue().DurationInFrames.ToString();
                    }
                };
                editor.AddChangeWatcher(current, v => editor.Text = v?.DurationInFrames.ToString() ?? "0");
            }
Example #17
0
        public FontPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            selector            = editorParams.DropDownListFactory();
            selector.LayoutCell = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(selector);
            var propType = editorParams.PropertyInfo.PropertyType;
            var items    = AssetBundle.Current.EnumerateFiles("Fonts").
                           Where(i => i.EndsWith(".fnt") || i.EndsWith(".tft")).
                           Select(i => new DropDownList.Item(Path.ChangeExtension(Path.GetFileName(i), null)));

            foreach (var i in items)
            {
                selector.Items.Add(i);
            }
            selector.Text     = GetFontName(CoalescedPropertyValue().GetValue());
            selector.Changed += a => {
                SetProperty(new SerializableFont((string)a.Value));
            };
            selector.AddChangeWatcher(CoalescedPropertyValue(), i => {
                selector.Text = GetFontName(i);
            });
        }