예제 #1
0
파일: UFGui.cs 프로젝트: iwaldrop/UFind
        internal static void SearchBar()
        {
            const string QUERY_FIELD_NAME = "query";

            using (new GUILayout.HorizontalScope(UFStyles.SearchField))
            {
                GUILayout.Box(string.Empty, UFStyles.SearchIcon);

                GUI.SetNextControlName(QUERY_FIELD_NAME);
                GUI.FocusControl(QUERY_FIELD_NAME);

                EditorGUI.BeginChangeCheck();
                var query = GUILayout.TextArea(UFModel.Context.Query.Value, UFStyles.SearchField);
//				var id = GUIUtility.GetControlID(FocusType.Keyboard, GUILayoutUtility.GetLastRect());
//				var editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), id - 1);

                if (EditorGUI.EndChangeCheck())
                {
                    UFController.UpdateQuery(query);
                }

                if (UFModel.Context.SelectedResult != null)
                {
                    GUILayout.Box(UFModel.Context.SelectedResult.Content.image, UFStyles.Icons);
                }
            }
        }
예제 #2
0
        void OnGUI()
        {
            if (Event.current.type == EventType.keyDown)
            {
                UFController.ProcessEvent(Event.current);
            }

            GUI.skin = UFStyles.Skin;
            UFGui.SearchBar();
            if (UFModel.ResultCount > 0)
            {
                UFGui.ResultList(WINDOW_WIDTH);
//				using (var h = new GUILayout.HorizontalScope())
//				{
//					UFGui.ResultList(WINDOW_WIDTH * 0.4f);
//					if (UFModel.Context.CurrentResult != null)
//					{
//						UFGui.DetailView(UFModel.Context.CurrentResult, WINDOW_WIDTH * 0.6f);
//					}
//				}
            }
            GUI.skin = null;

            position = WindowPosition;
            Repaint();
        }
예제 #3
0
        internal static void ProcessEvent(Event current)
        {
            // this section was for selecting a result by number; let's number them
            // before we worry about how to select them
//			if (char.IsNumber(current.character))
//			{
//				var index = int.Parse(current.character.ToString()) - 1;
//				Debug.Log(string.Format("char {0} => index {1}", current.character, index));
//				UFModel.Results.SelectAtIndex(index);
//				current.Use();
//				return;
//			}

            switch (current.keyCode)
            {
            case KeyCode.Escape:
                UFController.CloseWindow();
                current.Use();
                break;

            case KeyCode.UpArrow:
                UFModel.SelectPreviousResult();
                current.Use();
                break;

            case KeyCode.DownArrow:
                UFModel.SelectNextResult();
                current.Use();
                break;

            case KeyCode.KeypadEnter:
            case KeyCode.Return:
                UFModel.Context.SelectedResult.Execute(UFModel.Context);
                CloseWindow();
                current.Use();
                break;
            }
        }