public void AddTab(string name, TabSize size, whlButton button, baseContainer container) { var sizeTab = new Size(564, 325); switch (size) { case TabSize.Medium: sizeTab = new Size(896, 640); break; case TabSize.Large: sizeTab = new Size(896, 602); break; } if (button != null) { button.Click += Event_ShowContainer; button.Tag = name; } container.Hide(); if (button != null) { button.IsTabControlButton = true; } _list.Add(name, new Tab() { Name = name, Size = sizeTab, Button = button, Container = container }); }
public SizedTab(string tabText, TabSize size, Color textColor, int fontSize) { TabText = tabText; Size = size; TextColor = textColor; FontSize = fontSize; }
/*TODO: Fix it not being called. * void OnGUI() { * * bool active = false; * Event e = Event.current; * if(e != null && e.type == EventType.keyDown) { * * if(Event.current.keyCode == KeyCode.LeftShift) { * * active = true; * * } * * } * if(active) { * * for(int s = 0; s < SwatWindows.Count; s++) { * * bool activated = false; * for(int k = 0; k < SwatWindows[s].Shortcut.Count; k++) { * * if(Event.current.keyCode == SwatWindows[s].Shortcut[k]) { * * activated = true; * * } else { * * activated = false; * break; * * } * * } * * if(activated) { * * SelectedTab = SwatWindows[s]; * * } * * } * * } * * }*/ /// <summary> /// Render all tabs and selected SWAT window. /// </summary> public void Render() { RenderToolTip = false; if (!_initialized) { Initialize(PlayModeStateChange.EnteredEditMode); #if UNITY_2017_2_OR_NEWER EditorApplication.playModeStateChanged += Initialize; #else EditorApplication.playmodeStateChanged += Initialize; #endif } GUI.DrawTexture(new Rect(0, 0, position.width, position.height), WindowBackgroundTexture); if (popping) { GUI.DrawTexture(new Rect(0, 0, position.width, position.height), Swat.MakeTextureFromColor((Color) new Color32(100, 100, 100, 150))); } if (!SwatWindows.Any()) { return; } _tabButton = new GUIStyle(GUI.skin.button); _closeButtonWidth = 25; //Render tabs based on current size of window. _tabWidthTotal = 90 * SwatWindows.Count + _closeButtonWidth; if (position.width >= _tabWidthTotal) { _currentTabSize = TabSize.Large; } else if (position.width > (_tabWidthTotal / 1.25)) { _currentTabSize = TabSize.Medium; } else { _currentTabSize = TabSize.Small; } _tabWidthTotal = position.width; //Tabs will span the entire width of the Swat window. EditorGUILayout.BeginHorizontal(); //Only render the tab group if this is a primary window. Sub windows (such as Favorites) will not be included in the toolbar. if (SelectedTab.PriorityID >= 0) { for (int tb = 1; tb < SwatWindows.Count; tb++) { TabDetails tabDetails = SwatWindows.Find(s => s.PriorityID == tb); if (tabDetails == null) { continue; //Hidden window, so no tabs. } RenderTab(tabDetails); } List <TabDetails> priorityZeros = SwatWindows.FindAll(s => s.PriorityID == 0); for (int p = 0; p < priorityZeros.Count; p++) { RenderTab(priorityZeros[p]); } } _tabButton = new GUIStyle(GUI.skin.button); _tabButton.normal.textColor = SelectedTab.PriorityID >= 0 ? Color.red : TextGreen; _tabButton.margin = new RectOffset(-2, -2, 0, 0); _tabButton.fontSize = 14; _tabButton.alignment = TextAnchor.MiddleCenter; _tabButton.normal.background = TabButtonBackgroundTexture; _closeButtonWidth = SelectedTab.PriorityID >= 0 ? _closeButtonWidth : 50; Nexus.Self.Button(SelectedTab.PriorityID >= 0 ? "X" : "<<<", "Show/Hide currently-selected game object in heirarchy window.", new Nexus.SwatDelegate(delegate() { if (SelectedTab.PriorityID >= 0) { this.CloseSwat(); } else { SelectedTab = LastSelectedTab; } }), _tabButton, new GUILayoutOption[] { GUILayout.Height(25), GUILayout.Width(_closeButtonWidth) }); EditorGUILayout.EndHorizontal(); if (SelectedTab != LastSelectedTab) { _scroll = new Vector2(0, 0); SelectedTab.Window.OnTabSelected(); } if (!SelectedTab.OverrideScroll) { _scroll = EditorGUILayout.BeginScrollView(_scroll); } try { if (SelectedTab.Window == null) { return; } if (LastSelectedTab != SelectedTab && SelectedTab.PriorityID >= 0) { LastSelectedTab = SwatWindows.Find(x => x.Window == SelectedTab.Window); } SelectedTab.Window.Render(); RenderAnyError(); RenderLoadingOverlay(); } catch (Exception e) { if (IsValidError(e.Message)) { throw e; } } if (!SelectedTab.OverrideScroll) { EditorGUILayout.EndScrollView(); } RenderToolTipIfHovering(position); }
new LineFormattingOptions( UseTabs: useTabs, TabSize: tabSize, IndentationSize: indentationSize, NewLine: newLine),
public SizedTab(string tabText, TabSize size) : this(tabText, size, Swat.WindowDefaultTextColor, Swat.WindowDefaultTextSize) { }
} //Default key is KeyCode.LeftShift. All added keys will need to be clicked in addition to this. public SizedTab Get(TabSize tab) { return(Tabs.Find(x => x.Size == tab)); }
public void AddToXmlDoc(ref XmlNode parentNode) { XmlDocument xdoc = parentNode.OwnerDocument; XmlElement newNode = xdoc.CreateElement("TextStyle"); XmlAttribute newAtt = xdoc.CreateAttribute("Name"); newAtt.Value = Name; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Description"); newAtt.Value = Description; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Background"); newAtt.Value = Background ? "1" : "0"; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Bold"); newAtt.Value = Bold ? "1" : "0"; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Italic"); newAtt.Value = Italic ? "1" : "0"; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Underline"); newAtt.Value = Underline ? "1" : "0"; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Color"); newAtt.Value = string.Format("{0}-{1}-{2}", Color.R.ToString("D3"), Color.G.ToString("D3"), Color.B.ToString("D3")); newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("Leader"); newAtt.Value = Leader.Name; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("LeaderOffset"); newAtt.Value = LeaderOffset.ToString(); newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("LineWeight"); newAtt.Value = LineWeight.ToString(); newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("TextBox"); newAtt.Value = TextBox ? "1" : "0"; newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("TabSize"); newAtt.Value = TabSize.ToString(); newNode.Attributes.Append(newAtt); newAtt = xdoc.CreateAttribute("WidthFactor"); newAtt.Value = WidthFactor.ToString(); newNode.Attributes.Append(newAtt); parentNode.AppendChild(newNode); }