[baobab/color-unify: 2/5] Pass the entire item to the color picking function



commit 5044f08bbbc4aeed85af887baf5a154e61848aa3
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Tue Jun 16 11:36:33 2020 +0200

    Pass the entire item to the color picking function

 src/baobab-chart.vala      | 8 ++++----
 src/baobab-ringschart.vala | 4 +---
 src/baobab-treemap.vala    | 6 ++----
 3 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/baobab-chart.vala b/src/baobab-chart.vala
index 1f493f5..3b8b2c2 100644
--- a/src/baobab-chart.vala
+++ b/src/baobab-chart.vala
@@ -430,14 +430,14 @@ namespace Baobab {
             return color;
         }
 
-        protected Gdk.RGBA get_item_color (double rel_position, uint depth, bool highlighted) {
+        protected Gdk.RGBA get_item_color (ChartItem item, double rel_position, bool highlighted) {
             var context = get_style_context ();
 
             var color = Gdk.RGBA ();
 
-            double intensity = 1 - (((depth - 1) * 0.3) / MAX_DEPTH);
+            double intensity = 1 - (((item.depth - 1) * 0.3) / MAX_DEPTH);
 
-            if (depth == 0) {
+            if (item.depth == 0) {
                 context.lookup_color ("level_color", out color);
             } else {
                 Gdk.RGBA color_a, color_b;
@@ -456,7 +456,7 @@ namespace Baobab {
             }
 
             if (highlighted) {
-                if (depth == 0) {
+                if (item.depth == 0) {
                     context.lookup_color ("level_color_hi", out color);
                 } else {
                     double maximum = double.max (color.red, double.max (color.green, color.blue));
diff --git a/src/baobab-ringschart.vala b/src/baobab-ringschart.vala
index b1c5e39..8d02e64 100644
--- a/src/baobab-ringschart.vala
+++ b/src/baobab-ringschart.vala
@@ -270,9 +270,7 @@ namespace Baobab {
                 Gdk.cairo_set_source_rgba (cr, border_color);
                 cr.stroke ();
             } else {
-                var fill_color = get_item_color (ringsitem.start_angle / Math.PI * 99,
-                                                 item.depth,
-                                                 highlighted);
+                var fill_color = get_item_color (item, ringsitem.start_angle / Math.PI * 99, highlighted);
 
                 cr.arc (center_x, center_y, ringsitem.min_radius, ringsitem.start_angle, final_angle);
                 cr.arc_negative (center_x, center_y, ringsitem.max_radius, final_angle, 
ringsitem.start_angle);
diff --git a/src/baobab-treemap.vala b/src/baobab-treemap.vala
index 4a63542..6b90334 100644
--- a/src/baobab-treemap.vala
+++ b/src/baobab-treemap.vala
@@ -95,13 +95,11 @@ namespace Baobab {
             get_allocation (out allocation);
 
             if ((item.depth % 2) != 0) {
-                fill_color = get_item_color (rect.x / allocation.width * 200,
-                                             item.depth, highlighted);
+                fill_color = get_item_color (item, rect.x / allocation.width * 200, highlighted);
                 width = rect.width - ITEM_PADDING;
                 height = rect.height;
             } else {
-                fill_color = get_item_color (rect.y / allocation.height * 200,
-                                             item.depth, highlighted);
+                fill_color = get_item_color (item, rect.y / allocation.height * 200, highlighted);
                 width = rect.width;
                 height = rect.height - ITEM_PADDING;
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]