public RollAnimationTrackView(Row row) { this.row = row; trackRow = row.Components.Get <AnimationTrackRow>(); label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, OverflowMode = TextOverflowMode.Ellipsis, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBoxContainer = new Widget { Visible = false, Layout = new HBoxLayout(), LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue), }; propIcon = new Image { LayoutCell = new LayoutCell(Alignment.Center), Texture = IconPool.GetTexture("Nodes.Unknown"), MinMaxSize = new Vector2(16, 16) }; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); Widget = new Widget { Padding = new Thickness { Left = 4, Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center) }, Nodes = { (spacer = new Widget()), Spacer.HSpacer(6), propIcon, Spacer.HSpacer(3), label, editBoxContainer, Spacer.HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X), lockButton }, }; trackIdEditor = new RollNodeView.ObjectIdInplaceEditor(row, Track, label, editBoxContainer); label.AddChangeWatcher(() => Track.Id, s => label.Text = s); label.HitTestTarget = true; label.Gestures.Add(new DoubleClickGesture(() => { Document.Current.History.DoTransaction(() => { if (trackRow.Locked) { return; } var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { Rename(); } }); })); Widget.Gestures.Add(new ClickGesture(1, ShowContextMenu)); Widget.Components.Add(new AwakeBehavior()); Widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground)); }
public RollNodeView(Row row) { this.row = row; nodeData = row.Components.Get <NodeRow>(); label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBox = new ThemedEditBox { LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; nodeIcon = new Image(NodeIconPool.GetTexture(nodeData.Node.GetType())) { HitTestTarget = true, MinMaxSize = new Vector2(21, 16), Padding = new Thickness { Left = 5 } }; expandButton = CreateExpandButton(); var expandButtonContainer = new Widget { Layout = new StackLayout { IgnoreHidden = false }, LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0), Nodes = { expandButton } }; expandButtonContainer.CompoundPresenter.Add(new DelegatePresenter <Widget>(widget => { widget.PrepareRendererState(); var a = new Vector2(0, -4); var b = widget.Size + new Vector2(0, 3); Renderer.DrawRect(a, b, nodeData.Node.GetColor()); if (nodeData.Node.GetColorIndex() != 0) { Renderer.DrawRectOutline(a, b, ColorTheme.Current.TimelineRoll.Lines); } })); expandButtonContainer.Updating += delta => expandButton.Visible = nodeData.Node.Animators.Count > 0; enterButton = NodeCompositionValidator.CanHaveChildren(nodeData.Node.GetType()) ? CreateEnterButton() : null; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); lockAnimationButton = CreateLockAnimationButton(); widget = new Widget { Padding = new Thickness { Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { CellDefaults = new LayoutCell(Alignment.Center) }, HitTestTarget = true, Nodes = { expandButtonContainer, (indentSpacer = new Widget()), nodeIcon, new HSpacer(3), label, editBox, new Widget(), (Widget)enterButton ?? (Widget) new HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X), lockAnimationButton, eyeButton, lockButton, } }; label.AddChangeWatcher(() => nodeData.Node.Id, s => RefreshLabel()); label.AddChangeWatcher(() => IsGrayedLabel(nodeData.Node), s => RefreshLabel()); label.AddChangeWatcher(() => nodeData.Node.ContentsPath, s => RefreshLabel()); widget.CompoundPresenter.Push(new DelegatePresenter <Widget>(RenderBackground)); editBox.Visible = false; widget.Gestures.Add(new ClickGesture(1, ShowPropertyContextMenu)); widget.Gestures.Add(new DoubleClickGesture(() => { var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { Rename(); } else { Core.Operations.EnterNode.Perform(nodeData.Node); } })); nodeIcon.Gestures.Add(new DoubleClickGesture(() => { Core.Operations.ClearRowSelection.Perform(); Core.Operations.SelectRow.Perform(row); Rename(); })); }
public RollNodeView(Row row) { this.row = row; nodeData = row.Components.Get <NodeRow>(); label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, OverflowMode = TextOverflowMode.Ellipsis, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBoxContainer = new Widget { Visible = false, Layout = new HBoxLayout(), LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue), }; nodeIcon = new Image(NodeIconPool.GetTexture(nodeData.Node.GetType())) { HitTestTarget = true, MinMaxSize = new Vector2(21, 16), Padding = new Thickness { Left = 5 } }; expandButton = CreateExpandButton(); var expandButtonContainer = new Widget { Layout = new StackLayout { IgnoreHidden = false }, LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0), Nodes = { expandButton } }; expandButtonContainer.CompoundPresenter.Add(new SyncDelegatePresenter <Widget>(widget => { widget.PrepareRendererState(); var a = new Vector2(0, -4); var b = widget.Size + new Vector2(0, 3); int colorIndex = nodeData.Node.EditorState().ColorIndex; Renderer.DrawRect(a, b, ColorMarks[colorIndex]); if (colorIndex != 0) { Renderer.DrawRectOutline(a, b, ColorTheme.Current.TimelineRoll.Lines); } })); expandButtonContainer.Updating += delta => { bool visible = false; foreach (var a in nodeData.Node.Animators) { if (!a.IsZombie && a.AnimationId == Document.Current.AnimationId) { visible = true; break; } } expandButton.Visible = visible; }; enterButton = NodeCompositionValidator.CanHaveChildren(nodeData.Node.GetType()) ? CreateEnterButton() : null; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); lockAnimationButton = CreateLockAnimationButton(); widget = new Widget { HitTestTarget = true, Padding = new Thickness { Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center) }, Nodes = { expandButtonContainer, (indentSpacer = new Widget()), nodeIcon, Spacer.HSpacer(3), label, editBoxContainer, linkIndicatorButtonContainer, (Widget)enterButton ?? (Widget)Spacer.HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X), lockAnimationButton, eyeButton, lockButton, }, }; widget.Components.Add(new AwakeBehavior()); label.AddChangeWatcher(() => nodeData.Node.Id, s => RefreshLabel()); label.AddChangeWatcher(() => IsGrayedLabel(nodeData.Node), s => RefreshLabel()); label.AddChangeWatcher(() => nodeData.Node.ContentsPath, s => RefreshLabel()); widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground)); nodeIdEditor = new ObjectIdInplaceEditor(row, nodeData.Node, label, editBoxContainer); label.HitTestTarget = true; label.Gestures.Add(new DoubleClickGesture(() => { Document.Current.History.DoTransaction(() => { if (NodeData.Node.EditorState().Locked) { return; } var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { nodeIdEditor.Rename(); } else { EnterNode.Perform(nodeData.Node); } }); })); widget.Gestures.Add(new ClickGesture(1, ShowContextMenu)); }
public RollFolderView(Row row) { this.row = row; folder = row.Components.Get <FolderRow>().Folder; label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, OverflowMode = TextOverflowMode.Ellipsis, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBox = new ThemedEditBox { LayoutCell = new LayoutCell(Alignment.Center, stretchX: float.MaxValue) }; nodeIcon = new Image(IconPool.GetTexture("Tools.NewFolder")) { HitTestTarget = true, MinMaxSize = new Vector2(16, 16) }; expandButton = CreateExpandButton(); var expandButtonContainer = new Widget { Layout = new StackLayout { IgnoreHidden = false }, LayoutCell = new LayoutCell(Alignment.Center), Visible = true, Nodes = { expandButton } }; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); widget = new Widget { Padding = new Thickness { Left = 4, Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center) }, HitTestTarget = true, Nodes = { (spacer = new Widget()), expandButtonContainer, nodeIcon, Spacer.HSpacer(3), label, editBox, new Widget(), eyeButton, lockButton, }, }; widget.Components.Add(new AwakeBehavior()); label.HitTestTarget = true; label.AddChangeWatcher(() => folder.Id, s => label.Text = folder.Id); label.Gestures.Add(new DoubleClickGesture(() => { Document.Current.History.DoTransaction(() => { var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { Rename(); } else { Document.Current.History.DoTransaction(ExpandOrCollapse); } }); })); widget.Gestures.Add(new ClickGesture(1, ShowContextMenu)); widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground)); editBox.Visible = false; }