Browse Source

Change split view to horizontal

master
chrisgregan 11 years ago
parent
commit
eb929a570c
  1. 65
      Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs

65
Assets/Fungus/FungusScript/Editor/SplitViewWindow.cs

@ -4,49 +4,68 @@ using UnityEditor;
public class SplitViewWindow : EditorWindow public class SplitViewWindow : EditorWindow
{ {
private Vector2 scrollPos = Vector2.zero; private Vector2 scrollPos = Vector2.zero;
float currentScrollViewHeight; float commandViewWidth;
bool resize = false; bool resize = false;
Rect cursorChangeRect; Rect cursorChangeRect;
public float minViewWidth = 150;
[MenuItem("MyWindows/SplitView")] [MenuItem("MyWindows/SplitView")]
public static void Init(){ public static void Init(){
GetWindow<SplitViewWindow>(); GetWindow<SplitViewWindow>();
} }
void OnEnable(){ void OnEnable()
this.position = new Rect(200,200,400,300); {
currentScrollViewHeight = this.position.height/2; commandViewWidth = minViewWidth;
cursorChangeRect = new Rect(0,currentScrollViewHeight,this.position.width,5f); cursorChangeRect = new Rect(this.position.width - commandViewWidth, 0, 4f, this.position.height);
} }
void OnGUI(){ void OnGUI()
GUILayout.BeginVertical(); {
scrollPos = GUILayout.BeginScrollView(scrollPos,GUILayout.Height(currentScrollViewHeight)); GUILayout.BeginHorizontal();
for(int i=0;i<20;i++) DrawScriptView();
GUILayout.Label("dfs"); ResizeViews();
GUILayout.EndScrollView(); GUILayout.EndHorizontal();
ResizeScrollView(); Repaint();
}
GUILayout.FlexibleSpace(); void DrawScriptView()
GUILayout.Label("Lower part"); {
Rect scriptViewRect = new Rect(0, 0, this.position.width - commandViewWidth, this.position.height);
GUILayout.EndVertical(); scrollPos = GUI.BeginScrollView(scriptViewRect, scrollPos, scriptViewRect);
Repaint();
GUI.EndScrollView();
} }
private void ResizeScrollView(){ void ResizeViews()
GUI.DrawTexture(cursorChangeRect,EditorGUIUtility.whiteTexture); {
EditorGUIUtility.AddCursorRect(cursorChangeRect,MouseCursor.ResizeVertical); cursorChangeRect.x = this.position.width - commandViewWidth;
cursorChangeRect.height = this.position.height;
if( Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition)){ GUI.color = Color.grey;
GUI.DrawTexture(cursorChangeRect, EditorGUIUtility.whiteTexture);
EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeHorizontal);
if (Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition))
{
resize = true; resize = true;
} }
if(resize){ if (resize)
currentScrollViewHeight = Event.current.mousePosition.y; {
cursorChangeRect.Set(cursorChangeRect.x,currentScrollViewHeight,cursorChangeRect.width,cursorChangeRect.height); commandViewWidth = this.position.width - Event.current.mousePosition.x;
commandViewWidth = Mathf.Max(minViewWidth, commandViewWidth);
commandViewWidth = Mathf.Min(this.position.width - minViewWidth, commandViewWidth);
} }
if(Event.current.type == EventType.MouseUp) if(Event.current.type == EventType.MouseUp)
{
resize = false; resize = false;
} }
}
void DrawCommandView()
{
}
} }
Loading…
Cancel
Save