diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-29 14:26:34 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-29 14:26:34 -0400 |
commit | 4b367fc447f68e597bb2d7eb6a1bab210b3f8844 (patch) | |
tree | 4097e0abc0b5cdebfd6c0c216a6f95dc7fa45c0e | |
parent | 06f6f74dc69d461d7bc6e7bf9d03bc40d5e0c2c5 (diff) |
pull setting the curve in to its own function
-rw-r--r-- | ggamma.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -33,6 +33,14 @@ void curve_edited(GtkWidget *raw_curve, UNUSED GdkEvent *event, struct gamma_cha gamma->flush(); } +void curve_set(GtkGammaCurve *curve, struct gamma_channel *gamma) { + gfloat vec[gamma->size]; + for (int i = 0; i < gamma->size; i++) + vec[i] = gamma->data[i] * gamma->size / 65535.0; + gtk_curve_set_vector(GTK_CURVE(curve->curve), + gamma->size, vec); +} + GtkWidget *curve_new(struct gamma_channel *gamma) { GtkWidget *curve = gtk_gamma_curve_new(); GtkWidget *raw_curve = GTK_GAMMA_CURVE(curve)->curve; @@ -42,16 +50,11 @@ GtkWidget *curve_new(struct gamma_channel *gamma) { * So there's no point in making it awkwardly tall to get the * extra precision; just make it a square, we're not really * loosing anything. */ - gtk_curve_set_range(GTK_CURVE(raw_curve), /* x */0, gamma->size-1, /* y */0, gamma->size-1); - gfloat vec[gamma->size]; - for (int i = 0; i < gamma->size; i++) - vec[i] = gamma->data[i] * gamma->size / 65535.0; - gtk_curve_set_vector(GTK_CURVE(raw_curve), - gamma->size, vec); + curve_set(GTK_GAMMA_CURVE(curve), gamma); // TODO: find a better signal g_signal_connect(raw_curve, "event-after", G_CALLBACK(curve_edited), gamma); |