public override Placement Clone() { var clone = new TabBarPlacement(); Placements.Clone(clone); return(clone); }
private void CreateTabBarWidget(Splitter container, TabBarPlacement placement, float stretch, int insertAt) { var tabbedWidget = new TabbedWidget() { LayoutCell = new LayoutCell { StretchY = 0 }, AllowReordering = true }; tabbedWidget.FocusScope = new KeyboardFocusScope(tabbedWidget); var rootWidget = AddTitle(tabbedWidget, out ThemedTabCloseButton closeButton, out ThemedSimpleText titleLabel); foreach (var panelPlacement in placement.Placements) { var panel = Model.Panels.First(pan => pan.Id == panelPlacement.Id); panel.ContentWidget.Unlink(); if (panelPlacement.Hidden) { continue; } var tab = new ThemedTab { Text = panel.Id, Closable = true, }; tab.Closing += () => { Model.FindPanelPlacement(panel.Id).Hidden = true; Refresh(); }; tabbedWidget.AddTab(tab, new Widget { Id = $"DockPanel<{panel.Id}>", LayoutCell = new LayoutCell(), Layout = new VBoxLayout(), Padding = new Thickness(0, 1), Nodes = { panel.ContentWidget } }, true); CreateDragBehaviour(panelPlacement, tab, panel.ContentWidget); } tabbedWidget.ActiveTabIndex = 0; tabbedWidget.TabBar.OnReorder += args => { var item = placement.Placements[args.OldIndex]; placement.RemovePlacement(item); placement.Placements.Insert(args.NewIndex, item); tabbedWidget.ActivateTab(args.NewIndex); }; titleLabel.AddChangeWatcher( () => ((Tab)tabbedWidget.TabBar.Nodes[tabbedWidget.ActiveTabIndex]).Text, title => titleLabel.Text = title ); closeButton.Clicked += () => { foreach (var panelPlacement in placement.Placements) { panelPlacement.Hidden = true; } Refresh(); }; CreateDragBehaviour(placement, rootWidget.Nodes[0].AsWidget, rootWidget); container.Nodes.Insert(insertAt, rootWidget); container.Stretches.Insert(insertAt, stretch); }
private void DockPlacementTo(LinearPlacement placement, TabBarPlacement target) { var placements = placement.Placements.ToList(); foreach (var p in placements) { DockPlacementTo(p, target, DockSite.Fill, 0); } }
public void Clone(TabBarPlacement newOwner) { if (Count > 0) { foreach (var placement in this) { newOwner.Placements.Add((PanelPlacement)placement.Clone()); } } }
private void DockPlacementTo(TabBarPlacement placement, TabBarPlacement target) { var placements = placement.Placements.ToList(); foreach (var panelPlacement in placements) { panelPlacement.Unlink(); target.Placements.Add(panelPlacement); } }
private static void DockPlacementTo(TabBarPlacement placement, TabBarPlacement target) { var placements = placement.Placements.ToList(); placements.Reverse(); foreach (var panelPlacement in placements) { panelPlacement.Unlink(); target.Placements.Insert(0, panelPlacement); } }
private void DockPlacementTo(PanelPlacement placement, PanelPlacement target) { if (!(target.Parent is TabBarPlacement tabBarPlacement)) { tabBarPlacement = new TabBarPlacement(); var parent = (SplitPlacement)target.Parent; target.Unlink(); tabBarPlacement.Placements.Add(target); parent.Append(tabBarPlacement); } tabBarPlacement.Placements.Add(placement); }
private static void DockPlacementTo(PanelPlacement placement, PanelPlacement target) { if (!(target.Parent is TabBarPlacement tabBarPlacement)) { tabBarPlacement = new TabBarPlacement(); var parent = (LinearPlacement)target.Parent; target.Parent = null; int index = parent.Placements.IndexOf(target); tabBarPlacement.Placements.Add(target); parent.Placements[index] = tabBarPlacement; } tabBarPlacement.Placements.Insert(0, placement); }
private void DockPlacementTo(TabBarPlacement placement, PanelPlacement target) { var parent = target.Parent; if (parent is TabBarPlacement tabBarPlacement) { DockPlacementTo(placement, tabBarPlacement); return; } if (parent is SplitPlacement splitPlacement) { target.Unlink(); placement.Placements.Add(target); splitPlacement.Append(placement); } }
private static void DockPlacementTo(TabBarPlacement placement, PanelPlacement target) { var parent = target.Parent; if (parent is TabBarPlacement tabBarPlacement) { DockPlacementTo(placement, tabBarPlacement); return; } if (parent is LinearPlacement linearPlacement) { int index = linearPlacement.Placements.IndexOf(target); target.Parent = null; placement.Placements.Insert(0, target); linearPlacement.Placements[index] = placement; } }
public PanelPlacementList(TabBarPlacement owner) { list = new List <PanelPlacement>(); this.owner = owner; }
private void CreateTabBarWidget(Splitter container, TabBarPlacement placement, float stretch, bool requestTitle) { var tabbedWidget = new TabbedWidget { TabBar = new PanelTabBar(), AllowReordering = true, BarPlacement = TabbedWidget.TabBarPlacement.Bottom, PostPresenter = new SyncDelegatePresenter <TabbedWidget>(w => { w.PrepareRendererState(); var activeTab = (Tab)w.TabBar.Nodes[w.ActiveTabIndex]; var color = ColorTheme.Current.Docking.TabOutline; var a = activeTab.CalcPositionInSpaceOf(w); var start = a * Vector2.Down; var b = a + Vector2.Down * activeTab.ContentHeight; var c = b + activeTab.ContentWidth * Vector2.Right; var d = c - Vector2.Down * activeTab.ContentHeight; var end = start + w.Size * Vector2.Right; Renderer.DrawLine(start, a + Vector2.Right * 0.5f, color); Renderer.DrawLine(a, b, color); Renderer.DrawLine(b + new Vector2(-0.5f, -0.5f), c + new Vector2(0.5f, -0.5f), color); Renderer.DrawLine(c, d, color); Renderer.DrawLine(d + Vector2.Left * 0.5f, end, color); }) }; Widget rootWidget = tabbedWidget; tabbedWidget.FocusScope = new KeyboardFocusScope(tabbedWidget); tabbedWidget.TabBar.OnReordering += args => placement.Placements.Move(args.IndexFrom, args.IndexTo); if (requestTitle) { rootWidget = WrapWithTitle(tabbedWidget, out var closeButton, out var titleLabel); titleLabel.AddChangeWatcher( () => ((Tab)tabbedWidget.TabBar.Nodes[tabbedWidget.ActiveTabIndex]).Text, title => titleLabel.Text = title ); closeButton.Clicked += () => { placement.Placements.Where(p => !p.Hidden).ElementAt(tabbedWidget.ActiveTabIndex).Hidden = true; Refresh(); }; CreateDragBehaviour(placement, rootWidget.Nodes[0].AsWidget, rootWidget); } foreach (var panelPlacement in placement.Placements) { var panel = Model.Panels.First(pan => pan.Id == panelPlacement.Id); panel.ContentWidget.Unlink(); if (panelPlacement.Hidden) { continue; } var tab = new PanelTab { Text = panel.Id, Closable = false, }; tab.Closing += () => { Model.FindPanelPlacement(panel.Id).Hidden = true; Refresh(); }; tabbedWidget.AddTab(tab, new Widget { Id = $"DockPanel<{panel.Id}>", LayoutCell = new LayoutCell(), Layout = new VBoxLayout(), Padding = new Thickness(0, 1), Nodes = { panel.ContentWidget } }, true); CreateDragBehaviour(panelPlacement, tab, panel.ContentWidget); panel.PanelWidget = rootWidget; } tabbedWidget.ActiveTabIndex = 0; container.Nodes.Add(rootWidget); container.Stretches.Add(stretch); }