[Xfce4-commits] [panel-plugins/xfce4-hardware-monitor-plugin] 03/13: Initial implementation of "all monitor values" text overlay for CurveView
noreply at xfce.org
noreply at xfce.org
Wed Aug 12 18:39:07 CEST 2015
This is an automated email from the git hooks/post-receive script.
omegaphil pushed a commit to branch master
in repository panel-plugins/xfce4-hardware-monitor-plugin.
commit 47104649a7c6c47d50cd62b0cea44ae16b2557c9
Author: OmegaPhil <OmegaPhil at startmail.com>
Date: Tue Jul 28 21:53:07 2015 +0100
Initial implementation of "all monitor values" text overlay for CurveView
---
src/curve-view.cpp | 40 ++++++++++++++++++++++++++++++++--------
src/curve-view.hpp | 6 +++++-
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/src/curve-view.cpp b/src/curve-view.cpp
index ffab1f5..48af6d8 100644
--- a/src/curve-view.cpp
+++ b/src/curve-view.cpp
@@ -143,7 +143,8 @@ double Curve::get_max_value()
int const CurveView::pixels_per_sample = 2;
CurveView::CurveView()
- : CanvasView(true), text_overlay(NULL)
+ : CanvasView(true), text_overlay_enabled(false), text_overlay(NULL),
+ use_compact_format(false)
{
}
@@ -245,25 +246,48 @@ void CurveView::do_detach(Monitor *monitor)
void CurveView::do_draw_loop()
{
double max = 0;
- Glib::ustring max_formatted;
+ Glib::ustring max_formatted, monitor_data;
+
+ // Debug code
+ use_compact_format = true;
+ separator_string = " ";
+ text_overlay_enabled = true;
// Obtain maximum value of all curves in the view
for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i)
if ((*i)->get_max_value() > max)
max = (*i)->get_max_value();
- /* Draw the curves with the unified max value, use first monitor to obtain
- * the text formatted value (with units) - this mainly makes sense if all
- * curves belong to the same monitor type */
for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i)
{
- if (max_formatted.empty())
- max_formatted = (*i)->monitor->format_value(max);
+ if (text_overlay_enabled)
+ {
+ /* Using first monitor to obtain the text formatted value (with units) -
+ * this mainly makes sense if all curves belong to the same monitor type */
+ if (max_formatted.empty())
+ max_formatted = (*i)->monitor->format_value(max, use_compact_format);
+
+ // Collecting a string of monitor data to overlay later
+ if (monitor_data.empty())
+ {
+ monitor_data = (*i)->monitor->format_value((*i)->monitor->value(),
+ use_compact_format);
+ }
+ else
+ {
+ monitor_data.append(separator_string +
+ (*i)->monitor->format_value((*i)->monitor->value(),
+ use_compact_format));
+ }
+ }
+
+ // Drawing the curves with the unified max value
(*i)->draw(*canvas, width(), height(), max);
}
// Determination of text to overlay
- Glib::ustring overlay_text = _("Max: ") + max_formatted;
+ Glib::ustring overlay_text = use_compact_format ? _("M:") : _("Max: ");
+ overlay_text.append(max_formatted + separator_string + monitor_data);
/* Checking if overlay is already initialised
* Possibility that text is not shown at start up - not failing consistently
diff --git a/src/curve-view.hpp b/src/curve-view.hpp
index 2613d86..fb5f910 100644
--- a/src/curve-view.hpp
+++ b/src/curve-view.hpp
@@ -54,7 +54,11 @@ private:
typedef curve_sequence::iterator curve_iterator;
curve_sequence curves;
- Gnome::Canvas::Text *text_overlay; // Text 'overlay' for the CurveView
+ // Text 'overlay' data and settings
+ bool text_overlay_enabled;
+ Gnome::Canvas::Text *text_overlay;
+ Glib::ustring separator_string;
+ bool use_compact_format;
};
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list