--- /dev/null
+/****************************************************************************
+ * Familia Lignum - Genealogical program *
+ * Copyright (C) 2011-2014 Rafał Długołęcki <rafal@dlugolecki.net.pl> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; version 2 of the License. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * *
+ ****************************************************************************/
+
+#ifndef _FAMILIA_H
+#define _FAMILIA_H
+
+
+#include <gtk/gtkgl.h>
+#include "../config.h"
+
+typedef struct familia_data {
+ GtkAdjustment *vadjustment;
+ GtkAdjustment *hadjustment;
+} FamiliaData;
+
+#endif /*_FAMILIA_H */
#include "i18n.h"
#include "debug.h"
#include "commandline.h"
+#include "familia.h"
#include "storage/storage.h"
#include "gedcom/familia_gedcom.h"
GtkBuilder *builder = NULL;
GtkWidget *window = NULL;
GdkGLConfig *glconfig = NULL;
+ FamiliaData * app = NULL;
struct familia_storage * storage = NULL;
storage = familia_storage_new();
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, get_guidatafile(), NULL);
- gtk_builder_connect_signals(builder, NULL);
+
+ app = g_new(FamiliaData, 1);
+ app->hadjustment = gtk_builder_get_object(builder, "horizontal-adjustment");
+ app->vadjustment = gtk_builder_get_object(builder, "vertical-adjustment");
+
+ gtk_builder_connect_signals(builder, app);
window = GTK_WIDGET(gtk_builder_get_object(builder, "main-window"));
drawing_area = GTK_WIDGET(gtk_builder_get_object(builder, "drawing-area"));
storage = NULL;
}
+ g_free(app);
+
return 0;
}
#include <assert.h>
#include "../debug.h"
+#include "../familia.h"
#include "drawing_area.h"
#include "../math/3d.h"
#include "../graphics/constants.h"
/**
* The "scroll-event" signal handler. Responsible for correctly scrolling
- * drawing area.
+ * drawing area using mouse or touchpad.
*/
void drawing_area_event_scroll (GtkWidget *widget,
- GdkEventScroll *event, gpointer user_data)
+ 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:
- camera_pos_y++;
- gtk_widget_queue_draw(widget);
+ adjustment = data->vadjustment;
+ step = 1;
break;
case GDK_SCROLL_DOWN:
- camera_pos_y--;
- gtk_widget_queue_draw(widget);
+ 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);
+ }
}