From 3115ab647033b1a6faa3640c6215613210f8762f Mon Sep 17 00:00:00 2001 From: Omer Goshen Date: Sat, 19 Jul 2025 20:12:30 +0300 Subject: [PATCH] Add an abstract base class for chart background --- src/background.vala | 16 ++++++++++++---- src/chart.vala | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/background.vala b/src/background.vala index c7fc239..27cb47f 100644 --- a/src/background.vala +++ b/src/background.vala @@ -1,10 +1,18 @@ using Cairo; namespace LiveChart { - public class Background : Drawable, Object { + + public abstract class AbstractBackground : Drawable, Colorable, Object { + public abstract bool visible { get; set; default = true; } + public abstract Gdk.RGBA main_color { get; set; } + public abstract void draw(Context ctx, Config config); + + } + + public class Background : AbstractBackground { private BackgroundDrawer drawer = new BackgroundDrawer(); - public bool visible { get; set; default = true; } + public override bool visible { get; set; default = true; } public Gdk.RGBA color { get { @@ -16,7 +24,7 @@ namespace LiveChart { } [Version (deprecated = true, deprecated_since = "1.8.0", replacement = "Background.color")] - public Gdk.RGBA main_color { + public override Gdk.RGBA main_color { get; set; default = Gdk.RGBA() { red = 0.1f, green = 0.1f, @@ -25,7 +33,7 @@ namespace LiveChart { }; } - public void draw(Context ctx, Config config) { + public override void draw(Context ctx, Config config) { if (visible) { drawer.draw(ctx, config, this.color); } diff --git a/src/chart.vala b/src/chart.vala index 613a7a2..a0194b1 100644 --- a/src/chart.vala +++ b/src/chart.vala @@ -12,7 +12,7 @@ namespace LiveChart { private Cairo.Context? cairo_context = null; public Grid grid { get; set; default = new Grid(); } - public Background background { get; set; default = new Background(); } + public AbstractBackground background { get; set; default = new Background(); } public Legend legend { get; set; default = new HorizontalLegend(); } public Config config; public Series series;