Пример #1
0
    protected Vector2 FileListView(GUIContent label, Vector2 scrollPos, FilterDelegate filter, ChangeTypeDelegate changeTypeFetcher, WholeFileCommand cmd, ListSelectionState selectionCache)
    {
        int      id    = GUIUtility.GetControlID(FocusType.Passive);
        ListView state = (ListView)GUIUtility.GetStateObject(typeof(ListView), id);

        state.controlID = id;
        state.selection = selectionCache;

        Event current   = Event.current;
        bool  isChanged = false;

        GUILayout.Label(label, GitStyles.BoldLabel, GUIHelper.NoExpandWidth);
        Rect listPosition = EditorGUILayout.BeginVertical();

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GitStyles.FileListBox);
        if (changes != null)
        {
            for (int i = 0; i < changes.Length; i++)
            {
                if (filter(changes[i]))
                {
                    isChanged = isChanged || ShowFile(state, changes[i].path, changeTypeFetcher(changes[i]), cmd);
                }
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        switch (current.type)
        {
        case EventType.MouseDown:
            if (listPosition.Contains(current.mousePosition))
            {
                GUIUtility.hotControl      = id;
                GUIUtility.keyboardControl = id;
                current.Use();
            }
            else
            {
                if (GUIUtility.keyboardControl == id)
                {
                    GUIUtility.keyboardControl = 0;
                }
            }
            break;

        case EventType.MouseUp:
            if (GUIUtility.hotControl == id)
            {
                // Done dragging...
                GUIUtility.hotControl = 0;
                current.Use();
            }
            break;
        }
        state.hasFocus = GUIUtility.keyboardControl == id;
        if (!state.hasFocus)
        {
            state.selection.Clear();
        }
        if (isChanged)
        {
            GUI.changed = true;
            current.Use();
        }

        return(scrollPos);
    }
Пример #2
0
 public void Reset()
 {
     hasFocus = false;
       selection = null;
 }
Пример #3
0
 public void Reset()
 {
     hasFocus  = false;
     selection = null;
 }
Пример #4
0
    protected Vector2 FileListView(GUIContent label, Vector2 scrollPos, FilterDelegate filter, ChangeTypeDelegate changeTypeFetcher, WholeFileCommand cmd, ListSelectionState selectionCache)
    {
        int id = GUIUtility.GetControlID(FocusType.Passive);
        ListView state = (ListView)GUIUtility.GetStateObject(typeof(ListView), id);
        state.controlID = id;
        state.selection = selectionCache;

        Event current = Event.current;
        bool isChanged = false;

        GUILayout.Label(label, GitStyles.BoldLabel, GUIHelper.NoExpandWidth);
        Rect listPosition = EditorGUILayout.BeginVertical();
          scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GitStyles.FileListBox);
        if(changes != null) {
          for(int i = 0; i < changes.Length; i++) {
            if(filter(changes[i])) {
              isChanged = isChanged || ShowFile(state, changes[i].path, changeTypeFetcher(changes[i]), cmd);
            }
          }
        }
          EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        switch(current.type) {
          case EventType.MouseDown:
        if(listPosition.Contains(current.mousePosition)) {
          GUIUtility.hotControl = id;
          GUIUtility.keyboardControl = id;
          current.Use();
        } else {
          if(GUIUtility.keyboardControl == id) {
            GUIUtility.keyboardControl = 0;
          }
        }
        break;
          case EventType.MouseUp:
        if(GUIUtility.hotControl == id) {
          // Done dragging...
          GUIUtility.hotControl = 0;
          current.Use();
        }
        break;
        }
        state.hasFocus = GUIUtility.keyboardControl == id;
        if(!state.hasFocus) {
          state.selection.Clear();
        }
        if(isChanged) {
          GUI.changed = true;
          current.Use();
        }

        return scrollPos;
    }