예제 #1
0
        static void DrawClipLabel(string title, Rect availableRect, Color textColor, IconData[] leftIcons, IconData[] rightIcons, string tooltipMessage = "", bool displayTitle = true)
        {
            var neededIconWidthLeft  = 0.0f;
            var neededIconWidthRight = 0.0f;

            if (leftIcons != null)
            {
                for (int i = 0, n = leftIcons.Length; i < n; ++i)
                {
                    neededIconWidthLeft += leftIcons[i].width + k_IconsPadding;
                }
            }

            if (rightIcons != null)
            {
                for (int i = 0, n = rightIcons.Length; i < n; ++i)
                {
                    neededIconWidthRight += rightIcons[i].width + k_IconsPadding;
                }
            }

            var   neededIconWidth = Mathf.Max(neededIconWidthLeft, neededIconWidthRight);
            float iconPosX        = availableRect.center.x;
            float halfTextWidth   = 0;

            if (displayTitle)
            {
                s_TitleContent.text = title;
                var neededTextWidth = DirectorStyles.Instance.fontClip.CalcSize(s_TitleContent).x;
                if (neededTextWidth > availableRect.width)
                {
                    s_TitleContent.text = DirectorStyles.Elipsify(title, availableRect.width, neededTextWidth);
                }
                halfTextWidth = neededTextWidth / 2.0f;
            }
            else
            {
                // text is set explicitly to an empty string to avoid drawing the default text on mac.
                s_TitleContent.text = String.Empty;
                iconPosX           -= neededIconWidth / 2.0f;
            }

            // Atomic operation: We either show all icons or no icons at all
            if (halfTextWidth + neededIconWidth < availableRect.width / 2.0f)
            {
                if (leftIcons != null)
                {
                    DrawClipIcons(leftIcons, IconData.Side.Left, iconPosX - halfTextWidth, availableRect.center.y);
                }

                if (rightIcons != null)
                {
                    DrawClipIcons(rightIcons, IconData.Side.Right, iconPosX + halfTextWidth, availableRect.center.y);
                }
            }

            //draw label even if empty to display tooltip
            s_TitleContent.tooltip = tooltipMessage;
            DrawClipName(availableRect, s_TitleContent, textColor);
        }
        private static void DrawRecordBackground(Rect trackRect)
        {
            DirectorStyles instance = DirectorStyles.Instance;

            EditorGUI.DrawRect(trackRect, instance.customSkin.colorInfiniteTrackBackgroundRecording);
            Graphics.ShadowLabel(trackRect, instance.Elipsify(DirectorStyles.recordingLabel.get_text(), trackRect, instance.fontClip), instance.fontClip, Color.get_white(), Color.get_black());
        }
        static void DrawRecordBackground(Rect trackRect)
        {
            var styles = DirectorStyles.Instance;

            EditorGUI.DrawRect(trackRect, styles.customSkin.colorInfiniteTrackBackgroundRecording);

            Graphics.ShadowLabel(trackRect,
                                 DirectorStyles.Elipsify(DirectorStyles.recordingLabel.text, trackRect, styles.fontClip),
                                 styles.fontClip, Color.white, Color.black);
        }
예제 #4
0
        static void DrawClipLabel(string title, Rect availableRect, Color textColor, IconData[] leftIcons, IconData[] rightIcons, string tooltipMessage = "")
        {
            s_TitleContent.text = title;
            var neededTextWidth      = DirectorStyles.Instance.fontClip.CalcSize(s_TitleContent).x;
            var neededIconWidthLeft  = 0.0f;
            var neededIconWidthRight = 0.0f;

            if (leftIcons != null)
            {
                for (int i = 0, n = leftIcons.Length; i < n; ++i)
                {
                    neededIconWidthLeft += leftIcons[i].width + k_IconsPadding;
                }
            }

            if (rightIcons != null)
            {
                for (int i = 0, n = rightIcons.Length; i < n; ++i)
                {
                    neededIconWidthRight += rightIcons[i].width + k_IconsPadding;
                }
            }

            var neededIconWidth = Mathf.Max(neededIconWidthLeft, neededIconWidthRight);

            // Atomic operation: We either show all icons or no icons at all
            var showIcons = neededTextWidth / 2.0f + neededIconWidth < availableRect.width / 2.0f;

            if (showIcons)
            {
                if (leftIcons != null)
                {
                    DrawClipIcons(leftIcons, IconData.Side.Left, neededTextWidth, availableRect);
                }

                if (rightIcons != null)
                {
                    DrawClipIcons(rightIcons, IconData.Side.Right, neededTextWidth, availableRect);
                }
            }

            if (neededTextWidth > availableRect.width)
            {
                s_TitleContent.text = DirectorStyles.Elipsify(title, availableRect.width, neededTextWidth);
            }

            s_TitleContent.tooltip = tooltipMessage;
            DrawClipName(availableRect, s_TitleContent, textColor);
        }