public NodeComponentCollectionRow( Model3DAttachment.NodeComponentCollection source, ObservableCollection <Model3DAttachment.NodeComponentCollection> sourceCollection) : base(source, sourceCollection) { Layout = new VBoxLayout(); var expandedButton = new ThemedExpandButton { MinMaxSize = new Vector2(AttachmentMetrics.ExpandButtonSize), Anchors = Anchors.Left }; Padding = new Thickness(AttachmentMetrics.Spacing); Header.Nodes.Add(expandedButton); var nodeIdPropEditor = new StringPropertyEditor( Decorate(new PropertyEditorParams( Header, source, nameof(Model3DAttachment.NodeComponentCollection.NodeId)))); nodeIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth; var expandableContentWrapper = new Widget { Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }, LayoutCell = new LayoutCell { StretchY = 0 }, Padding = new Thickness { Left = AttachmentMetrics.ExpandContentPadding, Top = AttachmentMetrics.Spacing, Bottom = AttachmentMetrics.Spacing }, Visible = false, }; if (source.Components == null) { source.Components = new ObservableCollection <NodeComponent>(); } BuildList(source.Components, expandableContentWrapper); Nodes.Add(expandableContentWrapper); expandableContentWrapper.AddChangeWatcher( () => expandedButton.Expanded, (v) => expandableContentWrapper.Visible = v); CompoundPresenter.Add(Presenters.StripePresenter); }
private static Widget CreateFoldButton(Widget container) { var b = new ThemedExpandButton { Size = Vector2.One * RowHeight, MinMaxSize = Vector2.One * RowHeight, Padding = Thickness.Zero, Highlightable = false, }; b.Clicked = () => { container.Visible = !container.Visible; }; b.Updated += (dt) => { b.Visible = container.Nodes.Count != 0; }; return(b); }
private void BuildList <TData, TRow>(ObservableCollection <TData> source, Widget container, string title, Func <TData> activator, Widget header) where TRow : DeletableRow <TData> { ThemedExpandButton markersExpandButton; container.AddNode(new Widget { Layout = new HBoxLayout { Spacing = AttachmentMetrics.Spacing }, Nodes = { (markersExpandButton = new ThemedExpandButton { MinMaxSize = new Vector2(AttachmentMetrics.ExpandButtonSize) }), new ThemedSimpleText { Text = title }, } }); var list = new Widget { Layout = new VBoxLayout(), Padding = new Thickness { Left = AttachmentMetrics.ExpandContentPadding, Top = AttachmentMetrics.Spacing }, }; container.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <TData>( w => (TRow)Activator.CreateInstance(typeof(TRow), new object[] { w, source }), source); widgetFactory.AddHeader(header); widgetFactory.AddFooter(DeletableRow <TData> .CreateFooter(() => { history.DoTransaction(() => Core.Operations.InsertIntoList.Perform(source, source.Count, activator())); })); list.Components.Add(widgetFactory); this.AddChangeWatcher(() => markersExpandButton.Expanded, (e) => list.Visible = e); }
private void UpdateAllShortcutsView(ThemedScrollView allShortcutsView, ThemedScrollView selectedShortcutsView, HotkeyEditor hotkeyEditor, string filter) { allShortcutsView.Content.Nodes.Clear(); if (hotkeyEditor.Profile == null) { return; } foreach (var category in hotkeyEditor.Profile.Categories) { var expandableContent = new Frame { Layout = new VBoxLayout { Spacing = 4 }, Visible = true }; var expandButton = new ThemedExpandButton { Anchors = Anchors.Left, MinMaxSize = Vector2.One * 20f, Expanded = expandableContent.Visible }; var title = new ThemedSimpleText { Text = category.Title, VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, stretchX: 0) }; expandButton.Clicked += () => { expandableContent.Visible = !expandableContent.Visible; expandButton.Expanded = expandableContent.Visible; }; var header = new Widget { Layout = new HBoxLayout(), Nodes = { expandButton, title } }; allShortcutsView.Content.AddNode(header); allShortcutsView.Content.AddNode(expandableContent); var filteredCommands = String.IsNullOrEmpty(filter) ? category.Commands.Values : category.Commands.Values.Where(i => i.Title.ToLower().Contains(filter)); title.Color = filteredCommands.Any() ? Theme.Colors.BlackText : Theme.Colors.GrayText; expandButton.Enabled = filteredCommands.Any(); foreach (var command in filteredCommands) { var editor = new ShortcutPropertyEditor( new PreferencesPropertyEditorParams(expandableContent, command, propertyName: "Shortcut", displayName: command.Title)); editor.PropertyLabel.OverflowMode = TextOverflowMode.Ellipsis; editor.PropertyLabel.LayoutCell = new LayoutCell(Alignment.LeftCenter, 1); editor.PropertyLabel.Padding = new Thickness(expandButton.Width, 0); editor.PropertyLabel.CompoundPresenter.RemoveAll(i => i as SelectionPresenter != null); editor.PropertyLabel.Caret = new CaretPosition(); if (!String.IsNullOrEmpty(filter)) { var mc = new MultiCaretPosition(); var start = new CaretPosition { IsVisible = true, WorldPos = new Vector2(1, 1) }; var finish = new CaretPosition { IsVisible = true, WorldPos = new Vector2(1, 1) }; mc.Add(start); mc.Add(finish); editor.PropertyLabel.Caret = mc; start.TextPos = editor.PropertyLabel.Text.ToLower().IndexOf(filter); finish.TextPos = start.TextPos + filter.Length; new SelectionPresenter(editor.PropertyLabel, start, finish, new SelectionParams() { Color = Theme.Colors.TextSelection, OutlineThickness = 0 }); } editor.ContainerWidget.LayoutCell = new LayoutCell(Alignment.LeftCenter, 1); editor.PropertyChanged = () => { hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); }; var dragGesture = new DragGesture(); editor.ContainerWidget.Gestures.Add(dragGesture); var task = new Task(UpdateDragCursor(selectedShortcutsView, hotkeyEditor)); dragGesture.Recognized += () => editor.ContainerWidget.LateTasks.Add(task); dragGesture.Ended += () => { editor.ContainerWidget.LateTasks.Remove(task); var nodeUnderMouse = WidgetContext.Current.NodeUnderMouse; if (nodeUnderMouse == selectedShortcutsView && hotkeyEditor.Main != Key.Unknown) { if (hotkeyEditor.Main != Key.Unknown) { command.Shortcut = new Shortcut(hotkeyEditor.Modifiers, hotkeyEditor.Main); hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); hotkeyEditor.SetFocus(); } } else if (nodeUnderMouse as KeyboardButton != null) { var button = nodeUnderMouse as KeyboardButton; if (Shortcut.ValidateMainKey(button.Key) && !button.Key.IsModifier()) { command.Shortcut = new Shortcut(hotkeyEditor.Modifiers, button.Key); hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); hotkeyEditor.SetFocus(); } } }; } } }
public AnimationRow(Model3DAttachment.Animation animation, ObservableCollection <Model3DAttachment.Animation> options) : base(animation, options) { var isDefault = animation.Name == Model3DAttachment.DefaultAnimationName; deleteButton.Visible = !isDefault; Layout = new VBoxLayout(); var expandedButton = new ThemedExpandButton { MinMaxSize = new Vector2(AttachmentMetrics.ExpandButtonSize), Anchors = Anchors.Left }; Padding = new Thickness(AttachmentMetrics.Spacing); Header.Nodes.Add(expandedButton); var animationNamePropEditor = new StringPropertyEditor( Decorate(new PropertyEditorParams( Header, animation, nameof(Model3DAttachment.Animation.Name)))); animationNamePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth; Header.AddNode(new BlendingCell(Source, nameof(Model3DAttachment.Animation.Blending))); var expandableContentWrapper = new Widget { Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }, LayoutCell = new LayoutCell { StretchY = 0 }, Padding = new Thickness { Left = AttachmentMetrics.ExpandContentPadding, Top = AttachmentMetrics.Spacing, Bottom = AttachmentMetrics.Spacing }, Visible = false, }; BuildList <Model3DAttachment.MarkerData, MarkerRow>( animation.Markers, expandableContentWrapper, "Markers", () => new Model3DAttachment.MarkerData { Marker = new Marker { Id = "Marker", Frame = 0, } }, MarkerRow.CreateHeader()); BuildList <Model3DAttachment.MarkerBlendingData, MarkerBlendingRow>( animation.MarkersBlendings, expandableContentWrapper, "Marker Blendings", () => new Model3DAttachment.MarkerBlendingData { SourceMarkerId = "Marker2", DestMarkerId = "Marker1" }, MarkerBlendingRow.CreateHeader()); if (!isDefault) { BuildList <Model3DAttachment.NodeData, NodeRow>( animation.Nodes, expandableContentWrapper, "Nodes", () => new Model3DAttachment.NodeData { Id = "NodeId" }, NodeRow.CreateHeader()); BuildList <Model3DAttachment.NodeData, NodeRow>( animation.IgnoredNodes, expandableContentWrapper, "Ignored Nodes", () => new Model3DAttachment.NodeData { Id = "NodeId" }, NodeRow.CreateHeader()); } Nodes.Add(expandableContentWrapper); expandableContentWrapper.AddChangeWatcher( () => expandedButton.Expanded, (v) => expandableContentWrapper.Visible = v); CompoundPresenter.Add(Presenters.StripePresenter); }