summaryrefslogtreecommitdiff
path: root/snd-gmix.c
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at>2018-04-30 21:45:07 +0200
committerIOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at>2018-04-30 21:45:07 +0200
commitbe4b008536f3c28b5f025c8618ac3acb1cd065ad (patch)
treed58751a8750d39e167289b357c96e6da3e5fe67a /snd-gmix.c
parent0f71f6cd817b5747663b516d620059680789fbc1 (diff)
New upstream version 18.3
Diffstat (limited to 'snd-gmix.c')
-rw-r--r--snd-gmix.c126
1 files changed, 110 insertions, 16 deletions
diff --git a/snd-gmix.c b/snd-gmix.c
index 1a3f6d9..5a97ab8 100644
--- a/snd-gmix.c
+++ b/snd-gmix.c
@@ -5,6 +5,9 @@
static GtkWidget *mix_dialog = NULL;
static int mix_dialog_id = INVALID_MIX_ID, old_mix_dialog_id = INVALID_MIX_ID;
static env *dialog_env = NULL;
+#if GTK_CHECK_VERSION(3, 89, 0)
+static cairo_t *mix_cr;
+#endif
static bool dragging = false;
static int edpos_before_drag;
@@ -48,7 +51,10 @@ static void stop_dragging(int mix_id)
/* -------- speed -------- */
-static GtkWidget *w_speed, *w_speed_label, *w_speed_number, *w_speed_form, *w_speed_event, *w_speed_label_event;
+static GtkWidget *w_speed, *w_speed_label, *w_speed_number, *w_speed_form;
+#if (!GTK_CHECK_VERSION(3, 92, 1))
+static GtkWidget *w_speed_event, *w_speed_label_event;
+#endif
static GtkAdjustment *w_speed_adj;
static bool speed_pressed = false, speed_dragged = false;
/* can't use value_changed on adjustment and motion event happens even when the mouse merely moves across the slider without dragging */
@@ -183,7 +189,10 @@ static gboolean speed_press_callback(GtkWidget *w, GdkEventButton *ev, gpointer
/* -------- amp -------- */
-static GtkWidget *w_amp, *w_amp_label, *w_amp_number, *w_amp_event, *w_amp_form;
+static GtkWidget *w_amp, *w_amp_label, *w_amp_number, *w_amp_form;
+#if (!GTK_CHECK_VERSION(3, 92, 1))
+static GtkWidget *w_amp_event;
+#endif
static GtkAdjustment *w_amp_adj;
static mus_float_t scrollbar_to_amp(mus_float_t val)
@@ -312,13 +321,19 @@ static void mix_amp_env_resize(GtkWidget *w)
ax->w = w_env;
ax->gc = cur_gc;
}
+#if GTK_CHECK_VERSION(3, 89, 0)
+ if (!mix_cr) return;
+ ss->cr = mix_cr;
+#else
ss->cr = make_cairo(ax->wn);
+#endif
cairo_push_group(ss->cr);
/* erase previous */
cairo_set_source_rgba(ss->cr, cur_gc->bg_color->red, cur_gc->bg_color->green, cur_gc->bg_color->blue, cur_gc->bg_color->alpha);
cairo_rectangle(ss->cr, 0, 0, widget_width(w), widget_height(w));
cairo_fill(ss->cr);
+ cairo_set_line_width(ss->cr, 1.0);
spf->with_dots = true;
env_editor_display_env(spf, dialog_env, ax, "mix env", 0, 0, widget_width(w), widget_height(w), NOT_PRINTING);
@@ -327,16 +342,28 @@ static void mix_amp_env_resize(GtkWidget *w)
cairo_pop_group_to_source(ss->cr);
cairo_paint(ss->cr);
+#if (!GTK_CHECK_VERSION(3, 89, 0))
free_cairo(ss->cr);
+#endif
ss->cr = NULL;
}
static gboolean mix_drawer_button_press(GtkWidget *w, GdkEventButton *ev, gpointer data)
{
+ gdouble x, y;
if (!(mix_is_active(mix_dialog_id))) return(false);
+#if GTK_CHECK_VERSION(3, 89, 0)
+ ss->cr = mix_cr;
+#endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_event_get_coords((GdkEvent *)ev, &x, &y);
+#else
+ x = ev->x;
+ y = ev->y;
+#endif
spf->with_dots = false;
- if (env_editor_button_press(spf, (int)(EVENT_X(ev)), (int)(EVENT_Y(ev)), EVENT_TIME(ev), dialog_env))
+ if (env_editor_button_press(spf, (int)x, (int)y, event_time(ev), dialog_env))
mix_amp_env_resize(w);
return(false);
}
@@ -345,6 +372,9 @@ static gboolean mix_drawer_button_press(GtkWidget *w, GdkEventButton *ev, gpoint
static gboolean mix_drawer_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
{
if (!(mix_is_active(mix_dialog_id))) return(false);
+#if GTK_CHECK_VERSION(3, 89, 0)
+ ss->cr = mix_cr;
+#endif
env_editor_button_release(spf, dialog_env);
mix_amp_env_resize(w);
return(false);
@@ -353,39 +383,60 @@ static gboolean mix_drawer_button_release(GtkWidget *w, GdkEventButton *ev, gpoi
static gboolean mix_drawer_button_motion(GtkWidget *w, GdkEventMotion *ev, gpointer data)
{
+ GdkModifierType state;
if (!(mix_is_active(mix_dialog_id))) return(false);
- if (BUTTON1_PRESSED(EVENT_STATE(ev)))
+#if GTK_CHECK_VERSION(3, 89, 0)
+ ss->cr = mix_cr;
+#endif
+#if (GTK_CHECK_VERSION(3, 0, 0))
+ gdk_event_get_state((GdkEvent *)ev, &state);
+#else
+ state = ev->state;
+#endif
+ if (BUTTON1_PRESSED(state))
{
int x, y;
- GdkModifierType state;
if (EVENT_IS_HINT(ev))
window_get_pointer(ev, &x, &y, &state);
else
{
- x = (int)(EVENT_X(ev));
- y = (int)(EVENT_Y(ev));
+#if (GTK_CHECK_VERSION(3, 0, 0))
+ gdouble fx, fy;
+ gdk_event_get_coords((GdkEvent *)ev, &fx, &fy);
+ x = (int)fx;
+ y = (int)fy;
+#else
+ x = (int)(ev->x);
+ y = (int)(ev->y);
+#endif
}
spf->with_dots = false;
- env_editor_button_motion(spf, x, y, EVENT_TIME(ev), dialog_env);
+ env_editor_button_motion(spf, x, y, event_time(ev), dialog_env);
mix_amp_env_resize(w);
}
return(false);
}
-
+#if GTK_CHECK_VERSION(3, 89, 0)
+static void mix_amp_env_expose(GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
+{
+ mix_cr = cr;
+ mix_amp_env_resize(GTK_WIDGET(w));
+}
+#else
static gboolean mix_amp_env_expose_callback(GtkWidget *w, GdkEventExpose *ev, gpointer data)
{
mix_amp_env_resize(w);
return(false);
}
-
static gboolean mix_amp_env_resize_callback(GtkWidget *w, GdkEventConfigure *ev, gpointer data)
{
if (!(mix_is_active(mix_dialog_id))) return(false);
mix_amp_env_resize(w);
return(false);
}
+#endif
static GtkWidget *w_id = NULL, *w_beg = NULL, *w_id_label = NULL;
@@ -528,14 +579,23 @@ static void mix_play_callback(GtkWidget *w, gpointer context)
}
}
-
+#if (GTK_CHECK_VERSION(3, 89, 0))
+static void mix_play_pix_expose(GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
+{
+ if ((mix_play_ax) && (GDK_IS_WINDOW(mix_play_ax->wn)))
+ {
+ cairo_set_source_surface(cr, snd_icon(SND_PNG_SPEAKER), 0, 0);
+ cairo_paint(cr);
+ }
+}
+#else
static gboolean mix_play_pix_expose(GtkWidget *w, GdkEventExpose *ev, gpointer data)
{
draw_picture(mix_play_ax, snd_icon(SND_PNG_SPEAKER), 0, 0, 0, 0, 16, 16); /* in gtk2 this looks better if y-dest is 2 */
return(false);
}
#endif
-
+#endif
static void mix_dB_callback(GtkWidget *w, gpointer context)
{
@@ -760,12 +820,20 @@ GtkWidget *make_mix_dialog(void)
widget_modify_bg(mix_play, GTK_STATE_SELECTED, ss->basic_color);
mix_play_pix = gtk_drawing_area_new();
+#if (!GTK_CHECK_VERSION(3, 89, 0))
sg_widget_set_events(mix_play_pix, GDK_EXPOSURE_MASK);
+#endif
gtk_widget_set_size_request(mix_play_pix, 16, 16);
gtk_container_add(GTK_CONTAINER(mix_play), mix_play_pix);
gtk_widget_show(mix_play_pix);
+#if (GTK_CHECK_VERSION(3, 89, 0))
+ gtk_drawing_area_set_content_width(GTK_DRAWING_AREA(mix_play_pix), gtk_widget_get_allocated_width(mix_play_pix));
+ gtk_drawing_area_set_content_height(GTK_DRAWING_AREA(mix_play_pix), gtk_widget_get_allocated_height(mix_play_pix));
+ gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(mix_play_pix), mix_play_pix_expose, NULL, NULL);
+#else
SG_SIGNAL_CONNECT(mix_play_pix, DRAW_SIGNAL, mix_play_pix_expose, NULL);
#endif
+#endif
mix_next_button = button_new_with_icon(ICON_GO_FORWARD);
gtk_widget_set_name(mix_next_button, "dialog_button");
@@ -792,32 +860,44 @@ GtkWidget *make_mix_dialog(void)
w_speed_form = gtk_hbox_new(false, 2);
sg_box_pack_start(GTK_BOX(DIALOG_CONTENT_AREA(mix_dialog)), w_speed_form, false, false, 4);
+#if (!GTK_CHECK_VERSION(3, 92, 1))
w_speed_event = gtk_event_box_new();
sg_box_pack_start(GTK_BOX(w_speed_form), w_speed_event, false, false, 4);
gtk_widget_show(w_speed_event);
SG_SIGNAL_CONNECT(w_speed_event, "button_press_event", mix_speed_click_callback, NULL);
-
+#endif
#if (!GTK_CHECK_VERSION(3, 0, 0))
w_speed_label = gtk_label_new("speed:");
#else
w_speed_label = gtk_button_new_with_label("speed:");
add_highlight_button_style(w_speed_label);
#endif
+#if (!GTK_CHECK_VERSION(3, 92, 1))
gtk_container_add(GTK_CONTAINER(w_speed_event), w_speed_label);
+#else
+ sg_box_pack_start(GTK_BOX(w_speed_form), w_speed_label, false, false, 4);
+ SG_SIGNAL_CONNECT(w_speed_label, "button_press_event", mix_speed_click_callback, NULL);
+#endif
gtk_widget_show(w_speed_label);
+#if (!GTK_CHECK_VERSION(3, 92, 1))
w_speed_label_event = gtk_event_box_new();
sg_box_pack_start(GTK_BOX(w_speed_form), w_speed_label_event, false, false, 4);
gtk_widget_show(w_speed_label_event);
SG_SIGNAL_CONNECT(w_speed_label_event, "button_press_event", speed_label_click_callback, NULL);
-
+#endif
switch (speed_control_style(ss))
{
case SPEED_CONTROL_AS_RATIO: w_speed_number = gtk_label_new("1/1"); break;
case SPEED_CONTROL_AS_SEMITONE: w_speed_number = gtk_label_new("1"); break;
default: w_speed_number = gtk_label_new("1.00"); break;
}
+#if (!GTK_CHECK_VERSION(3, 92, 1))
gtk_container_add(GTK_CONTAINER(w_speed_label_event), w_speed_number);
+#else
+ sg_box_pack_start(GTK_BOX(w_speed_form), w_speed_number, false, false, 4);
+ SG_SIGNAL_CONNECT(w_speed_number, "button_press_event", speed_label_click_callback, NULL);
+#endif
gtk_widget_show(w_speed_number);
w_speed_adj = (GtkAdjustment *)gtk_adjustment_new(0.45, 0.0, 1.0, 0.001, 0.01, .1);
@@ -835,12 +915,13 @@ GtkWidget *make_mix_dialog(void)
w_amp_form = gtk_hbox_new(false, 2);
sg_box_pack_start(GTK_BOX(DIALOG_CONTENT_AREA(mix_dialog)), w_amp_form, false, false, 0);
-
+
+#if (!GTK_CHECK_VERSION(3, 92, 1))
w_amp_event = gtk_event_box_new();
sg_box_pack_start(GTK_BOX(w_amp_form), w_amp_event, false, false, 4);
gtk_widget_show(w_amp_event);
SG_SIGNAL_CONNECT(w_amp_event, "button_press_event", mix_amp_click_callback, NULL);
-
+#endif
snprintf(amplab, LABEL_BUFFER_SIZE, "%s", "amp:");
#if (!GTK_CHECK_VERSION(3, 0, 0))
w_amp_label = gtk_label_new(amplab);
@@ -848,7 +929,12 @@ GtkWidget *make_mix_dialog(void)
w_amp_label = gtk_button_new_with_label("amp:");
add_highlight_button_style(w_amp_label);
#endif
+#if (!GTK_CHECK_VERSION(3, 92, 1))
gtk_container_add(GTK_CONTAINER(w_amp_event), w_amp_label);
+#else
+ sg_box_pack_start(GTK_BOX(w_amp_form), w_amp_label, false, false, 4);
+ SG_SIGNAL_CONNECT(w_amp_label, "button_press_event", mix_amp_click_callback, NULL);
+#endif
gtk_widget_show(w_amp_label);
w_amp_number = gtk_label_new("1.00");
@@ -909,12 +995,20 @@ GtkWidget *make_mix_dialog(void)
/* GRAPH (drawing area) */
w_env = gtk_drawing_area_new();
+#if (!GTK_CHECK_VERSION(3, 89, 0))
sg_widget_set_events(w_env, GDK_ALL_EVENTS_MASK);
+#endif
gtk_container_add(GTK_CONTAINER(w_env_frame), w_env);
widget_modify_bg(w_env, GTK_STATE_NORMAL, ss->highlight_color);
gtk_widget_show(w_env);
+#if (GTK_CHECK_VERSION(3, 89, 0))
+ gtk_drawing_area_set_content_width(GTK_DRAWING_AREA(w_env), gtk_widget_get_allocated_width(w_env));
+ gtk_drawing_area_set_content_height(GTK_DRAWING_AREA(w_env), gtk_widget_get_allocated_height(w_env));
+ gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(w_env), mix_amp_env_expose, NULL, NULL);
+#else
SG_SIGNAL_CONNECT(w_env, DRAW_SIGNAL, mix_amp_env_expose_callback, NULL);
SG_SIGNAL_CONNECT(w_env, "configure_event", mix_amp_env_resize_callback, NULL);
+#endif
SG_SIGNAL_CONNECT(w_env, "button_press_event", mix_drawer_button_press, NULL);
SG_SIGNAL_CONNECT(w_env, "button_release_event", mix_drawer_button_release, NULL);
SG_SIGNAL_CONNECT(w_env, "motion_notify_event", mix_drawer_button_motion, NULL);