public override void Draw(Cairo.Context cr) { cr.Save(); cr.Color = new Color(1.0, 1.0, 1.0); cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0); cr.Fill(); cr.Color = new Color(0.0, 0.0, 0.0); cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0); cr.Stroke(); cr.Restore(); }
protected void DrawPaper(Cairo.Context cr, double x, double y, double w, double h) { // make the background white with a line around cr.Rectangle(x+shadowOffset*2,y+shadowOffset*2,w-shadowOffset*2,h-shadowOffset*2); cr.Color = shadowColor; cr.Fill(); GetInnerRegion(ref x,ref y,ref w,ref h); cr.Rectangle(x,y,w,h); cr.Color = new Cairo.Color(0, 0, 0); cr.StrokePreserve(); cr.Color = new Cairo.Color(1, 1, 1); cr.Fill(); }
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 (); }
protected override void ClippedRender (Cairo.Context cr) { Brush brush = Background; if (!brush.IsValid) { return; } double x = Double.IsNaN (brush.Width) ? 0 : (RenderSize.Width - brush.Width) * XAlign; double y = Double.IsNaN (brush.Height) ? 0 : (RenderSize.Height - brush.Height) * YAlign; cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height); cr.ClipPreserve (); if (x != 0 || y != 0) { cr.Translate (x, y); } cr.Antialias = Cairo.Antialias.None; brush.Apply (cr); cr.Fill (); }
static void draw (Cairo.Context gr, int width, int height) { int w, h; ImageSurface image; gr.Scale (width, height); gr.LineWidth = 0.04; gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI); gr.Clip (); gr.NewPath (); image = new ImageSurface("data/e.png"); w = image.Width; h = image.Height; gr.Scale (1.0/w, 1.0/h); image.Show (gr, 0, 0); image.Destroy(); gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI); gr.Clip (); gr.NewPath (); gr.Rectangle (new PointD (0, 0), 1, 1); gr.Fill (); gr.Color = new Color (0, 1, 0, 1); gr.MoveTo ( new PointD (0, 0) ); gr.LineTo ( new PointD (1, 1) ); gr.MoveTo ( new PointD (1, 0) ); gr.LineTo ( new PointD (0, 1) ); gr.Stroke (); }
public static void Fill(Cairo.Context context, int width, int height, Cairo.Color color) { context.NewPath(); context.Color = color; context.Rectangle(0, 0, width, height); context.Fill(); }
public static void Fill(Cairo.Context context, Gtk.Widget widget, Cairo.Color color) { context.NewPath(); context.Color = color; context.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height); context.Fill(); }
protected override bool OnDrawn(Cairo.Context cr) { double step_width = Allocation.Width / (double)steps; double step_height = Allocation.Height / (double)steps; double h = 1.0; double s = 0.0; for (int xi = 0, i = 0; xi < steps; xi++) { for (int yi = 0; yi < steps; yi++, i++) { double bg_b = (double)(i / 255.0); double fg_b = 1.0 - bg_b; double x = xi * step_width; double y = yi * step_height; cr.Rectangle (x, y, step_width, step_height); cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b); cr.Fill (); int tw, th; Pango.Layout layout = new Pango.Layout (PangoContext); layout.SetText (((int)(bg_b * 255.0)).ToString ()); layout.GetPixelSize (out tw, out th); cr.Translate (0.5, 0.5); cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0); cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b); PangoCairoHelper.ShowLayout (cr, layout); cr.Translate (-0.5, -0.5); } } return true; }
protected override bool OnDrawn(Cairo.Context cr) { bool ret = true; var rect = this.Allocation; if (rect.Width > 0 && rect.Height > 0) { var arrowWidth = popupButton.Allocation.Width; var arrowPos = rect.Width - arrowWidth; var arrowSize = 10; StyleContext.Save(); StyleContext.AddClass("entry"); StyleContext.RenderBackground(cr, 0, 0, rect.Width, rect.Height); ret = base.OnDrawn(cr); StyleContext.RenderArrow(cr, Math.PI, arrowPos, (rect.Height - arrowSize) / 2, arrowSize); cr.SetSourceColor(new Cairo.Color(.8, .8, .8)); cr.Rectangle(arrowPos - 5, 2, 1, rect.Height - 4); cr.Fill(); Entry.StyleContext.RenderFrame(cr, 0, 0, rect.Width, rect.Height); StyleContext.Restore(); } return ret; }
private static void Taskbar() { 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 = 30; Compositor.Server.Write(Data); Client.Read(Data); string HashCode = new string(Window->Buffer); var aBuffer = SHM.Obtain(HashCode, 0, false); TaskbarID = Window->WindowID; uint surface = Cairo.ImageSurfaceCreateForData(Window->Width * 4, Window->Height, Window->Width, ColorFormat.ARGB32, aBuffer); uint context = Cairo.Create(surface); uint pattern = Cairo.PatternCreateLinear(30, 0, 0, 0); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern); Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern); Cairo.SetOperator(Operator.Over, context); Cairo.Rectangle(30, VBE.Xres, 0, 0, context); Cairo.SetSource(pattern, context); Cairo.Fill(context); Cairo.Rectangle(2, VBE.Xres, 30 - 2, 0, context); Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, context); Cairo.Fill(context); Cairo.PatternDestroy(pattern); Cairo.Destroy(context); Cairo.SurfaceDestroy(surface); Request->Type = RequestType.Redraw; var Redraw = (Redraw *)Request; Redraw->WindowID = TaskbarID; Redraw->X = 0; Redraw->Y = 0; Redraw->Width = VBE.Xres; Redraw->Height = 40; Compositor.Server.Write(Data); TaskbarSurface = surface; TaskbarContext = context; Heap.Free(Data); }
bool IFoldMarginMarker.DrawBackground (TextEditor e, double marginWidth, Cairo.Context cr, Cairo.Rectangle area, DocumentLine documentLine, int line, double x, double y, double lineHeight) { if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) return false; cr.Rectangle (x, y, marginWidth, lineHeight); cr.Color = LineColor.Color; cr.Fill (); return true; }
public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics) { if (metrics.SelectionStart > 0) return true; cr.Color = color; cr.Rectangle (metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight); cr.Fill (); return true; }
public override bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics) { if (metrics.SelectionStart > 0) return true; cr.SetSourceColor (color); cr.Rectangle (metrics.TextRenderStartPosition, metrics.LineYRenderStartPosition, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight); cr.Fill (); return true; }
public override void BasicDraw(Cairo.Context context) { context.Rectangle(DisplayBox.X, DisplayBox.Y, DisplayBox.Width, DisplayBox.Height); context.Stroke(); classname.BasicDraw(context); }
void DrawMarginBackground (Cairo.Context cr, int line, double x, double y, double lineHeight) { if (editor.Caret.Line == line) { editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight); return; } cr.Rectangle (x, y, Width, lineHeight); cr.SetSourceColor (editor.ColorStyle.LineNumbers.Background); cr.Fill (); }
public virtual void Render(Cairo.Context cr, Layout layout, double x, double y, double w, double h) { cr.Save(); cr.Translate (x,y); // make the background white cr.Color = new Cairo.Color(1, 1, 1); cr.Rectangle(0,0,w,h); cr.Fill(); // calc some values int lw; string prefix = "INV-"+InventoryAbbreviation+"-"; string idString = Id.ToString("0000000000"); // basic text stuff layout.FontDescription = FontDescription.FromString(CalcFont(Layout,layout,h)); layout.Width = (int)(w*Scale.PangoScale); layout.Alignment = Alignment.Center; // draw the description int descH = 0; if(Layout.UseDescription){ Layout descLayout = layout.Copy(); descLayout.SetText (Description); descLayout.GetPixelSize(out lw, out descH); layout.Ellipsize = EllipsizeMode.Middle; layout.Justify = true; cr.Color = new Cairo.Color(0, 0, 0); Pango.CairoHelper.ShowLayout (cr, descLayout); } // draw the barcode text int codeH = 0; if(Layout.UseBarcodeText){ Layout codeLayout = layout.Copy(); codeLayout.SetText (prefix+idString); codeLayout.GetPixelSize(out lw, out codeH); cr.MoveTo(0,h-(double)codeH); cr.Color = new Cairo.Color(0, 0, 0); Pango.CairoHelper.ShowLayout (cr, codeLayout); } // draw the barcode if(Layout.UseBarcode){ double barcodeH = h-((double)codeH+(double)descH+Layout.SpacingSize*2); if(barcodeH>0){ IBarcode bc = new Code128(); bc.WriteString(prefix+idString); bc.WriteEnd(); RenderBarcode(bc,cr,0,descH+Layout.SpacingSize,w,barcodeH); } } cr.Restore(); }
protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { RectangleD rect = DisplayBox; rect.OffsetDot5(); context.Rectangle(GdkCairoHelper.CairoRectangle(rect)); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); }
void IIconBarMarker.DrawBackground (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height) { cr.Rectangle (x, y, width, height); cr.Color = LineColor.SecondColor; cr.Fill (); cr.MoveTo (x + width - 0.5, y); cr.LineTo (x + width - 0.5, y + height); cr.Color = LineColor.BorderColor; cr.Stroke (); if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) { cr.Rectangle (x, y, width, height); cr.Color = new Cairo.Color (ed.ColorStyle.IndicatorMargin.Color.R, ed.ColorStyle.IndicatorMargin.Color.G, ed.ColorStyle.IndicatorMargin.Color.B, 0.5); cr.Fill (); } }
public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { this.editor = editor; var line = editor.GetLine (loc.Line); if (line == null) return; var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition; cr.Rectangle (Math.Floor (x), Math.Floor (metrics.LineYRenderStartPosition) + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight : 0), tagMarkerWidth, tagMarkerHeight); cr.SetSourceColor ((HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5 ? Ide.Gui.Styles.Editor.SmartTagMarkerColorDark : Ide.Gui.Styles.Editor.SmartTagMarkerColorLight).ToCairoColor ()); cr.Fill (); }
protected override void OnLayoutOutline (Cairo.Context context) { if (ClipInputToTextExtents) { Pango.Layout layout = GetLayout (); layout.Width = Pango.Units.FromPixels ((int)Width); int w, h; layout.GetPixelSize (out w, out h); int x = (int)Width - w; x = (int) (x * XAlign); int y = (int)Height - h; y = (int) (y * YAlign); context.Rectangle (x, y, w, h); } else { context.Rectangle (0, 0, Width, Height); } }
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 (); }
public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { this.editor = editor; var line = editor.GetLine (loc.Line); if (line == null) return; var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition; cr.Rectangle (Math.Floor (x) + 0.5, Math.Floor (metrics.LineYRenderStartPosition) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth); if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) { cr.SetSourceRGBA (0.8, 0.8, 1, 0.9); } else { cr.SetSourceRGBA (0.2, 0.2, 1, 0.9); } cr.Stroke (); }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI); gr.Clip (); gr.NewPath (); gr.Rectangle (new PointD (0, 0), 1, 1); gr.Fill (); gr.Color = new Color (0, 1, 0, 1); gr.MoveTo ( new PointD (0, 0) ); gr.LineTo ( new PointD (1, 1) ); gr.MoveTo ( new PointD (1, 0) ); gr.LineTo ( new PointD (0, 1) ); gr.Stroke (); }
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { int markerStart = Offset; int markerEnd = EndOffset; double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max (@from, editor.TextViewMargin.XOffset); to = Math.Max (to, editor.TextViewMargin.XOffset); if (@from <= to) { if (metrics.TextEndOffset < markerEnd) to = metrics.WholeLineWidth + metrics.TextRenderStartPosition; var c1 = editor.Options.GetColorStyle ().PlainText.Background; var c2 = editor.Options.GetColorStyle ().SelectedText.Background; cr.SetSourceRGB ((c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2); cr.Rectangle (@from, y, to - @from, metrics.LineHeight); cr.Fill (); } }
public static void Render(Cairo.Context g, SlotHolder equipment, int x, int y, bool renderOrbs, bool renderBackground = true) { if (renderBackground) { g.Color = Colors.GRAY_1; g.Rectangle(x, y, 8 * SLOT_SPACING, SLOT_RADIUS * 2); g.Fill(); } for (int j = 0; j < equipment.Links; j++) { Shapes.RenderLine(g, gray2, 3, x + (SLOT_SPACING / 2) + (j * 2 * SLOT_SPACING), y + ys - zs, x + (SLOT_SPACING / 2) + ((j * 2 + 1) * SLOT_SPACING), y + ys - zs); Shapes.RenderLine(g, gray2, 3, x + (SLOT_SPACING / 2) + (j * 2 * SLOT_SPACING), y + ys, x + (SLOT_SPACING / 2) + ((j * 2 + 1) * SLOT_SPACING), y + ys); Shapes.RenderLine(g, gray2, 3, x + (SLOT_SPACING / 2) + (j * 2 * SLOT_SPACING), y + ys + zs, x + (SLOT_SPACING / 2) + ((j * 2 + 1) * SLOT_SPACING), y + ys + zs); } for (int i = 0; i < equipment.Slots.Length; i++) { Shapes.RenderCircle(g, gray2, SLOT_RADIUS, x + (i * SLOT_SPACING) + (SLOT_SPACING / 2), y + ys); if (equipment.Slots[i] == null || !renderOrbs) { Shapes.RenderCircle(g, gray1, MATERIA_RADIUS, x + (i * SLOT_SPACING) + (SLOT_SPACING / 2), y + ys); } else { Shapes.RenderCircle(g, equipment.Slots[i].Color, MATERIA_RADIUS, x + (i * SLOT_SPACING) + (SLOT_SPACING / 2), y + ys); } } }
static void draw (Cairo.Context gr, int width, int height) { int w, h; ImageSurface image; Matrix matrix; SurfacePattern pattern; gr.Scale (width, height); gr.LineWidth = 0.04; image = new ImageSurface ("data/e.png"); w = image.Width; h = image.Height; pattern = new SurfacePattern (image); pattern.Extend = Cairo.Extend.Repeat; gr.Translate (0.5, 0.5); gr.Rotate (M_PI / 4); gr.Scale (1 / Math.Sqrt (2), 1 / Math.Sqrt (2)); gr.Translate (- 0.5, - 0.5); matrix = new Matrix (); matrix.InitScale (w * 5.0, h * 5.0); pattern.Matrix = matrix; gr.Pattern = pattern; gr.Rectangle ( new PointD (0, 0), 1.0, 1.0); gr.Fill (); pattern.Destroy (); image.Destroy(); }
protected void DrawSearchResults (Cairo.Context cr) { foreach (var region in TextEditor.TextViewMargin.SearchResults) { int line = TextEditor.OffsetToLineNumber (region.Offset); double y = GetYPosition (line); bool isMainSelection = false; if (!TextEditor.TextViewMargin.MainSearchResult.IsInvalid) isMainSelection = region.Offset == TextEditor.TextViewMargin.MainSearchResult.Offset; cr.SetSourceColor (isMainSelection ? TextEditor.ColorStyle.SearchResultMain.Color : TextEditor.ColorStyle.SearchResult.Color); cr.Rectangle (barPadding, Math.Round (y) - 1, Allocation.Width - barPadding * 2, 2); cr.Fill (); } }
protected virtual void DrawBar (Cairo.Context cr) { if (vadjustment == null || vadjustment.Upper <= vadjustment.PageSize) return; double x, y, w, h; GetBarDimensions (out x, out y, out w, out h); if (Platform.IsWindows) { cr.Rectangle (x, y, w, h); } else { MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, x, y, w, h, 4); } bool prelight = State == StateType.Prelight; Cairo.Color c; if (Platform.IsWindows) { c = prelight ? win81SliderPrelight : win81Slider; //compute new color such that it will produce same color when blended with bg c = AddAlpha (win81Background, c, 0.5d); } else { c = new Cairo.Color (0, 0, 0, (prelight ? 50.0 : 22.0) / 255); } cr.SetSourceColor (c); cr.Fill (); }
protected Severity DrawQuickTasks (Cairo.Context cr) { Severity severity = Severity.None; /* foreach (var usage in AllUsages) { double y = GetYPosition (usage.Line); var usageColor = TextEditor.ColorStyle.PlainText.Foreground; usageColor.A = 0.4; cr.Color = usageColor; cr.MoveTo (0, y - 3); cr.LineTo (5, y); cr.LineTo (0, y + 3); cr.ClosePath (); cr.Fill (); } */ foreach (var task in AllTasks) { double y = GetYPosition (task.Location.Line); cr.SetSourceColor (GetBarColor (task.Severity)); cr.Rectangle (0, Math.Round (y) - 1, Allocation.Width, 2); cr.Fill (); switch (task.Severity) { case Severity.Error: severity = Severity.Error; break; case Severity.Warning: if (severity == Severity.None) severity = Severity.Warning; break; } } return severity; }
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 (); }
void DrawString (string text, bool isMarkup, Cairo.Context context, int x, int y, int width, double opacity, Pango.Context pango, StatusArea.RenderArg arg) { Pango.Layout pl = new Pango.Layout (pango); if (isMarkup) pl.SetMarkup (text); else pl.SetText (text); pl.FontDescription = Styles.StatusFont; pl.FontDescription.AbsoluteSize = Pango.Units.FromPixels (Styles.StatusFontPixelHeight); pl.Ellipsize = Pango.EllipsizeMode.End; pl.Width = Pango.Units.FromPixels(width); int w, h; pl.GetPixelSize (out w, out h); context.Save (); // use widget height instead of message box height as message box does not have a true height when no widgets are packed in it // also ensures animations work properly instead of getting clipped context.Rectangle (new Rectangle (x, arg.Allocation.Y, width, arg.Allocation.Height)); context.Clip (); // Subtract off remainder instead of drop to prefer higher centering when centering an odd number of pixels context.MoveTo (x, y - h / 2 - (h % 2)); context.Color = Styles.WithAlpha (FontColor (), opacity); Pango.CairoHelper.ShowLayout (context, pl); pl.Dispose (); context.Restore (); }
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(); } }
private static unsafe void DrawTaskbar(GuiRequest *request, byte[] xData) { request->Type = RequestType.NewWindow; request->Error = ErrorType.None; var taskbar = (NewWindow *)request; int height = 30; taskbar->X = 0; taskbar->Y = 0; taskbar->Width = VBE.Xres; taskbar->Height = height; Compositor.Server.Write(xData); SystemClient.Read(xData); if (request->Error != ErrorType.None) { Debug.Write("Error4: %d\n", (int)request->Error); return; } string HashCode = new string(taskbar->Buffer); var aBuffer = SHM.Obtain(HashCode, 0, false); int winID = taskbar->WindowID; Debug.Write("winID: %d\n", winID); uint surface = Cairo.ImageSurfaceCreateForData(VBE.Xres * 4, height, VBE.Xres, ColorFormat.ARGB32, aBuffer); uint cr = Cairo.Create(surface); uint pattern = Cairo.PatternCreateLinear(height, 0, 0, 0); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern); Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern); Cairo.SetOperator(Operator.Over, cr); Cairo.Rectangle(height, VBE.Xres, 0, 0, cr); Cairo.SetSource(pattern, cr); Cairo.Fill(cr); Cairo.Rectangle(2, VBE.Xres, height - 2, 0, cr); Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, cr); Cairo.Fill(cr); Cairo.SetSourceRGBA(1, 1, 1, 1, cr); Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.SetFontSize(20, cr); Cairo.MoveTo(20, 1215, cr); Cairo.ShowText(Marshal.C_String("20:10"), cr); Cairo.PatternDestroy(pattern); Cairo.Destroy(cr); Cairo.SurfaceDestroy(surface); request->Type = RequestType.Redraw; var req = (Redraw *)request; req->WindowID = winID; req->X = 0; req->Y = 0; req->Width = VBE.Xres; req->Height = height; Compositor.Server.Write(xData); }
private static unsafe void DrawWindow(GuiRequest *request, byte[] xData) { request->Type = RequestType.NewWindow; request->Error = ErrorType.None; var window = (NewWindow *)request; window->X = 340; window->Y = 159; window->Width = 600; window->Height = 450; Compositor.Server.Write(xData); SystemClient.Read(xData); if (request->Error != ErrorType.None) { Debug.Write("Error5: %d\n", (int)request->Error); return; } string HashCode = new string(window->Buffer); var aBuffer = SHM.Obtain(HashCode, 0, false); int winID = window->WindowID; Debug.Write("winID: %d\n", winID); uint surface = Cairo.ImageSurfaceCreateForData(600 * 4, 450, 600, ColorFormat.ARGB32, aBuffer); uint cr = Cairo.Create(surface); Cairo.SetOperator(Operator.Over, cr); Cairo.Rectangle(450, 600, 0, 0, cr); Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr); Cairo.Fill(cr); Cairo.Rectangle(446, 596, 2, 2, cr); Cairo.SetSourceRGBA(1, 0.87, 0.87, 0.87, cr); Cairo.Fill(cr); Cairo.Rectangle(410, 580, 30, 10, cr); Cairo.SetSourceRGBA(1, 1, 1, 1, cr); Cairo.Fill(cr); Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr); Cairo.SelectFontFace(FontWeight.Normal, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.SetFontSize(15, cr); Cairo.MoveTo(18, 215, cr); Cairo.ShowText(Marshal.C_String("Atom OS : Installation Guide"), cr); Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.MoveTo(18, 580, cr); Cairo.ShowText(Marshal.C_String("X"), cr); Cairo.SurfaceFlush(surface); Cairo.Destroy(cr); Cairo.SurfaceDestroy(surface); request->Type = RequestType.Redraw; var req = (Redraw *)request; req->WindowID = winID; req->X = 0; req->Y = 0; req->Width = 600; req->Height = 450; Compositor.Server.Write(xData); Debug.Write("Time: %d\n", Timer.TicksFromStart); while (true) { SystemClient.Read(xData); if (request->Error != ErrorType.None) { continue; } if (request->Type != RequestType.MouseEvent) { continue; } var mreq = (MouseEvent *)request; if (mreq->WindowID != winID) { continue; } if ((mreq->Function & MouseFunction.Click) != 0) { int x = mreq->Xpos; int y = mreq->Ypos; if (y < 40) { request->Type = RequestType.DragRequest; var mv = (DragRequest *)request; mv->WindowID = winID; Compositor.Server.Write(xData); } } } }