Beispiel #1
0
        void RenderButton(Cairo.Context context, Gdk.Point corner, double opacity, bool hovered)
        {
            Gdk.Rectangle region = new Gdk.Rectangle(corner.X,
                                                     corner.Y,
                                                     ButtonSize.Width, ButtonSize.Height);



            context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
            using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) {
                if (hovered)
                {
                    lg.AddColorStop(0, new Cairo.Color(.15, .76, .09, opacity));
                    lg.AddColorStop(1, new Cairo.Color(.41, .91, .46, opacity));
                }
                else
                {
                    lg.AddColorStop(0, new Cairo.Color(.41, .91, .46, opacity));
                    lg.AddColorStop(1, new Cairo.Color(.15, .76, .09, opacity));
                }

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

            context.SetSourceRGBA(.29, .79, .28, opacity);
            context.LineWidth = 1;
            context.Stroke();

            region.Inflate(-1, -1);
            context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 2);

            using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) {
                lg.AddColorStop(0, new Cairo.Color(1, 1, 1, .74 * opacity));
                lg.AddColorStop(0.1, new Cairo.Color(1, 1, 1, 0));
                lg.AddColorStop(0.9, new Cairo.Color(0, 0, 0, 0));
                lg.AddColorStop(1, new Cairo.Color(0, 0, 0, .34 * opacity));

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

            using (var layout = ButtonLayout(PangoContext)) {
                int w, h;
                layout.GetPixelSize(out w, out h);

                RenderShadowedText(context, new Gdk.Point(corner.X + ButtonSize.Width / 2 - w / 2, corner.Y + ButtonSize.Height / 2 - h / 2 - 1), opacity, layout);
            }
        }
Beispiel #2
0
        public void DrawFooterBackground(Cairo.Context cr, Gdk.Rectangle alloc, int top_offset, bool fill)
        {
            Color gtk_background_color = GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color gtk_base_color       = GetWidgetColor(GtkColorClass.Base, StateType.Normal);
            Color light_color          = gtk_background_color.ColorShade(1.1);
            Color dark_color           = gtk_background_color.ColorShade(0.95);

            const CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;

            if (fill)
            {
                LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
                grad.AddColorStop(0, light_color);
                grad.AddColorStop(0.75, dark_color);
                grad.AddColorStop(0, light_color);

                cr.Pattern = grad;
                cr.RoundedRectangle(alloc.X, alloc.Y + top_offset, alloc.Width, alloc.Height - top_offset, BORDER_RADIUS, corners);
                cr.Fill();

                cr.Color = gtk_base_color;
                cr.Rectangle(alloc.X, alloc.Y, alloc.Width, top_offset);
                cr.Fill();
            }
            else
            {
                cr.Color = gtk_base_color;
                cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, BORDER_RADIUS, corners);
                cr.Fill();
            }

            cr.LineWidth = 1.0;
            cr.Translate(alloc.Y + 0.5, alloc.Y - 0.5);

            cr.Color = border_color;
            cr.RoundedRectangle(alloc.X, alloc.Y - 4, alloc.Width - 1, alloc.Height + 4, BORDER_RADIUS, corners);
            cr.Stroke();

            if (fill)
            {
                cr.LineWidth = 1;
                cr.Antialias = Cairo.Antialias.None;
                cr.MoveTo(alloc.X + 1, alloc.Y + 1 + top_offset);
                cr.LineTo(alloc.X + alloc.Width - 1, alloc.Y + 1 + top_offset);
                cr.Stroke();
                cr.Antialias = Cairo.Antialias.Default;
            }
        }
        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);
            Gdk.CairoHelper.SetSourcePixbuf(context, starburst, -starburst.Width / 2, -starburst.Height / 2);
            context.FillPreserve();
            context.Restore();

            context.LineWidth = 1;
            context.SetSourceRGB(.29, .47, .67);
            context.Stroke();
        }
Beispiel #4
0
        public override void DrawBackground(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
        {
            this.editor = editor;
            int markerStart = base.Offset;
            int markerEnd   = base.EndOffset;

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            double @from;
            double to;
            var    startXPos = metrics.TextRenderStartPosition;
            var    endXPos   = metrics.TextRenderEndPosition;
            var    y         = metrics.LineYRenderStartPosition;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int start = startOffset < markerStart ? markerStart : startOffset;
                int end   = endOffset < markerEnd ? endOffset : markerEnd;

                uint curIndex = 0, byteIndex = 0;
                TextViewMargin.TranslateToUTF8Index(metrics.Layout.Text, (uint)(start - startOffset), ref curIndex, ref byteIndex);

                int x_pos = metrics.Layout.IndexToPos((int)byteIndex).X;

                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                TextViewMargin.TranslateToUTF8Index(metrics.Layout.Text, (uint)(end - startOffset), ref curIndex, ref byteIndex);
                x_pos = metrics.Layout.IndexToPos((int)byteIndex).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            @from = Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from < to)
            {
                cr.SetSourceColor(background(editor));
                cr.RoundedRectangle(@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2);                  // 2.5 to make space for the column guideline

                /* TODO: EditorTheme - do we need a border here ?
                 * if (background(editor).HasBorderColor) {
                 *      cr.FillPreserve ();
                 *
                 *      cr.SetSourceColor (background(editor).BorderColor);
                 *      cr.Stroke ();
                 * } else {*/
                cr.Fill();
                //				}
            }
        }
Beispiel #5
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height)
        {
            Color selection_color = GetWidgetColor(GtkColorClass.Background, StateType.Selected);

            LinearGradient grad = new LinearGradient(x, y, x, y + height);

            grad.AddColorStop(0, selection_color.ColorShade(1.1));
            grad.AddColorStop(1, selection_color.ColorShade(0.85));

            cr.Pattern = grad;
            cr.RoundedRectangle(x, y, width, height, BORDER_RADIUS);
            cr.Fill();

            cr.LineWidth = 0.5;
            cr.Color     = selection_color.ColorShade(0.75);
            cr.RoundedRectangle(x + 1, y + 1, width - 2, height - 2, BORDER_RADIUS);
            cr.Stroke();
        }
Beispiel #6
0
        public override void Render(Node node, Context context)
        {
            ButtonNode button = node as ButtonNode;

            context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding);
            if (button.Relief) {
                using (var lg = new global::Cairo.LinearGradient (0, 0, 0, button.Height)) {
                    CreateGradient (lg, button.State, button.Opacity);
                    context.Pattern = lg;
                    context.FillPreserve ();
                }

                context.LineWidth = 1;
                context.Color = new Color (0.8, 0.8, 0.8, button.Opacity).ToCairo ();
                context.Stroke ();
            }
        }
Beispiel #7
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.LineWidth = 1;
            context.SetSourceRGB(.29, .47, .67);
            context.Stroke();
        }
Beispiel #8
0
            public override bool DrawBackground(TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
            {
                if (metrics.SelectionStart >= 0 || editor.CurrentMode is TextLinkEditMode || editor.TextViewMargin.SearchResultMatchCount > 0)
                {
                    return(false);
                }
                foreach (var usage in Usages)
                {
                    int markerStart = usage.TextSegment.Offset;
                    int markerEnd   = usage.TextSegment.EndOffset;

                    if (markerEnd < metrics.TextStartOffset || markerStart > metrics.TextEndOffset)
                    {
                        return(false);
                    }

                    double @from;
                    double to;

                    if (markerStart < metrics.TextStartOffset && metrics.TextEndOffset < markerEnd)
                    {
                        @from = metrics.TextRenderStartPosition;
                        to    = metrics.TextRenderEndPosition;
                    }
                    else
                    {
                        int start = metrics.TextStartOffset < markerStart ? markerStart : metrics.TextStartOffset;
                        int end   = metrics.TextEndOffset < markerEnd ? metrics.TextEndOffset : markerEnd;

                        uint curIndex = 0, byteIndex = 0;
                        TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(start - metrics.TextStartOffset), ref curIndex, ref byteIndex);

                        int x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X;

                        @from = metrics.TextRenderStartPosition + (int)(x_pos / Pango.Scale.PangoScale);

                        TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(end - metrics.TextStartOffset), ref curIndex, ref byteIndex);
                        x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X;

                        to = metrics.TextRenderStartPosition + (int)(x_pos / Pango.Scale.PangoScale);
                    }

                    @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
                    to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
                    if (@from < to)
                    {
                        Mono.TextEditor.Highlighting.AmbientColor colorStyle;
                        if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write)
                        {
                            colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
                        }
                        else
                        {
                            colorStyle = editor.ColorStyle.UsagesRectangle;
                        }

                        using (var lg = new LinearGradient(@from + 1, y + 1, to, y + editor.LineHeight)) {
                            lg.AddColorStop(0, colorStyle.Color);
                            lg.AddColorStop(1, colorStyle.SecondColor);
                            cr.SetSource(lg);
                            cr.RoundedRectangle(@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4);
                            cr.FillPreserve();
                        }

                        cr.SetSourceColor(colorStyle.BorderColor);
                        cr.Stroke();
                    }
                }
                return(true);
            }
		public override void DrawBackground (Mono.TextEditor.MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset)
		{
			int markerStart = usage.Offset;
			int markerEnd = usage.EndOffset;

			if (markerEnd < startOffset || markerStart > endOffset) 
				return; 

			double @from;
			double to;
			var startXPos = metrics.TextRenderStartPosition;
			var endXPos = metrics.TextRenderEndPosition;
			var y = metrics.LineYRenderStartPosition;
			if (markerStart < startOffset && endOffset < markerEnd) {
				@from = startXPos;
				to = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;

				uint curIndex = 0, byteIndex = 0;
				TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);

				int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;

				@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

				TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
				x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;

				to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}

			@from = Math.Max (@from, editor.TextViewMargin.XOffset);
			to = Math.Max (to, editor.TextViewMargin.XOffset);
			if (@from < to) {
				Mono.TextEditor.Highlighting.AmbientColor colorStyle;
				if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write ||
					(usage.UsageType & ReferenceUsageType.Declariton) == ReferenceUsageType.Declariton) {
					colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
				} else {
					colorStyle = editor.ColorStyle.UsagesRectangle;
				}

				using (var lg = new LinearGradient (@from + 1, y + 1, to , y + editor.LineHeight)) {
					lg.AddColorStop (0, colorStyle.Color);
					lg.AddColorStop (1, colorStyle.SecondColor);
					cr.SetSource (lg);
					cr.RoundedRectangle (@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4);
					cr.FillPreserve ();
				}

				cr.SetSourceColor (colorStyle.BorderColor);
				cr.Stroke ();
			}
		}
Beispiel #10
0
 public override void ClipChildren(Node node, Context context)
 {
     ButtonNode button = node as ButtonNode;
     context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding);
     context.Clip ();
 }
Beispiel #11
0
        public override void Render(CellContext context, StateType state, double cellWidth, double cellHeight, CellPosition position)
        {
            Context cairo = context.Context;

            double x = 1.5;
            double y = 1.5;
            double r = 1;

            cellWidth  -= 3;
            cellHeight -= 3;
            // Draw backgound fill
            LinearGradient bgPattern = new LinearGradient(0, 0, 0, cellHeight);

            bgPattern.AddColorStop(0.0, new Color(219 / 255d, 219 / 255d, 219 / 255d));
            bgPattern.AddColorStop(0.2, new Color(233 / 255d, 233 / 255d, 233 / 255d));
            bgPattern.AddColorStop(0.2, new Color(221 / 255d, 221 / 255d, 221 / 255d));
            bgPattern.AddColorStop(0.3, new Color(221 / 255d, 221 / 255d, 221 / 255d));
            bgPattern.AddColorStop(0.3, new Color(218 / 255d, 218 / 255d, 218 / 255d));
            bgPattern.AddColorStop(0.4, new Color(218 / 255d, 218 / 255d, 218 / 255d));
            bgPattern.AddColorStop(0.8, new Color(250 / 255d, 250 / 255d, 250 / 255d));
            bgPattern.AddColorStop(1.0, new Color(221 / 255d, 221 / 255d, 221 / 255d));
            cairo.Pattern = bgPattern;
            cairo.RoundedRectangle(x - 0.5, y - 0.5, cellWidth + 1, cellHeight + 1, r);
            cairo.Fill();

            // Draw frame
            cairo.LineWidth = 1;
            cairo.Color     = new Color(181 / 255d, 181 / 255d, 181 / 255d);
            cairo.MoveTo(x + r, y);
            cairo.Arc(x + cellWidth - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
            cairo.Stroke();

            cairo.Color = new Color(215 / 255d, 215 / 255d, 215 / 255d);
            cairo.MoveTo(x + cellWidth, y + r);
            cairo.Arc(x + cellWidth - r, y + cellHeight - r, r, 0, Math.PI * 0.5);
            cairo.Stroke();

            cairo.Color = new Color(181 / 255d, 181 / 255d, 181 / 255d);
            cairo.MoveTo(x + cellWidth - r, y + cellHeight);
            cairo.Arc(x + r, y + cellHeight - r, r, Math.PI * 0.5, Math.PI);
            cairo.Stroke();

            cairo.Color = new Color(215 / 255d, 215 / 255d, 215 / 255d);
            cairo.MoveTo(x, y + cellHeight - r);
            cairo.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            cairo.Stroke();

            // Draw progress fill
            double         progressWidth = (cellWidth - 1) * Math.Max(Math.Min(double.IsNaN(progressValue) ? 0 : progressValue, 1), 0);
            LinearGradient fillPattern   = new LinearGradient(0, 0, 0, cellHeight);

            fillPattern.AddColorStop(0.0, new Color(128 / 255d, 168 / 255d, 121 / 255d));
            fillPattern.AddColorStop(0.1, new Color(128 / 255d, 168 / 255d, 121 / 255d));
            fillPattern.AddColorStop(0.2, new Color(146 / 255d, 186 / 255d, 229 / 255d));
            fillPattern.AddColorStop(0.4, new Color(83 / 255d, 149 / 255d, 223 / 255d));
            fillPattern.AddColorStop(0.5, new Color(66 / 255d, 143 / 255d, 231 / 255d));
            fillPattern.AddColorStop(0.8, new Color(119 / 255d, 201 / 255d, 255 / 255d));
            fillPattern.AddColorStop(1.0, new Color(125 / 255d, 191 / 255d, 255 / 255d));
            cairo.Pattern = fillPattern;
            cairo.Rectangle(x + 0.5, y - 0.5, progressWidth, cellHeight);
            cairo.Fill();
            cairo.MoveTo(x + 0.5, y);
            cairo.LineTo(x + progressWidth, y);
            cairo.Color = new Color(53 / 255d, 100 / 255d, 191 / 255d);
            cairo.Stroke();

            // Draw text
            PangoStyle style = parentColumn.ParentListView.QueryCellStyle(state, position);

            const double hPadding = 4;

            context.Layout.Width     = (int)((cellWidth - hPadding * 2) * Pango.Scale.PangoScale);
            context.Layout.Ellipsize = EllipsizeMode.End;
            context.Layout.Alignment = Alignment.Center;

            context.Layout.SetMarkup(style.GetMarkup(ObjectToString(boundObject)));
            int text_width;
            int text_height;

            context.Layout.GetPixelSize(out text_width, out text_height);

            cairo.MoveTo(x + hPadding, y + ((int)cellHeight - text_height) / 2);
            Color color = context.Theme.Colors.GetWidgetColor(
                context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, StateType.Normal);

            color.A = context.Sensitive ? 1.0 : 0.3;

            cairo.Color = color;
            cairo.ShowLayout(context.Layout);
        }