public void GuiRender() { GUI.skin = _settings.GUISkin; var fullRect = new Rect( 0, 0, _window.position.width, _window.position.height); _list.Draw(fullRect); if (IsBlocking) { ImguiUtil.DrawColoredQuad(fullRect, _settings.Theme.LoadingOverlayColor); DisplayGenericProcessingDialog(fullRect); } }
void DisplayGenericProcessingDialog(Rect fullRect) { var skin = _settings.AsyncPopupPane; var popupRect = ImguiUtil.CenterRectInRect(fullRect, skin.PopupSize); DrawPopupCommon(fullRect, popupRect); var contentRect = ImguiUtil.CreateContentRectWithPadding( popupRect, skin.PanelPadding); GUILayout.BeginArea(contentRect); { string title; if (string.IsNullOrEmpty(BlockedStatusTitle)) { title = "Processing"; } else { title = BlockedStatusTitle; } GUILayout.Label(title, skin.HeadingTextStyle, GUILayout.ExpandWidth(true)); GUILayout.Space(skin.HeadingBottomPadding); string statusMessage = ""; if (!string.IsNullOrEmpty(BlockedStatusMessage)) { statusMessage = BlockedStatusMessage; int numExtraDots = (int)(Time.realtimeSinceStartup * skin.DotRepeatRate) % 4; statusMessage += new String('.', numExtraDots); // This is very hacky but the only way I can figure out how to keep the message a fixed length // so that the text doesn't jump around as the number of dots change // I tried using spaces instead of _ but that didn't work statusMessage += ImguiUtil.WrapWithColor(new String('_', 3 - numExtraDots), _settings.Theme.LoadingOverlapPopupColor); } GUILayout.Label(statusMessage, skin.StatusMessageTextStyle, GUILayout.ExpandWidth(true)); } GUILayout.EndArea(); }
public void Draw(Rect fullRect) { Rect listRect; if (ShowSortPane) { var searchRect = new Rect(fullRect.xMin, fullRect.yMin, fullRect.width, _settings.IconRowHeight); DrawSearchPane(searchRect); listRect = Rect.MinMaxRect( fullRect.xMin, fullRect.yMin + _settings.IconRowHeight, fullRect.xMax, fullRect.yMax); } else { listRect = fullRect; } var searchFilter = SearchFilter.Trim().ToLowerInvariant(); var visibleEntries = _entries.Where(x => x.Name.ToLowerInvariant().Contains(searchFilter)).ToList(); var viewRect = new Rect(0, 0, listRect.width - 30.0f, visibleEntries.Count * _settings.ItemHeight); var isListUnderMouse = listRect.Contains(Event.current.mousePosition); ImguiUtil.DrawColoredQuad(listRect, GetListBackgroundColor(isListUnderMouse)); switch (Event.current.type) { case EventType.MouseUp: { break; } case EventType.ContextClick: { if (isListUnderMouse) { ContextMenuOpenRequested(); Event.current.Use(); } break; } } bool clickedItem = false; float yPos = 0; var newScrollPos = GUI.BeginScrollView(listRect, ScrollPos, viewRect); { foreach (var entry in visibleEntries) { var labelRect = new Rect(0, yPos, listRect.width, _settings.ItemHeight); bool isItemUnderMouse = labelRect.Contains(Event.current.mousePosition); Color itemColor; if (entry.IsSelected) { itemColor = _settings.Theme.ListItemSelectedColor; } else if (GUI.enabled && isItemUnderMouse) { itemColor = _settings.Theme.ListItemHoverColor; } else if (entry.Name == ActiveScene) { itemColor = _settings.Theme.ActiveSceneSelectedColor; } else { itemColor = _settings.Theme.ListItemColor; } ImguiUtil.DrawColoredQuad(labelRect, itemColor); switch (Event.current.type) { case EventType.MouseUp: { if (isItemUnderMouse && Event.current.button == 0) { if (!Event.current.shift && !Event.current.control) { ClearSelected(); ClickSelect(entry); } } break; } case EventType.MouseDown: { if (isItemUnderMouse) { // Unfocus on text field GUI.FocusControl(null); clickedItem = true; ClickSelect(entry); Event.current.Use(); } break; } } GUI.Label(labelRect, entry.Name, _settings.ItemTextStyle); yPos += _settings.ItemHeight; } } GUI.EndScrollView(); if (newScrollPos != ScrollPos) { ScrollPositionChanged(newScrollPos); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !clickedItem && isListUnderMouse) { // Unfocus on text field GUI.FocusControl(null); ClearSelected(); } }
void DrawSearchPane(Rect rect) { Assert.That(ShowSortPane); var startX = rect.xMin; var endX = rect.xMax; var startY = rect.yMin; var endY = rect.yMax; ImguiUtil.DrawColoredQuad(rect, _settings.IconRowBackgroundColor); endX = rect.xMax - 2 * _settings.ButtonWidth; var searchBarRect = Rect.MinMaxRect(startX, startY, endX, endY); if (GUI.enabled && searchBarRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(searchBarRect, _settings.MouseOverBackgroundColor); } GUI.Label(new Rect(startX + _settings.SearchIconOffset.x, startY + _settings.SearchIconOffset.y, _settings.SearchIconSize.x, _settings.SearchIconSize.y), _settings.SearchIcon); var newSearchFilter = GUI.TextField( searchBarRect, this.SearchFilter, _settings.SearchTextStyle); if (newSearchFilter != this.SearchFilter) { SearchFilterChanged(newSearchFilter); } startX = endX; endX = startX + _settings.ButtonWidth; Rect buttonRect; buttonRect = Rect.MinMaxRect(startX, startY, endX, endY); if (buttonRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(buttonRect, _settings.MouseOverBackgroundColor); if (Event.current.type == EventType.MouseDown) { SortDescendingToggled(); //SortDescending = !SortDescending; this.UpdateIndices(); } } GUI.DrawTexture(buttonRect, SortDescending ? _settings.SortDirUpIcon : _settings.SortDirDownIcon); startX = endX; endX = startX + _settings.ButtonWidth; buttonRect = Rect.MinMaxRect(startX, startY, endX, endY); if (buttonRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(buttonRect, _settings.MouseOverBackgroundColor); if (Event.current.type == EventType.MouseDown && !_sortMethodCaptions.IsEmpty()) { var startPos = new Vector2(buttonRect.xMin, buttonRect.yMax); ImguiUtil.OpenContextMenu(startPos, CreateSortMethodContextMenuItems()); } } GUI.DrawTexture(buttonRect, _settings.SortIcon); }
public void DrawPopupCommon(Rect fullRect, Rect popupRect) { ImguiUtil.DrawColoredQuad(popupRect, _settings.Theme.LoadingOverlapPopupColor); }
public void Open() { ImguiUtil.OpenContextMenu(GetContextMenuItems()); }