private int DrawTabHeader(Vector4 rectHeader) { GUI.BeginArea(rectHeader); if (m_verticalMode) { GUILayout.BeginVertical(); for (int i = 0; i < m_tabnames.Count; i++) { if (GUILayout.Button(m_tabnames[i], GUIOption.Width(m_verticalTabWidth))) { m_tabindex = i; } } GUILayout.EndVertical(); } else { GUILayout.BeginHorizontal(); for (int i = 0; i < m_tabnames.Count; i++) { if (GUILayout.Button(m_tabnames[i], GUIOption.Width(75))) { m_tabindex = i; } } GUILayout.EndHorizontal(); } GUI.EndArea(); return(m_tabindex); }
public int Draw(Vector4 rect, int index, List <string> tabnames, Action <int> drawFunction) { m_tabnames = tabnames; m_tabindex = index; var rectHeader = rect; if (m_verticalMode) { rectHeader.Z = m_verticalTabWidth; m_tabindex = DrawTabHeader(rectHeader); rect.X += m_verticalTabWidth; rect.Z -= m_verticalTabWidth; } else { rectHeader.W = m_tabhederHeght; m_tabindex = DrawTabHeader(rectHeader); rect.Y += m_tabhederHeght; rect.W -= m_tabhederHeght; } GUI.BeginArea(rect); if (drawFunction != null) { drawFunction.Invoke(index); } GUI.EndArea(); return(m_tabindex); }
public void Draw(bool click, GUIMenuList menu, Vector4 rect) { if (menu == null || menu.Items.Count == 0) { return; } if (click) { m_onActive = true; m_drawLevels.Clear(); m_drawLevels.Add(menu); m_drawOffset.Clear(); m_drawOffset.Add(0); //TODO //GUI.CurRegion.SetOverlayFocuse(true); } bool active = false; if (m_onActive) { var containerRectA = rect.Move(0, rect.w).SetSize(800, 300); GUI.BeginArea(containerRectA); { GUILayout.BeginHorizontal(); { for (int i = 0; i < m_drawLevels.Count; i++) { GUILayout.Space(m_drawOffset[i]); active |= DrawMenuList(m_drawLevels[i], i, active); GUILayout.Indent(-1); } } GUILayout.EndHorizontal(); } GUI.EndArea(); if (!active && GUI.Event.IsMouseActiveEvent() && !GUI.Event.Used) { m_onActive = false; //TODO //GUI.CurRegion.SetOverlayFocuse(false); } } }
public override void OnGUI(RigelGUIEvent e) { GUILayout.BeginHorizontal(); if (GUILayout.Button("<", GUIOption.Grid(0.1f))) { m_sampleIndex += m_sampleFunctions.Count - 1; m_sampleIndex = m_sampleIndex % m_sampleFunctions.Count; } GUILayout.Button(m_sampleFunctions[m_sampleIndex].Method.Name, GUIOption.Grid(0.8f)); if (GUILayout.Button(">", GUIOption.Grid(0.1f))) { m_sampleIndex++; m_sampleIndex = m_sampleIndex % m_sampleFunctions.Count; } GUILayout.EndHorizontal(); GUI.BeginArea(new Vector4(GUI.CurLayout.Offset, GUI.CurLayout.RemainSize), true); m_sampleFunctions[m_sampleIndex](e); GUI.EndArea(); }
public void Draw(Vector4 rect, Vector4 rectab, Vector2 pos, GUIScrollType scrolltype) { GUI.BeginArea(rect, true); m_rectAbsolute = rectab; if (!m_scrollInit) { m_scrollPos = pos; m_scrollType = scrolltype; m_scrollInit = true; } if ((m_scrollType & GUIScrollType.Vertical) > 0) { GUILayout.Space(m_scrollPos.y); m_scrollV = true; } if ((m_scrollType & GUIScrollType.Horizontal) > 0) { GUILayout.Indent(m_scrollPos.x); m_scrollH = true; } }
public static void Update() { if (EditForm != null) { Input.Enabled = !EditForm.Visible; } else { Input.Enabled = true; } GUI.Clear(GUIColors.White); // if (Tasks.Count != 0) { int TaskHeight = 65; int ScrollHeight = TaskHeight * TasksCount; ScrollOffset = GUI.BeginScrollView(new Rect(0, 0, GUI.Width - 230, GUI.Height), new Rect(0, 0, GUI.Width - 230, ScrollHeight), ScrollOffset); int offset = 0; int count = 0; TasksCount = 0; foreach (Task T in Tasks) { if (T.Deleted == 0) { Rect TaskArea = new Rect(0, offset * TaskHeight, GUI.Width - 230, TaskHeight); Rect ClickTaskArea = new Rect(0, offset * TaskHeight - ScrollOffset.Y, GUI.Width - 230 - 8, TaskHeight); GUI.BeginArea(TaskArea); if (CurrentTask == count) { GUI.DrawQuad(new Rect(0, 0, 5, TaskHeight), GUIColors.Orange); } GUI.Label(new Rect(7, 7, 550, 30), T.Title, Styles.TaskTitle); GUI.Label(new Rect(9, 37, 550, 30), T.Description, Styles.TaskDescription); if (T.State == 0) { GUI.Box(new Rect(GUI.Width - 230 - 115, 15, 100, 35), "Not solved", Styles.TaskNotSolved); } if (T.State == 1) { GUI.Box(new Rect(GUI.Width - 230 - 115, 15, 100, 35), "Solved", Styles.TaskSolved); } if (T.State == 2) { GUI.Box(new Rect(GUI.Width - 230 - 115, 15, 100, 35), "Processing", Styles.TaskProcessing); } GUI.Box(new Rect(0, TaskHeight - 1, GUI.Width - 230, 1), "", Styles.Divider); GUI.EndArea(); if (Input.Hover(ClickTaskArea) && Input.GetMouseLeftDown()) { if (CurrentTask != count) { CurrentTask = count; } else { CurrentTask = -1; } } // offset++; TasksCount++; } count++; } GUI.EndScrollView(); } else { GUI.Label(new Rect(10, 10, 500, 500), "No tasks yet"); } GUI.Box(new Rect(GUI.Width - 230, 0, 1, GUI.Height), "", Styles.Divider); if (GUI.Button(new Rect(GUI.Width - 215, 15, 200, 50), "New task")) { SetupEditForm(); OnEditTask = delegate { AddTask(UI.Controls["TaskTitle"].Text, UI.Controls["TaskDescription"].Text); }; //UI.Controls["FormPanel"].Visible = !UI.Controls["FormPanel"].Visible; EditForm.Visible = !EditForm.Visible; } if (CurrentTask >= 0) //if selected any task { Task T = Tasks[CurrentTask]; GUI.Box(new Rect(GUI.Width - 230, 80, 230, 1), "", Styles.Divider); if (GUI.Button(new Rect(GUI.Width - 215, 150, 200, 40), "Edit")) { SetupEditForm(); UI.Controls["TaskTitle"].Text = T.Title; UI.Controls["TaskDescription"].Text = T.Description; OnEditTask = delegate { EditTask(CurrentTask, UI.Controls["TaskTitle"].Text, UI.Controls["TaskDescription"].Text, T.State, T.Deleted); }; //UI.Controls["FormPanel"].Visible = !UI.Controls["FormPanel"].Visible; EditForm.Visible = !EditForm.Visible; } if (T.State == 0) { if (GUI.Button(new Rect(GUI.Width - 215, 95, 200, 40), "Processing", Styles.YellowButton)) { EditTask(CurrentTask, T.Title, T.Description, 2, T.Deleted); } } else if (T.State == 2) { if (GUI.Button(new Rect(GUI.Width - 215, 95, 200, 40), "Make as solved", Styles.GreenButton)) { EditTask(CurrentTask, T.Title, T.Description, 1, T.Deleted); } } else { if (GUI.Button(new Rect(GUI.Width - 215, 95, 200, 40), "Not solved", Styles.RedButton)) { EditTask(CurrentTask, T.Title, T.Description, 0, T.Deleted); } } if (GUI.Button(new Rect(GUI.Width - 215, 205, 200, 40), "Delete", Styles.RedButton)) { EditTask(CurrentTask, T.Title, T.Description, T.State, 1); } } }
private void SampleLayout(RigelGUIEvent e) { //Absolute and relative { GUI.Rect(new Vector4(0, 0, 20, 20), RigelColor.Red); Vector4 rectab = new Vector4(View.Rect.x + 21, View.Rect.y + 25, 20, 20); GUI.RectAbsolute(rectab, RigelColor.Red); } //Nested area { GUI.BeginArea(new Vector4(0, 25, 40, 40)); { GUI.Rect(new Vector4(0, 20, 20, 20), RigelColor.Blue); GUI.Rect(new Vector4(20, 0, 20, 20), RigelColor.Green); } GUI.EndArea(); } //Layout { var viewRect = View.Rect; GUI.BeginArea(new Vector4(viewRect.z / 2, 0, viewRect.z / 2, viewRect.w - 25)); { GUILayout.Button("Button1"); GUILayout.Button("Button2"); GUILayout.BeginHorizontal(); { //Option Grid GUILayout.Button("Btn3", GUIOption.Grid(0.5f)); //Indent GUILayout.Indent(10); //Line extrude GUILayout.Button("Btnh", GUIOption.Width(20), GUIOption.Height(50)); //Option Width GUILayout.Button("Btn4", GUIOption.Width(10)); } GUILayout.EndHorizontal(); GUILayout.Button("Btn5", GUIOption.Width(20)); GUILayout.BeginHorizontal(); { //OptionGrid base on LayoutInfo GUILayout.Button("H1", GUIOption.Grid(0.5f)); GUILayout.Button("H2", GUIOption.Grid(0.5f)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("H1", GUIOption.Width(30)); GUILayout.BeginVertical(); { GUILayout.Button("Test", GUIOption.Width(15)); //GUILayout.Indent(10); GUILayout.Button("Text", GUIOption.Width(60)); } GUILayout.EndVertical(); GUILayout.Button("H3", GUIOption.Width(30)); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label("Current Pointer " + e.Pointer); GUI.Rect(new Vector4(0, 0, 5, 5), RigelColor.Red); } GUI.EndArea(); } }