protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.Translate(Allocation.X, Allocation.Y); g.LineWidth = 1; titleLayout.SetMarkup(TitleText); int width, height; titleLayout.GetPixelSize(out width, out height); var tw = SupportsAlpha ? triangleWidth : 0; var th = SupportsAlpha ? triangleHeight : 0; width += xDescriptionBorder * 2; if (SupportsAlpha) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, true, tw + 0.5, 0.5, 12, Allocation.Width - 1 - tw, Allocation.Height); } else { g.Rectangle(0, 0, Allocation.Width, Allocation.Height); } g.SetSourceColor(Styles.InsertionCursorBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.InsertionCursorBorderColor.ToCairoColor()); g.Stroke(); g.MoveTo(tw + xDescriptionBorder, yTitleBorder); g.SetSourceColor(Styles.InsertionCursorTitleTextColor.ToCairoColor()); g.ShowLayout(titleLayout); if (SupportsAlpha) { g.MoveTo(tw, Allocation.Height / 2 - th / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(tw, Allocation.Height / 2 + th / 2); g.LineTo(tw + 5, Allocation.Height / 2 + th / 2); g.LineTo(tw + 5, Allocation.Height / 2 - th / 2); g.ClosePath(); g.SetSourceColor(Styles.InsertionCursorBackgroundColor.ToCairoColor()); g.Fill(); g.MoveTo(tw, Allocation.Height / 2 - th / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(tw, Allocation.Height / 2 + th / 2); g.SetSourceColor(Styles.InsertionCursorBorderColor.ToCairoColor()); g.Stroke(); } int y = height + yTitleBorder + yDescriptionBorder; int x = tw + xDescriptionBorder; g.SetSourceColor(Styles.InsertionCursorTextColor.ToCairoColor()); foreach (var desc in descTexts) { desc.Render(g, x, y + 4); y += desc.Height + 8; } } return(base.OnExposeEvent(args)); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { // var alloc = Allocation; double border = 1.0; // var halfBorder = border / 2.0; using (var cr = Gdk.CairoHelper.Create(evnt.Window)) { cr.LineWidth = border; cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); cr.Color = document.Editor.ColorStyle.Default.CairoBackgroundColor; cr.Fill(); FoldingScreenbackgroundRenderer.DrawRoundRectangle(cr, true, true, 0, 0, Allocation.Width / 2, Allocation.Width, Allocation.Height); cr.Color = isMouseInside || menuPushed ? document.Editor.ColorStyle.Default.CairoColor : document.Editor.ColorStyle.FoldLine.CairoColor; cr.Stroke(); evnt.Window.DrawPixbuf(Style.BaseGC(State), icon, 0, 0, (Allocation.Width - icon.Width) / 2, (Allocation.Height - icon.Height) / 2, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0); } return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { // var alloc = Allocation; double border = 1.0; // var halfBorder = border / 2.0; using (var cr = Gdk.CairoHelper.Create(evnt.Window)) { cr.LineWidth = border; cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); cr.Color = document.Editor.ColorStyle.PlainText.Background; cr.Fill(); FoldingScreenbackgroundRenderer.DrawRoundRectangle(cr, true, true, 0, 0, Allocation.Width / 2, Allocation.Width, Allocation.Height); cr.Color = isMouseInside || menuPushed ? document.Editor.ColorStyle.PlainText.Foreground : document.Editor.ColorStyle.FoldLineColor.Color; cr.Stroke(); Gdk.CairoHelper.SetSourcePixbuf(cr, icon, (Allocation.Width - icon.Width) / 2, (Allocation.Height - icon.Height) / 2); cr.Paint(); } return(true); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.SetSourceRGBA(1, 1, 1, 0); g.Operator = Cairo.Operator.Source; g.Paint(); } using (var g = Gdk.CairoHelper.Create(args.Window)) { g.LineWidth = 1.5; titleLayout.SetMarkup(TitleText); int width, height; titleLayout.GetPixelSize(out width, out height); width += xDescriptionBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, triangleWidth + 0.5, 0.5, height + yTitleBorder * 2 + 1.5, Allocation.Width - 1 - triangleWidth, height + yTitleBorder * 2); g.Color = titleBgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(triangleWidth + xDescriptionBorder, yTitleBorder); g.Color = titleTextColor; g.ShowLayout(titleLayout); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, triangleWidth + 0.5, height + yTitleBorder * 2 + 0.5, height, Allocation.Width - 1 - triangleWidth, Allocation.Height - height - yTitleBorder * 2 - 1); g.Color = bgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(triangleWidth, Allocation.Height / 2 - triangleHeight / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(triangleWidth, Allocation.Height / 2 + triangleHeight / 2); g.LineTo(triangleWidth + 5, Allocation.Height / 2 + triangleHeight / 2); g.LineTo(triangleWidth + 5, Allocation.Height / 2 - triangleHeight / 2); g.ClosePath(); g.Color = bgColor; g.Fill(); g.MoveTo(triangleWidth, Allocation.Height / 2 - triangleHeight / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(triangleWidth, Allocation.Height / 2 + triangleHeight / 2); g.Color = borderColor; g.Stroke(); int y = height + yTitleBorder * 2 + yDescriptionBorder; g.MoveTo(triangleWidth + xDescriptionBorder, y); g.Color = textColor; g.ShowLayout(descriptionLayout); } return(false); }
public void Render(Cairo.Context cr, double _x, double _y, int max_height) { double x = _x; double y = _y; int w = Width; int h = max_height; int inner_padding = 0; if (Outlined) { x -= outlinePadding; y -= outlinePadding; w += outlinePadding * 2; h += outlinePadding * 2; cr.MoveTo(x, y); cr.LineWidth = 1; cr.SetSourceColor(Styles.ModeHelpWindowTokenOutlineColor.ToCairoColor()); if (Symbol == SymbolTokenType.None) { inner_padding = textInnerPadding; } // -0.5f to fix the @1x stroke problem: // 1px stroke is rendered on the center of the shape edge, resulting in // two semitransparent pixels. Even worse the rounded rectangle renders // transparency artifacts on edge overlaps. See http://vncr.in/atks FoldingScreenbackgroundRenderer.DrawRoundRectangle(cr, true, true, x - inner_padding - 0.5f, y - 0.5f, 8, w + inner_padding * 2 + 1, h + 1); cr.Stroke(); if (Symbol == SymbolTokenType.Down) { RenderTriangleDown(cr, x + 4, y + 3, 8, 6); } else if (Symbol == SymbolTokenType.Up) { RenderTriangleUp(cr, x + 4, y + 3, 8, 6); } else { cr.MoveTo(x + outlinePadding, y + (max_height - Height - 0.5)); cr.ShowLayout(layout); } } else { cr.MoveTo(x, y); cr.SetSourceColor(Styles.ModeHelpWindowTokenTextColor.ToCairoColor()); cr.ShowLayout(layout); } }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.Translate(Allocation.X, Allocation.Y); g.LineWidth = 1; Gdk.GC gc = new Gdk.GC(args.Window); layout.SetMarkup(TitleText); int width, height; layout.GetPixelSize(out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.SetSourceColor(Styles.TableLayoutModeTitleBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xBorder, yBorder); g.ShowLayout(layout); g.Restore(); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.SetSourceColor(Styles.TableLayoutModeBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.MoveTo(xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo(xSpacer + 0.5, Allocation.Height - 1); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair <string, string> pair = Items[i]; layout.SetMarkup(pair.Key); layout.GetPixelSize(out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.SetSourceColor(Styles.TableLayoutModeCategoryBackgroundColor.ToCairoColor()); g.FillPreserve(); g.SetSourceColor(Styles.TableLayoutModeBorderColor.ToCairoColor()); g.Stroke(); g.MoveTo(xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo(xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); } gc.RgbFgColor = (HslColor)(i == 0 ? Styles.TableLayoutModeBackgroundColor : Styles.TableLayoutModeTextColor).ToCairoColor(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xBorder, y); g.ShowLayout(layout); g.Restore(); g.Save(); g.SetSourceColor(Styles.TableLayoutModeTextColor.ToCairoColor()); g.Translate(xSpacer + xBorder, y); layout.SetMarkup(pair.Value); g.ShowLayout(layout); g.Restore(); // draw top line if (i > 0) { g.MoveTo(1, y + 0.5); g.LineTo(Allocation.Width - 1, y + 0.5); g.SetSourceColor(Styles.TableLayoutModeGridColor.ToCairoColor()); g.Stroke(); } y += height; } gc.Dispose(); } return(base.OnExposeEvent(args)); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.SetSourceRGBA(1, 1, 1, 0); g.Operator = Cairo.Operator.Source; g.Paint(); } Cairo.Color bgColor = new Cairo.Color(1, 1, 1); Cairo.Color titleBgColor = new Cairo.Color(0.88, 0.88, 0.98); Cairo.Color categoryBgColor = new Cairo.Color(0.58, 0.58, 0.98); Cairo.Color borderColor = new Cairo.Color(0.4, 0.4, 0.6); Cairo.Color textColor = new Cairo.Color(0.3, 0.3, 1); Cairo.Color gridColor = new Cairo.Color(0.8, 0.8, 0.8); using (var g = Gdk.CairoHelper.Create(args.Window)) { g.LineWidth = 1; Gdk.GC gc = new Gdk.GC(args.Window); layout.SetMarkup(TitleText); int width, height; layout.GetPixelSize(out width, out height); width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2); g.Color = titleBgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); gc.RgbFgColor = (HslColor)textColor; args.Window.DrawLayout(gc, xBorder, yBorder, layout); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1); g.Color = bgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(xSpacer + 0.5, height * 2 + yBorder * 2); g.LineTo(xSpacer + 0.5, Allocation.Height - 1); g.Color = gridColor; g.Stroke(); int y = height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair <string, string> pair = Items[i]; layout.SetMarkup(pair.Key); layout.GetPixelSize(out width, out height); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height); g.Color = categoryBgColor; g.FillPreserve(); g.Color = borderColor; g.Stroke(); g.MoveTo(xSpacer + 0.5, height + yBorder * 2 + 1); g.LineTo(xSpacer + 0.5, height * 2 + yBorder * 2 + 1); g.Color = gridColor; g.Stroke(); } gc.RgbFgColor = (HslColor)(i == 0 ? bgColor : textColor); args.Window.DrawLayout(gc, xBorder, y, layout); layout.SetMarkup(pair.Value); args.Window.DrawLayout(gc, xSpacer + xBorder, y, layout); // draw top line if (i > 0) { g.MoveTo(1, y + 0.5); g.LineTo(Allocation.Width - 1, y + 0.5); g.Color = gridColor; g.Stroke(); } y += height; } gc.Dispose(); } GtkWorkarounds.UpdateNativeShadow(this); return(false); }
protected override void OnDraw(Context g, Rectangle bound) { g.Translate(Bounds.X, Bounds.Y); g.SetLineWidth(1.5); titleLayout.Markup = TitleText; var size = titleLayout.GetSize(); var tw = SupportsAlpha ? triangleWidth : 0; var th = SupportsAlpha ? triangleHeight : 0; size.Width += xDescriptionBorder * 2; if (SupportsAlpha) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, tw + 0.5, 0.5, size.Height + yTitleBorder * 2 + 1.5, Bounds.Width - 1 - tw, size.Height + yTitleBorder * 2); } else { g.Rectangle(0, 0, Bounds.Width, size.Height + yTitleBorder * 2); } g.SetSourceColor(titleBgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); g.MoveTo(tw + xDescriptionBorder, yTitleBorder); g.SetSourceColor(titleTextColor); g.ShowLayout(titleLayout); if (SupportsAlpha) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, tw + 0.5, size.Height + yTitleBorder * 2 + 0.5, size.Height, Bounds.Width - 1 - tw, Bounds.Height - size.Height - yTitleBorder * 2 - 1); } else { g.Rectangle(0, size.Height + yTitleBorder * 2, Bounds.Width, Bounds.Height - size.Height - yTitleBorder * 2); } g.SetSourceColor(bgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); if (SupportsAlpha) { g.MoveTo(tw, Bounds.Height / 2 - th / 2); g.LineTo(0, Bounds.Height / 2); g.LineTo(tw, Bounds.Height / 2 + th / 2); g.LineTo(tw + 5, Bounds.Height / 2 + th / 2); g.LineTo(tw + 5, Bounds.Height / 2 - th / 2); g.ClosePath(); g.SetSourceColor(bgColor); g.Fill(); g.MoveTo(tw, Bounds.Height / 2 - th / 2); g.LineTo(0, Bounds.Height / 2); g.LineTo(tw, Bounds.Height / 2 + th / 2); g.SetSourceColor(borderColor); g.Stroke(); } var y = size.Height + yTitleBorder * 2 + yDescriptionBorder; g.MoveTo(tw + xDescriptionBorder, y); g.SetSourceColor(textColor); g.ShowLayout(descriptionLayout); base.OnDraw(g, bound); }
protected override void OnDraw(Context g, Rectangle bound) { Color bgColor = new Color(1, 1, 1); Color titleBgColor = new Color(0.88, 0.88, 0.98); Color categoryBgColor = new Color(0.58, 0.58, 0.98); Color borderColor = new Color(0.4, 0.4, 0.6); Color textColor = new Color(0.3, 0.3, 1); Color gridColor = new Color(0.8, 0.8, 0.8); g.Translate(Bounds.X, Bounds.Y); g.SetLineWidth(1); layout.Markup = TitleText; var size = layout.GetSize(); size.Width += xBorder * 2; FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, 0.5, 0.5, size.Height + yBorder * 2 + 1.5, size.Width, size.Height + yBorder * 2); g.SetSourceColor(titleBgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); g.Save(); g.SetSourceColor(textColor); g.Translate(xBorder, yBorder); g.ShowLayout(layout); g.Restore(); FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, 0.5, size.Height * 2 + yBorder * 2 + 0.5, size.Height, Bounds.Width - 1, Bounds.Height - size.Height * 2 - yBorder * 2 - 1); g.SetSourceColor(bgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); g.MoveTo(xSpacer + 0.5, size.Height * 2 + yBorder * 2); g.LineTo(xSpacer + 0.5, Bounds.Height - 1); g.SetSourceColor(gridColor); g.Stroke(); var y = size.Height + yBorder * 2; for (int i = 0; i < Items.Count; i++) { KeyValuePair <string, string> pair = Items[i]; layout.Markup = pair.Key; size = layout.GetSize(); if (i == 0) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, false, false, 0, y + 0.5, size.Height + 1.5, Bounds.Width, size.Height); g.SetSourceColor(categoryBgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); g.MoveTo(xSpacer + 0.5, size.Height + yBorder * 2 + 1); g.LineTo(xSpacer + 0.5, size.Height * 2 + yBorder * 2 + 1); g.SetSourceColor(gridColor); g.Stroke(); } //gc.RgbFgColor = (HslColor)(i == 0 ? bgColor : textColor); g.Save(); g.SetSourceColor(textColor); g.Translate(xBorder, y); g.ShowLayout(layout); g.Restore(); g.Save(); g.SetSourceColor(textColor); g.Translate(xSpacer + xBorder, y); layout.Markup = pair.Value; g.ShowLayout(layout); g.Restore(); // draw top line if (i > 0) { g.MoveTo(1, y + 0.5); g.LineTo(Bounds.Width - 1, y + 0.5); g.SetSourceColor(gridColor); g.Stroke(); } y += size.Height; } base.OnDraw(g, bound); }
protected override bool OnExposeEvent(Gdk.EventExpose args) { using (var g = Gdk.CairoHelper.Create(args.Window)) { g.Translate(Allocation.X, Allocation.Y); g.LineWidth = 1.5; titleLayout.SetMarkup(TitleText); int width, height; titleLayout.GetPixelSize(out width, out height); var tw = SupportsAlpha ? triangleWidth : 0; var th = SupportsAlpha ? triangleHeight : 0; width += xDescriptionBorder * 2; if (SupportsAlpha) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, true, false, tw + 0.5, 0.5, height + yTitleBorder * 2 + 1.5, Allocation.Width - 1 - tw, height + yTitleBorder * 2); } else { g.Rectangle(0, 0, Allocation.Width, height + yTitleBorder * 2); } g.SetSourceColor(titleBgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); g.MoveTo(tw + xDescriptionBorder, yTitleBorder); g.SetSourceColor(titleTextColor); g.ShowLayout(titleLayout); if (SupportsAlpha) { FoldingScreenbackgroundRenderer.DrawRoundRectangle(g, false, true, tw + 0.5, height + yTitleBorder * 2 + 0.5, height, Allocation.Width - 1 - tw, Allocation.Height - height - yTitleBorder * 2 - 1); } else { g.Rectangle(0, height + yTitleBorder * 2, Allocation.Width, Allocation.Height - height - yTitleBorder * 2); } g.SetSourceColor(bgColor); g.FillPreserve(); g.SetSourceColor(borderColor); g.Stroke(); if (SupportsAlpha) { g.MoveTo(tw, Allocation.Height / 2 - th / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(tw, Allocation.Height / 2 + th / 2); g.LineTo(tw + 5, Allocation.Height / 2 + th / 2); g.LineTo(tw + 5, Allocation.Height / 2 - th / 2); g.ClosePath(); g.SetSourceColor(bgColor); g.Fill(); g.MoveTo(tw, Allocation.Height / 2 - th / 2); g.LineTo(0, Allocation.Height / 2); g.LineTo(tw, Allocation.Height / 2 + th / 2); g.SetSourceColor(borderColor); g.Stroke(); } int y = height + yTitleBorder * 2 + yDescriptionBorder; g.MoveTo(tw + xDescriptionBorder, y); g.SetSourceColor(textColor); g.ShowLayout(descriptionLayout); } return(base.OnExposeEvent(args)); }