[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 25/29: Port all view draw_loops to the new process_mon_maxes_text_overlay code

noreply at xfce.org noreply at xfce.org
Mon Dec 18 12:45:56 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 3b1479877bf8fa0db1a2856c2c6e82e9ca440b1c
Author: OmegaPhil <OmegaPhil at startmail.com>
Date:   Sun Dec 17 20:26:30 2017 +0000

    Port all view draw_loops to the new process_mon_maxes_text_overlay code
---
 src/bar-view.cpp    | 25 ++++++++++++-------------
 src/canvas-view.cpp |  4 +++-
 src/column-view.cpp | 24 +++++++++++-------------
 src/flame-view.cpp  | 24 +++++++++++-------------
 4 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/src/bar-view.cpp b/src/bar-view.cpp
index 3601fa0..25a6608 100644
--- a/src/bar-view.cpp
+++ b/src/bar-view.cpp
@@ -287,19 +287,18 @@ void BarView::do_draw_loop()
   int total = bars.size();
   int no = 0;
 
-  double max = 0;
-
-  /* Obtain maximum value of all columns in the view, ignoring any monitors with
-   * fixed maxes (their visualisations are not supposed to be scaled) */
-  for (bar_iterator i = bars.begin(), end = bars.end(); i != end; ++i)
-  {
-    if (!(*i)->monitor->fixed_max() && (*i)->get_max_value() > max)
-      max = (*i)->get_max_value();
-  }
-
-  // Drawing bars with the unified max value
-  for (bar_iterator i = bars.begin(), end = bars.end(); i != end; ++i)
-    (*i)->draw(*canvas, plugin, width(), height(), no++, total, time_offset, max);
+  /* Generating list of bars with correct maxima (unified and potentially
+   * grouped by monitor type) to then draw, and triggering processing of text
+   * overlay on the CanvasView if the user desires */
+  std::list<std::pair<Bar*, double>> bars_and_maxes =
+      process_mon_maxes_text_overlay(bars);
+
+  /* Looping for all bars to draw - in the std::pair, first is the Bar,
+   * second is the max */
+  for (std::list<std::pair<Bar*, double>>::iterator i = bars_and_maxes.begin(),
+       end = bars_and_maxes.end(); i != end; ++i)
+    i->first->draw(*canvas, plugin, width(), height(), no++, total, time_offset,
+                   i->second);
 
   ++draws_since_update;
 }
diff --git a/src/canvas-view.cpp b/src/canvas-view.cpp
index 28d4ea3..73a952c 100644
--- a/src/canvas-view.cpp
+++ b/src/canvas-view.cpp
@@ -27,6 +27,7 @@
 #include "plugin.hpp"
 
 #include "bar-view.hpp"
+#include "column-view.hpp"
 #include "curve-view.hpp"
 #include "flame-view.hpp"
 
@@ -481,6 +482,7 @@ template class std::list<std::pair<Bar*, double>> CanvasView::process_mon_maxes_
     typename std::list<Bar*> graph_elements);
 template class std::list<std::pair<Curve*, double>> CanvasView::process_mon_maxes_text_overlay(
     typename std::list<Curve*> graph_elements);
+template class std::list<std::pair<ColumnGraph*, double>> CanvasView::process_mon_maxes_text_overlay(
+    typename std::list<ColumnGraph*> graph_elements);
 template class std::list<std::pair<Flame*, double>> CanvasView::process_mon_maxes_text_overlay(
     typename std::list<Flame*> graph_elements);
-
diff --git a/src/column-view.cpp b/src/column-view.cpp
index 0e7d260..08e10e8 100644
--- a/src/column-view.cpp
+++ b/src/column-view.cpp
@@ -242,17 +242,15 @@ void ColumnView::do_detach(Monitor *monitor)
 
 void ColumnView::do_draw_loop()
 {
-  double max = 0;
-
-  /* Obtain maximum value of all columns in the view, ignoring any monitors with
-   * fixed maxes (their graphs are not supposed to be scaled) */
-  for (column_iterator i = columns.begin(), end = columns.end(); i != end; ++i)
-  {
-    if (!(*i)->monitor->fixed_max() && (*i)->get_max_value() > max)
-      max = (*i)->get_max_value();
-  }
-
-  // Drawing the columns with the unified max value
-  for (column_iterator i = columns.begin(), end = columns.end(); i != end; ++i)
-    (*i)->draw(*canvas, plugin, width(), height(), max);
+  /* Generating list of columns with correct maxima (unified and potentially
+   * grouped by monitor type) to then draw, and triggering processing of text
+   * overlay on the CanvasView if the user desires */
+  std::list<std::pair<ColumnGraph*, double>> columns_and_maxes =
+      process_mon_maxes_text_overlay(columns);
+
+  /* Looping for all columns to draw - in the std::pair, first is the
+   * ColumnGraph, second is the max */
+  for (std::list<std::pair<ColumnGraph*, double>>::iterator i =
+       columns_and_maxes.begin(), end = columns_and_maxes.end(); i != end; ++i)
+    i->first->draw(*canvas, plugin, width(), height(), i->second);
 }
diff --git a/src/flame-view.cpp b/src/flame-view.cpp
index b868d1a..5f96a80 100644
--- a/src/flame-view.cpp
+++ b/src/flame-view.cpp
@@ -313,17 +313,15 @@ void FlameView::do_detach(Monitor *monitor)
 
 void FlameView::do_draw_loop()
 {
-  double max = 0;
-
-  /* Obtain maximum value of all flames in the view, ignoring any monitors with
-   * fixed maxes (their visualisations are not supposed to be scaled) */
-  for (flame_iterator i = flames.begin(), end = flames.end(); i != end; ++i)
-  {
-    if (!(*i)->monitor->fixed_max() && (*i)->get_max_value() > max)
-      max = (*i)->get_max_value();
-  }
-
-  // Drawing flames with the unified max value
-  for (flame_iterator i = flames.begin(), end = flames.end(); i != end; ++i)
-    (*i)->burn(max);
+  /* Generating list of flames with correct maxima (unified and potentially
+   * grouped by monitor type) to then draw, and triggering processing of text
+   * overlay on the CanvasView if the user desires */
+  std::list<std::pair<Flame*, double>> flames_and_maxes =
+      process_mon_maxes_text_overlay(flames);
+
+  /* Looping for all flames to draw - in the std::pair, first is the Flame,
+   * second is the max */
+  for (std::list<std::pair<Flame*, double>>::iterator i =
+       flames_and_maxes.begin(), end = flames_and_maxes.end(); i != end; ++i)
+    i->first->burn(i->second);
 }

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


More information about the Xfce4-commits mailing list