예제 #1
0
파일: UFGui.cs 프로젝트: iwaldrop/UFind
        internal static void ResultItem(IFinderResult result)
        {
            using (new GUILayout.HorizontalScope())
            {
                if (UFModel.Context.SelectedResult == result)
                {
                    GUI.SetNextControlName("focused");
                    GUI.FocusControl("focused");
                }

                if (GUILayout.Button(string.Empty, GUILayout.ExpandWidth(true)))
                {
                    UFModel.SelectResult(result);
                }

                var buttonRect = GUILayoutUtility.GetLastRect();
                var content    = result.Content;

                var imageRect = new Rect(buttonRect);
                imageRect.size   = Vector2.one * buttonRect.height;
                imageRect.width += 20;

                var titleRect = new Rect(buttonRect);
                titleRect.xMin   = imageRect.xMax;
                titleRect.yMin   = buttonRect.yMin;
                titleRect.width  = buttonRect.width - imageRect.width;
                titleRect.height = buttonRect.height;

                var descriptionContent = result.Description;
                if (!(descriptionContent == null || string.IsNullOrEmpty(descriptionContent.text)))
                {
                    titleRect.height = buttonRect.height * 0.6f;

                    var descriptionRect = new Rect(titleRect);
                    descriptionRect.yMin = titleRect.yMax;
                    descriptionRect.yMax = buttonRect.yMax;
                    GUI.Label(descriptionRect, result.Description, UFStyles.Description);
                }

                GUI.Box(imageRect, content.image, GUI.skin.button);
                GUI.Label(titleRect, content.text, UFStyles.Title);
            }
        }
예제 #2
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;
            }
        }
예제 #3
0
 public static void ShowWindow()
 {
     UFModel.UpdateResults();
     UFModel.Window = ScriptableObject.CreateInstance <UFWindow>();
     UFModel.Window.Show();
 }
예제 #4
0
 internal static void UpdateQuery(string query)
 {
     UFModel.Context.Query = query;
     UFModel.UpdateResults();
 }