#include <gtk/gtkgl.h>
#include <GL/gl.h>
#include <GL/glu.h>
+#include <assert.h>
#include "../debug.h"
+#include "../familia.h"
#include "drawing_area.h"
#include "../math/3d.h"
#include "../graphics/constants.h"
{
/* Code */
}
+
+/**
+ * The "scroll-event" signal handler. Responsible for correctly scrolling
+ * drawing area using mouse or touchpad.
+ */
+void drawing_area_event_scroll (GtkWidget *widget,
+ GdkEventScroll *event, FamiliaData *data)
+{
+ GtkAdjustment *adjustment = NULL;
+ gdouble value = 0;
+ gdouble step = 0;
+
+ assert(event->type == GDK_SCROLL);
+
+ switch(event->direction) {
+ case GDK_SCROLL_UP:
+ adjustment = data->vadjustment;
+ step = 1;
+ break;
+ case GDK_SCROLL_DOWN:
+ adjustment = data->vadjustment;
+ step = -1;
+ break;
+ case GDK_SCROLL_LEFT:
+ adjustment = data->hadjustment;
+ step = -1;
+ break;
+ case GDK_SCROLL_RIGHT:
+ adjustment = data->hadjustment;
+ step = 1;
+ break;
+ }
+
+ if (adjustment != NULL) {
+ value = gtk_adjustment_get_value (adjustment);
+ step = step * gtk_adjustment_get_step_increment(adjustment);
+ value += step;
+
+ gtk_adjustment_set_value (adjustment, value);
+ gtk_adjustment_value_changed (adjustment);
+ }
+}