[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 26/29: Ensure visualisations are on the bottom z-order wise so that text overlay is an overlay

noreply at xfce.org noreply at xfce.org
Mon Dec 18 12:45:57 CET 2017


This is an automated email from the git hooks/post-receive script.

o   m   e   g   a   p   h   i   l       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-hardware-monitor-plugin.

commit 5b2761e2585b658b26e7856c5eb854e78442372d
Author: OmegaPhil <OmegaPhil at startmail.com>
Date:   Sun Dec 17 20:57:32 2017 +0000

    Ensure visualisations are on the bottom z-order wise so that text overlay is an overlay
---
 src/bar-view.cpp    | 50 ++++++++++++++++++++++++++++++++------------------
 src/column-view.cpp |  9 ++++++++-
 src/flame-view.cpp  |  9 +++++++--
 3 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/src/bar-view.cpp b/src/bar-view.cpp
index 25a6608..688ba03 100644
--- a/src/bar-view.cpp
+++ b/src/bar-view.cpp
@@ -74,29 +74,32 @@ void Bar::draw(Gnome::Canvas::Canvas &canvas,
 { 
   unsigned int outline_color = outlineified(fill_color);
 
-  // calculate parameters
+  // Calculate parameters
   int box_size;
-  // use min_spacing at least, except for last box which doesn't need spacing
+
+  // Use min_spacing at least, except for last box which doesn't need spacing
   int total_no_boxes;
   double box_spacing;
 
-  if (this->horizontal) {
+  if (this->horizontal)
+  {
     box_size = 3;
     int const min_spacing = 2;
     total_no_boxes = (width + min_spacing) / (box_size + min_spacing);
     box_spacing = (double(width) - box_size * total_no_boxes) / (total_no_boxes - 1);
   }
-  else {
-    // Assume that a vertical view has limited space, thus the number of boxes
-    // is hardcoded
+  else
+  {
+    /* Assume that a vertical view has limited space, thus the number of boxes
+     * is hardcoded */
     total_no_boxes = 5;
     box_spacing = 2;
     int const total_no_spacings = total_no_boxes - 1;
-    box_size = int(double(height - (total_no_spacings * box_spacing)) / total_no_boxes);
+    box_size = int(double(height -
+                          (total_no_spacings * box_spacing)) / total_no_boxes);
   }
   
-  
-  // don't attain new value immediately
+  // Don't attain new value immediately
   double value = old_value * (1 - time_offset) + new_value * time_offset;
 
   if (max <= 0)
@@ -115,23 +118,32 @@ void Bar::draw(Gnome::Canvas::Canvas &canvas,
   if (alpha == 0)   // x.0 should give an opaque last box
     alpha = 1;
   
-  // trim/expand boxes list
+  /* Trim/expand boxes list, lower to bottom in the canvas' 'z-order' so that
+   * the new text overlay is actually an overlay */
   while (boxes.size() < no_boxes)
-    boxes.push_back(new Gnome::Canvas::Rect(*canvas.root()));
-  while (boxes.size() > no_boxes) {
+  {
+    Gnome::Canvas::Rect *rect = new Gnome::Canvas::Rect(*canvas.root());
+    rect->lower_to_bottom();
+    boxes.push_back(rect);
+  }
+  while (boxes.size() > no_boxes)
+  {
     delete boxes.back();
     boxes.pop_back();
   }
 
   double coord = this->horizontal ? 0 : height;
-  // update parameters, starting from left
+
+  // Update parameters, starting from left
   for (box_sequence::iterator i = boxes.begin(), end = boxes.end(); i != end;
-       ++i) {
+       ++i)
+  {
     Gnome::Canvas::Rect &rect = **i;
     rect.property_fill_color_rgba() = fill_color;
     rect.property_outline_color_rgba() = outline_color;
     
-    if (this->horizontal) {
+    if (this->horizontal)
+    {
       rect.property_x1() = coord;
       rect.property_x2() = coord + box_size;
       rect.property_y1() = double(height) * no / total + 1;
@@ -139,7 +151,8 @@ void Bar::draw(Gnome::Canvas::Canvas &canvas,
       
       coord += box_size + box_spacing;
     }
-    else {
+    else
+    {
       rect.property_x1() = double(width) * no / total + 1;
       rect.property_x2() = double(width) * (no + 1) / total - 1;
       rect.property_y1() = coord;
@@ -149,8 +162,9 @@ void Bar::draw(Gnome::Canvas::Canvas &canvas,
     }
   }
 
-  // tint last box
-  if (!boxes.empty()) {
+  // Tint last box
+  if (!boxes.empty())
+  {
     Gnome::Canvas::Rect &last = *boxes.back();
     last.property_fill_color_rgba()
       = (fill_color & 0xffffff00) |
diff --git a/src/column-view.cpp b/src/column-view.cpp
index 08e10e8..3b9a625 100644
--- a/src/column-view.cpp
+++ b/src/column-view.cpp
@@ -121,7 +121,14 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, Plugin *plugin, int width,
   
   // Update columns
   if (columns.get() == 0)
-    columns.reset(new Gnome::Canvas::Pixbuf(*canvas.root(), 0, 0, pixbuf));
+  {
+    /* Make sure the new Gnome Canvas pixbuff is lower to bottom in the canvas'
+     * 'z-order' so that the new text overlay is actually an overlay */
+    Gnome::Canvas::Pixbuf *gc_pixbuff =
+        new Gnome::Canvas::Pixbuf(*canvas.root(), 0, 0, pixbuf);
+    gc_pixbuff->lower_to_bottom();
+    columns.reset(gc_pixbuff);
+  }
   else
     columns->property_pixbuf() = pixbuf;
 }
diff --git a/src/flame-view.cpp b/src/flame-view.cpp
index 5f96a80..8772dba 100644
--- a/src/flame-view.cpp
+++ b/src/flame-view.cpp
@@ -41,8 +41,13 @@ void Flame::update(Gnome::Canvas::Canvas &canvas,
     Glib::RefPtr<Gdk::Pixbuf> p =
       Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, width, height);
     p->fill(color & 0xFFFFFF00);
-    
-    flame.reset(new Gnome::Canvas::Pixbuf(*canvas.root(), 0, 0, p));
+
+    /* Make sure the new Gnome Canvas pixbuff is lower to bottom in the canvas'
+     * 'z-order' so that the new text overlay is actually an overlay */
+    Gnome::Canvas::Pixbuf *gc_pixbuff =
+        new Gnome::Canvas::Pixbuf(*canvas.root(), 0, 0, p);
+    gc_pixbuff->lower_to_bottom();
+    flame.reset(gc_pixbuff);
   }
   else
   {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list