Пример #1
0
        public override void DrawForeground(MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
        {
            double size            = metrics.Margin.Width;
            double borderLineWidth = cr.LineWidth;

            double x = Math.Floor(metrics.Margin.XOffset - borderLineWidth / 2);
            double y = Math.Floor(metrics.Y + (metrics.Height - size) / 2);

            var deltaX = size / 2 - DebugIcon.Width / 2 + 0.5f;
            var deltaY = size / 2 - DebugIcon.Height / 2 + 0.5f;

            if (drawInIconMarging)
            {
                cr.DrawImage(editor, DebugIcon, Math.Round(x + deltaX), Math.Round(y + deltaY));
            }
            else
            {
                cr.DrawImage(editor, DebugIcon, metrics.X, Math.Round(y + deltaY));
                var  lineSegment     = metrics.LineSegment;
                var  extendingMarker = lineSegment != null ? (IExtendingTextLineMarker)editor.Document.GetMarkers(lineSegment).FirstOrDefault(l => l is IExtendingTextLineMarker) : null;
                bool isSpaceAbove    = extendingMarker != null && extendingMarker.IsSpaceAbove;

                editor.TextArea.GutterMargin.DrawForeground(cr, (int)metrics.LineNumber, metrics.X, metrics.Y, metrics.Height, isSpaceAbove);
            }
        }
Пример #2
0
        void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity)
        {
            if (brandedIcon != null)
            {
                /*				if (previewSurface == null) {
                 *      previewSurface = new SurfaceWrapper (context, brandedIcon);
                 * }
                 * double scale = PreviewSize / previewSurface.Width;
                 *
                 * context.Save ();
                 * context.Translate (position.X, position.Y);
                 * context.Scale (scale * IconScale, scale * IconScale);
                 * context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2);
                 * context.PaintWithAlpha (opacity);
                 * context.Restore ();
                 */

                double scale = PreviewSize / brandedIcon.Width;
                context.Save();
                context.Translate(position.X, position.Y);
                context.Scale(scale * IconScale, scale * IconScale);
                context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2);
                context.Restore();
            }
        }
Пример #3
0
 void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity)
 {
     if (brandedIcon != null)
     {
         double scale = PreviewSize / brandedIcon.Width;
         context.Save();
         context.Translate(position.X, position.Y);
         context.Scale(scale * IconScale, scale * IconScale);
         context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2);
         context.Restore();
     }
 }
Пример #4
0
            protected override void OnDrawContent(Gdk.EventExpose evnt, Cairo.Context g)
            {
                Theme.BorderColor = marker.TooltipColor.Color;
                g.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                g.SetSourceColor(marker.TooltipColor.Color);
                g.Fill();

                using (var drawingLayout = new Pango.Layout(this.PangoContext)) {
                    drawingLayout.FontDescription = cache.tooltipFontDescription;

                    double y = verticalTextBorder;
                    var    showBulletedList = marker.Errors.Count > 1;

                    foreach (var msg in marker.Errors)
                    {
                        var icon = msg.IsError ? cache.errorPixbuf : cache.warningPixbuf;
                        int w, h;

                        if (!showBulletedList)
                        {
                            drawingLayout.Width = maxTextWidth;
                        }

                        drawingLayout.SetText(GetFirstLine(msg));
                        drawingLayout.GetPixelSize(out w, out h);

                        if (showBulletedList)
                        {
                            g.Save();

                            g.Translate(textBorder, y + verticalTextSpace / 2 + Math.Max(0, (h - icon.Height) / 2));
                            g.DrawImage(this, icon, 0, 0);
                            g.Restore();
                        }

                        g.Save();

                        g.Translate(showBulletedList ? textBorder + iconTextSpacing + icon.Width: textBorder, y + verticalTextSpace / 2);
                        g.SetSourceColor(marker.TagColor.SecondColor);
                        g.ShowLayout(drawingLayout);

                        g.Restore();

                        y += h + verticalTextSpace;
                    }
                }
            }
Пример #5
0
        void RenderBackground(Cairo.Context context, Gdk.Rectangle region)
        {
            region.Inflate(-Padding, -Padding);
            context.RenderOuterShadow(new Gdk.Rectangle(region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25);

            context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5);
            using (var lg = new LinearGradient(0, region.Y, 0, region.Bottom)) {
                lg.AddColorStop(0, new Cairo.Color(.36, .53, .73));
                lg.AddColorStop(1, new Cairo.Color(.21, .37, .54));

                context.SetSource(lg);
                context.FillPreserve();
            }

            context.Save();
            context.Translate(IconPosition.X, IconPosition.Y);
            context.Scale(0.75, 0.75);
            context.DrawImage(this, starburst, -starburst.Width / 2, -starburst.Height / 2);
            context.Restore();

            context.LineWidth = 1;
            context.SetSourceRGB(.29, .47, .67);
            context.Stroke();
        }
Пример #6
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            int x = region.X + region.Width / 2;
            int y = region.Y + region.Height / 2;

            var img = btnNormal;

            switch (state)
            {
            case StateType.Insensitive:
                img = btnInactive; break;

            case StateType.Prelight:
                img = btnHover; break;

            case StateType.Selected:
                img = btnPressed; break;
            }

            x -= (int)img.Width / 2;
            y -= (int)img.Height / 2;

            context.DrawImage(this, img, x, y);
        }
Пример #7
0
        void Draw(Cairo.Context ctx, List <TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
            {
                return;
            }

            Pango.Layout layout       = new Pango.Layout(PangoContext);
            TableRow     lastCategory = null;

            foreach (var r in rowList)
            {
                int w, h;
                layout.SetText(r.Label);
                layout.GetPixelSize(out w, out h);
                int indent = 0;

                if (r.IsCategory)
                {
                    var rh = h + CategoryTopBottomPadding * 2;
                    ctx.Rectangle(0, y, Allocation.Width, rh);
                    using (var gr = new LinearGradient(0, y, 0, rh)) {
                        gr.AddColorStop(0, new Cairo.Color(248d / 255d, 248d / 255d, 248d / 255d));
                        gr.AddColorStop(1, new Cairo.Color(240d / 255d, 240d / 255d, 240d / 255d));
                        ctx.SetSource(gr);
                        ctx.Fill();
                    }

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand)
                    {
                        ctx.MoveTo(0, y + 0.5);
                        ctx.LineTo(Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo(0, y + rh - 0.5);
                    ctx.LineTo(Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor(DividerColor);
                    ctx.Stroke();

                    ctx.MoveTo(x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor(CategoryLabelColor);
                    Pango.CairoHelper.ShowLayout(ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage(this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round((rh - img.Height) / 2));

                    y           += rh;
                    lastCategory = r;
                }
                else
                {
                    var cell = GetCell(r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save();
                    ctx.Rectangle(0, y, dividerX, h + PropertyTopBottomPadding * 2);
                    ctx.Clip();
                    ctx.MoveTo(x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor(Style.Text(state).ToCairoColor());
                    Pango.CairoHelper.ShowLayout(ctx, layout);
                    ctx.Restore();

                    if (r != currentEditorRow)
                    {
                        var bounds = GetInactiveEditorBounds(r);

                        cell.Render(GdkWindow, ctx, bounds, state);

                        if (r.IsExpandable)
                        {
                            var img = r.Expanded ? discloseUp : discloseDown;
                            ctx.DrawImage(
                                this, img,
                                Allocation.Width - img.Width - PropertyTopBottomPadding,
                                y + Math.Round((h + PropertyTopBottomPadding * 2 - img.Height) / 2)
                                );
                        }
                    }

                    y     += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand))
                {
                    int py = y;

                    ctx.Save();
                    if (r.AnimatingExpand)
                    {
                        ctx.Rectangle(0, y, Allocation.Width, r.AnimationHeight);
                    }
                    else
                    {
                        ctx.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                    }

                    ctx.Clip();
                    Draw(ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore();

                    if (r.AnimatingExpand)
                    {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle(0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor(LabelBackgroundColor);
                        ctx.Fill();
                        ctx.Rectangle(dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceRGB(1, 1, 1);
                        ctx.Fill();
                    }
                }
            }
        }
        public void Render(Cairo.Context context, StatusArea.RenderArg arg, Gtk.Widget widget)
        {
            context.CachedDraw(surface: ref backgroundSurface,
                               region: arg.Allocation,
                               draw: (c, o) => DrawBackground(c, new Gdk.Rectangle(0, 0, arg.Allocation.Width, arg.Allocation.Height)));

            if (arg.BuildAnimationOpacity > 0.001f)
            {
                DrawBuildEffect(context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);
            }

            if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999)
            {
                DrawErrorAnimation(context, arg);
            }

            DrawBorder(context, arg.Allocation);

            if (arg.HoverProgress > 0.001f)
            {
                context.Clip();
                int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
                int x2 = x1 + 400;
                using (Cairo.LinearGradient gradient = new LinearGradient(x1, 0, x2, 0))
                {
                    Cairo.Color targetColor      = Styles.StatusBarFill1Color;
                    Cairo.Color transparentColor = targetColor;
                    targetColor.A      = .7;
                    transparentColor.A = 0;

                    targetColor.A = .7 * arg.HoverProgress;

                    gradient.AddColorStop(0.0, transparentColor);
                    gradient.AddColorStop(0.5, targetColor);
                    gradient.AddColorStop(1.0, transparentColor);

                    context.SetSource(gradient);

                    context.Rectangle(x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
                    context.Fill();
                }
                context.ResetClip();
            }
            else
            {
                context.NewPath();
            }

            int progress_bar_x     = arg.ChildAllocation.X;
            int progress_bar_width = arg.ChildAllocation.Width;

            if (arg.CurrentPixbuf != null)
            {
                int y = arg.Allocation.Y + (arg.Allocation.Height - (int)arg.CurrentPixbuf.Size.Height) / 2;
                context.DrawImage(widget, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
                progress_bar_x     += (int)arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
                progress_bar_width -= (int)arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
            }

            int center = arg.Allocation.Y + arg.Allocation.Height / 2;

            Gdk.Rectangle progressArea = new Gdk.Rectangle(progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
            if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
            {
                DrawProgressBar(context, arg.ProgressBarFraction, progressArea, arg);
                ClipProgressBar(context, progressArea);
            }

            int text_x     = progress_bar_x + Styles.ProgressBarInnerPadding;
            int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);

            double textTweenValue = arg.TextAnimationProgress;

            if (arg.LastText != null)
            {
                double opacity = Math.Max(0.0f, 1.0f - textTweenValue);
                DrawString(arg.LastText, arg.LastTextIsMarkup, context, text_x,
                           center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
            }

            if (arg.CurrentText != null)
            {
                DrawString(arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x,
                           center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min(textTweenValue, 1.0), arg.Pango, arg);
            }

            if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
            {
                context.ResetClip();
            }
        }