private void SampleScrollView(RigelGUIEvent e) { GUILayout.BeginScrollView(m_sampleScrollPos, GUIScrollType.All); { GUILayout.Label("Clip:" + GUI.CurArea.Clip); GUILayout.Button("Button", GUIOption.Width(100)); GUILayout.Indent(300); for (int i = 0; i < 20; i++) { GUILayout.Indent(5); GUILayout.Label("Text" + i, Vector4.one); } } m_sampleScrollPos = GUILayout.EndScrollView(); }
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); } } }
protected override void OnDraw() { GUILayout.Button("ddd"); var offset = GUILayout.CurrentLayout.Offset; GUILayout.Space(m_size.Y - offset.Y - 50); m_targetpath = GUILayout.TextInput("FileName", m_targetpath); GUILayout.BeginHorizontal(); GUILayout.Indent((int)(m_size.X - 243)); if (GUILayout.Button("Open", GUIOption.Width(120))) { OnOpen(); } if (GUILayout.Button("Cancel", GUIOption.Width(120))) { OnCancel(); } GUILayout.EndHorizontal(); }
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; } }
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(); } }
private void SampleMenuList(RigelGUIEvent e) { GUILayout.Indent(250); GUILayout.DrawMenu(m_sampleMenuList, GUIOption.Width(150)); GUILayout.Button("Button on nextline"); }
public Vector2 LateDraw() { GUILayout.Indent(-GUI.CurLayout.Offset.x); GUILayout.Label("Content:" + GUI.CurArea.ContentMax); Vector2 content = GUI.CurArea.ContentMax - m_scrollPos; m_maxscroll = m_rectAbsolute.Size() - content; bool wheelScrollBarV = false; if (content.y > m_rectAbsolute.w && m_scrollV) { m_rectBarV = new Vector4(m_rectAbsolute.z - 6, 0, 6, m_rectAbsolute.w); GUI.Rect(m_rectBarV, GUIStyle.Current.ColorBackground); float ysize = m_rectAbsolute.w / content.y * (m_rectAbsolute.w - 6); float yoff = -m_scrollPos.y / content.y * (m_rectAbsolute.w - 6); var thumbRect = new Vector4(m_rectBarV.x, yoff, 6, ysize); var scrollBarVdrag = false; if (!GUI.Event.Used) { if (GUI.Event.EventType == RigelGUIEventType.MouseWheel) { m_scrollPos.y += 0.2f * GUI.Event.Delta; if (m_scrollPos.y > 0) { m_scrollPos.y = 0; } if (m_scrollPos.y < m_maxscroll.y) { m_scrollPos.y = m_maxscroll.y; } GUI.Event.Use(); wheelScrollBarV = true; } else { var thumbRectA = GUI.GetAbsoluteRect(thumbRect); var contains = GUIUtility.RectContainsCheck(thumbRectA, GUI.Event.Pointer); if (contains) { scrollBarVdrag = true; } if (m_scrollVertical.OnDrag(contains)) { m_scrollPos.y -= m_scrollVertical.OffSet.y; if (m_scrollPos.y > 0) { m_scrollPos.y = 0; } if (m_scrollPos.y < m_maxscroll.y) { m_scrollPos.y = m_maxscroll.y; } scrollBarVdrag = true; } } } GUI.Rect(thumbRect, scrollBarVdrag ? GUIStyle.Current.ColorActiveD : GUIStyle.Current.ColorBackgroundL2); } if (content.x > m_rectAbsolute.z && m_scrollH) { m_rectBarH = new Vector4(0, m_rectAbsolute.w - 6, m_rectAbsolute.z - 6, 6); GUI.Rect(m_rectBarH, GUIStyle.Current.ColorBackground); float xsize = m_rectAbsolute.z / content.x * (m_rectAbsolute.z - 6); float xoff = -m_scrollPos.x / content.x * (m_rectAbsolute.z - 6); var thumbRect = new Vector4(xoff, m_rectBarH.y, xsize, 6); var scrollBarHdrag = false; if (!GUI.Event.Used) { if (!wheelScrollBarV && GUI.Event.EventType == RigelGUIEventType.MouseWheel) { m_scrollPos.x += 0.2f * GUI.Event.Delta; if (m_scrollPos.x > 0) { m_scrollPos.x = 0; } if (m_scrollPos.x < m_maxscroll.x) { m_scrollPos.x = m_maxscroll.x; } GUI.Event.Use(); } else { var thumbRectA = GUI.GetAbsoluteRect(thumbRect); var contains = GUIUtility.RectContainsCheck(thumbRectA, GUI.Event.Pointer); if (contains) { scrollBarHdrag = true; } if (m_scrollHorizontal.OnDrag(contains)) { m_scrollPos.x -= m_scrollHorizontal.OffSet.x; if (m_scrollPos.x > 0) { m_scrollPos.x = 0; } if (m_scrollPos.x < m_maxscroll.x) { m_scrollPos.x = m_maxscroll.x; } scrollBarHdrag = true; } } } GUI.Rect(thumbRect, scrollBarHdrag ? GUIStyle.Current.ColorActiveD : GUIStyle.Current.ColorBackgroundL2); } GUI.EndArea(); return(m_scrollPos); }