/// <summary>
        /// Positions the GUI elements. Must be called after construction, but only after all content area entries have
        /// been constructed so that entry's final bounds are known.
        /// </summary>
        public void Initialize()
        {
            bounds = icon.Bounds;
            Rect2I labelBounds = label.Bounds;

            bounds.x     = MathEx.Min(bounds.x, labelBounds.x - SELECTION_EXTRA_WIDTH);
            bounds.y     = MathEx.Min(bounds.y, labelBounds.y) - 5; // 5 - Just padding for better look
            bounds.width = MathEx.Max(bounds.x + bounds.width,
                                      labelBounds.x + labelBounds.width) - bounds.x + SELECTION_EXTRA_WIDTH;
            bounds.height = MathEx.Max(bounds.y + bounds.height,
                                       labelBounds.y + labelBounds.height) - bounds.y;

            string hoistedPath = path;

            GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);

            overlayBtn.Bounds         = bounds;
            overlayBtn.OnClick       += () => OnEntryClicked(hoistedPath);
            overlayBtn.OnDoubleClick += () => OnEntryDoubleClicked(hoistedPath);
            overlayBtn.SetContextMenu(owner.Window.ContextMenu);

            owner.Overlay.AddElement(overlayBtn);
        }
        /// <summary>
        /// Positions the GUI elements. Must be called after construction, but only after all content area entries have
        /// been constructed so that entry's final bounds are known.
        /// </summary>
        public void Initialize()
        {
            Rect2I iconBounds = icon.Bounds;

            bounds = iconBounds;
            Rect2I labelBounds = label.Bounds;

            if (owner.GridLayout)
            {
                bounds.x      = labelBounds.x;
                bounds.y     -= VERT_PADDING;
                bounds.width  = labelBounds.width;
                bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
            }
            else
            {
                bounds.y      -= VERT_PADDING;
                bounds.width   = width;
                bounds.height += VERT_PADDING;
            }

            string hoistedPath = path;

            GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);

            overlayBtn.Bounds         = bounds;
            overlayBtn.OnClick       += () => OnEntryClicked(hoistedPath);
            overlayBtn.OnDoubleClick += () => OnEntryDoubleClicked(hoistedPath);
            overlayBtn.SetContextMenu(owner.Window.ContextMenu);

            owner.Overlay.AddElement(overlayBtn);

            if (groupUnderlay != null)
            {
                if (owner.GridLayout)
                {
                    int offsetToNext = BG_HORZ_PADDING + owner.HorzElementSpacing;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        offsetToNext = BG_HORZ_PADDING * 2;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x - BG_HORZ_PADDING, bounds.y,
                                                 bounds.width + offsetToNext, bounds.height);
                    groupUnderlay.Bounds = bgBounds;
                }
                else
                {
                    int offsetToNext = BG_VERT_PADDING + LibraryGUIContent.LIST_ENTRY_SPACING;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        offsetToNext = BG_VERT_PADDING * 2;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x, bounds.y - BG_VERT_PADDING,
                                                 bounds.width, bounds.height + offsetToNext);

                    groupUnderlay.Bounds = bgBounds;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Rebuilds the library window GUI. Should be called any time the active folder or contents change.
        /// </summary>
        private void Refresh()
        {
            requiresRefresh = false;

            LibraryEntry[] entriesToDisplay = new LibraryEntry[0];
            if (IsSearchActive)
            {
                entriesToDisplay = ProjectLibrary.Search("*" + searchQuery + "*");
            }
            else
            {
                DirectoryEntry entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                if (entry == null)
                {
                    CurrentFolder = ProjectLibrary.Root.Path;
                    entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                }

                if(entry != null)
                    entriesToDisplay = entry.Children;
            }

            inProgressRenameElement = null;

            RefreshDirectoryBar();

            SortEntries(entriesToDisplay);

            Rect2I visibleContentBounds = GetScrollAreaBounds();
            content.Refresh(viewType, entriesToDisplay, visibleContentBounds);

            foreach (var path in cutPaths)
                content.MarkAsCut(path, true);

            foreach (var path in selectionPaths)
                content.MarkAsSelected(path, true);

            content.MarkAsPinged(pingPath, true);

            Rect2I contentBounds = content.Bounds;

            contentBounds.height = Math.Max(contentBounds.height, visibleContentBounds.height);

            GUIButton catchAll = new GUIButton("", EditorStyles.Blank);
            catchAll.Bounds = contentBounds;
            catchAll.OnClick += OnCatchAllClicked;
            catchAll.SetContextMenu(entryContextMenu);

            content.Underlay.AddElement(catchAll);

            Rect2I focusBounds = contentBounds; // Contents + Folder bar
            Rect2I scrollBounds = contentScrollArea.Bounds;
            focusBounds.x += scrollBounds.x;
            focusBounds.y += scrollBounds.y;

            Rect2I folderBarBounds = folderListLayout.Bounds;
            focusBounds.y -= folderBarBounds.height;
            focusBounds.height += folderBarBounds.height;

            GUIButton focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.Blocking = false;
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost += () => hasContentFocus = false;
            focusCatcher.Bounds = focusBounds;

            GUIPanel focusPanel = GUI.AddPanel(-3);
            focusPanel.AddElement(focusCatcher);

            UpdateDragSelection(dragSelectionEnd);
        }
        /// <summary>
        /// Positions the GUI elements. Must be called after construction, but only after all content area entries have
        /// been constructed so that entry's final bounds are known.
        /// </summary>
        public void Initialize()
        {
            Rect2I iconBounds = icon.Bounds;

            bounds = iconBounds;
            Rect2I labelBounds = label.Bounds;

            if (owner.GridLayout)
            {
                bounds.x      = labelBounds.x;
                bounds.y     -= VERT_PADDING;
                bounds.width  = labelBounds.width;
                bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
            }
            else
            {
                bounds.y      -= VERT_PADDING;
                bounds.width   = width;
                bounds.height += VERT_PADDING;
            }

            string hoistedPath = path;

            GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);

            overlayBtn.Bounds         = bounds;
            overlayBtn.OnClick       += () => OnEntryClicked(hoistedPath);
            overlayBtn.OnDoubleClick += () => OnEntryDoubleClicked(hoistedPath);
            overlayBtn.SetContextMenu(owner.Window.ContextMenu);
            overlayBtn.AcceptsKeyFocus = false;

            owner.Overlay.AddElement(overlayBtn);

            if (groupUnderlay != null)
            {
                if (owner.GridLayout)
                {
                    bool firstInRow = index % owner.ElementsPerRow == 0;
                    bool lastInRow  = index % owner.ElementsPerRow == (owner.ElementsPerRow - 1);

                    int offsetToPrevious = 0;
                    if (type == LibraryGUIEntryType.MultiFirst)
                    {
                        if (firstInRow)
                        {
                            offsetToPrevious = owner.PaddingLeft / 3;
                        }
                        else
                        {
                            offsetToPrevious = spacing / 3;
                        }
                    }
                    else if (firstInRow)
                    {
                        offsetToPrevious = owner.PaddingLeft;
                    }

                    int offsetToNext = spacing;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        if (lastInRow)
                        {
                            offsetToNext = owner.PaddingRight / 3;
                        }
                        else
                        {
                            offsetToNext = spacing / 3;
                        }
                    }
                    else if (lastInRow)
                    {
                        offsetToNext = owner.PaddingRight + spacing;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x - offsetToPrevious, bounds.y,
                                                 bounds.width + offsetToNext + offsetToPrevious, bounds.height);
                    groupUnderlay.Bounds = bgBounds;
                }
                else
                {
                    int offsetToNext = BG_VERT_PADDING + LibraryGUIContent.LIST_ENTRY_SPACING;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        offsetToNext = BG_VERT_PADDING * 2;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x, bounds.y - BG_VERT_PADDING,
                                                 bounds.width, bounds.height + offsetToNext);

                    groupUnderlay.Bounds = bgBounds;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Positions the GUI elements. Must be called after construction, but only after all content area entries have
        /// been constructed so that entry's final bounds are known.
        /// </summary>
        public void Initialize()
        {
            Rect2I iconBounds = icon.Bounds;
            bounds = iconBounds;
            Rect2I labelBounds = label.Bounds;

            if (owner.GridLayout)
            {
                bounds.x = labelBounds.x;
                bounds.y -= VERT_PADDING;
                bounds.width = labelBounds.width;
                bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
            }
            else
            {
                bounds.y -= VERT_PADDING;
                bounds.width = width;
                bounds.height += VERT_PADDING;
            }

            string hoistedPath = path;

            GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);
            overlayBtn.Bounds = bounds;
            overlayBtn.OnClick += () => OnEntryClicked(hoistedPath);
            overlayBtn.OnDoubleClick += () => OnEntryDoubleClicked(hoistedPath);
            overlayBtn.SetContextMenu(owner.Window.ContextMenu);

            owner.Overlay.AddElement(overlayBtn);

            if (groupUnderlay != null)
            {
                if (owner.GridLayout)
                {
                    int offsetToNext = BG_HORZ_PADDING + owner.HorzElementSpacing;
                    if (type == LibraryGUIEntryType.MultiLast)
                        offsetToNext = BG_HORZ_PADDING * 2;

                    Rect2I bgBounds = new Rect2I(bounds.x - BG_HORZ_PADDING, bounds.y,
                        bounds.width + offsetToNext, bounds.height);
                    groupUnderlay.Bounds = bgBounds;
                }
                else
                {
                    int offsetToNext = BG_VERT_PADDING + LibraryGUIContent.LIST_ENTRY_SPACING;
                    if (type == LibraryGUIEntryType.MultiLast)
                        offsetToNext = BG_VERT_PADDING * 2;

                    Rect2I bgBounds = new Rect2I(bounds.x, bounds.y - BG_VERT_PADDING,
                        bounds.width, bounds.height + offsetToNext);

                    groupUnderlay.Bounds = bgBounds;
                }
            }
        }