aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-26 18:55:27 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-27 06:45:06 +0200
commitf8465d581c43982ef76ad82c7c792b5e96264475 (patch)
tree96531e6710445d398afa0c170b5c7e90c3f32d9a /src
parente07c21b1f16c79b1801ce1ba1ebd85aff903b660 (diff)
add corner radius to 3d effect on border
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/Border.cs91
1 files changed, 68 insertions, 23 deletions
diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs
index 375d7321..1e502e9a 100644
--- a/src/GraphicObjects/Border.cs
+++ b/src/GraphicObjects/Border.cs
@@ -119,34 +119,79 @@ namespace Crow
CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Fill ();
- if (BorderWidth > 0) {
- Foreground.SetAsSource (gr, rBack);
- CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
- }
-
- if (BorderStyle != BorderStyle.Normal) {
+ if (BorderStyle == BorderStyle.Normal) {
+ if (BorderWidth > 0) {
+ Foreground.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
+ }
+ }else{
gr.LineWidth = 1.0;
- gr.SetSourceColor (sunkenColor);
- gr.MoveTo (0.5 + rBack.Left, rBack.Bottom);
- gr.LineTo (0.5 + rBack.Left, 0.5 + rBack.Y);
- gr.LineTo (rBack.Right, 0.5 + rBack.Y);
- if (BorderStyle == BorderStyle.Raised) {
- gr.MoveTo (-1.5 + rBack.Right, 2.0 + rBack.Y);
- gr.LineTo (-1.5 + rBack.Right, -1.5 + rBack.Bottom);
- gr.LineTo (2.0 + rBack.Left, -1.5 + rBack.Bottom);
+ if (CornerRadius > 0.0) {
+ double radius = CornerRadius;
+ if ((radius > rBack.Height / 2.0) || (radius > rBack.Width / 2.0))
+ radius = Math.Min(rBack.Height / 2.0, rBack.Width / 2.0);
+ gr.SetSourceColor (sunkenColor);
+ gr.MoveTo(0.5 + rBack.Left, -0.5 + rBack.Bottom - radius);
+ gr.ArcNegative (0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius, Math.PI, Math.PI * 0.75);
+ gr.MoveTo(0.5 + rBack.Left, -0.5 + rBack.Bottom - radius);
+ gr.LineTo(0.5 + rBack.Left, 0.5 + rBack.Top + radius);
+ gr.Arc (0.5 + rBack.Left + radius, 0.5 + rBack.Top + radius, radius, Math.PI , Math.PI*1.5);
+ gr.LineTo(-0.5 + rBack.Right - radius, 0.5 + rBack.Top);
+ gr.Arc (-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius, Math.PI*1.5 , Math.PI*1.75);
+ gr.Stroke();
+ if (BorderStyle == BorderStyle.Raised) {
+ gr.MoveTo (-1.5 + rBack.Right , 1.5 + rBack.Top + radius);
+ gr.ArcNegative (-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius-1.0, 0, -Math.PI * 0.25);
+ gr.MoveTo (-1.5 + rBack.Right , 1.5 + rBack.Top + radius);
+ gr.LineTo (-1.5 + rBack.Right , -1.5 + rBack.Bottom - radius);
+ gr.Arc (-0.5 + rBack.Right -radius, -0.5 + rBack.Bottom - radius, radius-1.0, 0, Math.PI /2.0);
+ gr.LineTo (1.5 + rBack.Left + radius, -1.5 + rBack.Bottom);
+ gr.Arc (0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius-1.0, Math.PI / 2.0, Math.PI*0.75 );
+ gr.Stroke ();
+
+ gr.SetSourceColor (raiseColor);
+ gr.MoveTo (1.5 + rBack.Left, -1.5 + rBack.Bottom - radius);
+ gr.ArcNegative (0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius - 1.0, Math.PI, Math.PI * 0.75);
+ gr.MoveTo (1.5 + rBack.Left, -1.5 + rBack.Bottom - radius);
+ gr.LineTo (1.5 + rBack.Left, 1.5 + rBack.Top + radius);
+ gr.Arc (0.5 + rBack.Left + radius, 0.5 + rBack.Top + radius, radius - 1.0, Math.PI, Math.PI * 1.5);
+ gr.LineTo (-1.5 + rBack.Right - radius, 1.5 + rBack.Top);
+ gr.Arc (-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius - 1.0, Math.PI * 1.5, Math.PI * 1.75);
+ } else {
+ gr.Stroke ();
+ gr.SetSourceColor (raiseColor);
+ }
+ gr.MoveTo (-0.5 + rBack.Right , 0.5 + rBack.Top + radius);
+ gr.ArcNegative (-0.5 + rBack.Right - radius, 0.5 + rBack.Top + radius, radius, 0, -Math.PI * 0.25);
+ gr.MoveTo (-0.5 + rBack.Right , 0.5 + rBack.Top + radius);
+ gr.LineTo (-0.5 + rBack.Right , -0.5 + rBack.Bottom - radius);
+ gr.Arc (-0.5 + rBack.Right -radius, -0.5 + rBack.Bottom - radius, radius, 0, Math.PI /2.0);
+ gr.LineTo (0.5 + rBack.Left + radius, -0.5 + rBack.Bottom);
+ gr.Arc (0.5 + rBack.Left + radius, -0.5 + rBack.Bottom - radius, radius, Math.PI / 2.0, Math.PI*0.75 );
gr.Stroke ();
- gr.SetSourceColor (raiseColor);
- gr.MoveTo (1.5 + rBack.Left, -1.0 + rBack.Bottom);
- gr.LineTo (1.5 + rBack.Left, 1.5 + rBack.Y);
- gr.LineTo (rBack.Right, 1.5 + rBack.Y);
} else {
+ gr.SetSourceColor (sunkenColor);
+ gr.MoveTo (0.5 + rBack.Left, rBack.Bottom);
+ gr.LineTo (0.5 + rBack.Left, 0.5 + rBack.Y);
+ gr.LineTo (rBack.Right, 0.5 + rBack.Y);
+ if (BorderStyle == BorderStyle.Raised) {
+ gr.MoveTo (-1.5 + rBack.Right, 2.0 + rBack.Y);
+ gr.LineTo (-1.5 + rBack.Right, -1.5 + rBack.Bottom);
+ gr.LineTo (2.0 + rBack.Left, -1.5 + rBack.Bottom);
+ gr.Stroke ();
+ gr.SetSourceColor (raiseColor);
+ gr.MoveTo (1.5 + rBack.Left, -1.0 + rBack.Bottom);
+ gr.LineTo (1.5 + rBack.Left, 1.5 + rBack.Y);
+ gr.LineTo (rBack.Right, 1.5 + rBack.Y);
+ } else {
+ gr.Stroke ();
+ gr.SetSourceColor (raiseColor);
+ }
+ gr.MoveTo (-0.5 + rBack.Right, 1.5 + rBack.Y);
+ gr.LineTo (-0.5 + rBack.Right, -0.5 + rBack.Bottom);
+ gr.LineTo (1.0 + rBack.Left, -0.5 + rBack.Bottom);
gr.Stroke ();
- gr.SetSourceColor (raiseColor);
}
- gr.MoveTo (-0.5 + rBack.Right, 1.5 + rBack.Y);
- gr.LineTo (-0.5 + rBack.Right, -0.5 + rBack.Bottom);
- gr.LineTo (1.0 + rBack.Left, -0.5 + rBack.Bottom);
- gr.Stroke ();
}
gr.Save ();