aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2024-04-01 15:19:50 +0200
committerJeremias Stotter <jeremias@stotter.eu>2024-04-01 15:19:50 +0200
commit6d3eb09fd8974001eeb6366ac0362dcc91f65e39 (patch)
treeb3ccd785817d04b0bc74f85f3586efe42b8d7852
parent86d679b957d25e86a3e01e24a805fe9759acba73 (diff)
downloadnetwork-simulator-6d3eb09fd8974001eeb6366ac0362dcc91f65e39.tar.gz
network-simulator-6d3eb09fd8974001eeb6366ac0362dcc91f65e39.tar.bz2
network-simulator-6d3eb09fd8974001eeb6366ac0362dcc91f65e39.zip
Started refactoring mouse interactions
It now uses the drag controller provided by gtk. Actually moving devices is not yet supported
-rw-r--r--gui.c474
1 files changed, 306 insertions, 168 deletions
diff --git a/gui.c b/gui.c
index be3cf81..942f763 100644
--- a/gui.c
+++ b/gui.c
@@ -66,6 +66,8 @@ bool area_moving = false;
// The start postions of a click
double xstart = 0, ystart = 0;
double xnow = 0, ynow = 0;
+graphene_rect_t selection_rectangle = {0};
+bool selection_rectangle_active = false;
// The main window
GtkWidget* window = NULL;
@@ -425,10 +427,11 @@ void update_main_drawing_area(GtkDrawingArea* drawing_area,
// Draw a selection rectangle if we are in MODE_MOVE
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width(cr, 2);
- if(area_mode == MODE_MOVE && area_pressed && !area_moving) {
+ if(selection_rectangle_active) {
const double dashes[] = {12.0, 6.0};
cairo_set_dash(cr, dashes, 2, 0);
- cairo_rectangle(cr, xstart, ystart, xnow-xstart, ynow-ystart);
+ cairo_rectangle(cr, selection_rectangle.origin.x, selection_rectangle.origin.y,
+ selection_rectangle.size.width, selection_rectangle.size.height);
cairo_stroke(cr);
cairo_set_dash(cr, NULL, 0, 0);
@@ -755,52 +758,308 @@ void select_interface_at(double x, double y) {
gtk_popover_popup(GTK_POPOVER(selection_popover));
}
-double x_last = 0, y_last = 0;
+struct deco* sizing_deco = NULL;
-struct deco* current_move_deco = NULL;
-// This will point to the device we are currently moving
-struct device* current_move_dev = NULL;
+struct device_selection* moving_selection = NULL;
+struct deco* move_deco = NULL;
-struct deco* sizing_deco = NULL;
+void deco_activate(GtkText* self, struct deco* deco) {
+ const char* new_text = gtk_entry_buffer_get_text(gtk_text_get_buffer(self));
+
+ struct undo_entry* undo_new = NULL;
+ struct undo_set_deco_data* undo_set_deco_data_new = NULL;
+ NEW_UNDO_STRUCT(undo_set_deco, undo_set_deco_data, undo_new, undo_set_deco_data_new);
+ deco->refs++;
+ undo_set_deco_data_new->new_text = malloc(strlen(new_text) + 1);
+ strcpy(undo_set_deco_data_new->new_text, new_text);
+ undo_set_deco_data_new->old_text = malloc(strlen(deco->text) + 1);
+ strcpy(undo_set_deco_data_new->old_text, deco->text);
+ undo_set_deco_data_new->deco = deco;
+ undo_add_entry(undo_new);
+
+ deco_text_set(deco, new_text);
+
+ gtk_widget_queue_draw(main_drawing_area);
+
+ GtkWidget* parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(self)));
+ gtk_popover_popdown(GTK_POPOVER(parent));
+ gtk_widget_unparent(parent);
+}
+
+
+void text_popover_close(GtkPopover* self, gpointer user_data) {
+ g_signal_emit_by_name(G_OBJECT(gtk_popover_get_child(self)), "activate");
+}
+
+GtkWidget* new_text_popover_point_to(double x, double y, char* text, GCallback callback, void* callback_data) {
+ GtkWidget* popover = gtk_popover_new();
+ gtk_widget_set_parent(popover, main_drawing_area);
+ // Point to the device text
+ GdkRectangle text_rect = {.x = COORD_UNORM(x), .y = COORD_UNORM(y), .width = 1, .height = 1};
+ gtk_popover_set_pointing_to(GTK_POPOVER(popover), &text_rect);
+ GtkWidget* pop_text = gtk_text_new();
+ gtk_entry_buffer_set_text(gtk_text_get_buffer(GTK_TEXT(pop_text)), text ? text : "", -1);
+ gtk_popover_set_child(GTK_POPOVER(popover), pop_text);
+
+ g_signal_connect(G_OBJECT(popover), "closed", G_CALLBACK(text_popover_close), callback_data);
+ g_signal_connect(G_OBJECT(pop_text),
+ "activate",
+ G_CALLBACK(callback),
+ callback_data);
+ gtk_popover_popup(GTK_POPOVER(popover));
+ return popover;
+}
+
+void gui_change_deco_text(struct deco* deco) {
+ new_text_popover_point_to(deco->X + deco->width / 2.0, deco->Y + deco->height / 2.0,
+ deco->text,
+ G_CALLBACK(deco_activate), deco);
+}
+
+void rename_text_activate(GtkText* self, gpointer user_data) {
+ struct device* dev = (struct device*)user_data;
+
+ const char* new_name = gtk_entry_buffer_get_text(gtk_text_get_buffer(self));
+
+ struct device* exist_dev = dev_from_name(start_device, new_name);
+
+ if(exist_dev == dev);
+ else if(exist_dev) {
+ fprintf(stderr, "Error: Device with name %s already exists\n", new_name);
+ } else {
+ // Add an entry
+ struct undo_entry* uentry;
+ struct undo_ren_data* ren_data;
+
+ NEW_UNDO_STRUCT(undo_ren_dev, undo_ren_data, uentry, ren_data);
+ ren_data->dev = dev;
+ ren_data->old_name = malloc_or_abort(strlen(dev->name) + 1);
+ strcpy(ren_data->old_name, dev->name);
+ ren_data->new_name = malloc_or_abort(strlen(new_name) + 1);
+ strcpy(ren_data->new_name, new_name);
+
+ rename_device(dev, new_name);
+
+ undo_add_entry(uentry);
+ }
+ // Destruct
+ GtkWidget* parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(self)));
+ gtk_popover_popdown(GTK_POPOVER(parent));
+ gtk_widget_unparent(parent);
-// Mouseclick start
-void drawing_area_click(GtkGestureClick* self, gint n_press, gdouble x, gdouble y, gpointer user_data) {
+ gtk_widget_queue_draw(main_drawing_area);
+}
+
+void gui_rename_device(struct device* dev) {
+ new_text_popover_point_to(dev->X + dev->template->icon_size / 2,
+ dev->Y + dev->template->icon_size + AREA_TEXT_SIZE,
+ dev->name, G_CALLBACK(rename_text_activate), dev);
+}
+
+// Start position of the object being moved before the operation
+double movement_start_x = 0, movement_start_y = 0;
+
+void drawing_area_drag_begin(GtkGestureDrag* self, gdouble x, gdouble y, gpointer user_data) {
+ printf("%lf %lf\n", x, y);
+
x = COORD_NORM(x);
y = COORD_NORM(y);
- xstart = x;
- ystart = y;
- x_last = xstart, y_last = ystart;
- area_pressed = true;
+
+ printf("START\n");
+
if(area_mode == MODE_NEW_RECT || area_mode == MODE_NEW_CIRCLE) {
sizing_deco = deco_new(area_mode == MODE_NEW_RECT ?
- deco_type_rect :
- deco_type_circle);
- sizing_deco->X = x;
- sizing_deco->Y = y;
+ deco_type_rect :
+
+ deco_type_circle);
+ sizing_deco->X = x;
+ sizing_deco->Y = y;
- struct undo_entry* undo_new = NULL;
- struct undo_add_deco_data* undo_add_deco_data_new = NULL;
+ struct undo_entry* undo_new = NULL;
+ struct undo_add_deco_data* undo_add_deco_data_new = NULL;
+ NEW_UNDO_STRUCT(undo_add_deco, undo_add_deco_data, undo_new, undo_add_deco_data_new);
+ undo_add_deco_data_new->deco = sizing_deco;
+ sizing_deco->refs++;
+ undo_add_entry(undo_new);
+ return;
+ }
+ if(area_mode == MODE_MOVE) {
+ // Check for a device or deco directly beneath the pointer
+ if((moving_selection = get_device_at(x,y,x,y))){
+ if(moving_selection && device_in_selection(selected_devices, moving_selection->selected_device)) {
+ free_selection(moving_selection);
+ moving_selection = selected_devices;
+ }
+ }
+ else if((move_deco = get_deco_at(x,y,x,y))) {
+ movement_start_x = move_deco->X;
+ movement_start_y = move_deco->Y;
+ }
+ }
+}
+
+void move_device_selection(struct device_selection* sel,
+ double start_x, double start_y,
+ double xoff, double yoff, bool add_undo) {
+
+}
+
+void drawing_area_drag_update(GtkGestureDrag* self, gdouble xoff, gdouble yoff, gpointer user_data) {
+ printf("UPDATE\n");
+ double start_x, start_y;
+ gtk_gesture_drag_get_start_point(self, &start_x, &start_y);
+ if(move_deco) {
+ move_deco->X = movement_start_x + COORD_NORM(xoff);
+ move_deco->Y = movement_start_y + COORD_NORM(yoff);
+ } else if(moving_selection) {
+ move_device_selection(moving_selection, start_x, start_y, xoff, yoff, false);
+ } else if(sizing_deco) {
+ printf("SIZING\n");
+ sizing_deco->width = COORD_NORM(xoff);
+ sizing_deco->height = COORD_NORM(yoff);
+ } else if(area_mode == MODE_MOVE) {
+ selection_rectangle_active = true;
+ // Start a selection
+ selection_rectangle.origin.x = COORD_NORM(start_x);
+ selection_rectangle.origin.y = COORD_NORM(start_y);
+
+ selection_rectangle.size.width = COORD_NORM(xoff);
+ selection_rectangle.size.height = COORD_NORM(yoff);
+ }
+ gtk_widget_queue_draw(main_drawing_area);
+}
+
+void drawing_area_drag_end(GtkGestureDrag* self, gdouble xoff, gdouble yoff, gpointer user_data) {
+ printf("END\n");
+ double start_x, start_y, x, y;
+ gtk_gesture_drag_get_start_point(self, &start_x, &start_y);
+ x = COORD_NORM(start_x + xoff);
+ y = COORD_NORM(start_y + yoff);
+ struct undo_entry* undo_new = NULL;
+ switch(area_mode) {
+ case MODE_MOVE: {
+ // Open the device window on a short press
+ if(xoff < 5 && xoff > -5 && yoff < 5 && yoff > -5) {
+ struct device_selection* clicked_device = get_device_at(x,y,x,y);
+ struct deco* clicked_deco = NULL;
+ if(clicked_device) {
+ show_device_window(clicked_device->selected_device);
+ free_selection(clicked_device);
+ } else if((clicked_device = get_device_at(x,y-AREA_TEXT_SIZE,x,y-AREA_TEXT_SIZE))) {
+ gui_rename_device(clicked_device->selected_device);
+ } else if((clicked_deco = get_deco_at(x,y,x,y))) {
+ gui_change_deco_text(clicked_deco);
+ } else {
+ // Nothing has been clicked, free the selection
+ free_selection(selected_devices);
+ selected_devices = NULL;
+ gtk_widget_queue_draw(main_drawing_area);
+ }
+ } else {
+ // select devices
+ if(selection_rectangle_active) {
+ printf("SELECTING DEVICES\n");
+ free_selection(selected_devices);
+ selected_devices = get_device_at(selection_rectangle.size.width > 0 ? selection_rectangle.origin.x : selection_rectangle.origin.x + selection_rectangle.size.width,
+ selection_rectangle.size.height > 0 ? selection_rectangle.origin.y : selection_rectangle.origin.y + selection_rectangle.size.height,
+ selection_rectangle.size.width > 0 ? selection_rectangle.origin.x + selection_rectangle.size.width : selection_rectangle.origin.x,
+ selection_rectangle.size.height > 0 ? selection_rectangle.origin.y + selection_rectangle.size.height : selection_rectangle.origin.y
+ );
+ break;
+ }
+ }
+ break;
+ }
+ case MODE_NEW_DEVICE: {
+ char* dev_name = malloc_or_abort(strlen(selected_device_template->name) + 6);
+ strcpy(dev_name, selected_device_template->name);
+ // Use at most two digits
+ for(int i = 1; dev_from_name(start_device, dev_name) && i < 100; i++) {
+ sprintf(dev_name, "%s (%d)", selected_device_template->name, i);
+ }
+ struct device* created_device = new_device(&start_device, dev_name, selected_device_template, true);
+ free(dev_name);
+ if(created_device) {
+ created_device->X = x - (created_device->template->icon_size >> 2);
+ created_device->Y = y - (created_device->template->icon_size >> 2);
+ // Add the action to the list
+ struct undo_add_dev_data* undo_add_new;
+ NEW_UNDO_STRUCT(undo_add_dev, undo_add_dev_data, undo_new, undo_add_new);
+ undo_add_new->dev = created_device;
+ undo_add_new->template = created_device->template;
+ undo_add_entry(undo_new);
+ }
+ break;
+ }
+ case MODE_NEW_CONNECTION: {
+ select_interface_at(x, y);
+ break;
+ }
+ case MODE_NEW_TEXT: {
+ struct deco* new_deco = deco_new(deco_type_text);
+ new_deco->X = x;
+ new_deco->Y = y;
+ gui_change_deco_text(new_deco);
+
+ struct undo_add_deco_data* undo_add_deco_data_new = NULL;
NEW_UNDO_STRUCT(undo_add_deco, undo_add_deco_data, undo_new, undo_add_deco_data_new);
- undo_add_deco_data_new->deco = sizing_deco;
- sizing_deco->refs++;
+ undo_add_deco_data_new->deco = new_deco;
+ new_deco->refs++;
undo_add_entry(undo_new);
- return;
+ break;
+ }
+ case MODE_DELETE: {
+ struct device_selection* del_device = get_device_at(x,y,x,y);
+ // If we clicked a device delete it
+ if(del_device) {
+ // Use free device later once this action is removed from the undo stack
+ // Add the action to the list
+ struct undo_del_dev_data* undo_del_new;
+ NEW_UNDO_STRUCT(undo_del_dev, undo_del_dev_data, undo_new, undo_del_new);
+ undo_del_new->dev = del_device->selected_device;
+ delete_device(&start_device, del_device->selected_device);
+ undo_add_entry(undo_new);
+
+ free_selection(del_device);
+ break;
+ }
+ struct connection* delete_con = get_connection_at(x-2,y-2,x+2,y+2);
+ if(delete_con) {
+
+ struct undo_del_con_data* undo_del_con_new = NULL;
+ NEW_UNDO_STRUCT(undo_del_con, undo_del_con_data, undo_new, undo_del_con_new);
+ undo_del_con_new->int1 = delete_con->interface1;
+ undo_del_con_new->int2 = delete_con->interface2;
+ undo_del_con_new->template = delete_con->template;
+ undo_add_entry(undo_new);
+ delete_connection(delete_con);
+ break;
+ }
+ struct deco* delete_text = get_deco_at(x,y,x,y);
+ if(delete_text) {
+ struct undo_del_deco_data* undo_del_deco_data_new = NULL;
+ NEW_UNDO_STRUCT(undo_del_deco, undo_del_deco_data, undo_new, undo_del_deco_data_new);
+ undo_del_deco_data_new->deco = delete_text;
+ delete_text->refs++;
+ undo_add_entry(undo_new);
+
+ deco_unappend(delete_text);
+ }
+ break;
+ }
+
}
- struct device_selection* single_device;
- struct deco* clicked_deco;
- if((single_device = get_device_at(x,y,x,y))) {
- current_move_dev = single_device->selected_device;
- area_moving = true;
- free_selection(single_device);
- } else if((clicked_deco = get_deco_at(x,y,x,y))) {
- current_move_deco = clicked_deco;
- area_moving = true;
- } else
- area_moving = false;
+ sizing_deco = NULL;
+ move_deco = NULL;
+ moving_selection = NULL;
+ movement_start_x = 0, movement_start_y = 0;
+ selection_rectangle_active = false;
+ gtk_widget_queue_draw(main_drawing_area);
}
-// This will move a device or select the devices below the area
+
+/*// This will move a device or select the devices below the area
// Set undo to true if this should be recorded in the undo stack
void move_things(double x, double y, bool undo) {
double xoff = x - x_last;
@@ -903,6 +1162,7 @@ void move_things(double x, double y, bool undo) {
x_last = x, y_last = y;
gtk_widget_queue_draw(main_drawing_area);
}
+*/
// Delete the devices in the current selection
void delete_selection() {
@@ -926,99 +1186,7 @@ void delete_selection() {
}
}
-void rename_text_activate(GtkText* self, gpointer user_data) {
- struct device* dev = (struct device*)user_data;
-
- const char* new_name = gtk_entry_buffer_get_text(gtk_text_get_buffer(self));
-
- struct device* exist_dev = dev_from_name(start_device, new_name);
-
- if(exist_dev == dev);
- else if(exist_dev) {
- fprintf(stderr, "Error: Device with name %s already exists\n", new_name);
- } else {
- // Add an entry
- struct undo_entry* uentry;
- struct undo_ren_data* ren_data;
-
- NEW_UNDO_STRUCT(undo_ren_dev, undo_ren_data, uentry, ren_data);
- ren_data->dev = dev;
- ren_data->old_name = malloc_or_abort(strlen(dev->name) + 1);
- strcpy(ren_data->old_name, dev->name);
- ren_data->new_name = malloc_or_abort(strlen(new_name) + 1);
- strcpy(ren_data->new_name, new_name);
-
- rename_device(dev, new_name);
-
- undo_add_entry(uentry);
- }
- // Destruct
- GtkWidget* parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(self)));
- gtk_popover_popdown(GTK_POPOVER(parent));
- gtk_widget_unparent(parent);
-
- gtk_widget_queue_draw(main_drawing_area);
-}
-
-void text_popover_close(GtkPopover* self, gpointer user_data) {
- g_signal_emit_by_name(G_OBJECT(gtk_popover_get_child(self)), "activate");
-}
-
-GtkWidget* new_text_popover_point_to(double x, double y, char* text, GCallback callback, void* callback_data) {
- GtkWidget* popover = gtk_popover_new();
- gtk_widget_set_parent(popover, main_drawing_area);
- // Point to the device text
- GdkRectangle text_rect = {.x = COORD_UNORM(x), .y = COORD_UNORM(y), .width = 1, .height = 1};
- gtk_popover_set_pointing_to(GTK_POPOVER(popover), &text_rect);
- GtkWidget* pop_text = gtk_text_new();
- gtk_entry_buffer_set_text(gtk_text_get_buffer(GTK_TEXT(pop_text)), text ? text : "", -1);
- gtk_popover_set_child(GTK_POPOVER(popover), pop_text);
-
- g_signal_connect(G_OBJECT(popover), "closed", G_CALLBACK(text_popover_close), callback_data);
- g_signal_connect(G_OBJECT(pop_text),
- "activate",
- G_CALLBACK(callback),
- callback_data);
- gtk_popover_popup(GTK_POPOVER(popover));
- return popover;
-}
-
-void gui_rename_device(struct device* dev) {
- new_text_popover_point_to(dev->X + dev->template->icon_size / 2,
- dev->Y + dev->template->icon_size + AREA_TEXT_SIZE,
- dev->name, G_CALLBACK(rename_text_activate), dev);
-}
-
-void deco_activate(GtkText* self, struct deco* deco) {
- const char* new_text = gtk_entry_buffer_get_text(gtk_text_get_buffer(self));
-
- struct undo_entry* undo_new = NULL;
- struct undo_set_deco_data* undo_set_deco_data_new = NULL;
- NEW_UNDO_STRUCT(undo_set_deco, undo_set_deco_data, undo_new, undo_set_deco_data_new);
- deco->refs++;
- undo_set_deco_data_new->new_text = malloc(strlen(new_text) + 1);
- strcpy(undo_set_deco_data_new->new_text, new_text);
- undo_set_deco_data_new->old_text = malloc(strlen(deco->text) + 1);
- strcpy(undo_set_deco_data_new->old_text, deco->text);
- undo_set_deco_data_new->deco = deco;
- undo_add_entry(undo_new);
-
- deco_text_set(deco, new_text);
-
- gtk_widget_queue_draw(main_drawing_area);
-
- GtkWidget* parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(self)));
- gtk_popover_popdown(GTK_POPOVER(parent));
- gtk_widget_unparent(parent);
-}
-
-void gui_change_deco_text(struct deco* deco) {
- new_text_popover_point_to(deco->X + deco->width / 2.0, deco->Y + deco->height / 2.0,
- deco->text,
- G_CALLBACK(deco_activate), deco);
-}
-
-// Mouseclick release
+/*// Mouseclick release
void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdouble y, gpointer user_data) {
x = COORD_NORM(x);
y = COORD_NORM(y);
@@ -1054,25 +1222,7 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
area_moving = false;
break;
case MODE_NEW_DEVICE:;
- char* dev_name = malloc_or_abort(strlen(selected_device_template->name) + 6);
- strcpy(dev_name, selected_device_template->name);
- // Use at most two digits
- for(int i = 1; dev_from_name(start_device, dev_name) && i < 100; i++) {
- sprintf(dev_name, "%s (%d)", selected_device_template->name, i);
- }
- struct device* created_device = new_device(&start_device, dev_name, selected_device_template, true);
- free(dev_name);
- if(created_device) {
- created_device->X = x - (created_device->template->icon_size >> 2);
- created_device->Y = y - (created_device->template->icon_size >> 2);
- // Add the action to the list
- struct undo_add_dev_data* undo_add_new;
- NEW_UNDO_STRUCT(undo_add_dev, undo_add_dev_data, undo_new, undo_add_new);
- undo_add_new->dev = created_device;
- undo_add_new->template = created_device->template;
- undo_add_entry(undo_new);
- }
- break;
+
case MODE_NEW_CONNECTION:
select_interface_at(x, y);
break;
@@ -1135,6 +1285,7 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
gtk_widget_queue_draw(main_drawing_area);
area_pressed = false;
}
+*/
// Insert devices in the clipboard
void paste_selection_clipboard() {
@@ -1275,26 +1426,6 @@ bool drawing_area_key(GtkEventControllerKey* self, guint keyval, guint keycode,
}
}
-// Mouse movement
-void drawing_area_motion(GtkEventControllerKey* self, gdouble x, gdouble y, gpointer user_data) {
- x = COORD_NORM(x);
- y = COORD_NORM(y);
- xnow = x;
- ynow = y;
-
- if(area_mode == MODE_MOVE && area_moving && x >= 0 && y >= 0)
- move_things(x, y, false);
- else if(area_mode == MODE_NEW_RECT || area_mode == MODE_NEW_CIRCLE) {
- if(sizing_deco) {
- // Change deco size
- sizing_deco->width = x - xstart;
- sizing_deco->height = y - ystart;
- }
- }
- if(area_pressed)
- gtk_widget_queue_draw(gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(self)));
-}
-
// === Called by a device when it sends something
// Will be used to fill the tree of packets
@@ -1994,18 +2125,25 @@ void activate_main_window(GtkApplication* app, gpointer user_data) {
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (main_drawing_area), 1000);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (main_drawing_area), 1000);
// Handle mouse events for the drawing area
+ /*
GtkGesture* drawing_area_click_controller = gtk_gesture_click_new();
g_signal_connect(G_OBJECT(drawing_area_click_controller), "pressed", G_CALLBACK(drawing_area_click), NULL);
g_signal_connect(G_OBJECT(drawing_area_click_controller), "released", G_CALLBACK(drawing_area_release), NULL);
gtk_widget_add_controller(main_drawing_area, GTK_EVENT_CONTROLLER(drawing_area_click_controller));
+ */
+ GtkGesture* drawing_area_drag_controller = gtk_gesture_drag_new();
+ g_signal_connect(G_OBJECT(drawing_area_drag_controller), "drag-begin", G_CALLBACK(drawing_area_drag_begin), NULL);
+ g_signal_connect(G_OBJECT(drawing_area_drag_controller), "drag-end", G_CALLBACK(drawing_area_drag_end), NULL);
+ g_signal_connect(G_OBJECT(drawing_area_drag_controller), "drag-update", G_CALLBACK(drawing_area_drag_update), NULL);
+ gtk_widget_add_controller(main_drawing_area, GTK_EVENT_CONTROLLER(drawing_area_drag_controller));
// Handle keyboard events fot the drawing area
GtkEventController* drawing_area_key_controller = gtk_event_controller_key_new();
g_signal_connect(G_OBJECT(drawing_area_key_controller), "key-pressed", G_CALLBACK(drawing_area_key), NULL);
gtk_widget_add_controller(window, GTK_EVENT_CONTROLLER(drawing_area_key_controller));
- // Handle mouse movement inside the drawing area
+ /*// Handle mouse movement inside the drawing area
GtkEventController* drawing_area_motion_controller = gtk_event_controller_motion_new();
g_signal_connect(G_OBJECT(drawing_area_motion_controller), "motion", G_CALLBACK(drawing_area_motion), NULL);
- gtk_widget_add_controller(main_drawing_area, GTK_EVENT_CONTROLLER(drawing_area_motion_controller));
+ gtk_widget_add_controller(main_drawing_area, GTK_EVENT_CONTROLLER(drawing_area_motion_controller));*/
// Set the drawing area as child for the scrolling window
// Add a viewport around the drawing area
GtkWidget* drawing_area_viewport = gtk_viewport_new(NULL, NULL);
Jeremias Stotters git repositories generated by CGIT