//private double last_invalidate_value = -1; /*private void Invalidate () * { * double current_value = (IsValueUpdatePending ? PendingValue : Value); * * // FIXME: Something is wrong with the updating below causing an * // invalid region when IsValueUpdatePending is true, so when * // that is the case for now, we trigger a full invalidation * if (last_invalidate_value < 0 || IsValueUpdatePending) { * last_invalidate_value = current_value; * InvalidateRender (); * return; * } * * double max = Math.Max (last_invalidate_value, current_value) * RenderSize.Width; * double min = Math.Min (last_invalidate_value, current_value) * RenderSize.Width; * * Rect region = new Rect ( * InvalidationRect.X + min, * InvalidationRect.Y, * (max - min) + 2 * ThrobberSize, * InvalidationRect.Height * ); * * last_invalidate_value = current_value; * InvalidateRender (region); * }*/ /*protected override Rect InvalidationRect { * get { return new Rect ( * -Margin.Left - ThrobberSize / 2, * -Margin.Top, * Allocation.Width + ThrobberSize, * Allocation.Height); * } * }*/ protected override void ClippedRender(Cairo.Context cr) { double throbber_r = ThrobberSize / 2.0; double throbber_x = Math.Round(RenderSize.Width * (IsValueUpdatePending ? PendingValue : Value)); double throbber_y = (Allocation.Height - ThrobberSize) / 2.0 - Margin.Top + throbber_r; double bar_w = RenderSize.Width * Value; cr.SetSourceColor(Theme.Colors.GetWidgetColor(GtkColorClass.Base, Gtk.StateType.Normal)); cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height); cr.Fill(); Color color = Theme.Colors.GetWidgetColor(GtkColorClass.Dark, Gtk.StateType.Active); Color fill_color = CairoExtensions.ColorShade(color, 0.4); Color light_fill_color = CairoExtensions.ColorShade(color, 0.3); fill_color.A = 1.0; light_fill_color.A = 1.0; LinearGradient fill = new LinearGradient(0, 0, 0, RenderSize.Height); fill.AddColorStop(0, light_fill_color); fill.AddColorStop(0.5, fill_color); fill.AddColorStop(1, light_fill_color); cr.Rectangle(0, 0, bar_w, RenderSize.Height); cr.SetSource(fill); cr.Fill(); cr.SetSourceColor(fill_color); cr.Arc(throbber_x, throbber_y, throbber_r, 0, Math.PI * 2); cr.Fill(); }
public void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc) { /*Cairo.Color gtk_background_color = Colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal); * Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1); * Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95); * * CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight; * * LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom); * grad.AddColorStop (0, light_color); * grad.AddColorStop (0.75, dark_color); * grad.AddColorStop (0, light_color); * * cr.Pattern = grad; * CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners); * cr.Fill (); * * cr.Color = border_color; * cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth); * cr.Fill (); * grad.Destroy ();*/ Cairo.Color gtk_background_color = CairoExtensions.GdkRGBAToCairoColor(widget.StyleContext.GetBackgroundColor(StateFlags.Normal)); Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.80); cr.SetSourceColor(dark_color); cr.MoveTo(alloc.X, alloc.Bottom + 0.5); cr.LineTo(alloc.Right, alloc.Bottom + 0.5); cr.LineWidth = 1.0; cr.Stroke(); }
public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners) { color.A *= 0.85; Cairo.Color selection_color = color; Cairo.Color selection_stroke = CairoExtensions.ColorShade(selection_color, 0.85); selection_stroke.A = color.A; if (filled) { Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.05); Cairo.Color selection_fill_dark = selection_color; selection_fill_light.A = color.A; selection_fill_dark.A = color.A; LinearGradient grad = new LinearGradient(x, y, x, y + height); grad.AddColorStop(0, selection_fill_dark); grad.AddColorStop(1, selection_fill_light); cr.SetSource(grad); cr.Rectangle(x, y, width, height); cr.Fill(); grad.Dispose(); } if (stroked && !filled) { cr.LineWidth = 1.0; cr.SetSourceColor(selection_stroke); cr.Rectangle(x + 0.5, y + 0.5, width - 1, height - 1); cr.Stroke(); } }
private void PaintDraggingColumn(Cairo.Context cr) { if (!pressed_column_is_dragging || pressed_column_index < 0) { return; } CachedColumn column = column_cache[pressed_column_index]; int x = pressed_column_x_drag + 1 - HadjustmentValue; StyleContext.Save(); StyleContext.AddClass("entry"); Cairo.Color fill_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Normal)); Cairo.Color stroke_color = CairoExtensions.ColorShade(fill_color, 0.0); fill_color.A = 0.45; stroke_color.A = 0.3; StyleContext.Restore(); cr.Rectangle(x, header_rendering_alloc.Bottom + 1, column.Width - 2, list_rendering_alloc.Bottom - header_rendering_alloc.Bottom - 1); cr.Color = fill_color; cr.Fill(); cr.MoveTo(x - 0.5, header_rendering_alloc.Bottom + 0.5); cr.LineTo(x - 0.5, list_rendering_alloc.Bottom + 0.5); cr.LineTo(x + column.Width - 1.5, list_rendering_alloc.Bottom + 0.5); cr.LineTo(x + column.Width - 1.5, header_rendering_alloc.Bottom + 0.5); cr.Color = stroke_color; cr.LineWidth = 1.0; cr.Stroke(); }
public override void DrawHeaderSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x) { Cairo.Color gtk_background_color = CairoExtensions.GdkRGBAToCairoColor( Widget.StyleContext.GetBackgroundColor(StateFlags.Normal)); Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.80); Cairo.Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1); int y_1 = alloc.Top + 4; int y_2 = alloc.Bottom - 3; cr.LineWidth = 1; cr.Antialias = Cairo.Antialias.None; cr.Color = dark_color; cr.MoveTo(x, y_1); cr.LineTo(x, y_2); cr.Stroke(); cr.Color = light_color; cr.MoveTo(x + 1, y_1); cr.LineTo(x + 1, y_2); cr.Stroke(); cr.Antialias = Cairo.Antialias.Default; }
public override void DrawColumnHeaderFocus(Cairo.Context cr, Gdk.Rectangle alloc) { double top_offset = 2.0; double right_offset = 2.0; double margin = 0.5; double line_width = 0.7; Cairo.Color stroke_color = CairoExtensions.ColorShade( CairoExtensions.GdkRGBAToCairoColor( Widget.StyleContext.GetBackgroundColor(StateFlags.Selected)), 0.8); stroke_color.A = 0.1; cr.Color = stroke_color; CairoExtensions.RoundedRectangle(cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (margin + line_width) * 2.0 - right_offset, alloc.Height - (margin + line_width) * 2.0 - top_offset, Context.Radius / 2.0, CairoCorners.None); cr.Fill(); stroke_color.A = 1.0; cr.LineWidth = line_width; cr.Color = stroke_color; CairoExtensions.RoundedRectangle(cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (line_width + margin) * 2.0 - right_offset, alloc.Height - (line_width + margin) * 2.0 - right_offset, Context.Radius / 2.0, CairoCorners.All); cr.Stroke(); }
public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill) { var selection_color = color; var selection_highlight = CairoExtensions.ColorShade(selection_color, 1.24); var selection_stroke = CairoExtensions.ColorShade(selection_color, 0.85); selection_highlight.A = 0.5; selection_stroke.A = color.A; LinearGradient grad = null; if (filled) { if (flat_fill) { cr.SetSourceColor(selection_color); } else { var selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.12); var selection_fill_dark = selection_color; selection_fill_light.A = color.A; selection_fill_dark.A = color.A; grad = new LinearGradient(x, y, x, y + height); grad.AddColorStop(0, selection_fill_light); grad.AddColorStop(0.4, selection_fill_dark); grad.AddColorStop(1, selection_fill_light); cr.SetSource(grad); } CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true); cr.Fill(); if (grad != null) { grad.Dispose(); } } if (filled && stroked) { cr.LineWidth = 1.0; cr.SetSourceColor(selection_highlight); CairoExtensions.RoundedRectangle(cr, x + 1.5, y + 1.5, width - 3, height - 3, Context.Radius - 1, corners, true); cr.Stroke(); } if (stroked) { cr.LineWidth = 1.0; cr.SetSourceColor(selection_stroke); CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true); cr.Stroke(); } }
protected override void OnColorsRefreshed() { base.OnColorsRefreshed(); rule_color = CairoExtensions.ColorShade(ViewFill, 0.95); border_color = Colors.GetWidgetColor(GtkColorClass.Dark, StateType.Active); }
public override void DrawColumnHeaderFocus(Cairo.Context cr, Gdk.Rectangle alloc) { double top_offset = 2.0; double right_offset = 2.0; double margin = 0.5; double line_width = 0.7; var stroke_color = CairoExtensions.ColorShade( Colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected), 0.8); stroke_color.A = 0.1; cr.SetSourceColor(stroke_color); CairoExtensions.RoundedRectangle(cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (margin + line_width) * 2.0 - right_offset, alloc.Height - (margin + line_width) * 2.0 - top_offset, Context.Radius / 2.0, CairoCorners.None); cr.Fill(); stroke_color.A = 1.0; cr.LineWidth = line_width; cr.SetSourceColor(stroke_color); CairoExtensions.RoundedRectangle(cr, alloc.X + margin + line_width + right_offset, alloc.Y + margin + line_width + top_offset, alloc.Width - (line_width + margin) * 2.0 - right_offset, alloc.Height - (line_width + margin) * 2.0 - right_offset, Context.Radius / 2.0, CairoCorners.All); cr.Stroke(); }
//private double last_invalidate_value = -1; /*private void Invalidate () * { * double current_value = (IsValueUpdatePending ? PendingValue : Value); * * // FIXME: Something is wrong with the updating below causing an * // invalid region when IsValueUpdatePending is true, so when * // that is the case for now, we trigger a full invalidation * if (last_invalidate_value < 0 || IsValueUpdatePending) { * last_invalidate_value = current_value; * InvalidateRender (); * return; * } * * double max = Math.Max (last_invalidate_value, current_value) * RenderSize.Width; * double min = Math.Min (last_invalidate_value, current_value) * RenderSize.Width; * * Rect region = new Rect ( * InvalidationRect.X + min, * InvalidationRect.Y, * (max - min) + 2 * ThrobberSize, * InvalidationRect.Height * ); * * last_invalidate_value = current_value; * InvalidateRender (region); * }*/ /*protected override Rect InvalidationRect { * get { return new Rect ( * -Margin.Left - ThrobberSize / 2, * -Margin.Top, * Allocation.Width + ThrobberSize, * Allocation.Height); * } * }*/ protected override void ClippedRender(Cairo.Context cr) { double throbber_r = ThrobberSize / 2.0; double throbber_x = Math.Round(RenderSize.Width * (IsValueUpdatePending ? PendingValue : Value)); double throbber_y = (Allocation.Height - ThrobberSize) / 2.0 - Margin.Top + throbber_r; double bar_w = RenderSize.Width * Value; Theme.Widget.StyleContext.Save(); Theme.Widget.StyleContext.AddClass("entry"); Theme.Widget.StyleContext.RenderBackground(cr, 0, 0, RenderSize.Width, RenderSize.Height); var color = CairoExtensions.GdkRGBAToCairoColor(Theme.Widget.StyleContext.GetColor(Gtk.StateFlags.Active)); Theme.Widget.StyleContext.Restore(); // TODO get Dark color Color fill_color = CairoExtensions.ColorShade(color, 0.4); Color light_fill_color = CairoExtensions.ColorShade(color, 0.3); fill_color.A = 1.0; light_fill_color.A = 1.0; using (var fill = new LinearGradient(0, 0, 0, RenderSize.Height)) { fill.AddColorStop(0, light_fill_color); fill.AddColorStop(0.5, fill_color); fill.AddColorStop(1, light_fill_color); cr.Rectangle(0, 0, bar_w, RenderSize.Height); cr.SetSource(fill); cr.Fill(); cr.SetSourceColor(fill_color); cr.Arc(throbber_x, throbber_y, throbber_r, 0, Math.PI * 2); cr.Fill(); } }
public override void DrawPie(double fraction) { // Calculate the pie path fraction = Theme.Clamp(0.0, 1.0, fraction); double a1 = 3.0 * Math.PI / 2.0; double a2 = a1 + 2.0 * Math.PI * fraction; if (fraction == 0.0) { return; } Context.Cairo.MoveTo(Context.X, Context.Y); Context.Cairo.Arc(Context.X, Context.Y, Context.Radius, a1, a2); Context.Cairo.LineTo(Context.X, Context.Y); // Fill the pie Color color_a = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected); Color color_b = CairoExtensions.ColorShade(color_a, 1.4); using (RadialGradient fill = new RadialGradient(Context.X, Context.Y, 0, Context.X, Context.Y, 2.0 * Context.Radius)) { fill.AddColorStop(0, color_a); fill.AddColorStop(1, color_b); Context.Cairo.SetSource(fill); Context.Cairo.FillPreserve(); } // Stroke the pie Context.Cairo.SetSourceColor(CairoExtensions.ColorShade(color_a, 0.8)); Context.Cairo.LineWidth = Context.LineWidth; Context.Cairo.Stroke(); }
private void PaintDraggingColumn(Rectangle clip) { if (!pressed_column_is_dragging || pressed_column_index < 0) { return; } CachedColumn column = column_cache[pressed_column_index]; int x = pressed_column_x_drag + Allocation.X + 1 - HadjustmentValue; Cairo.Color fill_color = Theme.Colors.GetWidgetColor(GtkColorClass.Base, StateType.Normal); fill_color.A = 0.45; Cairo.Color stroke_color = CairoExtensions.ColorShade(Theme.Colors.GetWidgetColor( GtkColorClass.Base, StateType.Normal), 0.0); stroke_color.A = 0.3; cairo_context.Rectangle(x, header_rendering_alloc.Bottom + 1, column.Width - 2, list_rendering_alloc.Bottom - header_rendering_alloc.Bottom - 1); cairo_context.Color = fill_color; cairo_context.Fill(); cairo_context.MoveTo(x - 0.5, header_rendering_alloc.Bottom + 0.5); cairo_context.LineTo(x - 0.5, list_rendering_alloc.Bottom + 0.5); cairo_context.LineTo(x + column.Width - 1.5, list_rendering_alloc.Bottom + 0.5); cairo_context.LineTo(x + column.Width - 1.5, header_rendering_alloc.Bottom + 0.5); cairo_context.Color = stroke_color; cairo_context.LineWidth = 1.0; cairo_context.Stroke(); }
public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc) { var corners = CairoCorners.All; double top_extend = 0; double bottom_extend = 0; double left_extend = 0; double right_extend = 0; if (Context.ToplevelBorderCollapse) { if (Widget.Allocation.Top <= Widget.Toplevel.Allocation.Top) { corners &= ~(CairoCorners.TopLeft | CairoCorners.TopRight); top_extend = cr.LineWidth; } if (Widget.Allocation.Bottom >= Widget.Toplevel.Allocation.Bottom) { corners &= ~(CairoCorners.BottomLeft | CairoCorners.BottomRight); bottom_extend = cr.LineWidth; } if (Widget.Allocation.Left <= Widget.Toplevel.Allocation.Left) { corners &= ~(CairoCorners.BottomLeft | CairoCorners.TopLeft); left_extend = cr.LineWidth; } if (Widget.Allocation.Right >= Widget.Toplevel.Allocation.Right) { corners &= ~(CairoCorners.BottomRight | CairoCorners.TopRight); right_extend = cr.LineWidth; } } // FIXME Windows; shading the color by .8 makes it blend into the bg if (Widget.HasFocus && !Hyena.PlatformDetection.IsWindows) { cr.LineWidth = BorderWidth * 1.5; cr.Color = CairoExtensions.ColorShade(border_color, 0.8); } else { cr.LineWidth = BorderWidth; cr.Color = border_color; } double offset = (double)cr.LineWidth / 2.0; CairoExtensions.RoundedRectangle(cr, alloc.X + offset - left_extend, alloc.Y + offset - top_extend, alloc.Width - cr.LineWidth + left_extend + right_extend, alloc.Height - cr.LineWidth - top_extend + bottom_extend, Context.Radius, corners); cr.Stroke(); }
LinearGradient MakeSegmentGradient(int h, Color color, bool diag) { var grad = new LinearGradient(0, 0, 0, h); grad.AddColorStop(0, CairoExtensions.ColorShade(color, 1.1)); grad.AddColorStop(0.35, CairoExtensions.ColorShade(color, 1.2)); grad.AddColorStop(1, CairoExtensions.ColorShade(color, 0.8)); return(grad); }
public override void DrawFrameBorderFocused(Cairo.Context cr, Gdk.Rectangle alloc) { cr.LineWidth = BorderWidth * 1.5; cr.SetSourceColor(CairoExtensions.ColorShade(border_color, 0.8)); double offset = (double)cr.LineWidth / 2.0; CairoExtensions.RoundedRectangle(cr, alloc.X + offset, alloc.Y + offset, alloc.Width - cr.LineWidth, alloc.Height - cr.LineWidth, Context.Radius, CairoCorners.All); cr.Stroke(); }
private void SetBackground() { Cairo.Color light = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Normal)); Cairo.Color dark = CairoExtensions.ColorShade(light, 0.85); Cairo.LinearGradient grad = new Cairo.LinearGradient(0, Allocation.Y, 0, Allocation.Y + Allocation.Height); grad.AddColorStop(0, dark); grad.AddColorStop(1, light); FillPattern = grad; }
protected override void OnColorsRefreshed() { base.OnColorsRefreshed(); rule_color = CairoExtensions.ColorShade(ViewFill, 0.95); // On Windows we use Normal b/c Active incorrectly returns black (at least on XP) border_color = Colors.GetWidgetColor(GtkColorClass.Dark, Hyena.PlatformDetection.IsWindows ? StateType.Normal : StateType.Active ); }
protected override void OnColorsRefreshed() { base.OnColorsRefreshed(); rule_color = CairoExtensions.ColorShade(ViewFill, 0.95); // On Windows we use Normal b/c Active incorrectly returns black (at least on XP) // TODO: Check if this is still needed with GTK 3 border_color = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBorderColor( Hyena.PlatformDetection.IsWindows ? StateFlags.Normal : StateFlags.Active)); }
private void PaintHeaderCell(Cairo.Context cr, Rectangle area, int ci, bool dragging, ref bool have_drawn_separator) { if (ci < 0 || column_cache.Length <= ci) { return; } if (ci == ActiveColumn && HasFocus && HeaderFocused) { Theme.DrawColumnHeaderFocus(cr, area); } if (dragging) { Cairo.Color dark_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Normal)); dark_color = CairoExtensions.ColorShade(dark_color, 0.7); Theme.DrawColumnHighlight(cr, area, dark_color); StyleContext.Save(); StyleContext.AddClass("entry"); Cairo.Color base_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Normal)); StyleContext.Restore(); Cairo.Color stroke_color = CairoExtensions.ColorShade(base_color, 0.0); stroke_color.A = 0.3; cr.Color = stroke_color; cr.MoveTo(area.X + 0.5, area.Y + 1.0); cr.LineTo(area.X + 0.5, area.Bottom); cr.MoveTo(area.Right - 0.5, area.Y + 1.0); cr.LineTo(area.Right - 0.5, area.Bottom); cr.Stroke(); } ColumnCell cell = column_cache[ci].Column.HeaderCell; if (cell != null) { cr.Save(); cr.Translate(area.X, area.Y); cell_context.Area = area; cell_context.State = StateFlags.Normal; cell.Render(cell_context, area.Width, area.Height); cr.Restore(); } if (!dragging && ci < column_cache.Length - 1 && (have_drawn_separator || column_cache[ci].MaxWidth != column_cache[ci].MinWidth)) { have_drawn_separator = true; Theme.DrawHeaderSeparator(cr, area, area.Right); } }
protected override void OnColorsRefreshed() { base.OnColorsRefreshed(); if (widget == null) { return; } rule_color = CairoExtensions.ColorShade(CairoExtensions.GdkRGBAToCairoColor(widget.StyleContext.GetBackgroundColor(StateFlags.Normal)), 0.95); border_color = CairoExtensions.GdkRGBAToCairoColor(widget.StyleContext.GetBorderColor(StateFlags.Normal)); }
private void PaintView(Cairo.Context cr, Rect clip) { clip.Intersect((Rect)list_rendering_alloc); cr.Rectangle((Cairo.Rectangle)clip); cr.Clip(); cell_context.Clip = (Gdk.Rectangle)clip; cell_context.TextAsForeground = false; selected_rows.Clear(); for (int layout_index = 0; layout_index < ViewLayout.ChildCount; layout_index++) { var layout_child = ViewLayout[layout_index]; var child_allocation = layout_child.Allocation; if (!child_allocation.IntersectsWith(clip) || ViewLayout.GetModelIndex(layout_child) >= Model.Count) { continue; } if (Selection != null && Selection.Contains(ViewLayout.GetModelIndex(layout_child))) { selected_rows.Add(ViewLayout.GetModelIndex(layout_child)); var selection_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Selected)); if (!HasFocus || HeaderFocused) { selection_color = CairoExtensions.ColorShade(selection_color, 1.1); } Theme.DrawRowSelection(cr, (int)child_allocation.X, (int)child_allocation.Y, (int)child_allocation.Width, (int)child_allocation.Height, true, true, selection_color, CairoCorners.All); cell_context.State = StateFlags.Selected; } else { cell_context.State = StateFlags.Normal; } //cr.Save (); //cr.Translate (child_allocation.X, child_allocation.Y); //cr.Rectangle (0, 0, child_allocation.Width, child_allocation.Height); //cr.Clip (); layout_child.Render(cell_context); //cr.Restore (); } cr.ResetClip(); }
public override void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color) { Color light_color = CairoExtensions.ColorShade(color, 1.6); Color dark_color = CairoExtensions.ColorShade(color, 1.3); using (var 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(); } }
public override 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.Pattern = grad; cr.Rectangle(alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2); cr.Fill(); grad.Destroy(); }
private void PaintHeaderCell(Rectangle area, int ci, bool dragging, ref bool have_drawn_separator) { if (ci < 0 || column_cache.Length <= ci) { return; } if (ci == ActiveColumn && HasFocus && HeaderFocused) { Theme.DrawColumnHeaderFocus(cairo_context, area); } if (dragging) { Theme.DrawColumnHighlight(cairo_context, area, CairoExtensions.ColorShade(Theme.Colors.GetWidgetColor(GtkColorClass.Dark, StateType.Normal), 0.9)); Cairo.Color stroke_color = CairoExtensions.ColorShade(Theme.Colors.GetWidgetColor( GtkColorClass.Base, StateType.Normal), 0.0); stroke_color.A = 0.3; cairo_context.Color = stroke_color; cairo_context.MoveTo(area.X + 0.5, area.Y + 1.0); cairo_context.LineTo(area.X + 0.5, area.Bottom); cairo_context.MoveTo(area.Right - 0.5, area.Y + 1.0); cairo_context.LineTo(area.Right - 0.5, area.Bottom); cairo_context.Stroke(); } ColumnCell cell = column_cache[ci].Column.HeaderCell; if (cell != null) { cairo_context.Save(); cairo_context.Translate(area.X, area.Y); cell_context.Area = area; cell_context.State = StateType.Normal; cell.Render(cell_context, area.Width, area.Height); cairo_context.Restore(); } if (!dragging && ci < column_cache.Length - 1 && (have_drawn_separator || column_cache[ci].MaxWidth != column_cache[ci].MinWidth)) { have_drawn_separator = true; Theme.DrawHeaderSeparator(cairo_context, area, area.Right); } }
public override void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners) { Cairo.Color selection_color = color; Cairo.Color selection_highlight = CairoExtensions.ColorShade(selection_color, 1.24); Cairo.Color selection_stroke = CairoExtensions.ColorShade(selection_color, 0.85); selection_highlight.A = 0.5; selection_stroke.A = color.A; if (filled) { Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.12); Cairo.Color selection_fill_dark = selection_color; selection_fill_light.A = color.A; selection_fill_dark.A = color.A; LinearGradient grad = new LinearGradient(x, y, x, y + height); grad.AddColorStop(0, selection_fill_light); grad.AddColorStop(0.4, selection_fill_dark); grad.AddColorStop(1, selection_fill_light); cr.Pattern = grad; CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true); cr.Fill(); grad.Destroy(); } if (filled && stroked) { cr.LineWidth = 1.0; cr.Color = selection_highlight; CairoExtensions.RoundedRectangle(cr, x + 1.5, y + 1.5, width - 3, height - 3, Context.Radius - 1, corners, true); cr.Stroke(); } if (stroked) { cr.LineWidth = 1.0; cr.Color = selection_stroke; CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true); cr.Stroke(); } }
protected virtual void OnColorsRefreshed() { selection_fill = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Active)); selection_fill = CairoExtensions.ColorShade(selection_fill, 0.8); selection_stroke = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Selected)); Widget.StyleContext.Save(); Widget.StyleContext.AddClass("entry"); view_fill = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Normal)); var text_color = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetColor(StateFlags.Normal)); Widget.StyleContext.Restore(); view_fill_transparent = view_fill; view_fill_transparent.A = 0; text_mid = CairoExtensions.AlphaBlend(view_fill, text_color, 0.5); }
public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc) { Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal); Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1); Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.95); CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight; using (LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom)) { grad.AddColorStop(0, light_color); grad.AddColorStop(0.75, dark_color); grad.AddColorStop(0, light_color); cr.SetSource(grad); CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners); cr.Fill(); } cr.SetSourceColor(border_color); cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth); cr.Fill(); }
public override void DrawHeaderSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x) { Cairo.Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal); Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.8); Cairo.Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1); int y_1 = alloc.Top + 4; int y_2 = alloc.Bottom - 3; cr.LineWidth = 1; cr.Antialias = Antialias.None; cr.SetSourceColor(dark_color); cr.MoveTo(x, y_1); cr.LineTo(x, y_2); cr.Stroke(); cr.SetSourceColor(light_color); cr.MoveTo(x + 1, y_1); cr.LineTo(x + 1, y_2); cr.Stroke(); cr.Antialias = Cairo.Antialias.Default; }
public override void DrawPie(double fraction) { // Calculate the pie path fraction = Theme.Clamp(0.0, 1.0, fraction); double a1 = 3.0 * Math.PI / 2.0; double a2 = a1 + 2.0 * Math.PI * fraction; if (fraction == 0.0) { return; } Context.Cairo.MoveTo(Context.X, Context.Y); Context.Cairo.Arc(Context.X, Context.Y, Context.Radius, a1, a2); Context.Cairo.LineTo(Context.X, Context.Y); // Fill the pie Color color_a = CairoExtensions.GdkRGBAToCairoColor( Widget.StyleContext.GetBackgroundColor(StateFlags.Selected)); Color color_b = CairoExtensions.ColorShade(color_a, 1.4); RadialGradient fill = new RadialGradient(Context.X, Context.Y, 0, Context.X, Context.Y, 2.0 * Context.Radius); fill.AddColorStop(0, color_a); fill.AddColorStop(1, color_b); Context.Cairo.Pattern = fill; Context.Cairo.FillPreserve(); fill.Destroy(); // Stroke the pie Context.Cairo.Color = CairoExtensions.ColorShade(color_a, 0.8); Context.Cairo.LineWidth = Context.LineWidth; Context.Cairo.Stroke(); }
public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc) { Cairo.Color gtk_background_color = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Normal)); Cairo.Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1); Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.95); CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight; LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom); grad.AddColorStop(0, light_color); grad.AddColorStop(0.75, dark_color); grad.AddColorStop(0, light_color); cr.Pattern = grad; CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners); cr.Fill(); cr.Color = border_color; cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth); cr.Fill(); grad.Destroy(); }