Esempio n. 1
0
        internal static Rect DrawIconLeft(
            Rect rect,
            float rowHeight,
            Texture icon,
            Texture overlayIcon)
        {
            if (icon == null)
            {
                return(rect);
            }

            float iconWidth = rowHeight * ((float)icon.width / icon.height);

            Rect iconRect = new Rect(rect.x, rect.y, iconWidth, rowHeight);

            EditorGUI.LabelField(iconRect, new GUIContent(icon), UnityStyles.Tree.IconStyle);

            if (overlayIcon != null)
            {
                Rect overlayIconRect = OverlayRect.GetRightBottonRect(iconRect);

                GUI.DrawTexture(
                    overlayIconRect, overlayIcon,
                    ScaleMode.ScaleToFit);
            }

            rect.x     += iconRect.width;
            rect.width -= iconRect.width;

            return(rect);
        }
Esempio n. 2
0
 protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     CaptureMouse();
     mouseDown = e.GetPosition(this);
     ovr       = new OverlayRect(this, mouseDown);
     AdornerLayer.GetAdornerLayer(this).Add(ovr);
 }
Esempio n. 3
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (mouseDown.X > -1)
            {
                AdornerLayer.GetAdornerLayer(this).Remove(ovr);
                ovr = null;

                e.Handled = true;
                ReleaseMouseCapture();
                Point mouseUp = e.GetPosition(this);

                if (mouseUp.X == mouseDown.X && mouseUp.Y == mouseDown.Y)
                {
                    e.Handled = false;//--- might be handled in the main view
                }
                else if (mouseUp.X > mouseDown.X && mouseUp.Y > mouseDown.Y)
                {
                    var pixelDown = DipToPixel(mouseDown);
                    var pixelUp   = DipToPixel(mouseUp);
                    pixelMapper.Zoom(this, pixelDown, pixelUp);
                    Redraw();
                }
                else
                {
                    pixelMapper.Unzoom((mouseDown - mouseUp).Length < 200);
                    Redraw();
                }

                mouseDown.X = -1;
            }
        }
Esempio n. 4
0
            internal static void ForStatus(
                Rect selectionRect,
                AssetStatus status,
                string tooltipText)
            {
                Texture overlayIcon = GetOverlayIcon(status);

                if (overlayIcon == null)
                {
                    return;
                }

                Rect overlayRect = OverlayRect.GetRightBottonRect(
                    selectionRect);

                GUI.DrawTexture(
                    overlayRect, overlayIcon, ScaleMode.ScaleToFit);

                Rect tooltipRect = GetTooltipRect(selectionRect, overlayRect);

                GUI.Label(tooltipRect, new GUIContent(string.Empty, tooltipText));
            }
Esempio n. 5
0
        static void DrawStatusLabel(
            AssetsOverlays.AssetStatus assetStatus,
            LockStatusData lockStatusData)
        {
            Texture overlayIcon = DrawAssetOverlay.DrawOverlayIcon.
                                  GetOverlayIcon(assetStatus);

            if (overlayIcon == null)
            {
                return;
            }

            string statusText = DrawAssetOverlay.
                                GetStatusString(assetStatus);

            string tooltipText = DrawAssetOverlay.GetTooltipText(
                assetStatus, lockStatusData);

            Rect selectionRect = GUILayoutUtility.GetRect(
                new GUIContent(statusText + EXTRA_SPACE, overlayIcon),
                GUIStyle.none);

            selectionRect.height = UnityConstants.OVERLAY_STATUS_ICON_SIZE;

            Rect overlayRect = OverlayRect.GetCenteredRect(selectionRect);

            GUI.DrawTexture(
                overlayRect,
                overlayIcon,
                ScaleMode.ScaleToFit);

            selectionRect.x     += UnityConstants.OVERLAY_STATUS_ICON_SIZE;
            selectionRect.width -= UnityConstants.OVERLAY_STATUS_ICON_SIZE;

            GUI.Label(
                selectionRect,
                new GUIContent(statusText, tooltipText));
        }