private bool NotebookTabIsOpen(NotebookTab tab) { NotebookUI notebook = GameManager.Instance.NotebookUI; NotebookTabPicker picker = notebook.TabPicker; return(notebook.IsOpen && picker.CurrentTab == tab); }
NotebookTab CreateHomeTab() { void CreateNewTab(object sender, EventArgs args) { tabCounter += 1; var tab = new NotebookTab(UIStyle) { Tag = "Tab Content for " + tabCounter, HeaderContent = new Label(UIStyle, $"Tab {tabCounter}"), Content = new Label(UIStyle, "Tab Content for " + tabCounter) }; Content.Tabs.Add(tab); } return(new NotebookTab(UIStyle) { Content = new Button(UIStyle, "CreatePopup tab") { Anchor = AnchoredRect.CreateFull(10), OnActionPerformed = CreateNewTab }, HeaderContent = new Label(UIStyle, "Home"), IsPinned = true, Tag = "Home" }); }
public void Setup(NotebookTab tab, ToggleGroup parent, UnityAction <NotebookTab> callback) { // Setup the notebook child base base.Setup(); // Set the tab this.tab = tab; // Setup the toggle myToggle.group = parent; myToggle.onValueChanged.AddListener(OnToggleStateChanged); // Listen for the callback when selected event is raised selectedEvent.AddListener(callback); // Set the text on the GUI element tabName.text = tab.ToString(); if (GameManager.Instance) { // This toggle is only interactable if the tab scaffold says so LevelID current = LevelID.Current(); myToggle.interactable = UIParent.Config.TabScaffold.GetMask(current).Get(tab); } else { myToggle.interactable = true; } }
public void DragAnDrop_Inside_Arrange_Far_Right() { var style = LayoutTestStyle.Create(); var tab1 = new NotebookTab(style, new Label(style, "Tab 1"), null) { Tag = "Tab 1" }; var tab2 = new NotebookTab(style, new Label(style, "Tab 2"), null) { Tag = "Tab 2" }; var tab3 = new NotebookTab(style, new Label(style, "Tab 3"), null) { Tag = "Tab 3" }; var b = new DnDNoteBookTab(style) { tab1, tab2, tab3 }; style.StyleResolver.AddRoot(b); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDown(MouseButton.Left, 20, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDrag(MouseButton.Left, 500, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); // The dragged element floating range is limited to the visible space. b[0].LayoutRect.Should().Be(new Rectangle(30, 25, 155, 35)); b[1].LayoutRect.Should().Be(new Rectangle(325, 25, 155, 35)); b[2].LayoutRect.Should().Be(new Rectangle(170, 25, 155, 35)); }
public void ShowResult(NotebookTab tab, ITaskRunnerCommandResult result) { string message = GettextCatalog.GetString("Process terminated with code {0}{1}", result.ExitCode, Environment.NewLine); var tabInfo = tab.Child.Tag as TabInfo; tabInfo.LogView.WriteText(null, message); }
private void FreezeUntilNotebookTabOpen(NotebookTab tab) { // Freeze until notebook tab is open FreezingScheduler.FreezeUntilConditionIsMet(() => NotebookTabIsOpen(tab)); // Highlight notebook button if not open, then highlight correct tab HighlightingScheduler.SetHighlights(HighlightNotebookButton(), HighlightNotebookTabButton(tab)); }
public void Add(IWidgetBackend widget, NotebookTab tab) { NSTabViewItem item = new NSTabViewItem(); item.Label = tab.Label; item.View = GetWidget(widget); Widget.Add(item); }
public void HideRunningStatus(RunningTaskInformation runningTask) { NotebookTab taskOutputTab = GetTab(runningTask); if (taskOutputTab != null) { taskOutputTab.Label = runningTask.Name; } }
public void OpenTaskOutputTab(NotebookTab tab, RunningTaskInformation task) { tab.Label = GettextCatalog.GetString("{0} (Running)", task.Name); var tabInfo = tab.Child.Tag as TabInfo; tabInfo.Task = task; notebook.CurrentTab = tab; }
public void UpdateLabel(NotebookTab tab, string hint) { TabItem item = TabControl.Items.Cast <TabItem> ().FirstOrDefault(t => t.Tag == tab); if (item != null) { item.Header = tab.Label; } }
public void CloseButton_Triggers_Close_Request() { var closeRequested = false; var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.CloseRequested += (s, e) => closeRequested = true; tab[0][0].DispatchMouseClick(MouseButton.Left, 10, 20); closeRequested.Should().Be(true); }
public void IsPinned_InitialState() { var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.IsClosable.Should().Be(true); tab.IsPinned.Should().Be(false); tab[0][0].Should().BeAssignableTo <Button>(); tab[0][0].Visibility.Should().Be(Visibility.Visible); }
public void Mouse_Clicks_in_label_Activate_Tab() { var activationRequested = false; var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.ActivationRequested += (s, e) => activationRequested = true; tab[0][1].DispatchMouseClick(MouseButton.Left, 10, 20); activationRequested.Should().Be(true); }
private ConditionalHighlight[] HighlightItemPicker(NotebookTab targetTab, ItemID targetItem, string nameFilter) { NotebookUI notebook = GameManager.Instance.NotebookUI; // Get all pickers in the given tab ItemPicker[] pickers = notebook.TabPicker.GetTabRoot(targetTab).GetComponentsInChildren <ItemPicker>(true); // Find a picker whose name contains the filter ItemPicker picker = Array.Find(pickers, p => p.name.IndexOf(nameFilter, StringComparison.OrdinalIgnoreCase) >= 0); return(HighlightItemPicker(picker, targetItem)); }
public void UpdateLabel(NotebookTab tab, string hint) { IWidgetBackend widget = (IWidgetBackend)Toolkit.GetBackend(tab.Child); var v = GetWidget(widget); var t = FindTab(v); if (t != null) { t.Label = tab.Label; } }
private bool NotebookItemPicked(NotebookTab targetTab, ItemID targetItem, string nameFilter) { NotebookUI notebook = GameManager.Instance.NotebookUI; // Get all pickers in the given tab ItemPicker[] pickers = notebook.TabPicker.GetTabRoot(targetTab).GetComponentsInChildren <ItemPicker>(true); // Find a picker whose name contains the filter ItemPicker picker = Array.Find(pickers, p => p.name.IndexOf(nameFilter, StringComparison.OrdinalIgnoreCase) >= 0); return(picker.SelectedItem == targetItem && notebook.IsOpen && notebook.TabPicker.CurrentTab == targetTab); }
private ConditionalHighlight HighlightNotebookTabButton(NotebookTab tab) { NotebookUI notebook = GameManager.Instance.NotebookUI; RectTransform tabButton = notebook.TabPicker.GetTabSelectButton(tab).GetComponent <RectTransform>(); // Return a highlight that will be active while the tab is not picked return(new ConditionalHighlight() { predicate = () => notebook.TabPicker.CurrentTab != tab, target = () => tabButton }); }
private void FreezeUntilNotebookItemPicked(NotebookTab targetTab, ItemID targetItem, string nameFilter) { FreezingScheduler.FreezeUntilConditionIsMet(() => NotebookItemPicked(targetTab, targetItem, nameFilter)); // Highlight notebook button if not open, then highlight correct tab HighlightingScheduler.SetHighlights(HighlightNotebookButton(), // Highlight the correct tab HighlightNotebookTabButton(targetTab), // Highlight the dropdown in the picker HighlightItemPicker(targetTab, targetItem, nameFilter)[0], HighlightItemPicker(targetTab, targetItem, nameFilter)[1]); }
public void DragAndDrop_Move_Tab2_To_Tab3() { var style = LayoutTestStyle.Create(); var tab1 = new NotebookTab(style, new Label(style, "Tab 1"), null) { Tag = "Tab 1" }; var tab2 = new NotebookTab(style, new Label(style, "Tab 2"), null) { Tag = "Tab 2" }; var tab3 = new NotebookTab(style, new Label(style, "Tab 3"), null) { Tag = "Tab 3" }; var b = new DnDNoteBookTab(style) { tab1, tab2, tab3 }; style.StyleResolver.AddRoot(b); b.Arrange(new Rectangle(10, 20, 400, 40)); b[1].DispatchMouseDown(MouseButton.Left, 20, 30); b.Arrange(new Rectangle(10, 20, 400, 40)); b[1].DispatchMouseDrag(MouseButton.Left, 250, 30); b.DebugInfo.DraggedTab.Should().BeSameAs(b[1]); b.DebugInfo.DraggedTabEventOrigin.Should().Be(20); b.DebugInfo.DraggedTabOffsetOrigin.Should().Be(170); b.DebugInfo.DraggedTabOffset.Should().Be(170 + (250 - 20)); b.Arrange(new Rectangle(10, 20, 400, 40)); b[1].DispatchMouseUp(MouseButton.Left, 201, 30); b.DebugInfo.DraggedTab.Should().BeNull(); b.DebugInfo.DraggedTabEventOrigin.Should().Be(0); b.DebugInfo.DraggedTabOffsetOrigin.Should().Be(0); b.DebugInfo.DraggedTabOffset.Should().Be(0); b.Arrange(new Rectangle(10, 20, 400, 40)); b[0].Should().BeSameAs(tab1); b[1].Should().BeSameAs(tab3); b[2].Should().BeSameAs(tab2); // should retain normal layout. b[0].LayoutRect.Should().Be(new Rectangle(30, 25, 155, 35)); b[1].LayoutRect.Should().Be(new Rectangle(170, 25, 155, 35)); b[2].LayoutRect.Should().Be(new Rectangle(310, 25, 155, 35)); }
public NotebookTabSelectButton GetTabSelectButton(NotebookTab tab) { int index = (int)tab; if (index >= 0 && index < buttons.Count) { return(buttons[index]); } else { throw new System.IndexOutOfRangeException($"{nameof(NotebookTabPicker)}: " + $"No notebook tab button defined for tab '{tab}'. Total buttons: {buttons.Count}"); } }
public BookmarkData(string targetGameObjectName, object targetComponentData) { this.targetGameObjectName = targetGameObjectName; // Set the data to default values index = -1; data0 = 0; data1 = ItemID.Invalid; data2 = LevelID.Invalid; data3 = ResearchEncyclopediaArticleID.Empty; // Set the bookmark data SetData(targetComponentData); }
private void OnTabSelected(NotebookTab tab) { // Set the current tab to this tab // This order is critical! The current tab has to be set before // the game objects activate because some of them read the current tab // when they are enabled currentTab = tab; AudioManager.instance.PlayOneShot(SFXType.NotebookTabSwitch); // Enable / Disable the correct objects NotebookTab[] tabs = (NotebookTab[])System.Enum.GetValues(typeof(NotebookTab)); foreach (NotebookTab t in tabs) { tabObjects.Get(t).SetActive(t == tab); } }
public void ShowTaskRunnerExplorerLog() { if (taskRunnerExplorerOutputTab == null) { string name = GettextCatalog.GetString("Task Runner Explorer Output"); taskRunnerExplorerOutputTab = AddTab(taskRunnerExplorerOutputLogView, name); taskRunnerExplorerOutputTabAdded = true; } if (!taskRunnerExplorerOutputTabAdded) { notebook.Tabs.Add(taskRunnerExplorerOutputTab); taskRunnerExplorerOutputTabAdded = true; } notebook.CurrentTab = taskRunnerExplorerOutputTab; OnTaskRunnerOutputViewChanged(true); }
public void DragAnDrop_Inside_Move_Arrange() { var style = LayoutTestStyle.Create(); var tab1 = new NotebookTab(style, new Label(style, "Tab 1"), null) { Tag = "Tab 1" }; var tab2 = new NotebookTab(style, new Label(style, "Tab 2"), null) { Tag = "Tab 2" }; var tab3 = new NotebookTab(style, new Label(style, "Tab 3"), null) { Tag = "Tab 3" }; var tab4 = new NotebookTab(style, new Label(style, "Tab 4"), null) { Tag = "Tab 4" }; var b = new DnDNoteBookTab(style) { tab1, tab2, tab3, tab4 }; style.StyleResolver.AddRoot(b); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDown(MouseButton.Left, 20, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDrag(MouseButton.Left, 20 + 170, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); // The dragged element floats above all other elements, and the placeholder for the tab shifts accordingly. // we dragged the tab beyond the center point of Tab3, so Tab-3 moves forward to the space previously occupied // by Tab-2. b[0].LayoutRect.Should().Be(new Rectangle(30, 25, 155, 35)); b[1].LayoutRect.Should().Be(new Rectangle(170 + 170, 25, 155, 35)); b[2].LayoutRect.Should().Be(new Rectangle(170, 25, 155, 35)); b[3].LayoutRect.Should().Be(new Rectangle(450, 25, 155, 35)); }
public void Add(IWidgetBackend widget, NotebookTab tab) { UIElement element = (UIElement)widget.NativeWidget; TabItem ti = new TabItem { Content = element, Header = tab.Label, Tag = tab }; FrameworkElement felement = element as FrameworkElement; if (felement != null) { felement.Tag = widget; felement.Loaded += OnContentLoaded; } TabControl.Items.Add (ti); if (TabControl.SelectedIndex == -1) TabControl.SelectedIndex = 0; }
Gtk.Widget CreateLabel(NotebookTab tab) { var vbox = new Gtk.HBox(); Gtk.Label label = new Gtk.Label(); /* INTRODUCED BY houen */ if (tab.Label.Contains("\\_")) { label.Text = tab.Label.Replace("\\_", "_"); } else { label.TextWithMnemonic = tab.Label.Replace("\\_", "_"); } /* INTRODUCED BY houen */ label.Show(); vbox.PackStart(label); if (!label.Text.StartsWith(char.ConvertFromUtf32(0x200B))) { var closeImage = new Gtk.Image(Assembly.GetExecutingAssembly(), "Xwt.GtkBackend.delete.png"); var button = new Gtk.ToolButton(closeImage, ""); vbox.PackEnd(button, false, false, 0); button.Show(); closeImage.Show(); var nativeWidget = GetWidget((IWidgetBackend)Toolkit.GetBackend(tab.Child)); button.Clicked += (object sender, EventArgs e) => { tab.OnClosing(); Widget.Remove(nativeWidget); }; } return(vbox); }
public void DragAnDrop_Inside_Arrange_SelfPos() { var style = LayoutTestStyle.Create(); var tab1 = new NotebookTab(style, new Label(style, "Tab 1"), null) { Tag = "Tab 1" }; var tab2 = new NotebookTab(style, new Label(style, "Tab 2"), null) { Tag = "Tab 2" }; var tab3 = new NotebookTab(style, new Label(style, "Tab 3"), null) { Tag = "Tab 3" }; var b = new DnDNoteBookTab(style) { tab1, tab2, tab3 }; style.StyleResolver.AddRoot(b); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDown(MouseButton.Left, 20, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); // dragndrop mode only activates after the element moved at least 5 pixels. This ensures // tha clicks and double-clicks are smooth and dont cause disruptions b[1].DispatchMouseDrag(MouseButton.Left, 25, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); b[0].LayoutRect.Should().Be(new Rectangle(30, 25, 155, 35)); b[1].LayoutRect.Should().Be(new Rectangle(170, 25, 155, 35)); b[2].LayoutRect.Should().Be(new Rectangle(310, 25, 155, 35)); }
public void Add(IWidgetBackend widget, NotebookTab tab) { UIElement element = (UIElement)widget.NativeWidget; TabItem ti = new TabItem { Content = element, Header = tab.Label, Tag = tab }; FrameworkElement felement = element as FrameworkElement; if (felement != null) { felement.Tag = widget; felement.Loaded += OnContentLoaded; } TabControl.Items.Add(ti); if (TabControl.SelectedIndex == -1) { TabControl.SelectedIndex = 0; } }
public void DragAnDrop_Inside_Arrange_Over_Threshold() { var style = LayoutTestStyle.Create(); var tab1 = new NotebookTab(style, new Label(style, "Tab 1"), null) { Tag = "Tab 1" }; var tab2 = new NotebookTab(style, new Label(style, "Tab 2"), null) { Tag = "Tab 2" }; var tab3 = new NotebookTab(style, new Label(style, "Tab 3"), null) { Tag = "Tab 3" }; var b = new DnDNoteBookTab(style) { tab1, tab2, tab3 }; style.StyleResolver.AddRoot(b); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDown(MouseButton.Left, 20, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); b[1].DispatchMouseDrag(MouseButton.Left, 26, 30); b.Arrange(new Rectangle(10, 20, 600, 40)); // The dragged element floats above all other elements, but consumes its desired space. // Thus the layout will stay largely the same b[0].LayoutRect.Should().Be(new Rectangle(30, 25, 155, 35)); b[1].LayoutRect.Should().Be(new Rectangle(176, 25, 155, 35)); b[2].LayoutRect.Should().Be(new Rectangle(310, 25, 155, 35)); }
Gtk.Widget CreateLabel(NotebookTab tab) { var vbox = new Gtk.HBox(); Gtk.Label label = new Gtk.Label (); /* INTRODUCED BY houen */ if (tab.Label.Contains("\\_")) { label.Text = tab.Label.Replace("\\_", "_"); } else { label.TextWithMnemonic = tab.Label.Replace("\\_", "_"); } /* INTRODUCED BY houen */ label.Show (); vbox.PackStart(label); if(!label.Text.StartsWith(char.ConvertFromUtf32(0x200B))) { var closeImage = new Gtk.Image(Assembly.GetExecutingAssembly(), "Xwt.GtkBackend.delete.png"); var button = new Gtk.ToolButton(closeImage, ""); vbox.PackEnd(button, false, false, 0); button.Show(); closeImage.Show(); var nativeWidget = GetWidget((IWidgetBackend)Toolkit.GetBackend(tab.Child)); button.Clicked += (object sender, EventArgs e) => { tab.OnClosing(); Widget.Remove(nativeWidget); }; } return vbox; }
public void Add(IWidgetBackend widget, NotebookTab tab) { Gtk.Label label = new Gtk.Label (tab.Label); label.Show (); Widget.AppendPage (GetWidget (widget), label); }
Gtk.Widget CreateLabel (NotebookTab tab) { Gtk.Label label = new Gtk.Label (tab.Label); label.Show (); return label; }
public void UpdateLabel(NotebookTab tab, string hint) { TabItem item = TabControl.Items.Cast<TabItem> ().FirstOrDefault (t => t.Tag == tab); if (item != null) item.Header = tab.Label; }
public void Add (IWidgetBackend widget, NotebookTab tab) { Widget.AppendPage (GetWidgetWithPlacement (widget), CreateLabel (tab)); }
public void Add(IWidgetBackend widget, NotebookTab tab) { Gtk.Label label = new Gtk.Label(tab.Label); label.Show(); Widget.AppendPage(GetWidget(widget), label); }
public void UpdateLabel (NotebookTab tab, string hint) { IWidgetBackend widget = (IWidgetBackend) Toolkit.GetBackend (tab.Child); Widget.SetTabLabel (GetWidget (widget), CreateLabel (tab)); }
public void UpdateLabel(NotebookTab tab, string hint) { IWidgetBackend widget = (IWidgetBackend)Toolkit.GetBackend(tab.Child); Widget.SetTabLabel(GetWidget(widget), CreateLabel(tab)); }