Esempio n. 1
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);
         }
     };
 }
Esempio n. 2
0
        public TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ThemedButton button;

            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Editor.EditorParams.MaxLines = maxLines;
            editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1);
            var first     = true;
            var submitted = false;
            var current   = CoalescedPropertyValue();

            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
            button.Clicked += () => {
                var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => {
                    SetProperty(s);
                });
            };
            editor.Submitted += text => Submit();
            editor.AddChangeLateWatcher(() => editor.Text, text => {
                if (first)
                {
                    first = false;
                    return;
                }
                if (!editor.IsFocused())
                {
                    return;
                }
                if (submitted)
                {
                    Document.Current.History.Undo();
                }
                submitted = true;
                Submit();
            });
            editor.AddChangeLateWatcher(() => editor.IsFocused(), focused => {
                if (submitted)
                {
                    Document.Current.History.Undo();
                }
                if (!focused)
                {
                    submitted = false;
                }
            });
            ManageManyValuesOnFocusChange(editor, current);
        }
Esempio n. 3
0
        public EnumPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            Selector            = editorParams.DropDownListFactory();
            Selector.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(Selector);
            var propType      = editorParams.PropertyInfo.PropertyType;
            var fields        = propType.GetFields(BindingFlags.Public | BindingFlags.Static);
            var allowedFields = fields.Where(f => !Attribute.IsDefined((MemberInfo)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.AddChangeLateWatcher(CoalescedPropertyValue(), v => {
                if (v.IsDefined)
                {
                    Selector.Value = v.Value;
                }
                else
                {
                    Selector.Text = ManyValuesText;
                }
            });
        }
        private static Widget CreateValueEditor(
            IPropertyEditorParams editorParams,
            KeyValuePair keyValue,
            Func <Type, PropertyEditorParams, Widget, object, IEnumerable <IPropertyEditor> > populateEditors,
            PropertySetterDelegate setter = null
            )
        {
            var valueContainer = new Widget {
                Layout = new HBoxLayout()
            };
            var valuePropertyEditorParams = new PropertyEditorParams(
                valueContainer,
                new object[] { keyValue },
                editorParams.RootObjects,
                typeof(KeyValuePair),
                "Value",
                "Value"
                )
            {
                History = editorParams.History,
            };

            if (setter != null)
            {
                valuePropertyEditorParams.PropertySetter = setter;
            }
            var valueEditor = populateEditors(typeof(KeyValuePair), valuePropertyEditorParams, valueContainer, keyValue).First();

            // Hack in order to keep same background for KeyValue pair.
            valueEditor.ContainerWidget.CompoundPresenter.RemoveAt(valueEditor.ContainerWidget.CompoundPresenter.Count - 1);
            valueEditor.ContainerWidget.Padding = new Thickness(0f, 0f, 0f, 0f);
            return(valueContainer);
        }
Esempio n. 5
0
        public ThicknessPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorLeft   = editorParams.NumericEditBoxFactory()),
                    (editorRight  = editorParams.NumericEditBoxFactory()),
                    (editorTop    = editorParams.NumericEditBoxFactory()),
                    (editorBottom = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentLeft   = CoalescedPropertyComponentValue(v => v.Left);
            var currentRight  = CoalescedPropertyComponentValue(v => v.Right);
            var currentTop    = CoalescedPropertyComponentValue(v => v.Top);
            var currentBottom = CoalescedPropertyComponentValue(v => v.Bottom);

            editorLeft.Submitted   += text => SetComponent(editorParams, 0, editorLeft, currentLeft.GetValue());
            editorRight.Submitted  += text => SetComponent(editorParams, 1, editorRight, currentRight.GetValue());
            editorTop.Submitted    += text => SetComponent(editorParams, 2, editorTop, currentTop.GetValue());
            editorBottom.Submitted += text => SetComponent(editorParams, 3, editorBottom, currentBottom.GetValue());
            editorLeft.AddChangeLateWatcher(currentLeft, v => editorLeft.Text       = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorRight.AddChangeLateWatcher(currentRight, v => editorRight.Text    = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorTop.AddChangeLateWatcher(currentTop, v => editorTop.Text          = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorBottom.AddChangeLateWatcher(currentBottom, v => editorBottom.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorLeft, currentLeft);
            ManageManyValuesOnFocusChange(editorRight, currentRight);
            ManageManyValuesOnFocusChange(editorTop, currentTop);
            ManageManyValuesOnFocusChange(editorBottom, currentBottom);
        }
Esempio n. 6
0
 public TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new Widget {
         Layout = new HBoxLayout(),
         Nodes  =
         {
             (editor         = editorParams.EditBoxFactory()),
             Spacer.HSpacer(4),
             (button         = new ThemedButton {
                 Text        = "...",
                 MinMaxWidth =                             20,
                 LayoutCell  = new LayoutCell(Alignment.Center)
             })
         }
     });
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = maxLines;
     editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1);
     editor.Submitted += text => SetProperty(text);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v);
     button.Clicked += () => {
         var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => {
             SetProperty(s);
         });
     };
 }
 void SetComponent(IPropertyEditorParams editorParams, int component, NumericEditBox editor, CoalescedValue <float> currentValue)
 {
     if (Parser.TryParse(editor.Text, out double newValue))
     {
         DoTransaction(() => {
             SetProperty <NumericRange>(current => {
                 if (component == 0)
                 {
                     current.Median = (float)newValue;
                 }
                 else
                 {
                     current.Dispersion = (float)newValue;
                 }
                 return(current);
             });
         });
         editor.Text = newValue.ToString("0.###");
     }
     else
     {
         editor.Text = currentValue.IsDefined
                                         ? currentValue.Value.ToString("0.###")
                                         : ManyValuesText;
     }
 }
Esempio n. 8
0
        public QuaternionPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            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("0.###");
                editorY.Text = RoundAngle(ea.Y).ToString("0.###");
                editorZ.Text = RoundAngle(ea.Z).ToString("0.###");
            });
        }
Esempio n. 9
0
        public FontPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            selector            = editorParams.DropDownListFactory();
            selector.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(selector);
            var propType = editorParams.PropertyInfo.PropertyType;
            var items    = AssetBundle.Current.EnumerateFiles(defaultFontDirectory).
                           Where(i => i.EndsWith(".fnt") || i.EndsWith(".tft") || i.EndsWith(".cft")).
                           Select(i => new DropDownList.Item(FontPool.ExtractFontNameFromPath(i, defaultFontDirectory)));

            foreach (var i in items)
            {
                selector.Items.Add(i);
            }

            var current = CoalescedPropertyValue().GetValue();

            selector.Text     = current.IsDefined ? GetFontName(current.Value) : ManyValuesText;
            selector.Changed += a => {
                SetProperty(new SerializableFont((string)a.Value));
            };
            selector.AddChangeLateWatcher(CoalescedPropertyValue(), i => {
                selector.Text = i.IsDefined ? GetFontName(i.Value): ManyValuesText;
            });
        }
Esempio n. 10
0
 public CommonPropertyEditor(IPropertyEditorParams editorParams)
 {
     EditorParams    = editorParams;
     ContainerWidget = new Widget {
         Layout = new HBoxLayout {
             IgnoreHidden = false
         },
         LayoutCell = new LayoutCell {
             StretchY = 0
         },
     };
     editorParams.InspectorPane.AddNode(ContainerWidget);
     if (editorParams.ShowLabel)
     {
         PropertyLabel = new ThemedSimpleText {
             Text           = editorParams.DisplayName ?? editorParams.PropertyName,
             VAlignment     = VAlignment.Center,
             LayoutCell     = new LayoutCell(Alignment.LeftCenter, stretchX: 0),
             ForceUncutText = false,
             MinWidth       = 120,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = true,
             TabTravesable  = new TabTraversable()
         };
         PropertyLabel.Tasks.Add(ManageLabelTask());
         ContainerWidget.AddNode(PropertyLabel);
     }
 }
Esempio n. 11
0
        void SetComponent(IPropertyEditorParams editorParams, int component, NumericEditBox editor, float currentValue)
        {
            float newValue;

            if (float.TryParse(editor.Text, out newValue))
            {
                foreach (var obj in editorParams.Objects)
                {
                    var current = new Property <NumericRange>(obj, editorParams.PropertyName).Value;
                    if (component == 0)
                    {
                        current.Median = newValue;
                    }
                    else
                    {
                        current.Dispersion = newValue;
                    }
                    editorParams.PropertySetter(obj, editorParams.PropertyName, current);
                }
            }
            else
            {
                editor.Text = currentValue.ToString();
            }
        }
        public ShortcutPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor            = editorParams.EditBoxFactory();
            editor.Updating  += Updating;
            editor.Updated   += Updated;
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.AddChangeLateWatcher(CoalescedPropertyValue(), v => {
                var text    = v.Value.ToString();
                editor.Text = v.IsDefined ? v.Value.Main != Key.Unknown ? text : text.Replace("Unknown", "") : ManyValuesText;
            });
            editor.IsReadOnly = true;
            editor.TextWidget.Tasks.Clear();
            editor.TextWidget.Position = new Vector2(0, editor.MinHeight / 2);
            editor.TextWidget.Padding  = new Thickness(5, 0);
            editor.Gestures.Add(new ClickGesture(() => editor.SetFocus()));
            editor.Gestures.Add(new ClickGesture(1, () => {
                main      = Key.Unknown;
                modifiers = Modifiers.None;
                SetValue(new Shortcut(modifiers, main));
            }));
            editor.AddToNode(EditorContainer);

            PropertyLabel.Tasks.Clear();
            PropertyLabel.Tasks.Add(ManageLabelFocus());
            ContainerWidget.Tasks.Add(ManageFocusTask());

            var value = CoalescedPropertyValue().GetValue();

            main              = value.Value.Main;
            modifiers         = value.Value.Modifiers;
            flatFillPresenter = new WidgetFlatFillPresenter(Theme.Colors.GrayBackground);
            ContainerWidget.CompoundPresenter.Add(flatFillPresenter);
        }
Esempio n. 13
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    //new SimpleText { Text = "X" },
                    (editorX = editorParams.NumericEditBoxFactory()),
                    // new SimpleText { Text = "Y" },
                    (editorY = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            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.AddChangeLateWatcher(currentX, v => editorX.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorY.AddChangeLateWatcher(currentY, v => editorY.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorX, currentX);
            ManageManyValuesOnFocusChange(editorY, currentY);
        }
Esempio n. 14
0
        public Vector3PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);
            var currentZ = CoalescedPropertyComponentValue(v => v.Z);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, currentZ.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString("0.###"));
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString("0.###"));
            editorZ.AddChangeWatcher(currentZ, v => editorZ.Text = v.ToString("0.###"));
        }
        public DictionaryPropertyEditor(IPropertyEditorParams editorParams, Func <Type, PropertyEditorParams, Widget, object, IEnumerable <IPropertyEditor> > populateEditors) : base(editorParams)
        {
            if (EditorParams.Objects.Skip(1).Any())
            {
                EditorContainer.AddNode(new Widget()
                {
                    Layout = new HBoxLayout(),
                    Nodes  = { new ThemedSimpleText {
                                   Text = "Edit of dictionary properties isn't supported for multiple selection.", ForceUncutText = false
                               } },
                    Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground)
                });
                return;
            }
            this.populateEditors = populateEditors;
            dictionary           = PropertyValue(EditorParams.Objects.First()).GetValue();
            var addButton = new ThemedAddButton {
                Clicked = () => {
                    if (dictionary == null)
                    {
                        var pi = EditorParams.PropertyInfo;
                        var o  = EditorParams.Objects.First();
                        pi.SetValue(o, dictionary = Activator.CreateInstance <TDictionary>());
                    }
                    if (dictionary.ContainsKey(keyValueToAdd.Key))
                    {
                        AddWarning($"Key \"{keyValueToAdd.Key}\" already exists.", ValidationResult.Warning);
                        return;
                    }
                    using (Document.Current.History.BeginTransaction()) {
                        InsertIntoDictionary <TDictionary, string, TValue> .Perform(dictionary, keyValueToAdd.Key,
                                                                                    keyValueToAdd.Value);

                        ExpandableContent.Nodes.Add(CreateDefaultKeyValueEditor(keyValueToAdd.Key,
                                                                                keyValueToAdd.Value));
                        Document.Current.History.CommitTransaction();
                    }
                    keyValueToAdd.Value = DefaultValue;
                    keyValueToAdd.Key   = string.Empty;
                },
                LayoutCell = new LayoutCell(Alignment.LeftCenter),
            };
            var keyEditorContainer = CreateKeyEditor(editorParams, keyValueToAdd, s => keyValueToAdd.Key = s, addButton);

            ExpandableContent.Nodes.Add(keyEditorContainer);
            ExpandableContent.Nodes.Add(CreateValueEditor(editorParams, keyValueToAdd, populateEditors));
            Rebuild();
            EditorContainer.Tasks.AddLoop(() => {
                if (dictionary != null && ((ICollection)dictionary).Count != pairs.Count)
                {
                    Rebuild();
                }
            });
            var current = PropertyValue(EditorParams.Objects.First());

            ContainerWidget.AddChangeWatcher(() => current.GetValue(), d => {
                dictionary = d;
                Rebuild();
            });
        }
Esempio n. 16
0
 public TriggerPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     comboBox = new ThemedComboBox {
         LayoutCell = new LayoutCell(Alignment.Center)
     };
     EditorContainer.AddNode(comboBox);
     EditorContainer.AddNode(Spacer.HStretch());
     comboBox.Changed += ComboBox_Changed;
     foreach (var obj in editorParams.Objects)
     {
         var node = (Node)obj;
         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;
                 if (!comboBox.Items.Any(i => i.Text == id))
                 {
                     comboBox.Items.Add(new DropDownList.Item(id));
                 }
             }
         }
     }
     comboBox.AddChangeWatcher(CoalescedPropertyValue(), v => comboBox.Text = v);
 }
 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();
 }
Esempio n. 18
0
        protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Submitted += text => SetComponent(text);
            bool textValid = true;

            editor.AddChangeWatcher(() => editor.Text, text => textValid = IsValid(text));
            editor.CompoundPostPresenter.Add(new SyncDelegatePresenter <EditBox>(editBox => {
                if (!textValid)
                {
                    editBox.PrepareRendererState();
                    Renderer.DrawRect(Vector2.Zero, editBox.Size, Color4.Red.Transparentify(0.8f));
                }
            }));
            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);
                }
            };
            ExpandableContent.Padding = new Thickness(24, 10, 2, 2);
            var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix))
            {
                LabelWidth = 180
            });

            prefix.Prefix = GetLongestCommonPrefix(GetPaths());
            ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => {
                string oldPrefix = GetLongestCommonPrefix(GetPaths());
                if (oldPrefix == v)
                {
                    return;
                }
                SetPathPrefix(oldPrefix, v);
                prefix.Prefix = v.Trim('/');
            });
        }
Esempio n. 19
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current);
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString("0.###"));
        }
Esempio n. 20
0
 public RenderTargetPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     Selector.Items[1].Text += SmallTexDesc;
     Selector.Items[2].Text += SmallTexDesc;
     Selector.Items[3].Text += MiddleTexDesc;
     Selector.Items[4].Text += LargeTexDesc;
     Selector.Items[5].Text += LargeTexDesc;
     Selector.Items[6].Text += LargeTexDesc;
     Selector.Items[7].Text += LargeTexDesc;
 }
Esempio n. 21
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);
 }
Esempio n. 22
0
 public NodeIdPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = 1;
     EditorContainer.AddNode(editor);
     editor.Submitted += SetValue;
     editor.AddChangeLateWatcher(CoalescedPropertyValue(), v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
     ManageManyValuesOnFocusChange(editor, CoalescedPropertyValue());
 }
Esempio n. 23
0
        public static IDataflowProvider <R> GetProvider <R>(IPropertyEditorParams context, Func <IKeyframe, R> selector)
        {
            IDataflowProvider <R> provider = null;

            foreach (var obj in context.RootObjects)
            {
                var p = new DataflowProvider <IKeyframe>(() => new KeyframeDataflow(obj, context.PropertyPath)).Select(selector);
                provider = (provider == null) ? p : provider.SameOrDefault(p);
            }
            return(provider);
        }
Esempio n. 24
0
 public BlendingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     foreach (var item in Selector.Items)
     {
         string photoshopAnalog;
         if (blendingToPhotoshopAnalog.TryGetValue(item.Text, out photoshopAnalog))
         {
             item.Text += $" ({photoshopAnalog})";
         }
     }
 }
Esempio n. 25
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current.GetValue());
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Esempio n. 26
0
		public AnchorsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
		{
			group = new Widget { Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4 } };
			EditorContainer.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");
			group.AddNode(Spacer.HStretch());
		}
Esempio n. 27
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})"
                             );
 }
 public BezierEasingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new EasingEditorPanel(this, CoalescedPropertyValue(), (BezierEasing p) => SetProperty(p)).Widget);
     EditorContainer.Gestures.Add(new ClickGesture(1, () => {
         var reset = new Command("Reset", () => {
             DoTransaction(() => SetProperty <BezierEasing>(_ => BezierEasing.Default));
         });
         new Menu {
             reset
         }.Popup();
     }));
 }
Esempio n. 29
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;
            EditorContainer.AddNode(editor);
            editor.Submitted += text => SetProperty(text);
            var current = CoalescedPropertyValue();

            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Esempio n. 30
0
 public AlignmentPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     EditorContainer.AddNode(new Widget {
         Layout = new HBoxLayout {
             DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
         },
         Nodes =
         {
             (selectorH = editorParams.DropDownListFactory()),
             (selectorV = editorParams.DropDownListFactory())
         }
     });
     var items = new [] {