[SCM] calf/master: Eliminate unnecessary redraws.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:41:14 UTC 2013
The following commit has been merged in the master branch:
commit d690f5582f17a48bacdae6f2269dff722ca967a9
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Fri Sep 21 20:26:21 2012 +0100
Eliminate unnecessary redraws.
diff --git a/src/calf/gui.h b/src/calf/gui.h
index d1075ca..eb588b7 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -55,6 +55,7 @@ struct param_control: public control_base
std::string param_variable;
GtkWidget *label, *widget;
int in_change;
+ float old_displayed_value;
struct guard_change {
param_control *pc;
@@ -62,7 +63,7 @@ struct param_control: public control_base
~guard_change() { pc->in_change--; }
};
- param_control() { gui = NULL; param_no = -1; label = NULL; in_change = 0;}
+ param_control();
inline const parameter_properties &get_props();
virtual void init_xml(const char *element) {}
diff --git a/src/calf/gui_controls.h b/src/calf/gui_controls.h
index 0b8bc64..7623e42 100644
--- a/src/calf/gui_controls.h
+++ b/src/calf/gui_controls.h
@@ -88,6 +88,8 @@ struct label_param_control: public param_control
/// Display-only control: value text
struct value_param_control: public param_control, public send_updates_iface
{
+ std::string old_value;
+
virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
virtual void get() {}
virtual void set();
diff --git a/src/gui_controls.cpp b/src/gui_controls.cpp
index 0d83da6..3aa19c2 100644
--- a/src/gui_controls.cpp
+++ b/src/gui_controls.cpp
@@ -90,6 +90,16 @@ void control_container::set_std_properties()
/************************* param-associated control base class **************/
+param_control::param_control()
+{
+ gui = NULL;
+ param_no = -1;
+ label = NULL;
+ in_change = 0;
+ old_displayed_value = -1.f;
+}
+
+
void param_control::set_std_properties()
{
if (attribs.find("widget-name") != attribs.end())
@@ -112,7 +122,12 @@ GtkWidget *param_control::create_label()
void param_control::update_label()
{
const parameter_properties &props = get_props();
- gtk_label_set_text (GTK_LABEL (label), props.to_string(gui->plugin->get_param_value(param_no)).c_str());
+
+ float value = gui->plugin->get_param_value(param_no);
+ if (value == old_displayed_value)
+ return;
+ gtk_label_set_text (GTK_LABEL (label), props.to_string(value).c_str());
+ old_displayed_value = value;
}
void param_control::hook_params()
@@ -410,8 +425,14 @@ void value_param_control::set()
if (param_no == -1)
return;
_GUARD_CHANGE_
+
const parameter_properties &props = get_props();
- gtk_label_set_text (GTK_LABEL (widget), props.to_string(gui->plugin->get_param_value(param_no)).c_str());
+ string value = props.to_string(gui->plugin->get_param_value(param_no));
+
+ if (value == old_value)
+ return;
+ old_value = value;
+ gtk_label_set_text (GTK_LABEL (widget), value.c_str());
}
void value_param_control::send_status(const char *key, const char *value)
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list