public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { SplitterGUILayout.GUISplitterGroup guiSplitterGroup = (SplitterGUILayout.GUISplitterGroup) GUILayoutUtility.BeginLayoutGroup(style, (GUILayoutOption[]) null, typeof (SplitterGUILayout.GUISplitterGroup)); state.ID = GUIUtility.GetControlID(SplitterGUILayout.splitterHash, FocusType.Native); switch (Event.current.GetTypeForControl(state.ID)) { case EventType.MouseDown: if (Event.current.button != 0 || Event.current.clickCount != 1) break; int num1 = !guiSplitterGroup.isVertical ? (int) guiSplitterGroup.rect.x : (int) guiSplitterGroup.rect.y; int num2 = !guiSplitterGroup.isVertical ? (int) Event.current.mousePosition.x : (int) Event.current.mousePosition.y; for (int index = 0; index < state.relativeSizes.Length - 1; ++index) { if ((!guiSplitterGroup.isVertical ? new Rect(state.xOffset + (float) num1 + (float) state.realSizes[index] - (float) (state.splitSize / 2), guiSplitterGroup.rect.y, (float) state.splitSize, guiSplitterGroup.rect.height) : new Rect(state.xOffset + guiSplitterGroup.rect.x, (float) (num1 + state.realSizes[index] - state.splitSize / 2), guiSplitterGroup.rect.width, (float) state.splitSize)).Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num2; state.currentActiveSplitter = index; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num1 += state.realSizes[index]; } break; case EventType.MouseUp: if (GUIUtility.hotControl != state.ID) break; GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); break; case EventType.MouseDrag: if (GUIUtility.hotControl != state.ID || state.currentActiveSplitter < 0) break; int num3 = !guiSplitterGroup.isVertical ? (int) Event.current.mousePosition.x : (int) Event.current.mousePosition.y; int diff = num3 - state.splitterInitialOffset; if (diff != 0) { state.splitterInitialOffset = num3; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, diff); } Event.current.Use(); break; case EventType.Repaint: int num4 = !guiSplitterGroup.isVertical ? (int) guiSplitterGroup.rect.x : (int) guiSplitterGroup.rect.y; for (int index = 0; index < state.relativeSizes.Length - 1; ++index) { EditorGUIUtility.AddCursorRect(!guiSplitterGroup.isVertical ? new Rect(state.xOffset + (float) num4 + (float) state.realSizes[index] - (float) (state.splitSize / 2), guiSplitterGroup.rect.y, (float) state.splitSize, guiSplitterGroup.rect.height) : new Rect(state.xOffset + guiSplitterGroup.rect.x, (float) (num4 + state.realSizes[index] - state.splitSize / 2), guiSplitterGroup.rect.width, (float) state.splitSize), !guiSplitterGroup.isVertical ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num4 += state.realSizes[index]; } break; case EventType.Layout: guiSplitterGroup.state = state; guiSplitterGroup.resetCoords = false; guiSplitterGroup.isVertical = vertical; guiSplitterGroup.ApplyOptions(options); break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { float pos; var g = (GUISplitterGroup)GUILayoutUtility.BeginLayoutGroup(style, null, typeof(GUISplitterGroup)); state.ID = GUIUtility.GetControlID(splitterHash, FocusType.Passive); switch (Event.current.GetTypeForControl(state.ID)) { case EventType.Layout: { g.state = state; g.resetCoords = false; g.isVertical = vertical; g.ApplyOptions(options); break; } case EventType.MouseDown: { if ((Event.current.button == 0) && (Event.current.clickCount == 1)) { float cursor = GUIUtility.RoundToPixelGrid(g.isVertical ? g.rect.y : g.rect.x); pos = GUIUtility.RoundToPixelGrid(g.isVertical ? Event.current.mousePosition.y : Event.current.mousePosition.x); for (int i = 0; i < state.relativeSizes.Length - 1; i++) { Rect splitterRect = g.isVertical ? new Rect(state.xOffset + g.rect.x, cursor + state.realSizes[i] - state.splitSize / 2, g.rect.width, state.splitSize) : new Rect(state.xOffset + cursor + state.realSizes[i] - state.splitSize / 2, g.rect.y, state.splitSize, g.rect.height); if (GUIUtility.HitTest(splitterRect, Event.current)) { state.splitterInitialOffset = pos; state.currentActiveSplitter = i; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } cursor = GUIUtility.RoundToPixelGrid(cursor + state.realSizes[i]); } } break; } case EventType.MouseDrag: { if ((GUIUtility.hotControl == state.ID) && (state.currentActiveSplitter >= 0)) { pos = g.isVertical ? Event.current.mousePosition.y : Event.current.mousePosition.x; GUIUtility.RoundToPixelGrid(pos); float diff = pos - state.splitterInitialOffset; if (diff != 0) { state.splitterInitialOffset = pos; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, diff); } Event.current.Use(); } break; } case EventType.MouseUp: { if (GUIUtility.hotControl == state.ID) { GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); } break; } case EventType.Repaint: { float cursor = GUIUtility.RoundToPixelGrid(g.isVertical ? g.rect.y : g.rect.x); for (var i = 0; i < state.relativeSizes.Length - 1; i++) { var splitterRect = g.isVertical ? new Rect(state.xOffset + g.rect.x, cursor + state.realSizes[i] - state.splitSize / 2, g.rect.width, state.splitSize) : new Rect(state.xOffset + cursor + state.realSizes[i] - state.splitSize / 2, g.rect.y, state.splitSize, g.rect.height); EditorGUIUtility.AddCursorRect(splitterRect, g.isVertical ? MouseCursor.ResizeVertical : MouseCursor.SplitResizeLeftRight, state.ID); cursor += state.realSizes[i]; } } break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { SplitterGUILayout.GUISplitterGroup gUISplitterGroup = (SplitterGUILayout.GUISplitterGroup)GUILayoutUtility.BeginLayoutGroup(style, null, typeof(SplitterGUILayout.GUISplitterGroup)); state.ID = GUIUtility.GetControlID(SplitterGUILayout.splitterHash, FocusType.Native); switch (Event.current.GetTypeForControl(state.ID)) { case EventType.MouseDown: if (Event.current.button == 0 && Event.current.clickCount == 1) { int num = (!gUISplitterGroup.isVertical) ? ((int)gUISplitterGroup.rect.x) : ((int)gUISplitterGroup.rect.y); int num2 = (!gUISplitterGroup.isVertical) ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); for (int i = 0; i < state.relativeSizes.Length - 1; i++) { if (((!gUISplitterGroup.isVertical) ? new Rect(state.xOffset + (float)num + (float)state.realSizes[i] - (float)(state.splitSize / 2), gUISplitterGroup.rect.y, (float)state.splitSize, gUISplitterGroup.rect.height) : new Rect(state.xOffset + gUISplitterGroup.rect.x, (float)(num + state.realSizes[i] - state.splitSize / 2), gUISplitterGroup.rect.width, (float)state.splitSize)).Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num2; state.currentActiveSplitter = i; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num += state.realSizes[i]; } } break; case EventType.MouseUp: if (GUIUtility.hotControl == state.ID) { GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == state.ID && state.currentActiveSplitter >= 0) { int num2 = (!gUISplitterGroup.isVertical) ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); int num3 = num2 - state.splitterInitialOffset; if (num3 != 0) { state.splitterInitialOffset = num2; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, num3); } Event.current.Use(); } break; case EventType.Repaint: { int num4 = (!gUISplitterGroup.isVertical) ? ((int)gUISplitterGroup.rect.x) : ((int)gUISplitterGroup.rect.y); for (int j = 0; j < state.relativeSizes.Length - 1; j++) { Rect position = (!gUISplitterGroup.isVertical) ? new Rect(state.xOffset + (float)num4 + (float)state.realSizes[j] - (float)(state.splitSize / 2), gUISplitterGroup.rect.y, (float)state.splitSize, gUISplitterGroup.rect.height) : new Rect(state.xOffset + gUISplitterGroup.rect.x, (float)(num4 + state.realSizes[j] - state.splitSize / 2), gUISplitterGroup.rect.width, (float)state.splitSize); EditorGUIUtility.AddCursorRect(position, (!gUISplitterGroup.isVertical) ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num4 += state.realSizes[j]; } break; } case EventType.Layout: gUISplitterGroup.state = state; gUISplitterGroup.resetCoords = false; gUISplitterGroup.isVertical = vertical; gUISplitterGroup.ApplyOptions(options); break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { int num; GUISplitterGroup group = (GUISplitterGroup)GUILayoutUtility.BeginLayoutGroup(style, null, typeof(GUISplitterGroup)); state.ID = GUIUtility.GetControlID(splitterHash, FocusType.Native); switch (Event.current.GetTypeForControl(state.ID)) { case EventType.MouseDown: if ((Event.current.button == 0) && (Event.current.clickCount == 1)) { int num2 = !group.isVertical ? ((int)group.rect.x) : ((int)group.rect.y); num = !group.isVertical ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); for (int i = 0; i < (state.relativeSizes.Length - 1); i++) { Rect rect = !group.isVertical ? new Rect(((state.xOffset + num2) + state.realSizes[i]) - (state.splitSize / 2), group.rect.y, (float)state.splitSize, group.rect.height) : new Rect(state.xOffset + group.rect.x, (float)((num2 + state.realSizes[i]) - (state.splitSize / 2)), group.rect.width, (float)state.splitSize); if (rect.Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num; state.currentActiveSplitter = i; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num2 += state.realSizes[i]; } } break; case EventType.MouseUp: if (GUIUtility.hotControl == state.ID) { GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); } break; case EventType.MouseDrag: if ((GUIUtility.hotControl == state.ID) && (state.currentActiveSplitter >= 0)) { num = !group.isVertical ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); int diff = num - state.splitterInitialOffset; if (diff != 0) { state.splitterInitialOffset = num; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, diff); } Event.current.Use(); } break; case EventType.Repaint: { int num5 = !group.isVertical ? ((int)group.rect.x) : ((int)group.rect.y); for (int j = 0; j < (state.relativeSizes.Length - 1); j++) { Rect position = !group.isVertical ? new Rect(((state.xOffset + num5) + state.realSizes[j]) - (state.splitSize / 2), group.rect.y, (float)state.splitSize, group.rect.height) : new Rect(state.xOffset + group.rect.x, (float)((num5 + state.realSizes[j]) - (state.splitSize / 2)), group.rect.width, (float)state.splitSize); EditorGUIUtility.AddCursorRect(position, !group.isVertical ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num5 += state.realSizes[j]; } break; } case EventType.Layout: group.state = state; group.resetCoords = false; group.isVertical = vertical; group.ApplyOptions(options); break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { SplitterGUILayout.GUISplitterGroup guiSplitterGroup = (SplitterGUILayout.GUISplitterGroup)GUILayoutUtility.BeginLayoutGroup(style, (GUILayoutOption[])null, typeof(SplitterGUILayout.GUISplitterGroup)); state.ID = GUIUtility.GetControlID(SplitterGUILayout.splitterHash, FocusType.Native); switch (Event.current.GetTypeForControl(state.ID)) { case EventType.MouseDown: if (Event.current.button != 0 || Event.current.clickCount != 1) { break; } int num1 = !guiSplitterGroup.isVertical ? (int)guiSplitterGroup.rect.x : (int)guiSplitterGroup.rect.y; int num2 = !guiSplitterGroup.isVertical ? (int)Event.current.mousePosition.x : (int)Event.current.mousePosition.y; for (int index = 0; index < state.relativeSizes.Length - 1; ++index) { if ((!guiSplitterGroup.isVertical ? new Rect(state.xOffset + (float)num1 + (float)state.realSizes[index] - (float)(state.splitSize / 2), guiSplitterGroup.rect.y, (float)state.splitSize, guiSplitterGroup.rect.height) : new Rect(state.xOffset + guiSplitterGroup.rect.x, (float)(num1 + state.realSizes[index] - state.splitSize / 2), guiSplitterGroup.rect.width, (float)state.splitSize)).Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num2; state.currentActiveSplitter = index; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num1 += state.realSizes[index]; } break; case EventType.MouseUp: if (GUIUtility.hotControl != state.ID) { break; } GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); break; case EventType.MouseDrag: if (GUIUtility.hotControl != state.ID || state.currentActiveSplitter < 0) { break; } int num3 = !guiSplitterGroup.isVertical ? (int)Event.current.mousePosition.x : (int)Event.current.mousePosition.y; int diff = num3 - state.splitterInitialOffset; if (diff != 0) { state.splitterInitialOffset = num3; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, diff); } Event.current.Use(); break; case EventType.Repaint: int num4 = !guiSplitterGroup.isVertical ? (int)guiSplitterGroup.rect.x : (int)guiSplitterGroup.rect.y; for (int index = 0; index < state.relativeSizes.Length - 1; ++index) { EditorGUIUtility.AddCursorRect(!guiSplitterGroup.isVertical ? new Rect(state.xOffset + (float)num4 + (float)state.realSizes[index] - (float)(state.splitSize / 2), guiSplitterGroup.rect.y, (float)state.splitSize, guiSplitterGroup.rect.height) : new Rect(state.xOffset + guiSplitterGroup.rect.x, (float)(num4 + state.realSizes[index] - state.splitSize / 2), guiSplitterGroup.rect.width, (float)state.splitSize), !guiSplitterGroup.isVertical ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num4 += state.realSizes[index]; } break; case EventType.Layout: guiSplitterGroup.state = state; guiSplitterGroup.resetCoords = false; guiSplitterGroup.isVertical = vertical; guiSplitterGroup.ApplyOptions(options); break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { int num; GUISplitterGroup group = (GUISplitterGroup) GUILayoutUtility.BeginLayoutGroup(style, null, typeof(GUISplitterGroup)); state.ID = GUIUtility.GetControlID(splitterHash, FocusType.Native); switch (Event.current.type) { case EventType.MouseDown: if ((Event.current.button == 0) && (Event.current.clickCount == 1)) { int num2 = !group.isVertical ? ((int) group.rect.x) : ((int) group.rect.y); num = !group.isVertical ? ((int) Event.current.mousePosition.x) : ((int) Event.current.mousePosition.y); for (int i = 0; i < (state.relativeSizes.Length - 1); i++) { Rect rect = !group.isVertical ? new Rect(((state.xOffset + num2) + state.realSizes[i]) - (state.splitSize / 2), group.rect.y, (float) state.splitSize, group.rect.height) : new Rect(state.xOffset + group.rect.x, (float) ((num2 + state.realSizes[i]) - (state.splitSize / 2)), group.rect.width, (float) state.splitSize); if (rect.Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num; state.currentActiveSplitter = i; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num2 += state.realSizes[i]; } } break; case EventType.MouseUp: if (GUIUtility.hotControl == state.ID) { GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); } break; case EventType.MouseDrag: if ((GUIUtility.hotControl == state.ID) && (state.currentActiveSplitter >= 0)) { num = !group.isVertical ? ((int) Event.current.mousePosition.x) : ((int) Event.current.mousePosition.y); int diff = num - state.splitterInitialOffset; if (diff != 0) { state.splitterInitialOffset = num; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, diff); } Event.current.Use(); } break; case EventType.Repaint: { int num5 = !group.isVertical ? ((int) group.rect.x) : ((int) group.rect.y); for (int j = 0; j < (state.relativeSizes.Length - 1); j++) { Rect position = !group.isVertical ? new Rect(((state.xOffset + num5) + state.realSizes[j]) - (state.splitSize / 2), group.rect.y, (float) state.splitSize, group.rect.height) : new Rect(state.xOffset + group.rect.x, (float) ((num5 + state.realSizes[j]) - (state.splitSize / 2)), group.rect.width, (float) state.splitSize); EditorGUIUtility.AddCursorRect(position, !group.isVertical ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num5 += state.realSizes[j]; } break; } case EventType.Layout: group.state = state; group.resetCoords = false; group.isVertical = vertical; group.ApplyOptions(options); break; } }
public static void BeginSplit(SplitterState state, GUIStyle style, bool vertical, params GUILayoutOption[] options) { SplitterGUILayout.GUISplitterGroup gUISplitterGroup = (SplitterGUILayout.GUISplitterGroup)GUILayoutUtility.BeginLayoutGroup(style, null, typeof(SplitterGUILayout.GUISplitterGroup)); state.ID = GUIUtility.GetControlID(SplitterGUILayout.splitterHash, FocusType.Native); switch (Event.current.type) { case EventType.MouseDown: if (Event.current.button == 0 && Event.current.clickCount == 1) { int num = (!gUISplitterGroup.isVertical) ? ((int)gUISplitterGroup.rect.x) : ((int)gUISplitterGroup.rect.y); int num2 = (!gUISplitterGroup.isVertical) ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); for (int i = 0; i < state.relativeSizes.Length - 1; i++) { if (((!gUISplitterGroup.isVertical) ? new Rect(state.xOffset + (float)num + (float)state.realSizes[i] - (float)(state.splitSize / 2), gUISplitterGroup.rect.y, (float)state.splitSize, gUISplitterGroup.rect.height) : new Rect(state.xOffset + gUISplitterGroup.rect.x, (float)(num + state.realSizes[i] - state.splitSize / 2), gUISplitterGroup.rect.width, (float)state.splitSize)).Contains(Event.current.mousePosition)) { state.splitterInitialOffset = num2; state.currentActiveSplitter = i; GUIUtility.hotControl = state.ID; Event.current.Use(); break; } num += state.realSizes[i]; } } break; case EventType.MouseUp: if (GUIUtility.hotControl == state.ID) { GUIUtility.hotControl = 0; state.currentActiveSplitter = -1; state.RealToRelativeSizes(); Event.current.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == state.ID && state.currentActiveSplitter >= 0) { int num2 = (!gUISplitterGroup.isVertical) ? ((int)Event.current.mousePosition.x) : ((int)Event.current.mousePosition.y); int num3 = num2 - state.splitterInitialOffset; if (num3 != 0) { state.splitterInitialOffset = num2; state.DoSplitter(state.currentActiveSplitter, state.currentActiveSplitter + 1, num3); } Event.current.Use(); } break; case EventType.Repaint: { int num4 = (!gUISplitterGroup.isVertical) ? ((int)gUISplitterGroup.rect.x) : ((int)gUISplitterGroup.rect.y); for (int j = 0; j < state.relativeSizes.Length - 1; j++) { Rect position = (!gUISplitterGroup.isVertical) ? new Rect(state.xOffset + (float)num4 + (float)state.realSizes[j] - (float)(state.splitSize / 2), gUISplitterGroup.rect.y, (float)state.splitSize, gUISplitterGroup.rect.height) : new Rect(state.xOffset + gUISplitterGroup.rect.x, (float)(num4 + state.realSizes[j] - state.splitSize / 2), gUISplitterGroup.rect.width, (float)state.splitSize); EditorGUIUtility.AddCursorRect(position, (!gUISplitterGroup.isVertical) ? MouseCursor.SplitResizeLeftRight : MouseCursor.ResizeVertical, state.ID); num4 += state.realSizes[j]; } break; } case EventType.Layout: gUISplitterGroup.state = state; gUISplitterGroup.resetCoords = false; gUISplitterGroup.isVertical = vertical; gUISplitterGroup.ApplyOptions(options); break; } }