Example #1
0
 public static void DrawPixbuf(Cairo.Context cr, Pixbuf pixbuf)
 {
     cr.SetSourceRGBA(0.0, 0.0, 0.0, 1.0);
     cr.Operator = Cairo.Operator.DestIn;
     Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 0, 0);
     cr.Paint ();
     cr.Operator = Cairo.Operator.Over;
     cr.Paint ();
 }
Example #2
0
        public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "")
        {
            float widthRatio = 1f;
            float heightRatio = 1f;

            if (Scaled){
                widthRatio = (float)rect.Width / Dimensions.Width;
                heightRatio = (float)rect.Height / Dimensions.Height;
            }

            if (KeepProportions) {
                if (widthRatio < heightRatio)
                    heightRatio = widthRatio;
                else
                    widthRatio = heightRatio;
            }

            gr.Save ();

            gr.Translate (rect.Left,rect.Top);
            gr.Scale (widthRatio, heightRatio);
            gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);

            using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32,
                Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) {
                gr.SetSourceSurface (imgSurf, 0,0);
                gr.Paint ();
            }
            gr.Restore ();
        }
Example #3
0
 protected override bool OnExposed(Cairo.Context cr, Cairo.Rectangle area)
 {
     if(Pixbuf == null)
         return false;
     int w = Pixbuf.Width;
     int h = Pixbuf.Height;
     cr.Scale(Allocation.Width / w, Allocation.Height / h);
     Gdk.CairoHelper.SetSourcePixbuf(cr, Pixbuf, 0.0, 0.0);
     cr.Paint();
     return true;
 }
		void IIconBarMarker.DrawIcon (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
		{
			cr.Save ();
			cr.Translate (
				x + 0.5  + (width - cache.errorPixbuf.Width) / 2,
				y + 0.5 + (height - cache.errorPixbuf.Height) / 2
			);
			Gdk.CairoHelper.SetSourcePixbuf (
				cr,
				errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
			cr.Paint ();
			cr.Restore ();

		}
		protected override void OnRender (Cairo.Context context)
		{
			if (surfaceCache == null) {
				// will improve with CGLayer surfaces
				surfaceCache = new SurfaceWrapper (context, pbuf);
			}
			int x = (int)((Width - pbuf.Width) * XAlign);
			int y = (int)((Height - pbuf.Height) * YAlign);
			context.SetSourceSurface (surfaceCache.Surface, x, y);
			double opacity = Opacity;
			if (opacity == 1)
				context.Paint ();
			else
				context.PaintWithAlpha (Opacity);

			base.OnRender (context);
		}
Example #6
0
        private static void Desktop()
        {
            var Data    = new byte[Compositor.PACKET_SIZE];
            var Request = (GuiRequest *)Data.GetDataOffset();

            Request->ClientID = 0;
            Request->Type     = RequestType.NewWindow;

            var Window = (NewWindow *)Request;

            Window->X      = 0;
            Window->Y      = 0;
            Window->Width  = VBE.Xres;
            Window->Height = VBE.Yres;

            Compositor.Server.Write(Data);
            Client.Read(Data);

            string HashCode = new string(Window->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);

            DesktopID = Window->WindowID;

            uint surface = Cairo.ImageSurfaceCreateForData(Window->Width * 4, Window->Height, Window->Width, ColorFormat.ARGB32, aBuffer);
            uint context = Cairo.Create(surface);

            uint wallpaper = Cairo.ImageSurfaceFromPng(Marshal.C_String("disk0/wallpaper.png"));

            Cairo.SetSourceSurface(0, 0, wallpaper, context);
            Cairo.Paint(context);
            Cairo.SurfaceDestroy(wallpaper);

            Request->Type = RequestType.Redraw;
            var Redraw = (Redraw *)Request;

            Redraw->WindowID = DesktopID;
            Redraw->X        = 0;
            Redraw->Y        = 0;
            Redraw->Width    = VBE.Xres;
            Redraw->Height   = VBE.Yres;
            Compositor.Server.Write(Data);

            DesktopSurface = surface;
            DesktopContext = context;
            Heap.Free(Data);
        }
        protected override void RenderCoverArt (Cairo.Context cr, ImageSurface image)
        {
            if (image == null) {
                return;
            }

            Gdk.Rectangle alloc = RenderAllocation;
            int asr = ArtworkSizeRequest;
            int reflect = (int)(image.Height * 0.2);
            int surface_w = image.Width;
            int surface_h = image.Height + reflect;
            int x = alloc.X + alloc.Width - asr;
            int y = alloc.Y;

            Surface scene = null;
            if (!surfaces.TryGetValue (image, out scene)) {
                scene = CreateScene (cr, image, reflect);
                surfaces.Add (image, scene);
            }

            cr.Rectangle (x, y, asr, alloc.Height);
            cr.Color = BackgroundColor;
            cr.Fill ();

            x += (asr - surface_w) / 2;
            y += surface_h > asr ? 0 : (asr - surface_h) / 2;

            cr.SetSource (scene, x, y);
            cr.Paint ();
        }
		protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context context)
		{
			context.LineWidth = 1;
			var alloc = ChildAllocation;
			var adjustedMarginSize = alloc.X - Allocation.X  + headerMarginSize;

			var r = results.Where (res => res.Item2.ItemCount > 0).ToArray ();
			if (r.Any ()) {
				context.SetSourceColor (lightSearchBackground);
				context.Rectangle (Allocation.X, Allocation.Y, adjustedMarginSize, Allocation.Height);
				context.Fill ();

				context.SetSourceColor (darkSearchBackground);
				context.Rectangle (Allocation.X + adjustedMarginSize, Allocation.Y, Allocation.Width - adjustedMarginSize, Allocation.Height);
				context.Fill ();
				context.MoveTo (0.5 + Allocation.X + adjustedMarginSize, 0);
				context.LineTo (0.5 + Allocation.X + adjustedMarginSize, Allocation.Height);
				context.SetSourceColor (separatorLine);
				context.Stroke ();
			} else {
				context.SetSourceRGB (1, 1, 1);
				context.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
				context.Fill ();
			}

			double y = alloc.Y + yMargin;
			int w, h;
			if (topItem != null) {
				headerLayout.SetText (GettextCatalog.GetString ("Top Result"));
				headerLayout.GetPixelSize (out w, out h);
				context.MoveTo (alloc.Left + headerMarginSize - w - xMargin, y);
				context.SetSourceColor (headerColor);
				Pango.CairoHelper.ShowLayout (context, headerLayout);

				var category = topItem.Category;
				var dataSrc = topItem.DataSource;
				var i = topItem.Item;

				double x = alloc.X + xMargin + headerMarginSize;
				context.SetSourceRGB (0, 0, 0);
				layout.SetMarkup (GetRowMarkup (dataSrc, i));
				layout.GetPixelSize (out w, out h);
				if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
					context.SetSourceColor (selectionBackgroundColor);
					context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
					context.Fill ();
					context.SetSourceRGB (1, 1, 1);
				}

				var px = dataSrc.GetIcon (i);
				if (px != null) {
					Gdk.CairoHelper.SetSourcePixbuf (context, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2);
					context.Paint ();
					x += px.Width + iconTextSpacing + marginIconSpacing;
				}

				context.MoveTo (x, y);
				context.SetSourceRGB (0, 0, 0);
				Pango.CairoHelper.ShowLayout (context, layout);

				y += h + itemSeparatorHeight;

			}

			foreach (var result in r) {
				var category = result.Item1;
				var dataSrc = result.Item2;
				if (dataSrc.ItemCount == 0)
					continue;
				if (dataSrc.ItemCount == 1 && topItem != null && topItem.DataSource == dataSrc)
					continue;
				headerLayout.SetText (category.Name);
				headerLayout.GetPixelSize (out w, out h);

				if (y + h > Allocation.Height)
					break;

				context.MoveTo (alloc.X + headerMarginSize - w - xMargin, y);
				context.SetSourceColor (headerColor);
				Pango.CairoHelper.ShowLayout (context, headerLayout);

				layout.Width = Pango.Units.FromPixels (Allocation.Width - adjustedMarginSize - 35);

				for (int i = 0; i < maxItems && i < dataSrc.ItemCount; i++) {
					if (topItem != null && topItem.Category == category && topItem.Item == i)
						continue;
					double x = alloc.X + xMargin + headerMarginSize;
					context.SetSourceRGB (0, 0, 0);
					layout.SetMarkup (GetRowMarkup (dataSrc, i));
					layout.GetPixelSize (out w, out h);
					if (y + h + itemSeparatorHeight > Allocation.Height)
						break;
					if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
						context.SetSourceColor (selectionBackgroundColor);
						context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
						context.Fill ();
						context.SetSourceRGB (1, 1, 1);
					}

					var px = dataSrc.GetIcon (i);
					if (px != null) {
						Gdk.CairoHelper.SetSourcePixbuf (context, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2);
						context.Paint ();
						x += px.Width + iconTextSpacing + marginIconSpacing;
					}

					context.MoveTo (x, y);
					context.SetSourceRGB (0, 0, 0);
					Pango.CairoHelper.ShowLayout (context, layout);

					y += h + itemSeparatorHeight;
				}
				if (result != r.Last ()) {
					y += categorySeparatorHeight;
				}
			}
			if (y == alloc.Y + yMargin) {
				context.SetSourceRGB (0, 0, 0);
				layout.SetMarkup (isInSearch ? GettextCatalog.GetString ("Searching...") : GettextCatalog.GetString ("No matches"));
				context.MoveTo (alloc.X + xMargin, y);
				Pango.CairoHelper.ShowLayout (context, layout);
			}
		}
Example #9
0
	protected override bool OnDrawn (Cairo.Context cr)
	{
		Gdk.Rectangle titleArea = TitleArea;

		Gdk.CairoHelper.SetSourcePixbuf (cr, Icon, 0, 0);
		cr.Paint ();
		
		int layout_x = icon.Width + 1;
		titleArea.Width -= icon.Width - 1;
		
		int layoutWidth, layoutHeight;
		Layout.GetPixelSize (out layoutWidth, out layoutHeight);
		
		int layout_y = (titleArea.Height - layoutHeight) / 2;
		
		StyleContext.RenderLayout (cr, layout_x, layout_y, Layout);
	
		return base.OnDrawn (cr);
	}
Example #10
0
 /// <summary>
 /// Draws the Boards picture. 
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="path">Path.</param>
 /// <param name="maxWidth">Max width.</param>
 public static void SetMCUSurface(Cairo.Context context, string path, int maxWidth = int.MaxValue)
 {
     try {
         var surf =	GetImage (path);
         MCUImageXZero = ShiftX - surf.Width / 2;
         MCUImageYZero = ShiftY - surf.Height / 2;
         context.SetSource (
             surf,
             MCUImageXZero,
             MCUImageYZero
         );
         context.Paint ();
         surf.Dispose ();
     } catch (Exception ex) {
         Console.Error.WriteLine (ex);
     }
 }
Example #11
0
 void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
 {
     ctx.Save ();
     ctx.Translate (x, y);
     ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
     Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);
     if (idesc.Alpha == 1)
         ctx.Paint ();
     else
         ctx.PaintWithAlpha (idesc.Alpha);
     ctx.Restore ();
 }
		/// <summary>
		/// Paints the current condition.
		/// </summary>
		/// <param name="cr">
		/// A <see cref="Cairo.Context"/> to do the painting.
		/// </param>
		void DrawVertCurrentCondition (Cairo.Context cr)
		{
			int cellSize = Allocation.Height / 6;
			int iconSize = cellSize - 4;
			
			int yPos = 0;
			int topYPos = cellSize / 3;
			int botYPos = 2 * topYPos;
			
			// draw the temp
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("temp.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
				cr.Paint ();
			}
			yPos += cellSize;
			
			if (!WeatherController.Weather.ShowFeelsLike)
				DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit);
			else
				DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit + " (" + WeatherController.Weather.FeelsLike + AbstractWeatherSource.TempUnit + ")");
			

			// draw humidity
			string humidity = String.Format (Catalog.GetString ("{0} humidity"), WeatherController.Weather.Humidity);
			DrawVertConditionText (cr, yPos + botYPos, humidity);
			yPos += cellSize;
			

			// draw the wind
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("wind.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
				cr.Paint ();
			}
			yPos += iconSize;
			
			DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Wind + " " + AbstractWeatherSource.WindUnit);
			DrawVertConditionText (cr, yPos + botYPos, WeatherController.Weather.WindDirection);
			yPos += cellSize;

			
			// draw sun
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("sun.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
				cr.Paint ();
			}
			yPos += iconSize;
			
			DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.SunRise.ToShortTimeString ());
			DrawVertConditionText (cr, yPos + botYPos, WeatherController.Weather.SunSet.ToShortTimeString ());
		}
Example #13
0
 protected void paintBackground(Cairo.Context context, Field[,] fields)
 {
     context.SetSourceRGB (0.8, 0.8, 0.8);
     context.Paint ();
     for (int i = 0; i < width; i++) {
         for (int j = 0; j < height; j++) {
             paintSquare (context, i * fieldSize, j * fieldSize, fields [i, j].Full);
         }
     }
     paintGrid (context);
     context.Paint ();
 }
		protected void DrawIndicator (Cairo.Context cr, Severity severity)
		{
			cr.Save ();
			var pixbuf = GetIndicatorIcon (severity);
			cr.Translate (
				1 + (Allocation.Width - pixbuf.Width) / 2,
				1
			);

			CairoHelper.SetSourcePixbuf (
				cr,
				pixbuf,
				0, 0
			);
			cr.Paint ();
			cr.Restore ();
		}
Example #15
0
        protected void DrawScaledSurfaceAt(Cairo.Context gr, ImageSurface image, double x, double y, double height, double width)
        {
            //calculate proportional scaling
            var img_height = image.Height;
            var img_width = image.Width;

            var width_ratio = (width) / (img_width);
            var height_ratio = (height) / (img_height);
            var scale_xy = Math.Min(height_ratio, width_ratio);
            //scale image and add it
            gr.Save();
            gr.Scale(scale_xy, scale_xy);
            gr.Translate(x, y);
            gr.SetSource(image,(int)x, (int)y);

            gr.Paint();
            gr.Restore();
        }
Example #16
0
        protected override bool OnExposed(Cairo.Context cr, Cairo.Rectangle area)
        {
            Rectangle rectT = new Rectangle(0.0, 0.0, Allocation.Width, EdgeSize);
            Rectangle rectB = new Rectangle(0.0, Allocation.Height - EdgeSize, Allocation.Width, EdgeSize);
            Rectangle rectL = new Rectangle(0.0, 0.0, EdgeSize, Allocation.Height);
            Rectangle rectR = new Rectangle(Allocation.Width - EdgeSize, 0.0, EdgeSize, Allocation.Height);

            Rectangle areaT = Widget.Intersect(area, rectT);
            Rectangle areaB = Widget.Intersect(area, rectB);
            Rectangle areaL = Widget.Intersect(area, rectL);
            Rectangle areaR = Widget.Intersect(area, rectR);

            if(areaT.Width != 0.0 && areaT.Height != 0.0)
            {
                LinearGradient grT = new LinearGradient(0.0, 0.0, 0.0, EdgeSize);
                grT.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
                grT.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
                cr.Save();
                cr.Pattern = grT;
                //cr.Rectangle(areaT);
                cr.NewPath();
                cr.MoveTo(0.0, 0.0);
                cr.LineTo(Allocation.Width, 0.0);
                cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
                cr.LineTo(EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaB.Width != 0.0 && areaB.Height != 0.0)
            {
                LinearGradient grB = new LinearGradient(0.0, Allocation.Height, 0.0, Allocation.Height - EdgeSize);
                grB.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
                grB.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
                cr.Save();
                cr.Pattern = grB;
                //cr.Rectangle(areaB);
                cr.MoveTo(0.0, Allocation.Height);
                cr.LineTo(Allocation.Width, Allocation.Height);
                cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaL.Width != 0.0 && areaL.Height != 0.0)
            {
                LinearGradient grL = new LinearGradient(0.0, 0.0, EdgeSize, 0.0);
                grL.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
                grL.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
                cr.Save();
                cr.Pattern = grL;
                //cr.Rectangle(areaL);
                cr.MoveTo(0.0, 0.0);
                cr.LineTo(0.0, Allocation.Height);
                cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaR.Width != 0.0 && areaR.Height != 0.0)
            {
                LinearGradient grR = new LinearGradient(Allocation.Width, 0.0, Allocation.Width - EdgeSize, 0.0);
                grR.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
                grR.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
                cr.Save();
                cr.Pattern = grR;
                //cr.Rectangle(areaR);
                cr.MoveTo(Allocation.Width, 0.0);
                cr.LineTo(Allocation.Width, Allocation.Height);
                cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }
            return true;
        }
		public void DrawIcon (TextEditor editor, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
		{
			Gdk.CairoHelper.SetSourcePixbuf (
				cr,
				errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf,
				(int)(x + (width - cache.errorPixbuf.Width) / 2),
				(int)(y + (height - cache.errorPixbuf.Height) / 2));
			cr.Paint ();
		}
		/// TODO: CairoExtensions.CachedDraw seems not to work correctly for me.
		public static void CachedDraw (Cairo.Context self, ref SurfaceWrapper surface, Gdk.Rectangle region, object parameters = null, float opacity = 1.0f, Action<Cairo.Context, float> draw = null, double? forceScale = null)
		{
			double displayScale = forceScale.HasValue ? forceScale.Value : QuartzSurface.GetRetinaScale (self);
			int targetWidth = (int) (region.Width * displayScale);
			int targetHeight = (int) (region.Height * displayScale);

			bool redraw = false;
			if (surface == null || surface.Width != targetWidth || surface.Height != targetHeight) {
				if (surface != null)
					surface.Dispose ();
				surface = new SurfaceWrapper (self, targetWidth, targetHeight);
				redraw = true;
			} else if ((surface.Data == null && parameters != null) || (surface.Data != null && !surface.Data.Equals (parameters))) {
				redraw = true;
			}


			if (redraw) {
				surface.Data = parameters;
				using (var context = new Cairo.Context (surface.Surface)) {
					draw(context, 1.0f);
				}
			}

			self.SetSourceSurface (surface.Surface, 0, 0);
			self.Paint ();
		}
Example #19
0
        private static unsafe void Renderer()
        {
            int tmp_mouse_X, tmp_mouse_Y;
            int old_mouse_X = -1, old_mouse_Y = -1;

            bool update;

            while (true)
            {
                tmp_mouse_X = Mouse_X;
                tmp_mouse_Y = Mouse_Y;
                update      = false;

                Cairo.Save(MainContext);
                Cairo.Save(VideoContext);

                if (tmp_mouse_X != old_mouse_X || tmp_mouse_Y != old_mouse_Y)
                {
                    update = true;
                    Cairo.Rectangle(32, 32, old_mouse_Y, old_mouse_X, MainContext);
                    Cairo.Rectangle(32, 32, old_mouse_Y, old_mouse_X, VideoContext);
                    Cairo.Rectangle(32, 32, tmp_mouse_Y, tmp_mouse_X, VideoContext);
                }

                old_mouse_X = tmp_mouse_X;
                old_mouse_Y = tmp_mouse_Y;

                var queue = RedrawRects;
                Monitor.AcquireLock(ref RedrawRectsLock);
                while (queue.Count > 0)
                {
                    var rect = (Rect *)queue.Dequeue();

                    Cairo.Rectangle(rect->Height, rect->Width, rect->Y, rect->X, MainContext);
                    Cairo.Rectangle(rect->Height, rect->Width, rect->Y, rect->X, VideoContext);

                    Libc.free((uint)rect);

                    update = true;
                }
                Monitor.ReleaseLock(ref RedrawRectsLock);

                if (update)
                {
                    Cairo.Clip(MainContext);
                    var list = Stacking;
                    Monitor.AcquireLock(ref StackingLock);
                    int count = list.Count;
                    for (int index = 0; index < count; index++)
                    {
                        var win = list[index];
                        Cairo.Save(MainContext);
                        Cairo.Translate(win.Y, win.X, MainContext);
                        Cairo.SetSourceSurface(0, 0, win.Surface, MainContext);
                        Cairo.Paint(MainContext);
                        Cairo.Restore(MainContext);
                    }
                    Monitor.ReleaseLock(ref StackingLock);
                }

                if (update)
                {
                    Cairo.Clip(VideoContext);

                    Cairo.Translate(0, 0, VideoContext);
                    Cairo.SetOperator(Operator.Source, VideoContext);
                    Cairo.SetSourceSurface(0, 0, MainSurface, VideoContext);
                    Cairo.Paint(VideoContext);

                    Cairo.Translate(old_mouse_Y, old_mouse_X, VideoContext);
                    Cairo.SetOperator(Operator.Over, VideoContext);
                    Cairo.SetSourceSurface(0, 0, MouseSurface, VideoContext);
                    Cairo.Paint(VideoContext);
                }

                Cairo.Restore(MainContext);
                Cairo.Restore(VideoContext);

                Task.Switch();
            }
        }
Example #20
0
        void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
        {
            ctx.Save ();
            ctx.Translate (x, y);
            ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
            Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);

            // Fixes blur issue when rendering on an image surface
            ((Cairo.SurfacePattern)ctx.GetSource ()).Filter = Cairo.Filter.Fast;

            if (idesc.Alpha >= 1)
                ctx.Paint ();
            else
                ctx.PaintWithAlpha (idesc.Alpha);
            ctx.Restore ();
        }
Example #21
0
		void DrawPixbuf (Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
			Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);

			#pragma warning disable 618
			using (var pattern = ctx.Source as Cairo.SurfacePattern) {
				if (pattern != null) {
					if (idesc.Size.Width > img.Width || idesc.Size.Height > img.Height) {
						// Fixes blur issue when rendering on an image surface
						pattern.Filter = Cairo.Filter.Fast;
					} else
						pattern.Filter = Cairo.Filter.Good;
				}
			}
			#pragma warning restore 618

			if (idesc.Alpha >= 1)
				ctx.Paint ();
			else
				ctx.PaintWithAlpha (idesc.Alpha);
			ctx.Restore ();
		}
		public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			cr.Save ();
			cr.Translate (
				metrics.X + 0.5 + (metrics.Width - 2 - cache.errorPixbuf.Width) / 2,
				metrics.Y + 0.5 + (metrics.Height - cache.errorPixbuf.Height) / 2
				);
			Gdk.CairoHelper.SetSourcePixbuf (
				cr,
				errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
			cr.Paint ();
			cr.Restore ();

		}
Example #23
0
 protected virtual void ShapeSurface (Cairo.Context cr, Cairo.Color color)
 {
     cr.Operator = Cairo.Operator.Source;
     Cairo.Pattern pattern = new Cairo.SolidPattern (color, false);
     cr.Source = pattern;
     pattern.Destroy ();
     cr.Paint ();
 }
		/// <summary>
		/// Paints the current condition.
		/// </summary>
		/// <param name="cr">
		/// A <see cref="Cairo.Context"/> to do the painting.
		/// </param>
		void DrawCurrentCondition (Cairo.Context cr)
		{
			int ySpacing = 2;
			int iconSize = Allocation.Height - 2 * ySpacing;
			int textWidth = iconSize * (WeatherController.Weather.ForecastDays < 6 ? 2 : 3);
			int xSpacing = (int) Math.Max (0, (Allocation.Width - 2 * BUTTON_SIZE - 3 * iconSize - 3 * textWidth) / 7);
			
			int topYPos = Allocation.Height / 3;
			int botYPos = 2 * topYPos;
			
			int xPos = BUTTON_SIZE + (int) (1.5 * xSpacing);
			
			// draw the temp
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("temp.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xPos, ySpacing);
				cr.Paint ();
			}
			xPos += iconSize;
			
			if (!WeatherController.Weather.ShowFeelsLike)
				DrawConditionText (cr, xPos, textWidth, topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit);
			else
				DrawConditionText (cr, xPos, textWidth, topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit + " (" + WeatherController.Weather.FeelsLike + AbstractWeatherSource.TempUnit + ")");
			

			// draw humidity
			string humidity = String.Format (Catalog.GetString ("{0} humidity"), WeatherController.Weather.Humidity);
			DrawConditionText (cr, xPos, textWidth, botYPos, humidity);
			
			xPos += textWidth + 2 * xSpacing;
			

			// draw the wind
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("wind.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xPos, ySpacing);
				cr.Paint ();
			}
			xPos += iconSize;
			
			DrawConditionText (cr, xPos, textWidth, topYPos, WeatherController.Weather.Wind + " " + AbstractWeatherSource.WindUnit);
			DrawConditionText (cr, xPos, textWidth, botYPos, WeatherController.Weather.WindDirection);
			
			xPos += textWidth + 2 * xSpacing;

			
			// draw sun
			using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("sun.svg").Path, iconSize)) {
				Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xPos, ySpacing);
				cr.Paint ();
			}
			xPos += iconSize;
			
			DrawConditionText (cr, xPos, textWidth, topYPos, WeatherController.Weather.SunRise.ToShortTimeString ());
			DrawConditionText (cr, xPos, textWidth, botYPos, WeatherController.Weather.SunSet.ToShortTimeString ());
		}
		public void Draw (TextEditor editor, Cairo.Context g, int lineNr, Cairo.Rectangle lineArea)
		{
			EnsureLayoutCreated (editor);
			int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
			int errorNumber = lineNr - lineNumber;
			if (!IsCurrentErrorTextFitting ())
				errorNumber--;
			double x = editor.TextViewMargin.XOffset;
			double y = lineArea.Y;
			double right = editor.Allocation.Width;
			int errorCounterWidth = GetErrorCountBounds ().Item1;
//			int eh = GetErrorCountBounds ().Item2;
			
			double x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			if (errors.Count == 1)
				x2 = editor.TextViewMargin.XOffset;
//			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset  + lineSegment.EditableLength) : false;
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			bool isCaretInLine = lineSegment.Offset <= editor.Caret.Offset && editor.Caret.Offset <= lineSegment.EndOffsetIncludingDelimiter;
			bool highlighted = active == 0 && isCaretInLine;
			bool selected = false;
			var layout = layouts [errorNumber];
			x2 = right - LayoutWidth - border - (ShowIconsInBubble ? cache.errorPixbuf.Width : 0);
			
			x2 -= errorCounterWidth;
			x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			
			g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
			g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
			g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
			g.LineTo (new Cairo.PointD (right, y));
			g.ClosePath ();
			g.Color = TagColor.Color;// GetLineColorTop (highlighted, selected);
			g.Fill ();
			
			g.Color = TagColor.BorderColor; //GetLineColorBottom (highlighted, selected);
			g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
			g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
			if (errorNumber == errors.Count - 1)
				g.LineTo (new Cairo.PointD (lineArea.X + lineArea.Width, y + editor.LineHeight));
			g.Stroke ();
			
			if (editor.Options.ShowRuler) {
				double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
				if (divider >= x2) {
					g.MoveTo (new Cairo.PointD (divider + 0.5, y));
					g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
					g.Color = TagColor.BorderColor;
					g.Stroke ();
				}
			}
			g.Save ();
			g.Translate (x2 + (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2);
			g.Color = TextColor.Color;
			g.ShowLayout (layout.Layout);
			g.Restore ();
			
			if (ShowIconsInBubble) {
				var pixbuf = errors [errorNumber].IsError ? cache.errorPixbuf: cache.warningPixbuf;
				Gdk.CairoHelper.SetSourcePixbuf (g, pixbuf, x2, y + (editor.LineHeight - cache.errorPixbuf.Height) / 2);
				g.Paint ();
			}
		}
Example #26
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;
					CairoHelper.SetSourcePixbuf (ctx, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + (rh - img.Height) / 2);
					ctx.Paint ();

					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 ();
					}
				}
			}
		}
Example #27
0
 protected void DrawSurfaceAt(Cairo.Context gr, ImageSurface surface, double x, double y)
 {
     gr.Save();
     gr.SetSource(surface, this._x + x, this._y + y);
     gr.Paint();
     gr.Restore();
 }
 public void Render(Cairo.Context context, int x, int y, int width, int height)
 {
     // scale and draw moodbar
     double scaled_width = (width) / 1000.0;
     context.Save ();
     context.Scale (scaled_width, height * 2);
     context.SetSourceSurface (Surface, (int)(x / scaled_width), y);
     context.Paint ();
     context.Restore ();
 }
Example #29
0
			protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g)
			{
				Theme.BorderColor = marker.TooltipColor.Color;
				g.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				g.SetSourceColor (marker.TooltipColor.Color);
				g.Fill ();

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

					var showBulletedList = marker.Errors.Count > 1;
					foreach (var msg in marker.Errors) {

						var icon = msg.IsError ? cache.errorPixbuf : cache.warningPixbuf;

						if (!showBulletedList)
							drawingLayout.Width = maxTextWidth;
						drawingLayout.SetText (GetFirstLine (msg));
						int w;
						int h;
						drawingLayout.GetPixelSize (out w, out h);

						if (showBulletedList) {
							g.Save ();

							g.Translate (
								textBorder,
								y + verticalTextSpace / 2
							);
							Gdk.CairoHelper.SetSourcePixbuf (g, icon, 0, 0);
							g.Paint ();
							g.Restore ();
						}

						g.Save ();

						g.Translate (showBulletedList ? textBorder + iconTextSpacing + icon.Width + 1: textBorder, y + verticalTextSpace / 2 + 1);

						g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.1));
						g.ShowLayout (drawingLayout);

						g.Translate (-1, -1);

						g.SetSourceColor (marker.TagColor.SecondColor);
						g.ShowLayout (drawingLayout);

						g.Restore ();


						y += h + verticalTextSpace;
					}
				}

			}
Example #30
0
        protected override void OnRender(Cairo.Context cr, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, CellRendererState flags)
        {
            if (source == null || source is SourceManager.GroupSource) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateFlags state = RendererStateToWidgetState (widget, flags);

            RenderSelection (cr, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            int img_padding = 6;
            int expander_icon_spacing = 3;
            int x = cell_area.X;
            bool np_etc = (source.Order + Depth * 100) < 40;
            if (!np_etc) {
                x += Depth * img_padding + (int)Xpad;
            } else {
                // Don't indent NowPlaying and Play Queue as much
                x += Math.Max (0, (int)Xpad - 2);
            }

            // Draw the expander if the source has children
            double exp_h = (cell_area.Height - 2.0*Ypad) / 2.0;
            double exp_w = exp_h * 1.6;
            int y = Middle (cell_area, (int)exp_h);
            if (view != null && source.Children != null && source.Children.Count > 0) {
                var r = new Gdk.Rectangle (x, y, (int)exp_w, (int)exp_h);
                view.Theme.DrawArrow (cr, r, source.Expanded ? Math.PI/2.0 : 0.0);
            }

            if (!np_etc) {
                x += (int) exp_w;
                x += 2; // a little spacing after the expander
                expander_right_x = x;
            }

            // Draw icon
            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateFlags.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.StyleContext.RenderIconPixbuf (icon_source, (IconSize)(-1));

                dispose_icon = true;
                icon_source.Dispose ();
            }

            if (icon != null) {
                x += expander_icon_spacing;

                cr.Save ();
                Gdk.CairoHelper.SetSourcePixbuf (cr, icon, x, Middle (cell_area, icon.Height));
                cr.Paint ();
                cr.Restore ();

                x += icon.Width;

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            // Setup font info for the title/count, and see if we should show the count
            bool hide_count = source.EnabledCount <= 0 || source.Properties.Get<bool> ("SourceView.HideCount");
            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_count = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            // If we have a count to draw, setup its fonts and see how wide it is to see if we have room
            if (!hide_count) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            // Hide the count if the title has no space
            max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
            if (!hide_count && max_title_layout_width <= 0) {
                hide_count = true;
            }

            // Draw the source Name
            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            x += img_padding;
            widget.StyleContext.RenderLayout (cr, x, Middle (cell_area, title_layout_height), title_layout);

            title_layout.Dispose ();

            // Draw the count
            if (!hide_count) {
                if (view != null) {
                    cr.SetSourceColor (state == StateFlags.Normal || (view != null && state == StateFlags.Prelight)
                        ? view.Theme.TextMidColor
                        : CairoExtensions.GdkRGBAToCairoColor (view.Theme.Widget.StyleContext.GetColor (state)));

                    cr.MoveTo (
                        cell_area.X + cell_area.Width - count_layout_width - 2,
                        cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                    Pango.CairoHelper.ShowLayout (cr, count_layout);
                }

                count_layout.Dispose ();
            }

            fd.Dispose ();
        }
		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 ();
		}
Example #32
0
		private void DrawShape (Cairo.Context g, int width, int height)
		{
			int inner_x = radius + border + inner;
			int cx = Center.X;
			int cy = Center.Y;
			
			g.Operator = Operator.Source;
			g.Source = new SolidPattern (new Cairo.Color (0,0,0,0));
			g.Rectangle (0, 0, width, height);
			g.Paint ();

			g.NewPath ();
			g.Translate (cx, cy);
			g.Rotate (angle);
			
			g.Source = new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6));
			g.Operator = Operator.Over;
			g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
			g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
			g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
			g.Fill ();

			g.Source = new SolidPattern (new Cairo.Color (0, 0, 0, 1.0));
			g.Operator = Operator.DestOut;
			g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
#if true
			g.Fill ();
#else
			g.FillPreserve ();

			g.Operator = Operator.Over;
			RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner);
			rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5)); 
			rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1)); 
			rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
			g.Source = rg;
			g.Fill ();
			rg.Destroy ();
#endif
			g.Operator = Operator.Over;
			g.Matrix = new Matrix ();
			g.Translate (cx, cy);
			if (source != null)
				SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);

			g.Arc (0, 0, radius, 0, 2 * Math.PI);
			g.Fill ();

			if (overlay != null) {
				SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
				g.Arc (0, 0, radius, angle, angle + Math.PI);
				g.ClosePath ();
				g.FillPreserve ();
				g.Source = new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0));
				g.Stroke ();
			}
		}