public void OnGUI(Rect fullRect) { GUI.skin = _pmSettings.GUISkin; if (IsBlocked) { // Do not allow any input processing when running an async task GUI.enabled = false; } DrawArrowColumns(fullRect); var windowRect = Rect.MinMaxRect( _settings.ListVerticalSpacing + _settings.ArrowWidth, _settings.MarginTop, fullRect.width - _settings.ListVerticalSpacing - _settings.ArrowWidth, fullRect.height - _settings.MarginBottom); if (_split1 >= 0.1f) { DrawReleasePane(windowRect); } if (_split2 >= 0.1f) { DrawPackagesPane(windowRect); } if (_split2 <= 0.92f) { DrawProjectPane(windowRect); } GUI.enabled = true; if (IsBlocked) { if (ShowBlockedPopup || !_popupHandlers.IsEmpty()) { ImguiUtil.DrawColoredQuad(fullRect, _settings.Theme.LoadingOverlayColor); if (_popupHandlers.IsEmpty()) { DisplayGenericProcessingDialog(fullRect); } else { foreach (var info in _popupHandlers) { info.Handler(fullRect); } } } } }
public void Draw(Rect fullRect) { Rect listRect; if (ShowSortPane) { var releaseSkin = _pmSettings.ReleasesPane; var searchRect = new Rect(fullRect.xMin, fullRect.yMin, fullRect.width, releaseSkin.IconRowHeight); DrawSearchPane(searchRect); listRect = Rect.MinMaxRect( fullRect.xMin, fullRect.yMin + releaseSkin.IconRowHeight, fullRect.xMax, fullRect.yMax); } else { listRect = fullRect; } var searchFilter = _model.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: { // Clear our drag info in DragAndDrop so that we know that we are not dragging DragAndDrop.PrepareStartDrag(); break; } case EventType.DragPerform: // Drag has completed { if (isListUnderMouse) { DragAndDrop.AcceptDrag(); var receivedDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (receivedDragData != null) { DragAndDrop.PrepareStartDrag(); _manager.OnDragDrop(receivedDragData, this); } } break; } case EventType.MouseDrag: { if (isListUnderMouse) { var existingDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (existingDragData != null) { DragAndDrop.StartDrag("Dragging List Element"); Event.current.Use(); } } break; } case EventType.DragUpdated: { if (isListUnderMouse) { var existingDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (existingDragData != null && (_manager != null && _manager.IsDragAllowed(existingDragData, this))) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Event.current.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } break; } case EventType.ContextClick: { if (isListUnderMouse) { _manager.OpenContextMenu(this); Event.current.Use(); } break; } } bool clickedItem = false; float yPos = 0; _model.ScrollPos = GUI.BeginScrollView(listRect, _model.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 { itemColor = GUI.enabled && isItemUnderMouse ? _settings.Theme.ListItemHoverColor : _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) { _manager.ClearSelected(); ClickSelect(entry); } } break; } case EventType.MouseDown: { if (isItemUnderMouse) { // Unfocus on text field GUI.FocusControl(null); clickedItem = true; ClickSelect(entry); if (Event.current.button == 0) { DragAndDrop.PrepareStartDrag(); var dragData = new DragData() { Entries = GetSelected(), SourceList = this, }; DragAndDrop.SetGenericData(DragId, dragData); DragAndDrop.objectReferences = new UnityEngine.Object[0]; } Event.current.Use(); } break; } } GUI.Label(labelRect, entry.Name, _settings.ItemTextStyle); yPos += _settings.ItemHeight; } } GUI.EndScrollView(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !clickedItem && isListUnderMouse) { // Unfocus on text field GUI.FocusControl(null); _manager.ClearSelected(); } }
void DrawSearchPane(Rect rect) { Assert.That(ShowSortPane); var startX = rect.xMin; var endX = rect.xMax; var startY = rect.yMin; var endY = rect.yMax; var skin = _pmSettings.ReleasesPane; ImguiUtil.DrawColoredQuad(rect, skin.IconRowBackgroundColor); endX = rect.xMax - 2 * skin.ButtonWidth; var searchBarRect = Rect.MinMaxRect(startX, startY, endX, endY); if (GUI.enabled && searchBarRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(searchBarRect, skin.MouseOverBackgroundColor); } GUI.Label(new Rect(startX + skin.SearchIconOffset.x, startY + skin.SearchIconOffset.y, skin.SearchIconSize.x, skin.SearchIconSize.y), skin.SearchIcon); this.SearchFilter = GUI.TextField( searchBarRect, this.SearchFilter, skin.SearchTextStyle); startX = endX; endX = startX + skin.ButtonWidth; Rect buttonRect; buttonRect = Rect.MinMaxRect(startX, startY, endX, endY); if (buttonRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(buttonRect, skin.MouseOverBackgroundColor); if (Event.current.type == EventType.MouseDown) { SortDescending = !SortDescending; this.UpdateIndices(); } } GUI.DrawTexture(buttonRect, SortDescending ? skin.SortDirUpIcon : skin.SortDirDownIcon); startX = endX; endX = startX + skin.ButtonWidth; buttonRect = Rect.MinMaxRect(startX, startY, endX, endY); if (buttonRect.Contains(Event.current.mousePosition)) { ImguiUtil.DrawColoredQuad(buttonRect, skin.MouseOverBackgroundColor); if (Event.current.type == EventType.MouseDown && !_sortMethodCaptions.IsEmpty()) { var startPos = new Vector2(buttonRect.xMin, buttonRect.yMax); ImguiUtil.OpenContextMenu(startPos, CreateSortMethodContextMenuItems()); } } GUI.DrawTexture(buttonRect, skin.SortIcon); }
public void DrawPopupCommon(Rect fullRect, Rect popupRect) { ImguiUtil.DrawColoredQuad(popupRect, _settings.Theme.LoadingOverlapPopupColor); }