private bool DrawMenuList(GUIMenuList menuList, int level, bool active) { GUILayout.BeginVertical(); var bgdepth = GUI.GetDepth(1); foreach (var item in menuList.Items) { var offsety = GUI.CurLayout.Offset.y; if (GUILayout.Button(item.Label, GUIStyle.Current.ColorBackground, GUIOption.Width(100))) { if (item is GUIMenuItem) { var menuitem = item as GUIMenuItem; if (menuitem.Function != null) { menuitem.Function.Invoke(); } m_onActive = false; //TODO //GUI.CurRegion.SetOverlayFocuse(false); } else if (item is GUIMenuList) { var menulist = item as GUIMenuList; var levelLastIndex = m_drawLevels.Count - 1; if (m_drawLevels[levelLastIndex] != menulist) { if (levelLastIndex > level) { m_drawLevels.RemoveRange(level + 1, levelLastIndex - level); m_drawOffset.RemoveRange(level + 1, levelLastIndex - level); } m_drawLevels.Add(menulist); m_drawOffset.Add(offsety - (m_drawOffset[m_drawOffset.Count - 1])); } } } GUILayout.Space(-2); } GUILayout.Space(2); var layoutrect = GUILayout.EndVertical(); var layoutrectab = GUI.GetAbsoluteRect(layoutrect); var depthprev = GUI.SetDepth(bgdepth); GUI.RectAbsolute(layoutrectab, GUIStyle.Current.ColorActiveD); GUI.SetDepth(depthprev); if (!GUI.Event.Used && !active) { return(GUIUtility.RectContainsCheck(layoutrectab, GUI.Event.Pointer)); } return(active); }
internal bool CheckOver(Vector2 pointer) { if (GUIUtility.RectContainsCheck(Rect, pointer)) { return(true); } return(false); }
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); }