protected void DrawSearchIndicator(Cairo.Context cr) { var x1 = 1 + Allocation.Width / 2; var y1 = Allocation.Height - IndicatorHeight / 2; cr.Arc(x1, y1, (IndicatorHeight - 1) / 2, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg; darkColor.L *= 0.5; using (var pattern = new Cairo.RadialGradient(x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop(0, darkColor); pattern.AddColorStop(1, TextEditor.ColorStyle.SearchTextMainBg); cr.Pattern = pattern; cr.FillPreserve(); } cr.Color = darkColor; cr.Stroke(); }
protected override bool OnDrawn(Cairo.Context cr) { if (!pulsator.IsPulsing) { return(base.OnDrawn(cr)); } double x = Allocation.Width / 2; double y = Allocation.Height / 2; double r = Math.Min(Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine); Gdk.RGBA rgba = StyleContext.GetBackgroundColor(StateFlags.Selected); Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor(rgba); Cairo.RadialGradient fill = new Cairo.RadialGradient(x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop(0, color); fill.AddColorStop(0.5, color); color.A = 0; fill.AddColorStop(1, color); cr.Arc(x, y, r, 0, 2 * Math.PI); cr.Pattern = fill; cr.Fill(); fill.Destroy(); return(base.OnDrawn(cr)); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (!pulsator.IsPulsing) { return(base.OnExposeEvent(evnt)); } Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow); double x = Allocation.X + Allocation.Width / 2; double y = Allocation.Y + Allocation.Height / 2; double r = Math.Min(Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine); var color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Selected)); var fill = new Cairo.RadialGradient(x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop(0, color); fill.AddColorStop(0.5, color); color.A = 0; fill.AddColorStop(1, color); cr.Arc(x, y, r, 0, 2 * Math.PI); cr.SetSource(fill); cr.Fill(); fill.Dispose(); CairoExtensions.DisposeContext(cr); return(base.OnExposeEvent(evnt)); }
public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity) { cr.Save (); cr.Translate (rect.X, rect.Y); var x = rect.Width / 2.0; var y = rect.Height / 2.0; using (var grad = new Cairo.RadialGradient (x, y, 0, x, y, rect.Width / 2.0)) { grad.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.1 * opacity)); grad.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.35 * opacity)); cr.SetSource (grad); CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius); cr.Fill (); } cr.Restore (); }
public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity) { cr.Save(); cr.Translate(rect.X, rect.Y); var x = rect.Width / 2.0; var y = rect.Height / 2.0; using (var grad = new Cairo.RadialGradient(x, y, 0, x, y, rect.Width / 2.0)) { grad.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.1 * opacity)); grad.AddColorStop(1, new Cairo.Color(0, 0, 0, 0.35 * opacity)); cr.SetSource(grad); CairoExtensions.RoundedRectangle(cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius); cr.Fill(); } cr.Restore(); }
protected void DrawSearchIndicator(Cairo.Context cr) { int diameter = Math.Min(Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round(Allocation.Width / 2d); var y1 = Allocation.Height - Math.Floor(IndicatorHeight / 2d); if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc(x1, y1, diameter / 2d, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color; darkColor.L *= 0.5; if (flatStyle) { using (var pattern = new Cairo.SolidPattern(TextEditor.ColorStyle.SearchResultMain.Color)) { cr.Pattern = pattern; cr.FillPreserve(); } } else { using (var pattern = new Cairo.RadialGradient(x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop(0, darkColor); pattern.AddColorStop(1, TextEditor.ColorStyle.SearchResultMain.Color); cr.Pattern = pattern; cr.FillPreserve(); } } cr.Color = darkColor; cr.Stroke(); }
void DrawIndicator(Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor) { var width = Allocation.Width; int diameter = Math.Min(width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round(width / 2d); double y1 = indicatorPadding + diameter / 2; if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc(x1, y1, diameter / 2d, 0, 2 * Math.PI); if (Platform.IsWindows) { using (var pattern = new Cairo.SolidPattern(color)) { cr.SetSource(pattern); cr.FillPreserve(); } } else { using (var pattern = new Cairo.RadialGradient(x1, y1, width / 2, x1 - width, y1 - width, width)) { pattern.AddColorStop(0, borderColor); pattern.AddColorStop(1, color); cr.SetSource(pattern); cr.FillPreserve(); } } cr.SetSourceColor(borderColor); cr.Stroke(); }
protected virtual void Decorate(ProgressDial dial) { var pos = Context.Push(); var coord = pos.Coord(); Context.Cairo.Operator = Cairo.Operator.Source; Context.Cairo.LineWidth = StrokeWidth; var strokeColor = GetColor(ColorType.Stroke, dial.HitState).ToCairo(); var cx = dial.RenderWidth / 2.0 + pos.X; var cy = dial.RenderHeight / 2.0 + pos.Y; var outerRadius = dial.RenderWidth/2; // draw the outer background circle Context.Cairo.Pattern = GenerateGradient(coord, dial.RenderSize, AnchorLocation.NW, GetColor(ColorType.BackgroundStart, dial.HitState), GetColor(ColorType.BackgroundStop, dial.HitState)); Context.Cairo.Arc(cx, cy, outerRadius, 0, 2 * Math.PI); Context.Cairo.Fill(); Context.Cairo.Color = strokeColor; Context.Cairo.Arc(cx, cy, outerRadius, 0, 2 * Math.PI); Context.Cairo.Stroke(); // draw the outer highlighted circle var grad = new Cairo.RadialGradient(cx, cy, dial.InnerRadius, cx, cy, outerRadius); grad.AddColorStop(1, GetColor(ColorType.HighlightStart, dial.HitState).ToCairo()); grad.AddColorStop(0, GetColor(ColorType.HighlightStop, dial.HitState).ToCairo()); Context.Cairo.Pattern = grad; Context.Cairo.Arc(cx, cy, outerRadius, -Math.PI/2.0, dial.Value * 2 * Math.PI - Math.PI/2.0); Context.Cairo.LineTo(cx, cy); Context.Cairo.Fill(); Context.Cairo.Color = strokeColor; Context.Cairo.MoveTo(cx, cy); Context.Cairo.RelLineTo(0, -outerRadius); Context.Cairo.Stroke(); // draw the inner circle var start = new Coord(pos.X + dial.RenderWidth/2.0 - dial.InnerRadius, pos.Y + dial.RenderHeight/2.0 - dial.InnerRadius); var size = new Coord(dial.InnerRadius * 2, dial.InnerRadius * 2); Context.Cairo.Pattern = GenerateGradient(start, size, AnchorLocation.SE, GetColor(ColorType.BackgroundStart, dial.HitState), GetColor(ColorType.BackgroundStop, dial.HitState)); Context.Cairo.Arc(cx, cy, dial.InnerRadius, 0, 2 * Math.PI); Context.Cairo.Fill(); Context.Cairo.Color = strokeColor; Context.Cairo.Arc(cx, cy, dial.InnerRadius, 0, 2 * Math.PI); Context.Cairo.Stroke(); Context.Pop(); }
protected override bool OnExposeEvent(EventExpose evnt) { using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) { int delta = widget.OriginalEditor.Allocation.Y - Allocation.Y; if (widget.Diff != null) { foreach (Diff.Hunk hunk in widget.Diff) { if (!hunk.Same) { int y1 = delta + widget.DiffEditor.LineToVisualY(hunk.Right.Start) - (int)widget.OriginalEditor.VAdjustment.Value; int y2 = delta + widget.DiffEditor.LineToVisualY(hunk.Right.Start + hunk.Right.Count) - (int)widget.OriginalEditor.VAdjustment.Value; if (y1 == y2) { y2 = y1 + 1; } int z1 = delta + widget.OriginalEditor.LineToVisualY(hunk.Left.Start) - (int)widget.DiffEditor.VAdjustment.Value; int z2 = delta + widget.OriginalEditor.LineToVisualY(hunk.Left.Start + hunk.Left.Count) - (int)widget.DiffEditor.VAdjustment.Value; if (z1 == z2) { z2 = z1 + 1; } cr.MoveTo(Allocation.Width, y1); cr.LineTo(0, z1); cr.LineTo(0, z2); cr.LineTo(Allocation.Width, y2); cr.ClosePath(); cr.Color = GetColor(hunk, fillAlpha); cr.Fill(); cr.Color = GetColor(hunk, lineAlpha); cr.MoveTo(Allocation.Width, y1); cr.LineTo(0, z1); cr.Stroke(); cr.MoveTo(Allocation.Width, y2); cr.LineTo(0, z2); cr.Stroke(); int x = Allocation.Width / 2; int y = ((y1 + y2) / 2 + (z1 + z2) / 2) / 2; cr.Save(); cr.Translate(x, y); cr.Scale(10, 10); cr.Arc(0, 0, 1, 0, 2 * Math.PI); cr.Color = GetColor(hunk, 1); cr.FillPreserve(); Cairo.RadialGradient shadowGradient = new Cairo.RadialGradient(0.0, 0.0, .6, 0.0, 0.0, 1.0); shadowGradient.AddColorStop(0, new Cairo.Color(0, 0, 0, 0)); shadowGradient.AddColorStop(1, new Cairo.Color(0, 0, 0, 0.5)); cr.Source = shadowGradient; cr.FillPreserve(); if (selectedHunk != null && hunk.Left.Start == selectedHunk.Left.Start && hunk.Right.Start == selectedHunk.Right.Start) { cr.Scale(12, 12); shadowGradient = new Cairo.RadialGradient(0.0, 0.0, .6, 0.0, 0.0, 1.0); shadowGradient.AddColorStop(0, new Cairo.Color(1, 1, 1, 0.5)); shadowGradient.AddColorStop(1, new Cairo.Color(1, 1, 1, 0.2)); cr.Source = shadowGradient; cr.Fill(); } cr.Restore(); } } } } var result = base.OnExposeEvent(evnt); Gdk.GC gc = Style.DarkGC(State); evnt.Window.DrawLine(gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); evnt.Window.DrawLine(gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); evnt.Window.DrawLine(gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); evnt.Window.DrawLine(gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return(result); }
protected override bool OnExposeEvent (EventExpose evnt) { bool hideButton = widget.MainEditor.Document.ReadOnly; using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) { cr.Rectangle (evnt.Region.Clipbox.X, evnt.Region.Clipbox.Y, evnt.Region.Clipbox.Width, evnt.Region.Clipbox.Height); cr.Clip (); int delta = widget.MainEditor.Allocation.Y - Allocation.Y; if (Diff != null) { foreach (Mono.TextEditor.Utils.Hunk hunk in Diff) { double z1 = delta + fromEditor.LineToY (hunk.RemoveStart) - fromEditor.VAdjustment.Value; double z2 = delta + fromEditor.LineToY (hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value; if (z1 == z2) z2 = z1 + 1; double y1 = delta + toEditor.LineToY (hunk.InsertStart) - toEditor.VAdjustment.Value; double y2 = delta + toEditor.LineToY (hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value; if (y1 == y2) y2 = y1 + 1; if (!useLeft) { var tmp = z1; z1 = y1; y1 = tmp; tmp = z2; z2 = y2; y2 = tmp; } int x1 = 0; int x2 = Allocation.Width; if (!hideButton) { if (useLeft && hunk.Removed > 0 || !useLeft && hunk.Removed == 0) { x1 += 16; } else { x2 -= 16; } } if (z1 == z2) z2 = z1 + 1; cr.MoveTo (x1, z1); cr.CurveTo (x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.LineTo (x2, y2); cr.CurveTo (x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.ClosePath (); cr.Color = GetColor (hunk, this.useLeft, false, 1.0); cr.Fill (); cr.Color = GetColor (hunk, this.useLeft, true, 1.0); cr.MoveTo (x1, z1); cr.CurveTo (x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.Stroke (); cr.MoveTo (x2, y2); cr.CurveTo (x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.Stroke (); if (!hideButton) { bool isButtonSelected = hunk == selectedHunk; double x, y, w, h; bool drawArrow = useLeft ? GetButtonPosition (hunk, y1, y2, z1, z2, out x, out y, out w, out h) : GetButtonPosition (hunk, z1, z2, y1, y2, out x, out y, out w, out h); cr.Rectangle (x, y, w, h); if (isButtonSelected) { int mx, my; GetPointer (out mx, out my); // mx -= (int)x; // my -= (int)y; Cairo.RadialGradient gradient = new Cairo.RadialGradient (mx, my, h, mx, my, 2); var color = (Mono.TextEditor.HslColor)Style.Mid (StateType.Normal); color.L *= 1.05; gradient.AddColorStop (0, color); color.L *= 1.07; gradient.AddColorStop (1, color); cr.Pattern = gradient; } else { cr.Color = (Mono.TextEditor.HslColor)Style.Mid (StateType.Normal); } cr.FillPreserve (); cr.Color = (Mono.TextEditor.HslColor)Style.Dark (StateType.Normal); cr.Stroke (); cr.LineWidth = 1; cr.Color = new Cairo.Color (0, 0, 0); if (drawArrow) { DrawArrow (cr, x + w / 1.5, y + h / 2); DrawArrow (cr, x + w / 2.5, y + h / 2); } else { DrawCross (cr, x + w / 2 , y + (h) / 2); } cr.Stroke (); } } } } // var result = base.OnExposeEvent (evnt); // // Gdk.GC gc = Style.DarkGC (State); // evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); // evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); // // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return true; }
protected override bool OnExposeEvent(EventExpose evnt) { Style.PaintBox(Style, evnt.Window, StateType.Insensitive, ShadowType.None, Allocation, this, "base", 0, 0, Allocation.Width, Allocation.Height); var expanderBounds = GetExpanderBounds(); using (var cr = CairoHelper.Create(evnt.Window)) { CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight; if (!container.Expanded) { corners = CairoCorners.All; } int r = 10; CairoExtensions.RoundedRectangle(cr, 0, 0, Allocation.Width, Allocation.Height, r, corners); var lg = new Cairo.LinearGradient(0, 0, 0, Allocation.Height); var state = mouseOver ? StateType.Prelight : StateType.Normal; lg.AddColorStop(0, (Mono.TextEditor.HslColor)Style.Mid(state)); lg.AddColorStop(1, (Mono.TextEditor.HslColor)Style.Dark(state)); cr.Pattern = lg; cr.Fill(); if (mouseOver) { CairoExtensions.RoundedRectangle(cr, 0, 0, Allocation.Width, Allocation.Height, r, corners); double rx = mx; double ry = my; Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, Allocation.Width * 2, rx, ry, 2); gradient.AddColorStop(0, new Cairo.Color(0, 0, 0, 0)); Cairo.Color color = (Mono.TextEditor.HslColor)Style.Light(StateType.Normal); color.A = 0.2; gradient.AddColorStop(1, color); cr.Pattern = gradient; cr.Fill(); } cr.LineWidth = 1; CairoExtensions.RoundedRectangle(cr, 0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1, r, corners); cr.Color = (Mono.TextEditor.HslColor)Style.Dark(StateType.Normal); cr.Stroke(); using (var layout = new Pango.Layout(PangoContext)) { layout.SetMarkup(Label); int w, h; layout.GetPixelSize(out w, out h); const int padding = 4; cr.MoveTo(expanderBounds.Right + padding, (Allocation.Height - h) / 2); cr.Color = new Cairo.Color(0, 0, 0); cr.ShowLayout(layout); } DrawCloseButton(cr); } var state2 = mouseOver && !IsCloseSelected ? StateType.Prelight : StateType.Normal; Style.PaintExpander(Style, evnt.Window, state2, evnt.Region.Clipbox, this, "expander", expanderBounds.X + expanderBounds.Width / 2, expanderBounds.Y + expanderBounds.Width / 2, expanderStyle); return(true); }
protected override bool OnExposeEvent (EventExpose evnt) { var expanderBounds = GetExpanderBounds (); using (var cr = CairoHelper.Create (evnt.Window)) { cr.Rectangle (0, 0, Allocation.Width, Allocation.Height); var lg = new Cairo.LinearGradient (0, 0, 0, Allocation.Height); var state = mouseOver ? StateType.Prelight : StateType.Normal; if (container.Closeable) { lg.AddColorStop (0, (Mono.TextEditor.HslColor)Style.Mid (state)); lg.AddColorStop (1, (Mono.TextEditor.HslColor)Style.Dark (state)); } else { lg.AddColorStop (0, (Mono.TextEditor.HslColor)Style.Light (state)); lg.AddColorStop (1, (Mono.TextEditor.HslColor)Style.Mid (state)); } cr.Pattern = lg; cr.Fill (); if (mouseOver && container.Expandable) { cr.Rectangle (0, 0, Allocation.Width, Allocation.Height); double rx = mx; double ry = my; Cairo.RadialGradient gradient = new Cairo.RadialGradient (rx, ry, Allocation.Width * 2, rx, ry, 2); gradient.AddColorStop (0, new Cairo.Color (0 ,0, 0, 0)); Cairo.Color color = (Mono.TextEditor.HslColor)Style.Light (StateType.Normal); color.A = 0.2; gradient.AddColorStop (1, color); cr.Pattern = gradient; cr.Fill (); } cr.MoveTo (0, 0); cr.LineTo (0, Allocation.Height); cr.LineTo (Allocation.Width, Allocation.Height); cr.LineTo (Allocation.Width, 0); if (!container.Expandable) cr.LineTo (0, 0); cr.Color = (Mono.TextEditor.HslColor)Style.Dark (StateType.Normal); cr.Stroke (); using (var layout = new Pango.Layout (PangoContext)) { layout.SetMarkup ("<b>" + Label + "</b>"); int w, h; layout.GetPixelSize (out w, out h); const int padding = 4; cr.MoveTo (container.Expandable ? expanderBounds.Right + padding : padding, (Allocation.Height - h) / 2); cr.Color = new Cairo.Color (0, 0, 0); cr.ShowLayout (layout); } } if (container.Expandable) { var state2 = mouseOver ? StateType.Prelight : StateType.Normal; Style.PaintExpander (Style, evnt.Window, state2, evnt.Region.Clipbox, this, "expander", expanderBounds.X + expanderBounds.Width / 2, expanderBounds.Y + expanderBounds.Width / 2, expanderStyle); } return base.OnExposeEvent (evnt); }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { if (!pulsator.IsPulsing) { return base.OnExposeEvent (evnt); } Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow); double x = Allocation.X + Allocation.Width / 2; double y = Allocation.Y + Allocation.Height / 2; double r = Math.Min (Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine); Cairo.Color color = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Selected)); Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop (0, color); fill.AddColorStop (0.5, color); color.A = 0; fill.AddColorStop (1, color); cr.Arc (x, y, r, 0, 2 * Math.PI); cr.SetSource (fill); cr.Fill (); fill.Dispose (); CairoExtensions.DisposeContext (cr); return base.OnExposeEvent (evnt); }
protected void DrawSearchIndicator (Cairo.Context cr) { var x1 = 1 + Allocation.Width / 2; var y1 = Allocation.Height - IndicatorHeight / 2; cr.Arc (x1, y1, (IndicatorHeight - 1) / 2, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.GetColor ("color"); darkColor.L *= 0.5; using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, TextEditor.ColorStyle.SearchResultMain.GetColor ("color")); cr.Pattern = pattern; cr.FillPreserve (); } cr.Color = darkColor; cr.Stroke (); }
protected override bool OnDrawn(Cairo.Context cr) { if (!pulsator.IsPulsing) { return base.OnDrawn (cr); } double x = Allocation.Width / 2; double y = Allocation.Height / 2; double r = Math.Min (Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine); Gdk.RGBA rgba = StyleContext.GetBackgroundColor (StateFlags.Selected); Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor (rgba); Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop (0, color); fill.AddColorStop (0.5, color); color.A = 0; fill.AddColorStop (1, color); cr.Arc (x, y, r, 0, 2 * Math.PI); cr.Pattern = fill; cr.Fill (); fill.Destroy (); return base.OnDrawn (cr); }
void DrawSearchIndicator (Cairo.Context cr) { int x1 = 1 + Allocation.Width / 2; int y1 = Allocation.Height - Allocation.Width + (Allocation.Width + 3) / 2; cr.Arc (x1, y1, (Allocation.Width - 5) / 2, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg; darkColor.L *= 0.5; using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, TextEditor.ColorStyle.SearchTextMainBg); cr.Pattern = pattern; cr.FillPreserve (); } cr.Color = darkColor; cr.Stroke (); }
/// <summary> /// Highlights outside a rectangle defined by the position and size. /// </summary> protected virtual void OuterHighlightRectangle(Coord relPos, Coord size, Corner rounded) { // TODO: Controls - make outer highlight not suck var point = Context.Push(); // create the gradient var radius = Math.Min(size.X, size.Y); var cx = point.X + relPos.X + size.X / 2; var cy = point.Y + relPos.Y + size.Y / 2; var grad = new Cairo.RadialGradient(cx, cy, radius, cx, cy, radius * 1.5); grad.AddColorStop(0, FocusColor.ToCairo()); grad.AddColorStop(1, new Cairo.Color(1, 1, 1, 0)); Context.Cairo.Pattern = grad; // draw the rectangle path Context.Cairo.Arc(cx, cy, radius * 1.5, 0, 2 * Math.PI); // RectanglePath(point.Coord() + relPos, size, rounded); // var ar = size.Y / size.X; // Context.Cairo.Scale(1, ar); Context.Cairo.Fill(); Context.Pop(); }
/// <summary> /// Highlights inside a rectangle defined by the position and size. /// </summary> protected virtual void InnerHighlightRectangle(Coord relPos, Coord size, Corner rounded) { var point = Context.Push(); // create the gradient var radius = Math.Sqrt(size.X * size.X / 4 + size.Y * size.Y / 4); var cx = point.X + relPos.X + size.X / 2; var cy = point.Y + relPos.Y + size.Y / 2; var grad = new Cairo.RadialGradient(cx, cy, radius / 4.0, cx, cy, radius); grad.AddColorStop(0, new Cairo.Color(1, 1, 1, 0)); grad.AddColorStop(1, FocusColor.ToCairo()); Context.Cairo.Pattern = grad; // draw the rectangle path RectanglePath(point.Coord() + relPos, size, rounded); // var ar = size.Y / size.X; // Context.Cairo.Scale(1, ar); Context.Cairo.Fill(); Context.Pop(); }
protected override bool OnExposeEvent(EventExpose evnt) { var expanderBounds = GetExpanderBounds(); using (var cr = CairoHelper.Create(evnt.Window)) { cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); var lg = new Cairo.LinearGradient(0, 0, 0, Allocation.Height); var state = mouseOver ? StateType.Prelight : StateType.Normal; if (container.Closeable) { lg.AddColorStop(0, (Mono.TextEditor.HslColor)Style.Mid(state)); lg.AddColorStop(1, (Mono.TextEditor.HslColor)Style.Dark(state)); } else { lg.AddColorStop(0, (Mono.TextEditor.HslColor)Style.Light(state)); lg.AddColorStop(1, (Mono.TextEditor.HslColor)Style.Mid(state)); } cr.Pattern = lg; cr.Fill(); if (mouseOver && container.Expandable) { cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); double rx = mx; double ry = my; Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, Allocation.Width * 2, rx, ry, 2); gradient.AddColorStop(0, new Cairo.Color(0, 0, 0, 0)); Cairo.Color color = (Mono.TextEditor.HslColor)Style.Light(StateType.Normal); color.A = 0.2; gradient.AddColorStop(1, color); cr.Pattern = gradient; cr.Fill(); } cr.MoveTo(0, 0); cr.LineTo(0, Allocation.Height); cr.LineTo(Allocation.Width, Allocation.Height); cr.LineTo(Allocation.Width, 0); if (!container.Expandable) { cr.LineTo(0, 0); } cr.Color = (Mono.TextEditor.HslColor)Style.Dark(StateType.Normal); cr.Stroke(); using (var layout = new Pango.Layout(PangoContext)) { layout.SetMarkup("<b>" + Label + "</b>"); int w, h; layout.GetPixelSize(out w, out h); const int padding = 4; cr.MoveTo(container.Expandable ? expanderBounds.Right + padding : padding, (Allocation.Height - h) / 2); cr.Color = new Cairo.Color(0, 0, 0); cr.ShowLayout(layout); } } if (container.Expandable) { var state2 = mouseOver ? StateType.Prelight : StateType.Normal; Style.PaintExpander(Style, evnt.Window, state2, evnt.Region.Clipbox, this, "expander", expanderBounds.X + expanderBounds.Width / 2, expanderBounds.Y + expanderBounds.Width / 2, expanderStyle); } return(base.OnExposeEvent(evnt)); }
protected void DrawSearchIndicator (Cairo.Context cr) { int diameter = Math.Min (Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round (Allocation.Width / 2d); double y1 = indicatorPadding; if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color; darkColor.L *= 0.5; if (flatStyle) { using (var pattern = new Cairo.SolidPattern (TextEditor.ColorStyle.SearchResultMain.Color)) { cr.Pattern = pattern; cr.FillPreserve (); } } else { using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, TextEditor.ColorStyle.SearchResultMain.Color); cr.Pattern = pattern; cr.FillPreserve (); } } cr.Color = darkColor; cr.Stroke (); }
protected virtual void Decorate(RingButton ringButton) { Context.Push(); // generate the gradient for the background var ringBar = ringButton.Parent as RingBar; if (ringBar == null) return; var outerRadius = ringBar.OuterRadius; var innerRadius = ringBar.InnerRadius; var grad = new Cairo.RadialGradient(outerRadius, outerRadius, innerRadius, outerRadius, outerRadius, outerRadius); grad.AddColorStop(1, GetColor(ColorType.BackgroundStop, ringButton.HitState).ToCairo()); grad.AddColorStop(0, GetColor(ColorType.BackgroundStart, ringButton.HitState).ToCairo()); Context.Cairo.Pattern = grad; // draw the background ringButton.DrawOutline(Context.Cairo); Context.Cairo.Fill(); // draw the outline Context.Cairo.Color = GetColor(ColorType.Stroke, ringButton.HitState).ToCairo(); Context.Cairo.LineWidth = 1; ringButton.DrawOutline(Context.Cairo); Context.Cairo.Stroke(); Context.Pop(); }
protected override bool OnExposeEvent(EventExpose evnt) { bool hideButton = widget.MainEditor.Document.IsReadOnly; using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) { cr.Rectangle(evnt.Region.Clipbox.X, evnt.Region.Clipbox.Y, evnt.Region.Clipbox.Width, evnt.Region.Clipbox.Height); cr.Clip(); int delta = widget.MainEditor.Allocation.Y - Allocation.Y; if (Diff != null) { foreach (Hunk hunk in Diff) { double z1 = delta + fromEditor.LineToY(hunk.RemoveStart) - fromEditor.VAdjustment.Value; double z2 = delta + fromEditor.LineToY(hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value; if (z1 == z2) { z2 = z1 + 1; } double y1 = delta + toEditor.LineToY(hunk.InsertStart) - toEditor.VAdjustment.Value; double y2 = delta + toEditor.LineToY(hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value; if (y1 == y2) { y2 = y1 + 1; } if (!useLeft) { var tmp = z1; z1 = y1; y1 = tmp; tmp = z2; z2 = y2; y2 = tmp; } int x1 = 0; int x2 = Allocation.Width; if (!hideButton) { if (useLeft && hunk.Removed > 0 || !useLeft && hunk.Removed == 0) { x1 += 16; } else { x2 -= 16; } } if (z1 == z2) { z2 = z1 + 1; } cr.MoveTo(x1, z1); cr.CurveTo(x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.LineTo(x2, y2); cr.CurveTo(x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.ClosePath(); cr.SetSourceColor(GetColor(hunk, this.useLeft, false, 1.0)); cr.Fill(); cr.SetSourceColor(GetColor(hunk, this.useLeft, true, 1.0)); cr.MoveTo(x1, z1); cr.CurveTo(x1 + (x2 - x1) / 4, z1, x1 + (x2 - x1) * 3 / 4, y1, x2, y1); cr.Stroke(); cr.MoveTo(x2, y2); cr.CurveTo(x1 + (x2 - x1) * 3 / 4, y2, x1 + (x2 - x1) / 4, z2, x1, z2); cr.Stroke(); if (!hideButton) { bool isButtonSelected = hunk == selectedHunk; double x, y, w, h; bool drawArrow = useLeft ? GetButtonPosition(hunk, y1, y2, z1, z2, out x, out y, out w, out h) : GetButtonPosition(hunk, z1, z2, y1, y2, out x, out y, out w, out h); cr.Rectangle(x, y, w, h); if (isButtonSelected) { int mx, my; GetPointer(out mx, out my); // mx -= (int)x; // my -= (int)y; using (var gradient = new Cairo.RadialGradient(mx, my, h, mx, my, 2)) { var color = (MonoDevelop.Components.HslColor)Style.Mid(StateType.Normal); color.L *= 1.05; gradient.AddColorStop(0, color); color.L *= 1.07; gradient.AddColorStop(1, color); cr.SetSource(gradient); } } else { cr.SetSourceColor((MonoDevelop.Components.HslColor)Style.Mid(StateType.Normal)); } cr.FillPreserve(); cr.SetSourceColor((MonoDevelop.Components.HslColor)Style.Dark(StateType.Normal)); cr.Stroke(); cr.LineWidth = 1; cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.BaseForegroundColor.ToCairoColor()); if (drawArrow) { DrawArrow(cr, x + w / 1.5, y + h / 2); DrawArrow(cr, x + w / 2.5, y + h / 2); } else { DrawCross(cr, x + w / 2, y + (h) / 2); } cr.Stroke(); } } } } // var result = base.OnExposeEvent (evnt); // // Gdk.GC gc = Style.DarkGC (State); // evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom); // evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom); // // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y); // evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom); return(true); }
/// <summary> /// Redraws the circle_prototype which is used for all circles as template. /// This means a new circle is drawn with cairo and stored in a texture. /// </summary> static private void UpdatePrototype (CairoTexture actor, double r, double g, double b, double a, double arc, double a_r, double a_g, double a_b) { double size = (double)circle_size; actor.Clear(); Cairo.Context context = actor.Create(); Cairo.Gradient pattern = new Cairo.RadialGradient(size/2.0,size/2.0,size/3.0, size/2.0,size/2.0,size/2.0); pattern.AddColorStop(0,new Cairo.Color (r,g,b,a)); pattern.AddColorStop(1.0,new Cairo.Color (r,g,b,0.1)); context.LineWidth = (double)size/5.0; context.Arc (size/2.0, size/2.0, size/2.0-context.LineWidth/2.0,0,2*Math.PI); context.Save(); context.Pattern = pattern; context.Fill(); if (arc != 0) { context.LineWidth = (double)size/10.0; context.Arc (size/2.0, size/2.0, size/2.0-context.LineWidth/2.0,-Math.PI/2.0,2*Math.PI*arc/100.0-Math.PI/2.0); Hyena.Log.Debug ("Arc prototype "+ arc); context.Color = new Cairo.Color (a_r,a_g,a_b,0.5); context.Stroke (); } ((IDisposable) context.Target).Dispose (); ((IDisposable) context).Dispose (); }
void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor) { var width = Allocation.Width; int diameter = Math.Min (width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round (width / 2d); double y1 = indicatorPadding + diameter / 2; if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI); if (Platform.IsWindows) { using (var pattern = new Cairo.SolidPattern (color)) { cr.SetSource (pattern); cr.FillPreserve (); } } else { using (var pattern = new Cairo.RadialGradient (x1, y1, width / 2, x1 - width, y1 - width, width)) { pattern.AddColorStop (0, borderColor); pattern.AddColorStop (1, color); cr.SetSource (pattern); cr.FillPreserve (); } } cr.SetSourceColor (borderColor); cr.Stroke (); }
protected override bool OnExposeEvent (EventExpose evnt) { Style.PaintBox (Style, evnt.Window, StateType.Insensitive, ShadowType.None, Allocation, this, "base", 0, 0, Allocation.Width, Allocation.Height); var expanderBounds = GetExpanderBounds (); using (var cr = CairoHelper.Create (evnt.Window)) { CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight; if (!container.Expanded) corners = CairoCorners.All; int r = 10; CairoExtensions.RoundedRectangle (cr, 0, 0, Allocation.Width, Allocation.Height, r, corners); var lg = new Cairo.LinearGradient (0, 0, 0, Allocation.Height); var state = mouseOver ? StateType.Prelight : StateType.Normal; lg.AddColorStop (0, (Mono.TextEditor.HslColor)Style.Mid (state)); lg.AddColorStop (1, (Mono.TextEditor.HslColor)Style.Dark (state)); cr.Pattern = lg; cr.Fill (); if (mouseOver) { CairoExtensions.RoundedRectangle (cr, 0, 0, Allocation.Width, Allocation.Height, r, corners); double rx = mx; double ry = my; Cairo.RadialGradient gradient = new Cairo.RadialGradient (rx, ry, Allocation.Width * 2, rx, ry, 2); gradient.AddColorStop (0, new Cairo.Color (0 ,0, 0, 0)); Cairo.Color color = (Mono.TextEditor.HslColor)Style.Light (StateType.Normal); color.A = 0.2; gradient.AddColorStop (1, color); cr.Pattern = gradient; cr.Fill (); } cr.LineWidth = 1; CairoExtensions.RoundedRectangle (cr, 0.5, 0.5, Allocation.Width-1, Allocation.Height - 1, r, corners); cr.Color = (Mono.TextEditor.HslColor)Style.Dark (StateType.Normal); cr.Stroke (); using (var layout = new Pango.Layout (PangoContext)) { layout.SetMarkup (Label); int w, h; layout.GetPixelSize (out w, out h); const int padding = 4; cr.MoveTo (expanderBounds.Right + padding, (Allocation.Height - h) / 2); cr.Color = new Cairo.Color (0, 0, 0); cr.ShowLayout (layout); } DrawCloseButton (cr); } var state2 = mouseOver && !IsCloseSelected ? StateType.Prelight : StateType.Normal; Style.PaintExpander (Style, evnt.Window, state2, evnt.Region.Clipbox, this, "expander", expanderBounds.X + expanderBounds.Width / 2, expanderBounds.Y + expanderBounds.Width / 2, expanderStyle); return true; }