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 4f9d1af74bbd03417115f9b8e0ac6e5d5c91317d Author: OmegaPhil <omegap...@startmail.com> Date: Fri Nov 24 21:58:26 2017 +0000 Column visualisation maxes from value history, fixed max monitors excluded from max calculations --- src/column-view.cpp | 60 +++++++++++++++++++++++++++++++++++++++-------------- src/curve-view.cpp | 26 +++++++++++------------ src/ui.glade | 49 +++++++++++++++++++++++-------------------- 3 files changed, 84 insertions(+), 51 deletions(-) diff --git a/src/column-view.cpp b/src/column-view.cpp index 241f0fc..86999fe 100644 --- a/src/column-view.cpp +++ b/src/column-view.cpp @@ -38,14 +38,15 @@ class ColumnGraph public: ColumnGraph(Monitor *monitor, unsigned int color); - void update(unsigned int max_samples); // gather info from monitor - void draw(Gnome::Canvas::Canvas &canvas, // redraw columns on canvas - Plugin *plugin, int width, int height); + void update(unsigned int max_samples); // Gather info from monitor + void draw(Gnome::Canvas::Canvas &canvas, // Redraw columns on canvas + Plugin *plugin, int width, int height, double max); + double get_max_value(); // Used to get overall max across columns Monitor *monitor; private: - // a pixbuf is used for the columns + // A pixbuf is used for the columns std::auto_ptr<Gnome::Canvas::Pixbuf> columns; ValueHistory value_history; @@ -67,8 +68,8 @@ void ColumnGraph::update(unsigned int max_samples) remaining_draws = CanvasView::draw_iterations; } -void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, - Plugin *plugin, int width, int height) +void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, Plugin *plugin, int width, + int height, double max) { if (remaining_draws <= 0) return; @@ -80,15 +81,17 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, ValueHistory::iterator vi = value_history.values.begin(), vend = value_history.values.end(); - if (vi == vend) // there must be at least one point + // There must be at least one point + if (vi == vend) return; - // make sure we got a pixbuf and that it has the right size + // Make sure we got a pixbuf and that it has the right size Glib::RefPtr<Gdk::Pixbuf> pixbuf; if (columns.get() == 0) pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, width, height); - else { + else + { pixbuf = columns->property_pixbuf(); // but perhaps the dimensions have changed @@ -98,11 +101,17 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, pixbuf->fill(color & 0xFFFFFF00); - double max = monitor->max(); + /* Use the actual maxima associated with all columns in the view, unless + * the monitor has a fixed max (variable maxes should not normally be used + * with monitors like the CPU usage monitor, although the user can configure + * this nowadays) */ + if (monitor->fixed_max()) + max = monitor->max(); + if (max <= 0) max = 0.0000001; - // start from right + // Start from right double l = width - ColumnView::pixels_per_sample + ColumnView::pixels_per_sample * time_offset; @@ -121,7 +130,7 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, { PixelPosition pos = get_position(pixbuf, x, t); - // anti-aliasing effect; if we are partly on a pixel, scale alpha down + // Anti-aliasing effect; if we are partly on a pixel, scale alpha down double scale = 1.0; if (x < l) scale -= l - std::floor(l); @@ -138,13 +147,20 @@ void ColumnGraph::draw(Gnome::Canvas::Canvas &canvas, l -= ColumnView::pixels_per_sample; } while (++vi != vend); - // update columns + // Update columns if (columns.get() == 0) columns.reset(new Gnome::Canvas::Pixbuf(*canvas.root(), 0, 0, pixbuf)); else columns->property_pixbuf() = pixbuf; } +double ColumnGraph::get_max_value() +{ + /* Used as part of determination of the max value for all columns in + * the view */ + return value_history.get_max_value(); +} + // // class ColumnView @@ -167,9 +183,10 @@ void ColumnView::do_update() { CanvasView::do_update(); - // update each column graph + // Update each column graph for (column_iterator i = columns.begin(), end = columns.end(); i != end; ++i) - // one extra because of animation + + // One extra because of animation (*i)->update(width() / pixels_per_sample + 1); } @@ -253,6 +270,17 @@ 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()); + (*i)->draw(*canvas, plugin, width(), height(), max); } diff --git a/src/curve-view.cpp b/src/curve-view.cpp index 296d879..50dd1f6 100644 --- a/src/curve-view.cpp +++ b/src/curve-view.cpp @@ -108,8 +108,9 @@ void Curve::draw(Gnome::Canvas::Canvas &canvas, int width, int height, line->property_width_units() = line_width; /* Use the actual maxima associated with all curves in the view, unless - * the monitor has a fixed max (variable maxes should not be used with - * monitors like the CPU usage monitor) */ + * the monitor has a fixed max (variable maxes should not normally be used + * with monitors like the CPU usage monitor, although the user can configure + * this nowadays) */ if (monitor->fixed_max()) max = monitor->max(); @@ -266,7 +267,7 @@ void CurveView::do_detach(Monitor *monitor) void CurveView::do_draw_loop() { - double max = 0, tmp_max = 0; + double max = 0, fixed_max = 0; Glib::ustring max_formatted, max_formatted_compact, monitor_data, monitor_data_compact, text_overlay_format_string, tag_string, separator_string = plugin->get_viewer_text_overlay_separator(); @@ -274,20 +275,19 @@ void CurveView::do_draw_loop() monitor_data_needed = false, monitor_data_compact_needed = false, text_overlay_enabled = plugin->get_viewer_text_overlay_enabled(); - /* Obtain maximum value of all curves in the view, respecting individual - * curve/monitor's fixed maxes if present */ + /* Obtain maximum value of all curves in the view, separately tracking fixed + * maxes incase all monitors are fixed. Graphs with fixed monitors are not + * supposed to be scaled, but the text overlay still needs to refer to a max + * if there are no normal monitors present */ for (curve_iterator i = curves.begin(), end = curves.end(); i != end; ++i) { - if ((*i)->monitor->fixed_max()) - { - tmp_max = ((*i)->get_max_value() < (*i)->monitor->fixed_max()) ? - (*i)->get_max_value() : (*i)->monitor->fixed_max(); - if (tmp_max > max) - max = tmp_max; - } - else if ((*i)->get_max_value() > max) + if (!(*i)->monitor->fixed_max() && (*i)->get_max_value() > max) max = (*i)->get_max_value(); + else if ((*i)->monitor->fixed_max() && (*i)->monitor->max() > fixed_max) + fixed_max = (*i)->monitor->max(); } + if (max == 0 && fixed_max > 0) + max = fixed_max; // If the text overlay is enabled, detecting all information required to output if (text_overlay_enabled) diff --git a/src/ui.glade b/src/ui.glade index 3a4f46e..8f6b5f0 100644 --- a/src/ui.glade +++ b/src/ui.glade @@ -467,8 +467,8 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a maximum value of 100%</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a maximum value of 100%</property> <property name="draw_indicator">True</property> </object> <packing> @@ -667,8 +667,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed to a -user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified maximum +value</property> <property name="draw_indicator">True</property> </object> <packing> @@ -950,9 +951,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a maximum value based on -the size of the volume</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a maximum value based +on the size of the volume</property> <property name="active">True</property> <property name="draw_indicator">True</property> </object> @@ -1225,8 +1226,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified +maximum value</property> <property name="draw_indicator">True</property> </object> <packing> @@ -1437,9 +1439,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a maximum value based on -the amount of swap available</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a maximum value based +on the amount of swap available</property> <property name="active">True</property> <property name="draw_indicator">True</property> </object> @@ -1636,8 +1638,8 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a maximum value based on + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a maximum value based on the amount of RAM available</property> <property name="active">True</property> <property name="draw_indicator">True</property> @@ -1929,8 +1931,8 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified maximum value</property> <property name="draw_indicator">True</property> </object> <packing> @@ -2227,8 +2229,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified maximum +value</property> <property name="draw_indicator">True</property> </object> <packing> @@ -2451,8 +2454,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified maximum +value</property> <property name="draw_indicator">True</property> </object> <packing> @@ -3021,8 +3025,9 @@ taken by the monitor</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Resulting visualisation is fixed -to a user-specified maximum value</property> + <property name="tooltip_text" translatable="yes">Resulting time-based visualisation +is fixed to a user-specified maximum +value</property> <property name="draw_indicator">True</property> </object> <packing> -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits