Ejemplo n.º 1
0
        public override void Draw()
        {
            EditorDrawingHelper.DrawRoundedRect(Owner.BoundingBox, CurrentColor, 10f);

            IValidationHandler validation = EditorConfigurator.Instance.Validation;

            if (validation.IsAllowedToValidate())
            {
                IContextResolver resolver = validation.ContextResolver;

                IContext context = resolver.FindContext(Owner.Step.Data, GlobalEditorHandler.GetCurrentCourse());
                if (validation.LastReport != null)
                {
                    List <EditorReportEntry> errors = validation.LastReport.GetEntriesFor(context);
                    if (errors.Count > 0)
                    {
                        string tooltip = ValidationTooltipGenerator.CreateStepTooltip(errors,
                                                                                      resolver.FindContext(Owner.ActiveChapter.Data, GlobalEditorHandler.GetCurrentCourse()));
                        GUIContent content = new GUIContent("", null, tooltip);
                        Rect       rect    = new Rect(Owner.BoundingBox.x + Owner.BoundingBox.width * 0.70f, Owner.BoundingBox.y - 8, 16, 16);
                        // Label icons are too small so we draw a label for the tool tip and icon separated.
                        GUI.Label(rect, content);
                        GUI.DrawTexture(rect, EditorGUIUtility.IconContent("Warning").image);
                    }
                }
            }

            float labelX      = Owner.BoundingBox.x + labelBorderOffsetInwards;
            float labelY      = Owner.BoundingBox.y + labelBorderOffsetInwards;
            float labelWidth  = Owner.BoundingBox.width - labelBorderOffsetInwards * 2f;
            float labelHeight = Owner.BoundingBox.height - labelBorderOffsetInwards * 2f;

            Rect labelPosition = new Rect(labelX, labelY, labelWidth, labelHeight);

            GUIStyle labelStyle = new GUIStyle
            {
                alignment = TextAnchor.MiddleCenter,
                normal    = { textColor = TextColor },
                wordWrap  = false,
            };

            string name = EditorDrawingHelper.TruncateText(Owner.Step.Data.Name, labelStyle, labelPosition.width);

            GUIContent labelContent = new GUIContent(name);

            GUI.Label(labelPosition, labelContent, labelStyle);
        }
Ejemplo n.º 2
0
        ///<inheritdoc />
        public override void Draw()
        {
            Rect rect = Owner.BoundingBox;

            rect.x      = Mathf.Round(rect.x);
            rect.y      = Mathf.Round(rect.y);
            rect.height = Mathf.Round(rect.height);
            rect.width  = Mathf.Round(rect.width);

            EditorDrawingHelper.DrawRoundedRect(rect, CurrentColor, 4f);
            GUIStyle style = new GUIStyle()
            {
                alignment = TextAnchor.MiddleCenter,
                normal    = new GUIStyleState()
                {
                    textColor = TextColor
                }
            };

            GUI.Label(rect, "+", style);
        }
Ejemplo n.º 3
0
        public override void Draw()
        {
            EditorDrawingHelper.DrawRoundedRect(Owner.BoundingBox, CurrentColor, 10f);

            float labelX      = Owner.BoundingBox.x + labelBorderOffsetInwards;
            float labelY      = Owner.BoundingBox.y + labelBorderOffsetInwards;
            float labelWidth  = Owner.BoundingBox.width - labelBorderOffsetInwards * 2f;
            float labelHeight = Owner.BoundingBox.height - labelBorderOffsetInwards * 2f;

            Rect labelPosition = new Rect(labelX, labelY, labelWidth, labelHeight);

            GUIStyle labelStyle = new GUIStyle
            {
                alignment = TextAnchor.MiddleCenter,
                normal    = { textColor = TextColor },
                wordWrap  = false,
            };

            string name = EditorDrawingHelper.TruncateText(Owner.Step.Data.Name, labelStyle, labelPosition.width);

            GUIContent labelContent = new GUIContent(name);

            GUI.Label(labelPosition, labelContent, labelStyle);
        }