private void RebuildTabs() { tabBar.Nodes.Clear(); foreach (var doc in Project.Current.Documents) { var tab = new ThemedTab { Closable = true }; tab.Tasks.Add(Tooltip.Instance.ShowOnMouseOverTask(tab, () => doc.FullPath.Replace('/', '\\'))); tab.AddChangeWatcher(() => Document.Current, _ => { if (doc == Document.Current) { tabBar.ActivateTab(tab); } }); tab.Gestures.Add(new ClickGesture(1, () => { DocumentTabContextMenu.Create(doc); })); tab.AddChangeWatcher(() => doc.DisplayName, _ => tab.Text = doc.DisplayName); tab.Clicked += doc.MakeCurrent; tab.Closing += () => Project.Current.CloseDocument(doc); tabBar.AddNode(tab); } tabBar.AddNode(new Widget { LayoutCell = new LayoutCell { StretchX = 0 } }); }
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); }
public override void Initialize() { Tab = new ThemedTab { Text = "Devices" }; Content = new Widget { Layout = new VBoxLayout(), Nodes = { (mainToolbar = new RemoteScriptingWidgets.Toolbar()), new Widget { Layout = new HBoxLayout(), Nodes = { (devicesScrollView = new ThemedScrollView { MinMaxWidth = 300, TabTravesable = new TabTraversable() }), (deviceWidgetPlaceholder = new Widget() { Layout = new HBoxLayout() }) } } } }; RefreshMainToolbar(); Content.AddChangeWatcher( () => CompiledAssembly.Instance, _ => { RefreshMainToolbar(); } ); void SelectDeviceBasedOnMousePosition() { devicesScrollView.SetFocus(); var index = (devicesScrollView.Content.LocalMousePosition().Y / rowHeight).Floor(); if (index < devices.Count) { SelectDevice(index); } } var mouseDownGesture = new ClickGesture(0); mouseDownGesture.Began += SelectDeviceBasedOnMousePosition; devicesScrollView.Gestures.Add(mouseDownGesture); devicesScrollView.Content.CompoundPresenter.Insert(0, new SyncDelegatePresenter <Widget>(w => { w.PrepareRendererState(); Renderer.DrawRect( 0, rowHeight * selectedDeviceIndex, w.Width, rowHeight * (selectedDeviceIndex + 1), devicesScrollView.IsFocused() ? Theme.Colors.SelectedBackground : Theme.Colors.SelectedInactiveBackground ); })); }
public void AddTab(string name, Widget content, bool isActive = false, bool canClose = false) { var tab = new ThemedTab { Text = name, Closable = canClose }; AddTab(tab, content, isActive); }
public override void Initialize() { Tab = new ThemedTab { Text = "Application Output" }; Content = new Widget { Layout = new VBoxLayout(), Nodes = { (textView = new RemoteScriptingWidgets.TextView(maxRowsCount: 1500)) } }; }
public void AddTab(string name, Widget content, bool IsActive = false) { var newTab = new ThemedTab { Text = name, Active = IsActive }; TabBar.Nodes.Add(newTab); newTab.Clicked += () => ActivateTab(newTab); content.Visible = false; Frame.Nodes.Add(content); if (IsActive) { ActivateTab(newTab); } }
public override void Initialize() { Tab = new ThemedTab { Text = "Assembly" }; RemoteScriptingWidgets.Toolbar toolbar; Content = new Widget { Layout = new VBoxLayout(), Nodes = { (toolbar = new RemoteScriptingWidgets.Toolbar()), (assemblyBuilderLog = new RemoteScriptingWidgets.TextView()) } }; toolbar.Content.Nodes.AddRange( buildAssemblyButton = new ToolbarButton("Build Assembly") { Clicked = () => BuildAssembly(requiredBuildGame: false) }, buildGameAndAssemblyButton = new ToolbarButton("Build Game and Assembly") { Clicked = () => BuildAssembly() } ); var preferences = ProjectPreferences.Instance; var arePreferencesCorrect = !string.IsNullOrEmpty(preferences.ScriptsPath) && !string.IsNullOrEmpty(preferences.ScriptsAssemblyName) && !string.IsNullOrEmpty(preferences.RemoteStoragePath); if (!arePreferencesCorrect) { buildAssemblyButton.Enabled = false; buildGameAndAssemblyButton.Enabled = false; SetStatusAndLog("Preferences is invalid."); } }
private void RebuildTabs(TabBar tabBar) { tabBar.Nodes.Clear(); foreach (var doc in Project.Current.Documents) { var tab = new ThemedTab { Closable = true }; var currentDocumentChanged = new Property <bool>(() => Document.Current == doc).DistinctUntilChanged().Where(i => i); tab.Tasks.Add(currentDocumentChanged.Consume(_ => tabBar.ActivateTab(tab))); tab.AddChangeWatcher(() => doc.Path, _ => RefreshTabText(doc, tab)); tab.AddChangeWatcher(() => doc.IsModified, _ => RefreshTabText(doc, tab)); tab.Clicked += doc.MakeCurrent; tab.Closing += () => Project.Current.CloseDocument(doc); tab.Updated += (dt) => { if (tab.Input.WasKeyReleased(Key.Mouse1)) { var menu = new Menu { GenericCommands.CloseDocument, GenericCommands.Save, FilesystemCommands.NavigateTo, FilesystemCommands.OpenInSystemFileManager, }; var path = Path.Combine(Project.Current.AssetsDirectory, doc.Path); FilesystemCommands.NavigateTo.UserData = path; FilesystemCommands.OpenInSystemFileManager.UserData = path; menu.Popup(); } }; tabBar.AddNode(tab); } tabBar.AddNode(new Widget { LayoutCell = new LayoutCell { StretchX = 0 } }); }
private void RebuildTabs(TabBar tabBar) { tabBar.Nodes.Clear(); foreach (var doc in Project.Current.Documents) { var tab = new ThemedTab { Closable = true }; var currentDocumentChanged = new Property <bool>(() => Document.Current == doc).DistinctUntilChanged().Where(i => i); tab.Tasks.Add(currentDocumentChanged.Consume(_ => tabBar.ActivateTab(tab))); tab.AddChangeWatcher(() => doc.Path, _ => RefreshTabText(doc, tab)); tab.AddChangeWatcher(() => doc.IsModified, _ => RefreshTabText(doc, tab)); tab.Clicked += doc.MakeCurrent; tab.Closing += () => Project.Current.CloseDocument(doc); tab.Updated += (dt) => { if (tab.Input.WasKeyReleased(Key.Mouse1)) { DocumentTabContextMenu.Create(doc); } }; DragGesture dragGesture = new DragGesture(); tab.Gestures.Add(dragGesture); dragGesture.Changed += () => { int index = -1; foreach (Tab tabEl in tabBar.Nodes.OfType <Tab>()) { index++; if (tabEl == tab) { continue; } Vector2 localMousePosition = tabEl.LocalMousePosition(); if (!(localMousePosition.X >= 0 && localMousePosition.Y >= 0 && localMousePosition.X < tabEl.Width && localMousePosition.Y < tabEl.Height)) { continue; } Project.Current.ReorderDocument(doc, index); int previousIndex = tabBar.Nodes.IndexOf(tab); int toIndex = tabBar.Nodes.IndexOf(tabEl); if (previousIndex < 0 || toIndex < 0) { RebuildTabs(tabBar); break; } tabBar.Nodes.Remove(tab); tabBar.Nodes.Insert(toIndex, tab); break; } }; tabBar.AddNode(tab); } tabBar.AddNode(new Widget { LayoutCell = new LayoutCell { StretchX = 0 } }); }