Наследование: Cairo.Gradient
Пример #1
0
        public static void DrawLinearReflectedGradient(this Context g, Surface oldsurface, GradientColorMode mode, Color c1, Color c2, PointD p1, PointD p2)
        {
            g.Save();

            Gradient gradient = new Cairo.LinearGradient(p1.X, p1.Y, p2.X, p2.Y);

            if (mode == GradientColorMode.Color)
            {
                gradient.AddColorStop(0, c1);
                gradient.AddColorStop(0.5, c2);
                gradient.AddColorStop(1, c1);
                g.Source = gradient;
                g.Paint();
            }
            else if (mode == GradientColorMode.Transparency)
            {
                gradient.AddColorStop(0, new Color(0, 0, 0, 1));
                gradient.AddColorStop(0.5, new Color(0, 0, 0, 0));
                gradient.AddColorStop(1, new Color(0, 0, 0, 1));
                g.Source = new SurfacePattern(oldsurface);
                g.Mask(gradient);
            }

            g.Restore();
        }
Пример #2
0
        public override void SetAsSource(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();
        }
Пример #3
0
		protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			using (Cairo.Context gr = Gdk.CairoHelper.Create (window)) {
				gr.Rectangle (cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
				gr.Color = (HslColor)widget.Style.Base ((flags & CellRendererState.Selected) == CellRendererState.Selected ? StateType.Selected : StateType.Normal);
				gr.Fill ();
				var size = Math.Max (0, cell_area.Width - cell_area.Width * Time / 100.0);
				var linearGradient = new LinearGradient (cell_area.X, cell_area.Y, cell_area.Right, cell_area.Bottom);
				linearGradient.AddColorStop (0, new Cairo.Color (1, 0, 0));
				linearGradient.AddColorStop (1, new Cairo.Color (1, 1, 1));
				gr.Pattern = linearGradient;
				
				gr.Rectangle (cell_area.X + size, cell_area.Y + 2, cell_area.Width - size, cell_area.Height - 4);
				gr.Fill ();
				
				var layout = gr.CreateLayout ();
				layout.FontDescription = widget.PangoContext.FontDescription;
				layout.SetText (string.Format ("{0:0.0}", Time));
				int w, h;
				layout.GetPixelSize (out w, out h);
				gr.MoveTo (cell_area.X + cell_area.Width - 2 - w, cell_area.Y + (cell_area.Height - h) / 2);
				gr.Color = new Cairo.Color (0, 0, 0);
				gr.ShowLayout (layout);
				layout.Dispose ();
			}
		}
Пример #4
0
        public override void Render(Cairo.Context c)
        {
            InvalidateBound();

            c.Save();
            c.FillRectangle(AbsoluteBound, section.BackgroundColor.ToCairoColor());



            Rectangle r = new Rectangle(AbsoluteBound.X, AbsoluteBound.Y, parentReport.Width, SectionheaderHeight);

            Cairo.Gradient pat = new Cairo.LinearGradient(0, AbsoluteBound.Y, 0, AbsoluteBound.Y + SectionheaderHeight);
            pat.AddColorStop(0, sectionHeaderColor);
            pat.AddColorStop(1, sectionHeaderColor1);
            c.FillRectangle(r, pat);
            c.DrawText(new Cairo.PointD(r.X + 3, r.Y + 3), "Tahoma", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal, 11, blackColor, 600, Section.Name);
            c.FillRectangle(GripperAbsoluteBound, SectionGripperColor);
            c.Translate(AbsoluteDrawingStartPoint.X, AbsoluteDrawingStartPoint.Y);

            for (int j = 0; j < Controls.Count; j++)
            {
                var ctrl = Controls [j];
                ctrl.Render(c);
            }

            c.Restore();
        }
Пример #5
0
        //system top
        public void SystemTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(5, 5); p2 = new PointD(width, 5); s1 = new PointD(width + 2, 7); s2 = new PointD(width + 2, 28);
            p3 = new PointD(width, 30); p4 = new PointD(5, 30); s3 = new PointD(3, 28); s4 = new PointD(3, 7);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1);  g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 60);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat;
            g.FillPreserve();

            g.SetFontSize(17);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.MoveTo(new PointD(12, 23));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("General system information");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #6
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		LinearGradient pat;		
		
		pat = new LinearGradient (0.0, 0.0,  0.0, 1.0);
		pat.AddColorStop (1, new Color (0, 0, 0, 1) );
		pat.AddColorStop (0, new Color (1, 1, 1, 1) );
		gr.Rectangle ( new PointD (0, 0),
			       1, 1
			       );
		
		gr.Pattern =  pat;
		gr.Fill ();
		pat.Destroy ();

		RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
				     0.4,  0.4, 0.5);
		
		pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
		pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
		gr.Pattern =  pat2;
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Fill ();
		pat2.Destroy ();
	}
Пример #7
0
        //intro top Welcome
        public void IntroTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(10, 10); p2 = new PointD(width, 10); s1 = new PointD(width + 2, 12); s2 = new PointD(width + 2, 38);
            p3 = new PointD(width, 40); p4 = new PointD(10, 40); s3 = new PointD(8, 38); s4 = new PointD(8, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat; g.FillPreserve();

            g.SetFontSize(22);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.MoveTo(new PointD(22, 33));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("Welcome to");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #8
0
        //intro bottom tips
        public void IntroBottom(Cairo.Context g)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(30, 10); p2 = new PointD(420, 10); s1 = new PointD(422, 12); s2 = new PointD(422, 88);
            p3 = new PointD(420, 90); p4 = new PointD(30, 90); s3 = new PointD(28, 88); s4 = new PointD(28, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 0.8);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 20, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0));
            pat.AddColorStop(1, new Cairo.Color(0.3, 0.4, 0.6, 0.3));
            g.Pattern = pat;
            g.FillPreserve();


            g.Color = new Color(0, 0, 0, 0.8);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.SetFontSize(18);
            g.MoveTo(new PointD(88, 28));
            g.ShowText(".");
            g.MoveTo(new PointD(88, 58));
            g.ShowText(".");
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Normal);
            g.SetFontSize(10);
            g.MoveTo(new PointD(98, 30));
            g.ShowText("Use the navigation on the left to choose different categories");
            g.MoveTo(new PointD(98, 42));
            g.ShowText("of your computer and system information to display.");
            g.MoveTo(new PointD(98, 60));
            g.ShowText("When you click on a category in the navigation, the dynamic");
            g.MoveTo(new PointD(98, 72));
            g.ShowText("information is automatically refreshed.");

            g.MoveTo(new PointD(38, 35));
            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(18);
            g.ShowText("Tips");

            g.NewPath();

            /*
             * g.Color = new Color (0.3, 0.4, 0.6, 0.8);
             * g.Scale (34, 34);
             * g.LineWidth = 0.06;
             * g.Arc (1.0, 1.0, 0.6, 0, 360);
             * g.Stroke ();*/

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #9
0
        protected override void OnSizeAllocated(Gdk.Rectangle alloc)
        {
            base.OnSizeAllocated(alloc);

            // XXX: Not sure why we need to transpose this. Probably
            //      setting up our GdkWindow incorrectly.

            /*if (this.Toplevel as Gtk.Container != null) {
             *  Container parent = this.Toplevel as Container;
             *  alloc.X -= (int) parent.BorderWidth;
             *  alloc.Y -= (int) parent.BorderWidth;
             * }*/
            alloc.X = 0;
            alloc.Y = 0;

            int x = m_Xoffset;
            int y = m_Yoffset;

            // Create and cache our children allocation areas.
            foreach (Crumb crumb in this.m_Crumbs)
            {
                Gdk.Rectangle crumbAlloc = new Gdk.Rectangle();

                crumbAlloc.X         = x;
                crumbAlloc.Y         = y;
                crumbAlloc.Width     = m_Requests[crumb].Width;
                crumbAlloc.Height    = alloc.Height - (y * 2);
                this.m_Coords[crumb] = crumbAlloc;
                crumb.Widget.SizeAllocate(crumbAlloc);

                x += crumbAlloc.Width + (2 * Spacing) + 2;
            }

            // Normal Crumb Background
            m_NormalBg = new Cairo.LinearGradient(
                alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
            m_NormalBg.AddColorStop(0.3, m_NormalBgBegin);
            m_NormalBg.AddColorStop(0.9, m_NormalBgEnd);

            // Cursor Hover Crumb Background
            m_PrelightBg = new Cairo.LinearGradient(
                alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
            m_PrelightBg.AddColorStop(0.3, m_PrelightBgBegin);
            m_PrelightBg.AddColorStop(0.9, m_PrelightBgEnd);

            // Selected Crumb Background
            m_SelectedBg = new Cairo.LinearGradient(
                alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
            m_SelectedBg.AddColorStop(0.3, m_SelectedBgBegin);
            m_SelectedBg.AddColorStop(0.9, m_SelectedBgEnd);
        }
Пример #10
0
        public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
        {
            Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
            Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (1, dark_color);

            cr.SetSource (grad);
            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill ();
            grad.Dispose ();
        }
Пример #11
0
        protected override void PaintFill()
        {
            base.PaintFill();

            using (var fade = new Cairo.LinearGradient(0, 0, 0, height)) {
                fade.AddColorStop(0, new Cairo.Color(1, 1, 1, 0));
                fade.AddColorStop(.75, new Cairo.Color(1, 1, 1, .25));

                cairo.Save();
                cairo.NewPath();
                GlossOverlay(cairo);

                cairo.SetSource(fade);
                cairo.FillPreserve();

                cairo.Restore();
            }
        }
Пример #12
0
        public override void Render(Context cr)
        {
            if (!CanResize) {
                return;
            }

            var selected_color = CairoExtensions.GdkColorToCairoColor (Window.Style.Dark (StateType.Active));
            var grad = new LinearGradient (0, 0, 0, Allocation.Height);

            selected_color.A = 0.4;
            grad.AddColorStop (0, selected_color);
            selected_color.A = 1.0;
            grad.AddColorStop (1, selected_color);

            cr.Pattern = grad;
            cr.LineWidth = 1.0;
            cr.Rectangle (0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1);
            cr.Stroke ();

            selected_color.A = 0.5;
            cr.Color = selected_color;

            double handle_size = 8;
            double ty = 0.5 + Allocation.Height - handle_size - 3;
            double tx = 0.5 + (Window.Direction == TextDirection.Ltr
                ? Allocation.Width - handle_size - 3
                : 3);

            cr.Translate (tx, ty);

            for (double i = 0; i < 3; i++) {
                if (Window.Direction == TextDirection.Ltr) {
                    cr.MoveTo (i * 3, handle_size);
                    cr.LineTo (handle_size, i * 3);
                } else {
                    cr.MoveTo (0, i * 3);
                    cr.LineTo (handle_size - i * 3, handle_size);
                }
            }

            cr.Stroke ();

            cr.Translate (-tx, -ty);
        }
Пример #13
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			Pango.Layout la = new Pango.Layout (PangoContext);
			int w, h;
			if (UseMarkup)
				la.SetMarkup (Text);
			else
				la.SetText (Text);

			la.GetPixelSize (out w, out h);

			int tx = Allocation.X + (int) Xpad + (int) ((float)(Allocation.Width - (int)(Xpad*2) - w) * Xalign);
			int ty = Allocation.Y + (int) Ypad + (int) ((float)(Allocation.Height - (int)(Ypad*2) - h) * Yalign);

			using (var ctx = CairoHelper.Create (evnt.Window)) {
				ctx.SetSourceColor (Style.Text (State).ToCairoColor ());
				ctx.MoveTo (tx, ty);

				// In order to get the same result as in MonoDevelop.Components.DockNotebook.TabStrip.DrawTab()
				// (document tabs) we need to draw using a LinearGradient (because of issues below),
				// but we don't want to mask the actual text here, like in the doc tabs.
				// Therefore we use a LinearGradient and mask only the last vertical pixel line
				// of the label with 0.99 alpha, which forces Cairo to render the whole layout
				// in the desired way.

				// Semi-transparent gradient disables sub-pixel rendering of the label (reverting to grayscale antialiasing).
				// As Mac sub-pixel font rendering looks stronger than grayscale rendering, the label used in pad tabs
				// looked different. We need to simulate same gradient treatment as we have in document tabs.

				using (var lg = new LinearGradient (tx + w - 1, 0, tx + w, 0)) {
					var color = Style.Text (State).ToCairoColor ();
					lg.AddColorStop (0, color);
					color.A = 0.99;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayout (ctx, la);
				}
			}
			
			la.Dispose ();
			return true;
		}
Пример #14
0
        public static void RoundedSelection(Cairo.Context cr, Gtk.Widget widget, double x, double y, double w, double h, double a)
        {
            Cairo.Color selection_color = CairoFu.GdkColorToCairoColor(widget.Style.Backgrounds [(int)Gtk.StateType.Selected]);

            Cairo.Color selection_stroke     = CairoFu.ColorShade(selection_color, 0.85);
            Cairo.Color selection_fill_light = CairoFu.ColorShade(selection_color, 1.1);
            Cairo.Color selection_fill_dark  = CairoFu.ColorShade(selection_color, 0.90);
            selection_stroke.A = selection_fill_light.A = selection_fill_dark.A = a;

            Cairo.LinearGradient pattern = new Cairo.LinearGradient(x, y, x, y + h);
            pattern.AddColorStop(0, selection_fill_light);
            pattern.AddColorStop(1, selection_fill_dark);

            RoundedRectangle(cr, x, y, w, h, 3);
            cr.Pattern = pattern;
            cr.Fill();

            RoundedRectangle(cr, x + 0.5, y + 0.5, w - 0.5, h - 0.5, 3);
            cr.Color     = selection_stroke;
            cr.LineWidth = 1.0;
            cr.Stroke();
        }
Пример #15
0
		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int)(padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));

			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (var gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();

			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));

					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)

			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3,
				            tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
				            CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
Пример #16
0
		void DrawBackground (Context ctx, Gdk.Rectangle region)
		{
			var h = region.Height;
			ctx.Rectangle (0, 0, region.Width, h);
			using (var gr = new LinearGradient (0, 0, 0, h)) {
				if (isActiveNotebook) {
					gr.AddColorStop (0, Styles.TabBarActiveGradientStartColor);
					gr.AddColorStop (1, Styles.TabBarActiveGradientEndColor);
				} else {
					gr.AddColorStop (0, Styles.TabBarGradientStartColor);
					gr.AddColorStop (1, Styles.TabBarGradientEndColor);
				}
				ctx.SetSource (gr);
				ctx.Fill ();
			}

			ctx.MoveTo (region.X, 0.5);
			ctx.LineTo (region.Right + 1, 0.5);
			ctx.LineWidth = 1;
			ctx.SetSourceColor (Styles.TabBarGradientShadowColor);
			ctx.Stroke ();
		}
Пример #17
0
		static void DrawCloseButton (Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				const double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				const double fillColor = .74;

				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);

				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();

				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);

					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();

					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.SetSource (lg);
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();

				}
			}
		}
Пример #18
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            color.A *= 0.85;
            Cairo.Color selection_color = color;
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_stroke.A = color.A;

            if (filled) {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.05);
                Cairo.Color selection_fill_dark = selection_color;

                selection_fill_light.A = color.A;
                selection_fill_dark.A = color.A;

                LinearGradient grad = new LinearGradient (x, y, x, y + height);
                grad.AddColorStop (0, selection_fill_dark);
                grad.AddColorStop (1, selection_fill_light);

                cr.SetSource (grad);
                cr.Rectangle (x, y, width, height);
                cr.Fill ();
                grad.Dispose ();
            }

            if (stroked && !filled) {
                cr.LineWidth = 1.0;
                cr.SetSourceColor (selection_stroke);
                cr.Rectangle (x + 0.5, y + 0.5, width - 1, height - 1);
                cr.Stroke ();
            }
        }
Пример #19
0
		public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle)
		{
			if (IsSeparator) {
				cr.NewPath ();
				double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5;
				cr.MoveTo (x, rectangle.Y + 0.5 + 2);
				cr.RelLineTo (0, rectangle.Height - 1 - 4);
				cr.ClosePath ();
				cr.Color = (HslColor)parent.Style.Dark (StateType.Normal);
				cr.LineWidth = 1;
				cr.Stroke ();
				return;
			}
			
			if (Active || HoverPosition.X >= 0) {
				if (Active) {
					cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
					using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
						gr.AddColorStop (0, Tabstrip.ActiveGradientStart);
						gr.AddColorStop (1, Tabstrip.ActiveGradientEnd);
						cr.Pattern = gr;
					}
					cr.Fill ();
					cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1);
					cr.Color = new Cairo.Color (1, 1, 1, 0.05);
					cr.LineWidth = 1;
					cr.Stroke ();
				} else if (HoverPosition.X >= 0) {
					cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
					using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
						var c1 = Tabstrip.ActiveGradientStart;
						var c2 = Tabstrip.ActiveGradientEnd;
						c1.A = 0.2;
						c2.A = 0.2;
						gr.AddColorStop (0, c1);
						gr.AddColorStop (1, c2);
						cr.Pattern = gr;
					}
					cr.Fill ();
				}
			}
			
			if (Active)
				cr.Color = new Cairo.Color (1, 1, 1);
			else
				cr.Color = parent.Style.Text (StateType.Normal).ToCairoColor ();

			cr.MoveTo (rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2);
			Pango.CairoHelper.ShowLayout (cr, layout);
		}
Пример #20
0
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Cairo.Color gtk_background_color =
                CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBackgroundColor (StateFlags.Normal));
            Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
            Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95);

            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (0.75, dark_color);
            grad.AddColorStop (0, light_color);

            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
            cr.Fill ();

            cr.Color = border_color;
            cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill ();
            grad.Destroy ();
        }
Пример #21
0
        private void RedrawControls(ButtonStates closeState, ButtonStates minimizeState, bool initDraw)
        {
            bool mustRedraw = _closeState != closeState || (_minimizeState != minimizeState && _showMinimize) || initDraw;

            //Background
            if (mustRedraw)
            {
                using (Context ctx = Gdk.CairoHelper.Create(titlebar.GdkWindow))
                {
                    Cairo.Gradient pat = new Cairo.LinearGradient(0, 0, 0, this.titlebar.HeightRequest);

                    pat.AddColorStop(0, new Cairo.Color(0.81, 0.96, 0.99));
                    pat.AddColorStop(1, new Cairo.Color(1, 1, 1));

                    ctx.SetSource(pat);
                    ctx.Operator = Operator.Source;
                    ctx.Paint();
                }

                titlebar.GdkWindow.DrawLayout(titlebar.Style.TextGC(StateType.Normal), 10, 10, titleLayout);
            }

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

            //Close Button
            if (mustRedraw)
            {
                switch (closeState)
                {
                case ButtonStates.DownInside:
                    cr.SetSourceRGB(1.0, 0, 0);
                    break;

                case ButtonStates.DownOutside:
                case ButtonStates.Inside:
                    cr.SetSourceRGB(0.86, 0.86, 0.86);
                    break;

                case ButtonStates.Outside:
                    cr.SetSourceRGBA(0, 0, 0, 0);
                    break;
                }
                cr.Rectangle(_closeStart.X, _closeStart.Y, ButtonWidth, ButtonHeight);
                cr.Fill();

                cr.LineWidth = CrossLineWidth;
                cr.SetSourceRGB(0.2, 0.2, 0.2);
                cr.MoveTo(_closeStart.X + CrossLineOffsetX, _closeStart.Y + CrossLineOffsetY);
                cr.LineTo(_closeStart.X + CrossLineOffsetX + CrossLineLength, _closeStart.Y + CrossLineOffsetY + CrossLineLength);
                cr.Stroke();

                cr.LineWidth = CrossLineWidth;
                cr.MoveTo(_closeStart.X + CrossLineOffsetX + CrossLineLength, _closeStart.Y + CrossLineOffsetY);
                cr.LineTo(_closeStart.X + CrossLineOffsetX, _closeStart.Y + CrossLineOffsetY + CrossLineLength);
                cr.Stroke();
            }
            _closeState = closeState;
            //Minimize
            if (mustRedraw && _showMinimize)
            {
                switch (minimizeState)
                {
                case ButtonStates.DownInside:
                    cr.SetSourceRGB(0.105, 0.63, 0.886);
                    break;

                case ButtonStates.DownOutside:
                case ButtonStates.Inside:
                    cr.SetSourceRGB(0.86, 0.86, 0.86);
                    break;

                case ButtonStates.Outside:
                    cr.SetSourceRGBA(0, 0, 0, 0);
                    break;
                }
                cr.Rectangle(_minimizeStart.X, _minimizeStart.Y, ButtonWidth, ButtonHeight);
                cr.Fill();

                cr.LineWidth = MinimizeLineWidth;
                cr.SetSourceRGB(0, 0, 0);
                cr.MoveTo(_minimizeStart.X + MinimizeLineOffsetX, _minimizeStart.Y + MinimizeLineOffsetY);
                cr.LineTo(_minimizeStart.X + MinimizeLineOffsetX + MinimizeLineLength, _minimizeStart.Y + MinimizeLineOffsetY);
                cr.Stroke();
            }

            if (_showMinimize)
            {
                _minimizeState = minimizeState;
            }
        }
Пример #22
0
		public void Render (Cairo.Context context, StatusArea.RenderArg arg)
		{
			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.Pattern = 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 - arg.CurrentPixbuf.Height) / 2;
				Gdk.CairoHelper.SetSourcePixbuf (context, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
				context.Paint ();
				progress_bar_x += arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
				progress_bar_width -= 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 ();
		}
Пример #23
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad = radius - 0.5;
            int centerX = region.X + region.Width / 2;
            int centerY = region.Y + region.Height / 2;

            context.MoveTo (centerX + rad, centerY);
            context.Arc (centerX, centerY, rad, 0, Math.PI * 2);

            double high;
            double low;
            switch (state) {
            case StateType.Selected:
                high = 0.85;
                low = 1.0;
                break;
            case StateType.Prelight:
                high = 1.0;
                low = 0.9;
                break;
            case StateType.Insensitive:
                high = 0.95;
                low = 0.83;
                break;
            default:
                high = 1.0;
                low = 0.85;
                break;
            }
            using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
                lg.AddColorStop (0, new Cairo.Color (high, high, high));
                lg.AddColorStop (1, new Cairo.Color (low, low, low));
                context.SetSource (lg);
                context.FillPreserve ();
            }

            context.SetSourceRGBA (0, 0, 0, 0.4);
            context.LineWidth = 1;
            context.Stroke ();
        }
Пример #24
0
        public void DrawTimeBar(CairoContextEx gr, double x, double y, double percentage)
        {
            double width = 0.04, height = 0.6;
            const double w = 0.003, h = 0.003;

            gr.DrawTextCentered (x + (width / 2), y + height + 0.05, Translations.GetString ("Time left"));
            gr.Stroke ();

            gr.Save ();
            gr.Color = new Color (0, 0, 0);
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.Stroke ();

            x+= w;
            y+= h;
            width -= w * 2;
            height -= h * 2;
            y += height * (100 - percentage) / 100;
            height *= percentage / 100;

            if (gradient == null) {
                gradient = new LinearGradient (x, y, x + width, y + height);
                gradient.AddColorStop (0, new Color (1, 0, 0, 1));
                gradient.AddColorStop (1, new Color (0.2, 0, 0, 1));
            }

            gr.Source = gradient;
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.FillPreserve ();
            gr.Stroke ();
            gr.Restore ();
        }
Пример #25
0
        public override void Finish()
        {
            if (downview != null)
                FinishCountDown ();
            else
                timer.Enabled = false;

            if (gradient != null) {
                gradient.Dispose ();
                gradient = null;
            }
        }
Пример #26
0
		// VERY SLOW, only use on cached renders
		public static void RenderOuterShadow (this Cairo.Context self, Gdk.Rectangle area, int size, int rounding, double strength)
		{
			area.Inflate (-1, -1);
			size++;

			int doubleRounding = rounding * 2;
			// left side
			self.Rectangle (area.X - size, area.Y + rounding, size, area.Height - doubleRounding - 1);
			using (var lg = new LinearGradient (area.X, 0, area.X - size, 0)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// right side
			self.Rectangle (area.Right, area.Y + rounding, size, area.Height - doubleRounding - 1);
			using (var lg = new LinearGradient (area.Right, 0, area.Right + size, 0)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// top side
			self.Rectangle (area.X + rounding, area.Y - size, area.Width - doubleRounding - 1, size);
			using (var lg = new LinearGradient (0, area.Y, 0, area.Y - size)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// bottom side
			self.Rectangle (area.X + rounding, area.Bottom, area.Width - doubleRounding - 1, size);
			using (var lg = new LinearGradient (0, area.Bottom, 0, area.Bottom + size)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// top left corner
			self.Rectangle (area.X - size, area.Y - size, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.X + rounding, area.Y + rounding, rounding, area.X + rounding, area.Y + rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// top right corner
			self.Rectangle (area.Right - rounding, area.Y - size, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.Right - rounding, area.Y + rounding, rounding, area.Right - rounding, area.Y + rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// bottom left corner
			self.Rectangle (area.X - size, area.Bottom - rounding, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.X + rounding, area.Bottom - rounding, rounding, area.X + rounding, area.Bottom - rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// bottom right corner
			self.Rectangle (area.Right - rounding, area.Bottom - rounding, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.Right - rounding, area.Bottom - rounding, rounding, area.Right - rounding, area.Bottom - rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}
		}
Пример #27
0
        public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            cr.LineWidth = BorderWidth;
            border_color.A = 0.3;
            cr.SetSourceColor (border_color);

            double offset = (double)BorderWidth / 2.0;
            double w = Math.Max (0, alloc.Width * 0.75);
            double x = alloc.X + (alloc.Width - w) * 0.5 + offset;
            double y = alloc.Y + alloc.Height + offset;

            LinearGradient g = new LinearGradient (x, y, x + w, y);

            Color transparent = border_color;
            transparent.A = 0.0;

            g.AddColorStop (0, transparent);
            g.AddColorStop (0.4, border_color);
            g.AddColorStop (0.6, border_color);
            g.AddColorStop (1, transparent);

            cr.SetSource (g);

            cr.MoveTo (x, y);
            cr.LineTo (x + w, y);
            cr.Stroke ();

            g.Dispose ();
        }
Пример #28
0
            public static void DrawShadow(Cairo.Context cr, double x, double y, double width,
                                          double height, double radius, ShadowParameters shadowParams)
            {
                using (Surface sr = cr.CreateSimilarToTarget((int)width + (int)(2 * shadowParams.shadowRadius) + (int)x,
                                                             (int)height + (int)(2 * shadowParams.shadowRadius) + (int)y))
                {
                    using (Context cairo = new Context(sr))
                    {
                        radius++;
                        y++;
                        height--;
                        Cairo.Gradient shadow;
                        /* Top Left */
                        using (shadow = new Cairo.RadialGradient(x + radius, y + radius, radius,
                                                                 x + radius, y + radius, radius + shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(x - shadowParams.shadowRadius, y - shadowParams.shadowRadius,
                                            radius + shadowParams.shadowRadius, radius + shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }
                        /* Top */
                        using (shadow = new Cairo.LinearGradient(0.0, y, 0.0, y - shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(x + radius, y - shadowParams.shadowRadius,
                                            width - radius * 2, shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }
                        /* Top Right */
                        using (shadow = new Cairo.RadialGradient(width + x - radius, y + radius, radius,
                                                                 width + x - radius, y + radius, radius + shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(width + x - radius, y - shadowParams.shadowRadius,
                                            radius + shadowParams.shadowRadius, radius + shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        /* Right */
                        using (shadow = new Cairo.LinearGradient(width + x, 0.0,
                                                                 width + x + shadowParams.shadowRadius, 0.0))
                        {
                            cairo.Rectangle(width + x, y + radius, shadowParams.shadowRadius, height - radius * 2);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        /* Bottom Right */
                        using (shadow = new Cairo.RadialGradient(width + x - radius, height + y - radius, radius,
                                                                 width + x - radius, height + y - radius, radius + shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(width + x - radius, height + y - radius,
                                            radius + shadowParams.shadowRadius, radius + shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        /* Bottom */
                        using (shadow = new Cairo.LinearGradient(0.0, height + y,
                                                                 0.0, height + y + shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(x + radius, height + y,
                                            width - radius * 2, shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        /* Bottom Left */
                        using (shadow = new Cairo.RadialGradient(x + radius, height + y - radius, radius,
                                                                 x + radius, height + y - radius, radius + shadowParams.shadowRadius))
                        {
                            cairo.Rectangle(x - shadowParams.shadowRadius, height + y - radius,
                                            radius + shadowParams.shadowRadius, radius + shadowParams.shadowRadius);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        /* Left */
                        using (shadow = new Cairo.LinearGradient(x, 0.0,
                                                                 x - shadowParams.shadowRadius, 0.0))
                        {
                            cairo.Rectangle(x - shadowParams.shadowRadius, y + radius,
                                            radius + shadowParams.shadowRadius, height - radius * 2);
                            FillShadowPattern(cairo, shadow, shadowParams);
                        }

                        y--;
                        height++;
                        /* Clear inner rectangle */
                        GetFrame(cairo, x, y, width, height, radius);
                        cairo.Operator = Cairo.Operator.Clear;
                        cairo.Fill();

                        cr.SetSource(sr);
                        cr.Paint();
                    }
                }
            }
Пример #29
0
		protected sealed override void PaintSurface (DockySurface surface)
		{
			surface.Clear ();
			
			lock (buffers) {
				if (slideCounter > 0 && slideCounter < slideSteps) {
					double offset = Allocation.Width * Math.Log (slideCounter) / Math.Log (slideSteps);
					
					if (MovedLeft) {
						ShowBuffer (surface, Page, offset - Allocation.Width);
						ShowBuffer (surface, LastPage, offset);
					} else {
						ShowBuffer (surface, Page, Allocation.Width - offset);
						ShowBuffer (surface, LastPage, -offset);
					}
					
					// fade out the edges during a slide
					Gradient linpat = new LinearGradient (0, surface.Height / 2, surface.Width, surface.Height / 2);
					linpat.AddColorStop (0, new Color(1, 1, 1, 1));
					linpat.AddColorStop (2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1 - 2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1, new Color(1, 1, 1, 1));
						
					surface.Context.Save ();
					surface.Context.Operator = Operator.Source;
					surface.Context.Color = new Cairo.Color (0, 0, 0, 0);
					surface.Context.Mask (linpat);
					surface.Context.PaintWithAlpha (0);
					surface.Context.Restore ();
					linpat.Destroy ();
				} else {
					ShowBuffer (surface, Page, 0);
				}
			}
			
			// overlay the prev/next arrow buttons
			if (buttonBuffer != null && (buttonBuffer.Width != surface.Width || buttonBuffer.Height != surface.Height))
				ResetButtons ();
			
			if (buttonBuffer == null) {
				buttonBuffer = new DockySurface (surface.Width, surface.Height, surface);
				DrawButtonsBuffer ();
			}
			
			buttonBuffer.Internal.Show (surface.Context, 0, 0);
		}
Пример #30
0
        private Surface CreateScene (Cairo.Context window_cr, ImageSurface image, int reflect)
        {
            Surface surface = window_cr.Target.CreateSimilar (window_cr.Target.Content,
                image.Width, image.Height + reflect);
            Cairo.Context cr = new Context (surface);

            cr.Save ();

            cr.SetSource (image);
            cr.Paint ();

            cr.Rectangle (0, image.Height, image.Width, reflect);
            cr.Clip ();

            Matrix matrix = new Matrix ();
            matrix.InitScale (1, -1);
            matrix.Translate (0, -(2 * image.Height) + 1);
            cr.Transform (matrix);

            cr.SetSource (image);
            cr.Paint ();

            cr.Restore ();

            Color bg_transparent = BackgroundColor;
            bg_transparent.A = 0.65;

            LinearGradient mask = new LinearGradient (0, image.Height, 0, image.Height + reflect);
            mask.AddColorStop (0, bg_transparent);
            mask.AddColorStop (1, BackgroundColor);

            cr.Rectangle (0, image.Height, image.Width, reflect);
            cr.Pattern = mask;
            cr.Fill ();

            ((IDisposable)cr).Dispose ();
            return surface;
        }
Пример #31
0
        void UpdateBgImage()
        {
            m_bgImage = null;

            if (TextColumn < 0 || WeightColumn < 0)
            {
                return;
            }

            m_bgImage = new Cairo.ImageSurface(Format.Rgb24, Allocation.Width, this.Allocation.Height);

            using (var c = new Cairo.Context(m_bgImage))
            {
                // Paint the default background (linear gradient)
                var g = new Cairo.LinearGradient(0, 0, 1, this.Allocation.Height);
                g.AddColorStop(0.2, CairoExtensions.GdkColorToCairoColor(m_Background));
                g.AddColorStop(0.9, CairoExtensions.GdkColorToCairoColor(this.Style.Background(Gtk.StateType.Normal)));
                c.Rectangle(0, 0, this.Allocation.Width, this.Allocation.Height);
                c.Pattern = g;
                c.Paint();
                g.Dispose();

                Gtk.TreeIter iter;

                List <TreeMapItem> rootItems = new List <TreeMapItem> ();

                if (m_Model.GetIterFirst(out iter))
                {
                    do
                    {
                        var item = new TreeMapItem(m_Model, ref iter, true, m_TextColumn, m_WeightColumn);
                        rootItems.Add(item);
                    } while (m_Model.IterNext(ref iter));

                    double t = 0.0;

                    rootItems.ForEach(delegate(TreeMapItem i) {
                        t += Math.Abs(i.Weight);
                    });

                    double x = 0, y = 0, w = this.Allocation.Width, h = this.Allocation.Height;
                    double myx = 0, myy = 0, myw = 0, myh = 0;

                    rootItems.ForEach(delegate(TreeMapItem i) {
                        var ratio = Math.Abs(i.Weight) / t;
                        myx       = x;
                        myy       = y;
                        myw       = w * ratio;
                        myh       = h;
                        x        += myw;

                        i.SetArea(myx, myy, myw, myh);
                        i.Render(c, m_Background);
                    });

                    // clear right away to lower refs
                    if (this.m_rootItems != null)
                    {
                        this.m_rootItems.Clear();
                    }

                    this.m_rootItems = rootItems;
                }
            }
        }
Пример #32
0
		protected virtual void DrawBackground (Cairo.Context context, Gdk.Rectangle region)
		{	
			LayoutRoundedRectangle (context, region);
			context.ClipPreserve ();

			using (LinearGradient lg = new LinearGradient (region.X, region.Y, region.X, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarFill1Color);
				lg.AddColorStop (1, Styles.StatusBarFill4Color);

				context.Pattern = lg;
				context.FillPreserve ();
			}

			context.Save ();
			double midX = region.X + region.Width / 2.0;
			double midY = region.Y + region.Height;
			context.Translate (midX, midY);

			using (RadialGradient rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				rg.AddColorStop (0, Styles.StatusBarFill1Color);
				rg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarFill1Color, 0));

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.Pattern = rg;
				context.Fill ();
			}
			context.Restore ();

			using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarShadowColor1);
				lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2));

				LayoutRoundedRectangle (context, region, 0, -1);
				context.LineWidth = 1;
				context.Pattern = lg;
				context.Stroke ();
			}

			using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarShadowColor2);
				lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2));

				LayoutRoundedRectangle (context, region, 0, -2);
				context.LineWidth = 1;
				context.Pattern = lg;
				context.Stroke ();
			}

			context.ResetClip ();
		}
Пример #33
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
        {
            Cairo.Color selection_color = color;
            Cairo.Color selection_highlight = CairoExtensions.ColorShade (selection_color, 1.24);
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_highlight.A = 0.5;
            selection_stroke.A = color.A;
            LinearGradient grad = null;

            if (filled) {
                if (flat_fill) {
                    cr.Color = selection_color;
                } else {
                    Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.12);
                    Cairo.Color selection_fill_dark = selection_color;

                    selection_fill_light.A = color.A;
                    selection_fill_dark.A = color.A;

                    grad = new LinearGradient (x, y, x, y + height);
                    grad.AddColorStop (0, selection_fill_light);
                    grad.AddColorStop (0.4, selection_fill_dark);
                    grad.AddColorStop (1, selection_fill_light);

                    cr.Pattern = grad;
                }

                CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill ();

                if (grad != null) {
                    grad.Destroy ();
                }
            }

            if (filled && stroked) {
                cr.LineWidth = 1.0;
                cr.Color = selection_highlight;
                CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3,
                    Context.Radius - 1, corners, true);
                cr.Stroke ();
            }

            if (stroked) {
                cr.LineWidth = 1.0;
                cr.Color = selection_stroke;
                CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1,
                    Context.Radius, corners, true);
                cr.Stroke ();
            }
        }
Пример #34
0
        void DrawCloseButton(Cairo.Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
        {
            if (hovered)
            {
                double radius = 6;
                context.Arc(center.X, center.Y, radius, 0, Math.PI * 2);
                context.Color = new Cairo.Color(.6, .6, .6, opacity);
                context.Fill();

                context.Color     = new Cairo.Color(0.95, 0.95, 0.95, opacity);
                context.LineWidth = 2;

                context.MoveTo(center.X - 3, center.Y - 3);
                context.LineTo(center.X + 3, center.Y + 3);
                context.MoveTo(center.X - 3, center.Y + 3);
                context.LineTo(center.X + 3, center.Y - 3);
                context.Stroke();
            }
            else
            {
                double lineColor = .63 - .1 * animationProgress;
                double fillColor = .74;

                double heightMod = Math.Max(0, 1.0 - animationProgress * 2);
                context.MoveTo(center.X - 3, center.Y - 3 * heightMod);
                context.LineTo(center.X + 3, center.Y + 3 * heightMod);
                context.MoveTo(center.X - 3, center.Y + 3 * heightMod);
                context.LineTo(center.X + 3, center.Y - 3 * heightMod);

                context.LineWidth = 2;
                context.Color     = new Cairo.Color(lineColor, lineColor, lineColor, opacity);
                context.Stroke();

                if (animationProgress > 0.5)
                {
                    double partialProg = (animationProgress - 0.5) * 2;
                    context.MoveTo(center.X - 3, center.Y);
                    context.LineTo(center.X + 3, center.Y);

                    context.LineWidth = 2 - partialProg;
                    context.Color     = new Cairo.Color(lineColor, lineColor, lineColor, opacity);
                    context.Stroke();


                    double radius = partialProg * 3.5;

                    // Background
                    context.Arc(center.X, center.Y, radius, 0, Math.PI * 2);
                    context.Color = new Cairo.Color(fillColor, fillColor, fillColor, opacity);
                    context.Fill();

                    // Inset shadow
                    using (var lg = new Cairo.LinearGradient(0, center.Y - 5, 0, center.Y)) {
                        context.Arc(center.X, center.Y + 1, radius, 0, Math.PI * 2);
                        lg.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.2 * opacity));
                        lg.AddColorStop(1, new Cairo.Color(0, 0, 0, 0));
                        context.Pattern = lg;
                        context.Stroke();
                    }

                    // Outline
                    context.Arc(center.X, center.Y, radius, 0, Math.PI * 2);
                    context.Color = new Cairo.Color(lineColor, lineColor, lineColor, opacity);
                    context.Stroke();
                }
            }
        }
Пример #35
0
        private void DrawGradient(Context g)
        {
            Rectangle rect = GradientRectangle;

            Gradient pat = new LinearGradient(rect.X, rect.Y, rect.X,
                                              rect.Y + rect.Height);
            pat.AddColorStop (0, MaxColor);
            pat.AddColorStop (1, new Cairo.Color (0, 0, 0));

            g.Rectangle (rect);
            g.Pattern = pat;
            g.Fill();
        }
Пример #36
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)
                        cell.Render (GdkWindow, ctx, r.EditorBounds, state);

                    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 ();
                    }
                }
            }
        }
Пример #37
0
        public static void DrawLinearReflectedGradient(this Context g, Surface oldsurface, GradientColorMode mode, Cairo.Color c1, Cairo.Color c2, PointD p1, PointD p2)
        {
            g.Save ();

            Gradient gradient = new Cairo.LinearGradient (p1.X, p1.Y, p2.X, p2.Y);

            if (mode == GradientColorMode.Color) {
                gradient.AddColorStop (0, c1);
                gradient.AddColorStop (0.5, c2);
                gradient.AddColorStop (1, c1);
                g.Source = gradient;
                g.Paint ();
            }
            else if (mode == GradientColorMode.Transparency) {
                gradient.AddColorStop (0, new Cairo.Color (0, 0, 0, 1));
                gradient.AddColorStop (0.5, new Cairo.Color (0, 0, 0, 0));
                gradient.AddColorStop (1, new Cairo.Color (0, 0, 0, 1));
                g.Source = new SurfacePattern (oldsurface);
                g.Mask (gradient);
            }

            g.Restore ();
        }
Пример #38
0
        //private double last_invalidate_value = -1;

        /*private void Invalidate ()
        {
            double current_value = (IsValueUpdatePending ? PendingValue : Value);

            // FIXME: Something is wrong with the updating below causing an
            // invalid region when IsValueUpdatePending is true, so when
            // that is the case for now, we trigger a full invalidation
            if (last_invalidate_value < 0 || IsValueUpdatePending) {
                last_invalidate_value = current_value;
                InvalidateRender ();
                return;
            }

            double max = Math.Max (last_invalidate_value, current_value) * RenderSize.Width;
            double min = Math.Min (last_invalidate_value, current_value) * RenderSize.Width;

            Rect region = new Rect (
                InvalidationRect.X + min,
                InvalidationRect.Y,
                (max - min) + 2 * ThrobberSize,
                InvalidationRect.Height
            );

            last_invalidate_value = current_value;
            InvalidateRender (region);
        }*/

        /*protected override Rect InvalidationRect {
            get { return new Rect (
                -Margin.Left - ThrobberSize / 2,
                -Margin.Top,
                Allocation.Width + ThrobberSize,
                Allocation.Height);
            }
        }*/

        protected override void ClippedRender (Cairo.Context cr)
        {
            double throbber_r = ThrobberSize / 2.0;
            double throbber_x = Math.Round (RenderSize.Width * (IsValueUpdatePending ? PendingValue : Value));
            double throbber_y = (Allocation.Height - ThrobberSize) / 2.0 - Margin.Top + throbber_r;
            double bar_w = RenderSize.Width * Value;

            cr.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, Gtk.StateType.Normal);
            cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
            cr.Fill ();

            Color color = Theme.Colors.GetWidgetColor (GtkColorClass.Dark, Gtk.StateType.Active);
            Color fill_color = CairoExtensions.ColorShade (color, 0.4);
            Color light_fill_color = CairoExtensions.ColorShade (color, 0.3);
            fill_color.A = 1.0;
            light_fill_color.A = 1.0;

            LinearGradient fill = new LinearGradient (0, 0, 0, RenderSize.Height);
            fill.AddColorStop (0, light_fill_color);
            fill.AddColorStop (0.5, fill_color);
            fill.AddColorStop (1, light_fill_color);

            cr.Rectangle (0, 0, bar_w, RenderSize.Height);
            cr.Pattern = fill;
            cr.Fill ();

            cr.Color = fill_color;
            cr.Arc (throbber_x, throbber_y, throbber_r, 0, Math.PI * 2);
            cr.Fill ();
        }
Пример #39
0
 public void FillGradient(double x, double y, double w, double h)
 {
     Save ();
     LinearGradient shadow = new LinearGradient (x, y, x + w, y + h);
     shadow.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.3));
     shadow.AddColorStop (0.5, new Cairo.Color (0, 0, 0, 0.1));
     Source = shadow;
     Fill ();
     Restore ();
     ((IDisposable)shadow).Dispose ();
 }
Пример #40
0
		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			double rightPadding = (active ? TabActivePadding.Right : TabPadding.Right) - (LeanWidth / 2);
			rightPadding = (rightPadding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));
			double leftPadding = (active ? TabActivePadding.Left : TabPadding.Left) - (LeanWidth / 2);
			leftPadding = (leftPadding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));
			double bottomPadding = active ? TabActivePadding.Bottom : TabPadding.Bottom;

			DrawTabBackground (this, ctx, allocation, tabBounds.Width, tabBounds.X, active);

			ctx.LineWidth = 1;
			ctx.NewPath ();

			// Render Close Button (do this first so we can tell how much text to render)

			var closeButtonAlloation = new Cairo.Rectangle (tabBounds.Right - rightPadding - (tabCloseImage.Width / 2) - CloseButtonMarginRight,
			                                 tabBounds.Height - bottomPadding - tabCloseImage.Height - CloseButtonMarginBottom,
			                                 tabCloseImage.Width, tabCloseImage.Height);
			
			tab.CloseButtonActiveArea = closeButtonAlloation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonActiveArea.Contains (tracker.MousePosition);
			bool tabHovered = tracker.Hovered && tab.Allocation.Contains (tracker.MousePosition);
			bool drawCloseButton = active || tabHovered;

			if (!closeButtonHovered && tab.DirtyStrength > 0.5) {
				ctx.DrawImage (this, tabDirtyImage, closeButtonAlloation.X, closeButtonAlloation.Y);
				drawCloseButton = false;
			}

			if (drawCloseButton)
				ctx.DrawImage (this, tabCloseImage.WithAlpha ((closeButtonHovered ? 1.0 : 0.5) * tab.Opacity), closeButtonAlloation.X, closeButtonAlloation.Y);
			
			// Render Text
			double tw = tabBounds.Width - (leftPadding + rightPadding);
			if (drawCloseButton || tab.DirtyStrength > 0.5)
				tw -= closeButtonAlloation.Width / 2;

			double tx = tabBounds.X + leftPadding;
			var baseline = la.GetLine (0).Layout.GetPixelBaseline ();
			double ty = tabBounds.Height - bottomPadding - baseline;

			ctx.MoveTo (tx, ty);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(tw * Pango.Scale.PangoScale);
				ctx.SetSourceColor ((tab.Notify ? Styles.TabBarNotifyTextColor : (active ? Styles.TabBarActiveTextColor : Styles.TabBarInactiveTextColor)).ToCairoColor ());
				Pango.CairoHelper.ShowLayout (ctx, la.GetLine (0).Layout);
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (tx + tw - 10, 0, tx + tw, 0)) {
					var color = (tab.Notify ? Styles.TabBarNotifyTextColor : (active ? Styles.TabBarActiveTextColor : Styles.TabBarInactiveTextColor)).ToCairoColor ();
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayout (ctx, la.GetLine (0).Layout);
				}
			}
            la.Dispose ();
		}
Пример #41
0
		void DrawErrorAnimation (Cairo.Context context, StatusArea.RenderArg arg)
		{
			const int surfaceWidth = 2000;
			double opacity;
			int progress;

			if (arg.ErrorAnimationProgress < .5f) {
				progress = (int) (arg.ErrorAnimationProgress * arg.Allocation.Width * 2.4);
				opacity = 1.0d;
			} else {
				progress = (int) (arg.ErrorAnimationProgress * arg.Allocation.Width * 2.4);
				opacity = 1.0d - (arg.ErrorAnimationProgress - .5d) * 2;
			}

			LayoutRoundedRectangle (context, arg.Allocation);

			context.Clip ();
			context.CachedDraw (surface: ref errorSurface,
			                    position: new Gdk.Point (arg.Allocation.X - surfaceWidth + progress, arg.Allocation.Y),
			                    size: new Gdk.Size (surfaceWidth, arg.Allocation.Height),
			                    opacity: (float)opacity,
			                    draw: (c, o) => {
				// The smaller the pixel range of our gradient the less error there will be in it.
				using (var lg = new LinearGradient (surfaceWidth - 250, 0, surfaceWidth, 0)) {
					lg.AddColorStop (0.00, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.15 * o));
					lg.AddColorStop (0.10, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.15 * o));
					lg.AddColorStop (0.88, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.30 * o));
					lg.AddColorStop (1.00, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.00 * o));

					c.Pattern = lg;
					c.Paint ();
				}
			});
			context.ResetClip ();
		}
Пример #42
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			using (var cr = Gdk.CairoHelper.Create (evnt.Window)) {
				cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				using (LinearGradient gr = new LinearGradient (0, 0, 0, Allocation.Height)) {
					gr.AddColorStop (0, BackgroundGradientStart);
					gr.AddColorStop (1, BackgroundGradientEnd);
					cr.Pattern = gr;
				}
				cr.Fill ();

				cr.MoveTo (0.5, 0.5);
				cr.Line (0.5, 0.5, Allocation.Width - 1, 0.5);
				cr.Color = new Cairo.Color (1,1,1);
				cr.LineWidth = 1;
				cr.Stroke ();

				for (int i = tabs.Count; i --> 0;) {
					if (i == ActiveTab)
						continue;
					var tab = tabs[i];
					var bounds = GetBounds (tab);
					tab.HoverPosition = tab == hoverTab ? new Cairo.PointD (mx - bounds.X, my) : new Cairo.PointD (-1, -1);
					tab.Draw (cr, bounds);
				}
				
				tabs[ActiveTab].Draw (cr, GetBounds (tabs[ActiveTab]));
			}
			return base.OnExposeEvent (evnt);
		}
Пример #43
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			using (var context = Gdk.CairoHelper.Create (evnt.Window)) {
				context.Rectangle (
					evnt.Area.X,
					evnt.Area.Y,
					evnt.Area.Width,
					evnt.Area.Height
				);
				context.Clip ();
				context.LineWidth = 1;
				if (Background != null && Background.Width > 0) {
					for (int x=0; x < Allocation.Width; x += Background.Width) {
						Background.Show (context, x, -TitleBarHeight);
					}
				} else {
					context.Rectangle (0, 0, Allocation.Width, Allocation.Height);
					using (var lg = new LinearGradient (0, 0, 0, Allocation.Height)) {
						lg.AddColorStop (0, (HslColor)Style.Light (StateType.Normal));
						lg.AddColorStop (1, (HslColor)Style.Mid (StateType.Normal));
						context.SetSource (lg);
					}
					context.Fill ();

				}
				context.MoveTo (0, Allocation.Height - 0.5);
				context.RelLineTo (Allocation.Width, 0);
				context.SetSourceColor (Styles.ToolbarBottomBorderColor);
				context.Stroke ();

				context.MoveTo (0, Allocation.Height - 1.5);
				context.RelLineTo (Allocation.Width, 0);
				context.SetSourceColor (Styles.ToolbarBottomGlowColor);
				context.Stroke ();

			}
			return base.OnExposeEvent (evnt);
		}
Пример #44
0
        public PreferencesDialog()
        {
            this.Build();

            notebook1.ShowTabs   = false;
            notebook1.ShowBorder = false;

            ChangeTab(0);

            storeMovieFolders = new NodeStore(typeof(StringNode));
            storeTvFolders    = new NodeStore(typeof(StringNode));

            foreach (string folder in iMetaLibrary.Settings.MovieFolders)
            {
                storeMovieFolders.AddNode(new StringNode()
                {
                    Value = folder
                });
            }
            nvMovieFolders.NodeStore = storeMovieFolders;
            nvMovieFolders.AppendColumn("Folder", new Gtk.CellRendererText(), "text", 0);

            foreach (string folder in iMetaLibrary.Settings.TvFolders)
            {
                storeTvFolders.AddNode(new StringNode()
                {
                    Value = folder
                });
            }
            nvTvFolders.NodeStore = storeTvFolders;
            nvTvFolders.AppendColumn("Folder", new Gtk.CellRendererText(), "text", 0);


            btnMovieFolderAdd.Clicked += delegate {
                AddFolder(storeMovieFolders);
            };
            btnTvFolderAdd.Clicked += delegate {
                AddFolder(storeTvFolders);
            };
            btnMovieFolderRemove.Clicked += delegate {
                RemoveFolder(nvMovieFolders, storeMovieFolders);
            };
            btnTvFolderRemove.Clicked += delegate {
                RemoveFolder(nvTvFolders, storeTvFolders);
            };
            eventTabGeneral.ButtonPressEvent += delegate {
                ChangeTab(0);
            };
            eventTabMovies.ButtonPressEvent += delegate {
                ChangeTab(1);
            };
            eventTabTvShows.ButtonPressEvent += delegate {
                ChangeTab(2);
            };
            eventTabAdvanced.ButtonPressEvent += delegate {
                ChangeTab(3);
            };
            eventTabMovies.ExposeEvent += delegate {
                using (Cairo.Context ctx = Gdk.CairoHelper.Create(eventTabMovies.GdkWindow)) {
                    //ctx.SetSourceRGB(0.2, 0.23, 0.9);
                    //ctx.Rectangle(0, 0, 200, 200);
                    //ctx.Fill();

                    /*
                     * Cairo.Gradient pat = new Cairo.LinearGradient (0, 0, 100, 100);
                     * pat.AddColorStop (0, new Cairo.Color (0,0,0));
                     * pat.AddColorStop (1, new Cairo.Color (1,1,1));
                     * ctx.Pattern = pat;
                     */

                    // Shape
                    ctx.MoveTo(new PointD(0, 0));
                    ctx.MoveTo(new PointD(200, 0));
                    ctx.MoveTo(new PointD(200, 200));
                    ctx.MoveTo(new PointD(0, 0));

                    ctx.ClosePath();
                    // Save the state to restore it later. That will NOT save the path
                    ctx.Save();
                    Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
                    pat.AddColorStop(0, new Cairo.Color(0, 0, 0, 1));
                    pat.AddColorStop(1, new Cairo.Color(1, 0, 0, 1));
                    ctx.Pattern = pat;

                    // Fill the path with pattern
                    ctx.FillPreserve();

                    // We "undo" the pattern setting here
                    ctx.Restore();

                    // Color for the stroke
                    ctx.Color = new Color(0, 0, 0);

                    ctx.LineWidth = 3;
                    ctx.Stroke();
                }
            };


            fcbCachePath.SetUri(iMetaLibrary.Settings.CachePath);

            storeVideoExtensions = new ListStore(typeof(string));
            List <string> extensions = new List <string> (iMetaLibrary.Settings.VideoExtensions);

            extensions.Sort();
            foreach (string extension in extensions)
            {
                storeVideoExtensions.AppendValues(extension);
            }
            nvVideoExtensions.Model = storeVideoExtensions;

            nvVideoExtensions.AppendColumn("Extension", new CellRendererText(), "text", 0);

            txtTvRegex.Text = iMetaLibrary.Settings.TvRegularExpression;
            txtTvEpisodeNumbersRegex.Text = iMetaLibrary.Settings.TvEpisodeExpression;
            txtTvSeasonRegex.Text         = iMetaLibrary.Settings.TvSeasonExpression;
            txtTvShowTitleRegex.Text      = iMetaLibrary.Settings.TvShowTitleExpression;

            numMaxFanArt.Value = iMetaLibrary.Settings.MaxFanArt;
            chkAddYearToMovieFolders.Active            = iMetaLibrary.Settings.AddYearToMovieFolders;
            chkAttempToDownloadTrailers.Active         = iMetaLibrary.Settings.AttemptTrailerDownload;
            chkAttemptToDownloadMissingTrailers.Active = iMetaLibrary.Settings.AttemptTrailerDownloadMissingTrailers;
            chkUseFolderNameForMovieLookup.Active      = iMetaLibrary.Settings.UseFolderNameForMovieLookup;

            chkAutoRenameEpisodes.Active = iMetaLibrary.Settings.AutoRenameEpisodes;

            txtFanArtResolution.Text           = iMetaLibrary.Settings.FanArtWidth + "x" + iMetaLibrary.Settings.FanArtHeight;
            txtPosterResolution.Text           = iMetaLibrary.Settings.PosterWidth + "x" + iMetaLibrary.Settings.PosterHeight;
            txtBannerResolution.Text           = iMetaLibrary.Settings.BannerWidth + "x" + iMetaLibrary.Settings.BannerHeight;
            txtImageQuality.Text               = iMetaLibrary.Settings.ImageQuality.ToString();
            chkUseBannersForFolderImage.Active = iMetaLibrary.Settings.UseBannersForTvFolders;

            buttonOk.Clicked += HandleButtonOkClicked;

            /*
             * buttonCancel.Clicked += delegate
             * {
             *      this.DialogResult = Gtk.ResponseType.Cancel;
             *      this.Destroy();
             * };*/

            btnAddVideoExtension.Clicked    += delegate {
            };
            btnRemoveVideoExtension.Clicked += delegate {
            };
        }