public override void SetPattern(object backend, object p)
        {
            var cb      = (CairoContextBackend)backend;
            var toolkit = ApplicationContext.Toolkit;

            Cairo.Context ctx = cb.Context;
            p = toolkit.GetSafeBackend(p);
            if (p is ImagePatternBackend)
            {
                cb.PatternAlpha = ((ImagePatternBackend)p).Image.Alpha;
                p = ((ImagePatternBackend)p).GetPattern(ApplicationContext, ((CairoContextBackend)backend).ScaleFactor);
            }
            else
            {
                cb.PatternAlpha = 1;
            }

            if (p != null)
            {
                ctx.SetSource((Cairo.Pattern)p);
            }
            else
            {
                ctx.SetSource((Cairo.Pattern)null);
            }
        }
        static void DrawIcon(MonoTextEditor editor, Cairo.Context cr, DocumentLine lineSegment, double x, double y, double width, double height)
        {
            if (lineSegment.IsBookmarked)
            {
                var color1 = editor.ColorStyle.Bookmarks.Color;
                var color2 = editor.ColorStyle.Bookmarks.SecondColor;

                DrawRoundRectangle(cr, x + 1, y + 1, 8, width - 4, height - 4);

                // FIXME: VV: Remove gradient features
                using (var pat = new Cairo.LinearGradient(x + width / 4, y, x + width / 2, y + height - 4)) {
                    pat.AddColorStop(0, color1);
                    pat.AddColorStop(1, color2);
                    cr.SetSource(pat);
                    cr.FillPreserve();
                }

                // FIXME: VV: Remove gradient features
                using (var pat = new Cairo.LinearGradient(x, y + height, x + width, y)) {
                    pat.AddColorStop(0, color2);
                    //pat.AddColorStop (1, color1);
                    cr.SetSource(pat);
                    cr.Stroke();
                }
            }
        }
        void DrawBackground(Cairo.Context cr, Gdk.Rectangle allocation)
        {
            cr.LineWidth = 1;
            cr.Rectangle(0, 0, allocation.Width, allocation.Height);

            if (TextEditor.ColorStyle != null)
            {
                if (MonoDevelop.Core.Platform.IsWindows)
                {
                    using (var pattern = new Cairo.SolidPattern(win81Background)) {
                        cr.SetSource(pattern);
                        cr.Fill();
                    }
                }
                else
                {
                    var col = TextEditor.ColorStyle.PlainText.Background.ToXwtColor();
                    col.Light *= 0.948;
                    using (var grad = new Cairo.LinearGradient(0, 0, allocation.Width, 0)) {
                        grad.AddColorStop(0, col.ToCairoColor());
                        grad.AddColorStop(0.7, TextEditor.ColorStyle.PlainText.Background);
                        grad.AddColorStop(1, col.ToCairoColor());
                        cr.SetSource(grad);
                        cr.Fill();
                    }
                }
            }
            DrawLeftBorder(cr);
        }
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            if (TextEditor == null)
            {
                return(true);
            }
            using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window)) {
                cr.LineWidth = 1;
                cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);

                if (TextEditor.ColorStyle != null)
                {
                    if (Platform.IsWindows)
                    {
                        using (var pattern = new Cairo.SolidPattern(win81Background)) {
                            cr.SetSource(pattern);
                        }
                    }
                    else
                    {
                        var col = new Cairo.Color(229 / 255.0, 229 / 255.0, 229 / 255.0);
                        using (var grad = new Cairo.LinearGradient(0, 0, Allocation.Width, 0)) {
                            grad.AddColorStop(0, col);
                            grad.AddColorStop(0.5, new Cairo.Color(1, 1, 1));
                            grad.AddColorStop(1, col);
                            cr.SetSource(grad);
                        }
                    }
                }
                cr.Fill();

                if (TextEditor == null)
                {
                    return(true);
                }

                if (TextEditor.HighlightSearchPattern)
                {
                    DrawSearchResults(cr);
                    DrawSearchIndicator(cr);
                }
                else
                {
                    if (!Debugger.DebuggingService.IsDebugging)
                    {
                        var severity = DrawQuickTasks(cr);
                        DrawIndicator(cr, severity);
                    }
                }
                DrawCaret(cr);

                DrawBar(cr);
                DrawLeftBorder(cr);
            }

            return(true);
        }
Exemple #5
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnDrawn(cr));
            }

            double x     = Allocation.Width / 2;
            double y     = Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            Gdk.RGBA    rgba  = StyleContext.GetBackgroundColor(StateFlags.Selected);
            Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor(rgba);
            using (var fill = new Cairo.RadialGradient(x, y, 0, x, y, r)) {
                color.A = alpha;
                fill.AddColorStop(0, color);
                fill.AddColorStop(0.5, color);
                color.A = 0;
                fill.AddColorStop(1, color);

                cr.Arc(x, y, r, 0, 2 * Math.PI);
                cr.SetSource(fill);
                cr.Fill();
            }

            return(base.OnDrawn(cr));
        }
Exemple #6
0
        private void HeaderExpose(object ob, Gtk.ExposeEventArgs a)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle(0, 0, header.Allocation.Width - 1, header.Allocation.Height);
            HslColor      gcol = frame.Style.Background(Gtk.StateType.Normal);

            if (pointerHover)
            {
                gcol.L *= 1.05;
            }
            gcol.L = Math.Min(1, gcol.L);

            using (Cairo.Context cr = Gdk.CairoHelper.Create(a.Event.Window)) {
                cr.NewPath();
                cr.MoveTo(0, 0);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                Cairo.SolidPattern solidPattern = new Cairo.SolidPattern(gcol);
                cr.SetSource(solidPattern);
                cr.FillPreserve();
                solidPattern.Dispose();
            }

            header.GdkWindow.DrawRectangle(frame.Style.DarkGC(Gtk.StateType.Normal), false, rect);

            foreach (Widget child in header.Children)
            {
                header.PropagateExpose(child, a.Event);
            }
        }
Exemple #7
0
        protected virtual void PaintFill()
        {
            double r, g, b;

            r = (double)fillColor.Red / ushort.MaxValue;
            g = (double)fillColor.Green / ushort.MaxValue;
            b = (double)fillColor.Blue / ushort.MaxValue;

            cairo.Save();
            GetFrame(cairo);

            if (!drawGradient)
            {
                cairo.SetSourceRGBA(r, g, b, fillAlpha);
            }
            else
            {
                using (var grad = CreateGradient()) {
                    cairo.SetSource(grad);
                }
            }

            cairo.FillPreserve();
            cairo.Restore();
        }
 /// <summary>
 /// Override the OnRender function to add a button to the cell.
 /// </summary>
 /// <param name="cr"></param>
 /// <param name="widget"></param>
 /// <param name="background_area"></param>
 /// <param name="cell_area"></param>
 /// <param name="flags"></param>
 protected override void OnRender(Cairo.Context cr, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, CellRendererState flags)
 {
     //base.OnRender(cr, widget, background_area, cell_area, flags);
     LastRect = new Gdk.Rectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
     // This probably doesn't work
     cr.SetSource(new Cairo.SurfacePattern(new Cairo.ImageSurface(Pixbuf.SaveToBuffer("png"), Cairo.Format.ARGB32, cell_area.Width, cell_area.Height, 1)));
 }
Exemple #9
0
        /// <summary>
        /// Renders the pager background. Clip is already set to prevent rendering outside of the primary borders of the popoverwindow.
        /// </summary>
        protected virtual void RenderPagerBackground(Cairo.Context context, Gdk.Rectangle bounds)
        {
            // draw background
            CairoExtensions.RoundedRectangle(context,
                                             bounds.X,
                                             bounds.Y,
                                             bounds.Width,
                                             bounds.Height,
                                             CornerRadius,
                                             CairoCorners.BottomLeft);
            using (var lg = new Cairo.LinearGradient(0, bounds.Y, 0, bounds.Y + bounds.Height)) {
                lg.AddColorStop(0, PagerBackgroundColorTop);
                lg.AddColorStop(1, PagerBackgroundColorBottom);

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

            // draw outline
            CairoExtensions.RoundedRectangle(context,
                                             bounds.X + .5,
                                             bounds.Y + .5,
                                             bounds.Width - 1,
                                             bounds.Height - 1,
                                             CornerRadius,
                                             CairoCorners.BottomLeft);
            context.LineWidth = 1;
            context.SetSourceColor(BorderColor);
            context.Stroke();
        }
Exemple #10
0
        public virtual void RenderShadow(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
        {
            RenderBorder(context, region, arrowPosition);
            double r = CornerRadius;
            double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

            context.MoveTo(x + w, y + h - r);
            context.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
            if (ShowArrow && (arrowPosition & PopupPosition.Bottom) != 0)
            {
                double apos = ArrowOffset;
                context.LineTo(x + apos + ArrowWidth / 2, y + h);
                context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
            }
            context.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);

            // FIXME: VV: Remove gradient features
            using (var lg = new Cairo.LinearGradient(0, y + h - r, 0, y + h)) {
                lg.AddColorStop(0.5, ShadowColor.MultiplyAlpha(0.0));
                lg.AddColorStop(1, ShadowColor);
                context.SetSource(lg);
                context.LineWidth = 1;
                context.Stroke();
            }
        }
Exemple #11
0
        public override void SetAsSource(Cairo.Context ctx, Rectangle bounds = default(Rectangle))
        {
            Cairo.Gradient grad = null;
            switch (GradientType)
            {
            case Type.Vertical:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
                break;

            case Type.Horizontal:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Right, bounds.Top);
                break;

            case Type.Oblic:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
                break;

            case Type.Radial:
                throw new NotImplementedException();
            }

            foreach (ColorStop cs in Stops)
            {
                grad.AddColorStop(cs.Offset, cs.Color);
            }

            ctx.SetSource(grad);
            grad.Dispose();
        }
Exemple #12
0
        protected override bool OnExposeEvent(Gdk.EventExpose ev)
        {
            base.OnExposeEvent(ev);

            if (thumbnail == null)
            {
                UpdateThumbnail();
            }

            Rectangle rect = GdkWindow.GetBounds();

            Cairo.PointD pos   = PositionToClientPt(Position);
            Cairo.Color  black = new Cairo.Color(0, 0, 0);

            using (Cairo.Context g = CairoHelper.Create(GdkWindow)) {
                //background
                g.SetSource(thumbnail, 0.0, 0.0);
                g.Paint();

                g.DrawRectangle(new Cairo.Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 1, rect.Height - 1), new Cairo.Color(.75, .75, .75), 1);
                g.DrawRectangle(new Cairo.Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3), black, 1);

                //cursor
                g.DrawLine(new Cairo.PointD(pos.X + 1, rect.Top + 2), new Cairo.PointD(pos.X + 1, rect.Bottom - 2), black, 1);
                g.DrawLine(new Cairo.PointD(rect.Left + 2, pos.Y + 1), new Cairo.PointD(rect.Right - 2, pos.Y + 1), black, 1);

                //point
                g.DrawEllipse(new Cairo.Rectangle(pos.X - 1, pos.Y - 1, 3, 3), black, 2);
            }
            return(true);
        }
Exemple #13
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnExposeEvent(evnt));
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow);

            double x     = Allocation.X + Allocation.Width / 2;
            double y     = Allocation.Y + Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            var color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Selected));
            var fill  = new Cairo.RadialGradient(x, y, 0, x, y, r);

            color.A = alpha;
            fill.AddColorStop(0, color);
            fill.AddColorStop(0.5, color);
            color.A = 0;
            fill.AddColorStop(1, color);

            cr.Arc(x, y, r, 0, 2 * Math.PI);
            cr.SetSource(fill);
            cr.Fill();
            fill.Dispose();

            CairoExtensions.DisposeContext(cr);
            return(base.OnExposeEvent(evnt));
        }
Exemple #14
0
        private void SetBrush(Brush brush, Size destinationSize)
        {
            var solid = brush as SolidColorBrush;
            var linearGradientBrush = brush as LinearGradientBrush;

            if (solid != null)
            {
                _context.SetSourceRGBA(
                    solid.Color.R / 255.0,
                    solid.Color.G / 255.0,
                    solid.Color.B / 255.0,
                    solid.Color.A / 255.0);
            }
            else if (linearGradientBrush != null)
            {
                Cairo.LinearGradient g = new Cairo.LinearGradient(linearGradientBrush.StartPoint.X * destinationSize.Width, linearGradientBrush.StartPoint.Y * destinationSize.Height, linearGradientBrush.EndPoint.X * destinationSize.Width, linearGradientBrush.EndPoint.Y * destinationSize.Height);

                foreach (var s in linearGradientBrush.GradientStops)
                {
                    g.AddColorStopRgb(s.Offset, new Cairo.Color(s.Color.R, s.Color.G, s.Color.B, s.Color.A));
                }

                g.Extend = Cairo.Extend.Pad;

                _context.SetSource(g);
            }
        }
Exemple #15
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = Style.Background(Gtk.StateType.Normal);

                using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    using (var pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) {
                        Cairo.Color color1 = gcol;
                        pat.AddColorStop(0, color1);
                        gcol.L -= 0.1;
                        if (gcol.L < 0)
                        {
                            gcol.L = 0;
                        }
                        pat.AddColorStop(1, gcol);
                        cr.SetSource(pat);
                        cr.FillPreserve();
                    }
                }
            }

            bool res = base.OnExposeEvent(evnt);

            Gdk.GC borderColor = Style.DarkGC(Gtk.StateType.Normal);

            rect = Allocation;
            for (int n = 0; n < topMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);
            }

            for (int n = 0; n < bottomMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Bottom - n - 1, rect.Right - 1, rect.Bottom - n - 1);
            }

            for (int n = 0; n < leftMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom - 1);
            }

            for (int n = 0; n < rightMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.Right - n - 1, rect.Y, rect.Right - n - 1, rect.Bottom - 1);
            }

            return(res);
        }
Exemple #16
0
 protected virtual void ShapeSurface(Cairo.Context cr, Cairo.Color color)
 {
     cr.Operator = Cairo.Operator.Source;
     using (var pattern = new Cairo.SolidPattern(color, false)) {
         cr.SetSource(pattern);
         cr.Paint();
     }
 }
Exemple #17
0
        public override void Apply(object control, Cairo.Context context)
        {
            var gradient = ((EtoGradient)control);

            context.Transform(gradient.RenderTransform);
            context.SetSource(gradient);
            context.Transform(gradient.RenderTransformInverse);
        }
Exemple #18
0
 protected static void DrawBorder(Cairo.Context cr, Cairo.Color color, double x, double y, double size)
 {
     using (var pat = new Cairo.LinearGradient(x, y + size, x + size, y)) {
         pat.AddColorStop(0, color);
         cr.SetSource(pat);
         cr.Stroke();
     }
 }
Exemple #19
0
        // TileGridViewer override
        protected override void TileDrawer(int index, Cairo.Context cr)
        {
            int x      = index % _map.MapWidth;
            int y      = index / _map.MapWidth;
            var source = GetTileImage(x, y);

            cr.SetSource(source, 0, 0);
            cr.Paint();
        }
Exemple #20
0
 protected static void FillGradient(Cairo.Context cr, Cairo.Color color1, Cairo.Color color2, double x, double y, double size)
 {
     using (var pat = new Cairo.LinearGradient(x + size / 4, y, x + size / 2, y + size - 4)) {
         pat.AddColorStop(0, color1);
         pat.AddColorStop(1, color2);
         cr.SetSource(pat);
         cr.FillPreserve();
     }
 }
Exemple #21
0
        void DrawBlockBg(Cairo.Context ctx, double x, int width, BlockInfo block)
        {
            if (!IsChangeBlock(block.Type))
            {
                return;
            }

            var    color  = block.Type == BlockType.Added ? Styles.LogView.DiffAddBackgroundColor : Styles.LogView.DiffRemoveBackgroundColor;
            double y      = block.YStart;
            int    height = block.YEnd - block.YStart;

            double markerx = x + LeftPaddingBlock;
            double rd      = RoundedSectionRadius;

            if (block.SectionStart)
            {
                ctx.Arc(x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
                ctx.LineTo(markerx, y);
            }
            else
            {
                ctx.MoveTo(markerx, y);
            }

            ctx.LineTo(markerx, y + height);

            if (block.SectionEnd)
            {
                ctx.LineTo(x + rd, y + height);
                ctx.Arc(x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
            }
            else
            {
                ctx.LineTo(x, y + height);
            }
            if (block.SectionStart)
            {
                ctx.LineTo(x, y + rd);
            }
            else
            {
                ctx.LineTo(x, y);
            }
            ctx.SetSourceColor(color.AddLight(0.1).ToCairoColor());
            ctx.Fill();

            ctx.Rectangle(markerx, y, width - markerx, height);

            // FIXME: VV: Remove gradient features
            using (Cairo.Gradient pat = new Cairo.LinearGradient(x, y, x + width, y)) {
                pat.AddColorStop(0, color.AddLight(0.21).ToCairoColor());
                pat.AddColorStop(1, color.AddLight(0.3).ToCairoColor());
                ctx.SetSource(pat);
                ctx.Fill();
            }
        }
Exemple #22
0
 /// <summary>
 /// Renders the background. Rendering will automatically be clipped to border constraints in later steps.
 /// </summary>
 public virtual void RenderBackground(Cairo.Context context, Gdk.Rectangle region)
 {
     using (var lg = new Cairo.LinearGradient(0, region.Y, 0, region.Y + region.Height)) {
         lg.AddColorStop(0, TopColor);
         lg.AddColorStop(1, BottomColor);
         context.Rectangle(region.X, region.Y, region.Width, region.Height);
         context.SetSource(lg);
         context.Fill();
     }
 }
Exemple #23
0
 static void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, Eto.Drawing.Color.FromArgb(240, 240, 230, 75).ToCairo());
     pat.AddColorStop(1, Eto.Drawing.Color.FromArgb(0, 0, 0, 50).ToCairo());
     e.LineWidth = 0.1;
     e.SetSource(pat);
     e.FillPreserve();
     e.Stroke();
 }
 void FillGradient(Cairo.Context cr, double y, double h)
 {
     cr.Rectangle(0.5, y, Allocation.Width, h);
     using (var grad = new Cairo.LinearGradient(0, y, Allocation.Width, y)) {
         var col = (HslColor)Style.Base(StateType.Normal);
         col.L *= 0.95;
         grad.AddColorStop(0, col);
         grad.AddColorStop(0.7, (HslColor)Style.Base(StateType.Normal));
         grad.AddColorStop(1, col);
         cr.SetSource(grad);
         cr.Fill();
     }
 }
Exemple #25
0
        private IDisposable SetBrush(IBrush brush, Size destinationSize)
        {
            _context.Save();

            BrushImpl impl = CreateBrushImpl(brush, destinationSize);

            _context.SetSource(impl.PlatformBrush);
            return(Disposable.Create(() =>
            {
                impl.Dispose();
                _context.Restore();
            }));
        }
        protected void DrawSearchIndicator(Cairo.Context cr)
        {
            int    diameter = Math.Min(Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2;
            var    x1       = Math.Round(Allocation.Width / 2d);
            double y1       = indicatorPadding;

            if (diameter % 2 == 0)
            {
                x1 += 0.5;
                y1 += 0.5;
            }

            cr.Arc(x1, y1, diameter / 2d, 0, 2 * Math.PI);

            var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color;

            darkColor.L *= 0.5;

            if (flatStyle)
            {
                using (var pattern = new Cairo.SolidPattern(TextEditor.ColorStyle.SearchResultMain.Color)) {
                    cr.SetSource(pattern);
                    cr.FillPreserve();
                }
            }
            else
            {
                using (var pattern = new Cairo.RadialGradient(x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) {
                    pattern.AddColorStop(0, darkColor);
                    pattern.AddColorStop(1, TextEditor.ColorStyle.SearchResultMain.Color);
                    cr.SetSource(pattern);
                    cr.FillPreserve();
                }
            }

            cr.SetSourceColor(darkColor);
            cr.Stroke();
        }
        public override void Apply(object control, Cairo.Context context)
        {
            var gradient = ((EtoGradient)control);

            if (!ReferenceEquals(gradient.Transform, null))
            {
                context.Transform(gradient.Transform);
            }
            context.SetSource(gradient);
            if (!ReferenceEquals(gradient.TransformInverse, null))
            {
                context.Transform(gradient.TransformInverse);
            }
        }
Exemple #28
0
        void DrawTab(Gdk.EventExpose evnt, Tab tab, int pos)
        {
            Gdk.Rectangle rect = GetTabArea(tab, pos);
            StateType     st;

            if (tab.Active)
            {
                st = StateType.Normal;
            }
            else
            {
                st = StateType.Active;
            }

            if (DockFrame.IsWindows)
            {
                GdkWindow.DrawRectangle(Style.DarkGC(Gtk.StateType.Normal), false, rect);
                rect.X++;
                rect.Width--;
                if (tab.Active)
                {
                    GdkWindow.DrawRectangle(Style.LightGC(Gtk.StateType.Normal), true, rect);
                }
                else
                {
                    using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) {
                        cr.NewPath();
                        cr.MoveTo(rect.X, rect.Y);
                        cr.RelLineTo(rect.Width, 0);
                        cr.RelLineTo(0, rect.Height);
                        cr.RelLineTo(-rect.Width, 0);
                        cr.RelLineTo(0, -rect.Height);
                        cr.ClosePath();
                        Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height);
                        Cairo.Color    color1 = DockFrame.ToCairoColor(Style.Mid(Gtk.StateType.Normal));
                        pat.AddColorStop(0, color1);
                        color1.R *= 1.2;
                        color1.G *= 1.2;
                        color1.B *= 1.2;
                        pat.AddColorStop(1, color1);
                        cr.SetSource(pat);
                        cr.FillPreserve();
                    }
                }
            }
            else
            {
                Gtk.Style.PaintExtension(Style, GdkWindow, st, ShadowType.Out, evnt.Area, this, "tab", rect.X, rect.Y, rect.Width, rect.Height, Gtk.PositionType.Top);
            }
        }
Exemple #29
0
        void DrawShadow(Cairo.Context ctx, Gdk.Rectangle ar, PositionType pos, List <Section> secs)
        {
            foreach (Section s in secs)
            {
                Cairo.Gradient pat = null;
                Gdk.Rectangle  r   = ar;
                switch (pos)
                {
                case PositionType.Top:
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X     += s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.X, r.Bottom);
                    break;

                case PositionType.Bottom:
                    r.Y      = r.Bottom - shadowSize;
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X      = r.X + s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Bottom, r.X, r.Y);
                    break;

                case PositionType.Left:
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.Right, r.Y);
                    break;

                case PositionType.Right:
                    r.X      = r.Right - shadowSize;
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.Right, r.Y, r.X, r.Y);
                    break;
                }
                Cairo.Color c = darkColor.ToCairoColor();
                pat.AddColorStop(0, c);
                c.A = 0;
                pat.AddColorStop(1, c);
                ctx.NewPath();
                ctx.Rectangle(r.X, r.Y, r.Width, r.Height);
                ctx.SetSource(pat);
                ctx.Fill();
                pat.Dispose();
            }
        }
        void DrawIndicator(Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor)
        {
            var width = Allocation.Width;

            int    diameter = Math.Min(width, (int)IndicatorHeight) - indicatorPadding * 2;
            var    x1       = Math.Round(width / 2d);
            double y1       = indicatorPadding + diameter / 2;

            if (diameter % 2 == 0)
            {
                x1 += 0.5;
                y1 += 0.5;
            }

            cr.Arc(x1, y1, diameter / 2d, 0, 2 * Math.PI);

            if (Platform.IsWindows)
            {
                using (var pattern = new Cairo.SolidPattern(color)) {
                    cr.SetSource(pattern);
                    cr.FillPreserve();
                }
            }
            else
            {
                using (var pattern = new Cairo.RadialGradient(x1, y1, width / 2, x1 - width, y1 - width, width)) {
                    pattern.AddColorStop(0, borderColor);
                    pattern.AddColorStop(1, color);
                    cr.SetSource(pattern);
                    cr.FillPreserve();
                }
            }

            cr.SetSourceColor(borderColor);
            cr.Stroke();
        }
Exemple #31
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            painting = false;

            using (Cairo.Context g = new Cairo.Context (doc.CurrentLayer.Surface)) {
                g.SetSource (doc.ToolLayer.Surface);
                g.Paint ();
            }

            base.OnMouseUp (canvas, args, point);

            offset = new Point (int.MinValue, int.MinValue);
            last_point = new Point (int.MinValue, int.MinValue);

            doc.ToolLayer.Clear ();
            doc.ToolLayer.Hidden = true;
            doc.Workspace.Invalidate ();
        }
Exemple #32
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            if (!painting || offset.IsNotSet ())
                return;

            int x = (int)point.X;
            int y = (int)point.Y;

            if (last_point.IsNotSet ()) {
                last_point = new Point (x, y);
                return;
            }

            using (Cairo.Context g = new Cairo.Context (PintaCore.Layers.ToolLayer.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = Cairo.Antialias.Subpixel;

                g.MoveTo (last_point.X, last_point.Y);
                g.LineTo (x, y);

                g.SetSource (PintaCore.Workspace.ActiveDocument.CurrentLayer.Surface, offset.X, offset.Y);
                g.LineWidth = BrushWidth;
                g.LineCap = Cairo.LineCap.Round;

                g.Stroke ();
            }

            var dirty_rect = GetRectangleFromPoints (last_point, new Point (x, y));

            last_point = new Point (x, y);
            surface_modified = true;
            PintaCore.Workspace.Invalidate (dirty_rect);
        }