/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = TextBox.DefaultHeight; gridControl.SlotsHorizontally = 2; gridControl.SlotsVertically = 1; LimitAttribute limit = null; var attributes = Values.GetAttributes(); if (attributes != null) { limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute); } XElement = grid.FloatValue(); XElement.SetLimits(limit); XElement.FloatValue.ValueChanged += OnValueChanged; XElement.FloatValue.SlidingEnd += ClearToken; YElement = grid.FloatValue(); YElement.SetLimits(limit); YElement.FloatValue.ValueChanged += OnValueChanged; YElement.FloatValue.SlidingEnd += ClearToken; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <GridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = TextBox.DefaultHeight; gridControl.RowFill = new[] { 1.0f, }; gridControl.ColumnFill = new[] { 0.9f, 0.1f }; _element = grid.Custom <InputBindingBox>(); SetText(); _element.CustomControl.WatermarkText = "Type a binding"; _element.CustomControl.EditEnd += OnValueChanged; var button = grid.Button("X"); button.Button.TooltipText = "Remove binding"; button.Button.Clicked += OnXButtonClicked; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = TextBox.DefaultHeight; gridControl.SlotsHorizontally = 4; gridControl.SlotsVertically = 1; Major = grid.IntegerValue(); Major.IntValue.SetLimits(0, 100000000); Major.IntValue.ValueChanged += OnValueChanged; Major.IntValue.SlidingEnd += ClearToken; Minor = grid.IntegerValue(); Minor.IntValue.SetLimits(0, 100000000); Minor.IntValue.ValueChanged += OnValueChanged; Minor.IntValue.SlidingEnd += ClearToken; Build = grid.IntegerValue(); Build.IntValue.SetLimits(-1, 100000000); Build.IntValue.ValueChanged += OnValueChanged; Build.IntValue.SlidingEnd += ClearToken; Revision = grid.IntegerValue(); Revision.IntValue.SetLimits(-1, 100000000); Revision.IntValue.ValueChanged += OnValueChanged; Revision.IntValue.SlidingEnd += ClearToken; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = TextBox.DefaultHeight * 4; gridControl.SlotsHorizontally = 4; gridControl.SlotsVertically = 4; LimitAttribute limit = null; if (Values.Info != null) { var attributes = Values.Info.GetCustomAttributes(true); limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute); } for (int i = 0; i < 16; i++) { var elemnt = grid.FloatValue(); elemnt.SetLimits(limit); elemnt.FloatValue.ValueChanged += OnValueChanged; elemnt.FloatValue.SlidingEnd += ClearToken; Elements[i] = elemnt; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.Height = TextBox.DefaultHeight; gridControl.SlotsHorizontally = 4; gridControl.SlotsVertically = 1; LimitAttribute limit = null; if (Values.Info != null) { var attributes = Values.Info.GetCustomAttributes(true); limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute); } xElement = grid.FloatValue(); xElement.SetLimits(limit); xElement.FloatValue.ValueChanged += OnValueChanged; yElement = grid.FloatValue(); yElement.SetLimits(limit); yElement.FloatValue.ValueChanged += OnValueChanged; zElement = grid.FloatValue(); zElement.SetLimits(limit); zElement.FloatValue.ValueChanged += OnValueChanged; wElement = grid.FloatValue(); wElement.SetLimits(limit); wElement.FloatValue.ValueChanged += OnValueChanged; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var item = layout.CustomContainer <BezierCurveEditor <T> >(); _curve = item.CustomControl; _curve.Height = 120.0f; _curve.Edited += OnCurveEdited; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { layout.Space(10); var grid = layout.CustomContainer <UniformGridPanel>(); grid.CustomControl.SlotsHorizontally = 2; grid.CustomControl.SlotsVertically = 1; grid.Button("Set Linear Tangents").Button.Clicked += OnSetTangentsLinear; grid.Button("Set Smooth Tangents").Button.Clicked += OnSetTangentsSmooth; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { float trackBallSize = 80.0f; float margin = 4.0f; // Panel var masterPanel = layout.CustomContainer <GridPanel>(); var masterPanelControl = masterPanel.CustomControl; masterPanelControl.ClipChildren = false; masterPanelControl.SlotPadding = new Margin(0, 0, margin, margin); masterPanelControl.Height = trackBallSize + margin + margin; masterPanelControl.ColumnFill = new[] { -trackBallSize, 1.0f }; masterPanelControl.RowFill = new[] { 1.0f }; // Trackball _trackball = masterPanel.Custom <ColorSelector>(); _trackball.CustomControl.ColorChanged += OnColorWheelChanged; _trackball.CustomControl.SlidingEnd += ClearToken; // Scale editor { var grid = masterPanel.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.SlotPadding = new Margin(4, 2, 2, 2); gridControl.ClipChildren = false; gridControl.SlotsHorizontally = 1; gridControl.SlotsVertically = 4; LimitAttribute limit = null; var attributes = Values.GetAttributes(); if (attributes != null) { limit = (LimitAttribute)attributes.FirstOrDefault(x => x is LimitAttribute); } _xElement = CreateFloatEditor(grid, limit, Color.Red); _yElement = CreateFloatEditor(grid, limit, Color.Green); _zElement = CreateFloatEditor(grid, limit, Color.Blue); _wElement = CreateFloatEditor(grid, limit, Color.White); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.Height = TextBox.DefaultHeight; gridControl.SlotsHorizontally = 3; gridControl.SlotsVertically = 1; XElement = grid.FloatValue(); XElement.FloatValue.ValueChanged += OnValueChanged; YElement = grid.FloatValue(); YElement.FloatValue.ValueChanged += OnValueChanged; ZElement = grid.FloatValue(); ZElement.FloatValue.ValueChanged += OnValueChanged; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Check for prefab link if (Values.IsSingleObject && Values[0] is Actor actor && actor.HasPrefabLink) { // TODO: consider editing more than one instance of the same prefab asset at once var prefab = FlaxEngine.Content.LoadAsync <Prefab>(actor.PrefabID); // TODO: don't stall here? if (prefab && !prefab.WaitForLoaded()) { var prefabObjectId = actor.PrefabObjectID; var prefabInstance = Prefab.Internal_GetDefaultInstance(prefab.unmanagedPtr, ref prefabObjectId); if (prefabInstance != null) { // Use default prefab instance as a reference for the editor Values.SetReferenceValue(prefabInstance); // Add some UI var panel = layout.CustomContainer <UniformGridPanel>(); panel.CustomControl.Height = 20.0f; panel.CustomControl.SlotsVertically = 1; panel.CustomControl.SlotsHorizontally = 2; // Selecting actor prefab asset var selectPrefab = panel.Button("Select Prefab"); selectPrefab.Button.Clicked += () => Editor.Instance.Windows.ContentWin.Select(prefab); // Viewing changes applied to this actor var viewChanges = panel.Button("View Changes"); viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Vector2(0.0f, 20.0f)); // Link event to update editor on prefab apply _linkedPrefabId = prefab.ID; Editor.Instance.Prefabs.PrefabApplying += OnPrefabApplying; Editor.Instance.Prefabs.PrefabApplied += OnPrefabApplied; } } } base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var grid = layout.CustomContainer <UniformGridPanel>(); var gridControl = grid.CustomControl; gridControl.ClipChildren = false; gridControl.Height = TextBox.DefaultHeight; gridControl.SlotsHorizontally = 3; gridControl.SlotsVertically = 1; XElement = grid.FloatValue(); XElement.ValueBox.ValueChanged += OnValueChanged; XElement.ValueBox.SlidingEnd += ClearToken; YElement = grid.FloatValue(); YElement.ValueBox.ValueChanged += OnValueChanged; YElement.ValueBox.SlidingEnd += ClearToken; ZElement = grid.FloatValue(); ZElement.ValueBox.ValueChanged += OnValueChanged; ZElement.ValueBox.SlidingEnd += ClearToken; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Check for prefab link if (Values.IsSingleObject && Values[0] is Actor actor && actor.HasPrefabLink) { // TODO: consider editing more than one instance of the same prefab asset at once var prefab = FlaxEngine.Content.LoadAsync <Prefab>(actor.PrefabID); // TODO: don't stall here? if (prefab && !prefab.WaitForLoaded()) { var prefabObjectId = actor.PrefabObjectID; var prefabInstance = prefab.GetDefaultInstance(ref prefabObjectId); if (prefabInstance != null) { // Use default prefab instance as a reference for the editor Values.SetReferenceValue(prefabInstance); // Add some UI var panel = layout.CustomContainer <UniformGridPanel>(); panel.CustomControl.Height = 20.0f; panel.CustomControl.SlotsVertically = 1; panel.CustomControl.SlotsHorizontally = 2; // Selecting actor prefab asset var selectPrefab = panel.Button("Select Prefab"); selectPrefab.Button.Clicked += () => Editor.Instance.Windows.ContentWin.Select(prefab); // Viewing changes applied to this actor var viewChanges = panel.Button("View Changes"); viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Vector2(0.0f, 20.0f)); // Link event to update editor on prefab apply _linkedPrefabId = prefab.ID; Editor.Instance.Prefabs.PrefabApplying += OnPrefabApplying; Editor.Instance.Prefabs.PrefabApplied += OnPrefabApplied; } } } base.Initialize(layout); // Add custom settings button to General group for (int i = 0; i < layout.Children.Count; i++) { if (layout.Children[i] is GroupElement group && group.Panel.HeaderText == "General") { const float settingsButtonSize = 14; var settingsButton = new Image { TooltipText = "Settings", AutoFocus = true, AnchorPreset = AnchorPresets.TopRight, Parent = group.Panel, Bounds = new Rectangle(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize), IsScrollable = false, Color = FlaxEngine.GUI.Style.Current.ForegroundGrey, Margin = new Margin(1), Brush = new SpriteBrush(FlaxEngine.GUI.Style.Current.Settings), }; settingsButton.Clicked += OnSettingsButtonClicked; break; } } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _scripts.Clear(); // Area for drag&drop scripts var dragArea = layout.CustomContainer <DragAreaControl>(); dragArea.CustomControl.ScriptsEditor = this; // No support to show scripts for more than one actor selected // TODO: support showing scripts from objects that has the same scripts layout if (Values.Count != 1) { return; } // Scripts arrange bar var dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(0, this); // Scripts var scripts = (Script[])Values[0]; _scripts.AddRange(scripts); var elementType = typeof(Script); for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; if (script == null) { AddMissingScript(i, layout); continue; } var values = new ListValueContainer(elementType, i, Values); var type = script.GetType(); var editor = CustomEditorsUtil.CreateEditor(type, false); // Create group var title = CustomEditorsUtil.GetPropertyNameUI(type.Name); var group = layout.Group(title); group.Panel.Open(false); // Customize var typeAttributes = type.GetCustomAttributes(true); var tooltip = (TooltipAttribute)typeAttributes.FirstOrDefault(x => x is TooltipAttribute); if (tooltip != null) { group.Panel.TooltipText = tooltip.Text; } // Add toggle button to the group var scriptToggle = new CheckBox(2, 0, script.Enabled) { TooltipText = "If checked, script will be enabled", IsScrollable = false, Size = new Vector2(14, 14), BoxSize = 12.0f, Tag = script, Parent = group.Panel }; scriptToggle.StateChanged += ScriptToggleOnCheckChanged; // Add drag button to the group const float dragIconSize = 14; var scriptDrag = new ScriptDragIcon(this, script, scriptToggle.Right, 0.5f, dragIconSize) { TooltipText = "Script reference", CanFocus = true, IsScrollable = false, Color = new Color(0.7f), Margin = new Margin(1), ImageSource = new SpriteImageSource(Editor.Instance.UI.DragBar12), Tag = script, Parent = group.Panel }; // Add settings button to the group const float settingsButtonSize = 14; var settingsButton = new Image(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize) { TooltipText = "Settings", CanFocus = true, AnchorStyle = AnchorStyle.UpperRight, IsScrollable = false, Color = new Color(0.7f), Margin = new Margin(1), ImageSource = new SpriteImageSource(FlaxEngine.GUI.Style.Current.Settings), Tag = script, Parent = group.Panel }; settingsButton.Clicked += SettingsButtonOnClicked; group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2); group.Object(values, editor); // Scripts arrange bar dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(i + 1, this); } base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _readOnly = false; _canReorderItems = true; _notNullItems = false; // No support for different collections for now if (HasDiffrentValues || HasDiffrentTypes) { return; } var type = Values.Type; var size = Count; // Try get MemberCollectionAttribute for collection editor meta if (Values.Info != null) { var attributes = Values.Info.GetCustomAttributes(true); var memberCollection = (MemberCollectionAttribute)attributes.FirstOrDefault(x => x is MemberCollectionAttribute); if (memberCollection != null) { // TODO: handle ReadOnly and NotNullItems by filtering child editors SetValue // TODO: handle CanReorderItems _readOnly = memberCollection.ReadOnly; _canReorderItems = memberCollection.CanReorderItems; _notNullItems = memberCollection.NotNullItems; } } // Size if (_readOnly) { layout.Label("Size", size.ToString()); } else { _size = layout.IntegerValue("Size"); _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = ushort.MaxValue; _size.IntValue.Value = size; _size.IntValue.ValueChanged += OnSizeChanged; } // Elements if (size > 0) { var argTypes = type.GetGenericArguments(); var keyType = argTypes[0]; var valueType = argTypes[1]; var keysEnumerable = ((IDictionary)Values[0]).Keys.OfType <object>(); var keys = keysEnumerable as object[] ?? keysEnumerable.ToArray(); for (int i = 0; i < size; i++) { var item = layout.CustomContainer <UniformGridPanel>(); var itemGrid = item.CustomControl; itemGrid.Height = TextBox.DefaultHeight;// TODO: make slots auto sizable instead of fixed height itemGrid.SlotsHorizontally = 2; itemGrid.SlotsVertically = 1; // Key // TODO: allow edit keys var key = keys.ElementAt(i); item.Label(key.ToString()); // Value item.Object(new DictionaryValueContainer(valueType, key, Values)); } } _elementsCount = size; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Area for drag&drop scripts var dragArea = layout.CustomContainer <DragAreaControl>(); dragArea.CustomControl.ScriptsEditor = this; // No support for showing scripts from multiple actors that have different set of scripts var scripts = (Script[])Values[0]; _scripts.Clear(); _scripts.AddRange(scripts); for (int i = 1; i < Values.Count; i++) { var e = (Script[])Values[i]; if (scripts.Length != e.Length) { return; } for (int j = 0; j < e.Length; j++) { var t1 = scripts[j]?.TypeName; var t2 = e[j]?.TypeName; if (t1 != t2) { return; } } } // Scripts arrange bar var dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(0, this); // Scripts var elementType = new ScriptType(typeof(Script)); _scriptToggles = new CheckBox[scripts.Length]; for (int i = 0; i < scripts.Length; i++) { var script = scripts[i]; if (script == null) { AddMissingScript(i, layout); continue; } var values = new ScriptsContainer(elementType, i, Values); var scriptType = TypeUtils.GetObjectType(script); var editor = CustomEditorsUtil.CreateEditor(scriptType, false); // Create group var title = Utilities.Utils.GetPropertyNameUI(scriptType.Name); var group = layout.Group(title, editor); if ((Presenter.Features & FeatureFlags.CacheExpandedGroups) != 0) { if (Editor.Instance.ProjectCache.IsCollapsedGroup(title)) { group.Panel.Close(false); } else { group.Panel.Open(false); } group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed); } else { group.Panel.Open(false); } // Customize group.Panel.TooltipText = Editor.Instance.CodeDocs.GetTooltip(scriptType); if (script.HasPrefabLink) { group.Panel.HeaderTextColor = FlaxEngine.GUI.Style.Current.ProgressNormal; } // Add toggle button to the group var scriptToggle = new CheckBox { TooltipText = "If checked, script will be enabled.", IsScrollable = false, Checked = script.Enabled, Parent = group.Panel, Size = new Float2(14, 14), Bounds = new Rectangle(2, 0, 14, 14), BoxSize = 12.0f, Tag = script, }; scriptToggle.StateChanged += OnScriptToggleCheckChanged; _scriptToggles[i] = scriptToggle; // Add drag button to the group const float dragIconSize = 14; var scriptDrag = new ScriptDragIcon(this, script) { TooltipText = "Script reference", AutoFocus = true, IsScrollable = false, Color = FlaxEngine.GUI.Style.Current.ForegroundGrey, Parent = group.Panel, Bounds = new Rectangle(scriptToggle.Right, 0.5f, dragIconSize, dragIconSize), Margin = new Margin(1), Brush = new SpriteBrush(Editor.Instance.Icons.DragBar12), Tag = script, }; // Add settings button to the group const float settingsButtonSize = 14; var settingsButton = new Image { TooltipText = "Settings", AutoFocus = true, AnchorPreset = AnchorPresets.TopRight, Parent = group.Panel, Bounds = new Rectangle(group.Panel.Width - settingsButtonSize, 0, settingsButtonSize, settingsButtonSize), IsScrollable = false, Color = FlaxEngine.GUI.Style.Current.ForegroundGrey, Margin = new Margin(1), Brush = new SpriteBrush(FlaxEngine.GUI.Style.Current.Settings), Tag = script, }; settingsButton.Clicked += OnSettingsButtonClicked; group.Panel.HeaderTextMargin = new Margin(scriptDrag.Right, 15, 2, 2); group.Object(values, editor); // Scripts arrange bar dragBar = layout.Custom <ScriptArrangeBar>(); dragBar.CustomControl.Init(i + 1, this); } base.Initialize(layout); }