gboolean ghid_note_event_location (GdkEventButton * ev) { gint event_x, event_y; gboolean moved; if (!ev) { gdk_window_get_pointer (gtk_widget_get_window (ghid_port.drawing_area), &event_x, &event_y, NULL); } else { event_x = ev->x; event_y = ev->y; } ghid_event_to_pcb_coords (event_x, event_y, &gport->pcb_x, &gport->pcb_y); moved = MoveCrosshairAbsolute (gport->pcb_x, gport->pcb_y); if (moved) { AdjustAttachedObjects (); notify_crosshair_change (true); } ghid_set_cursor_position_labels (); return moved; }
gboolean ghid_port_button_release_cb (GtkWidget * drawing_area, GdkEventButton * ev, GtkUIManager * ui) { ModifierKeysState mk; gboolean drag; GdkModifierType state; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); drag = have_crosshair_attachments (); if (drag) HideCrosshair (TRUE); do_mouse_action(ev->button, mk + M_Release); if (drag) { AdjustAttachedObjects (); ghid_invalidate_all (); RestoreCrosshair (TRUE); ghid_screen_update (); } ghid_set_status_line_label (); g_idle_add (ghid_idle_cb, NULL); return TRUE; }
gboolean ghid_note_event_location (GdkEventButton * ev) { gint x, y; gboolean moved; if (!ev) { gdk_window_get_pointer (ghid_port.drawing_area->window, &x, &y, NULL); event_x = x; event_y = y; } else { event_x = ev->x; event_y = ev->y; } gport->view_x = event_x * gport->zoom + gport->view_x0; gport->view_y = event_y * gport->zoom + gport->view_y0; moved = MoveCrosshairAbsolute (SIDE_X (gport->view_x), SIDE_Y (gport->view_y)); if (moved) { AdjustAttachedObjects (); RestoreCrosshair (false); } ghid_set_cursor_position_labels (); return moved; }
gboolean ghid_port_key_release_cb (GtkWidget * drawing_area, GdkEventKey * kev, gpointer data) { gint ksym = kev->keyval; if (ghid_is_modifier_key_sym (ksym)) ghid_note_event_location (NULL); AdjustAttachedObjects (); ghid_invalidate_all (); g_idle_add (ghid_idle_cb, NULL); return FALSE; }
gboolean ghid_port_key_release_cb (GtkWidget * drawing_area, GdkEventKey * kev, GtkUIManager * ui) { gint ksym = kev->keyval; if (ghid_is_modifier_key_sym (ksym)) ghid_note_event_location (NULL); HideCrosshair (TRUE); AdjustAttachedObjects (); ghid_invalidate_all (); RestoreCrosshair (TRUE); ghid_screen_update (); g_idle_add (ghid_idle_cb, NULL); return FALSE; }
gboolean ghid_port_button_release_cb (GtkWidget * drawing_area, GdkEventButton * ev, gpointer data) { ModifierKeysState mk; GdkModifierType state; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); do_mouse_action(ev->button, mk + M_Release); AdjustAttachedObjects (); ghid_invalidate_all (); ghid_window_set_name_label (PCB->Name); ghid_set_status_line_label (); g_idle_add (ghid_idle_cb, NULL); return TRUE; }
/* --------------------------------------------------------------------------- * set a new mode and update X cursor */ void SetMode (int Mode) { static bool recursing = false; /* protect the cursor while changing the mode * perform some additional stuff depending on the new mode * reset 'state' of attached objects */ if (recursing) return; recursing = true; notify_crosshair_change (false); addedLines = 0; Crosshair.AttachedObject.Type = NO_TYPE; Crosshair.AttachedObject.State = STATE_FIRST; Crosshair.AttachedPolygon.PointN = 0; if (PCB->RatDraw) { if (Mode == ARC_MODE || Mode == RECTANGLE_MODE || Mode == VIA_MODE || Mode == POLYGON_MODE || Mode == POLYGONHOLE_MODE || Mode == TEXT_MODE || Mode == INSERTPOINT_MODE || Mode == THERMAL_MODE) { Message (_("That mode is NOT allowed when drawing ratlines!\n")); Mode = NO_MODE; } } if (Settings.Mode == LINE_MODE && Mode == ARC_MODE && Crosshair.AttachedLine.State != STATE_FIRST) { Crosshair.AttachedLine.State = STATE_FIRST; Crosshair.AttachedBox.State = STATE_SECOND; Crosshair.AttachedBox.Point1.X = Crosshair.AttachedBox.Point2.X = Crosshair.AttachedLine.Point1.X; Crosshair.AttachedBox.Point1.Y = Crosshair.AttachedBox.Point2.Y = Crosshair.AttachedLine.Point1.Y; AdjustAttachedObjects (); } else if (Settings.Mode == ARC_MODE && Mode == LINE_MODE && Crosshair.AttachedBox.State != STATE_FIRST) { Crosshair.AttachedBox.State = STATE_FIRST; Crosshair.AttachedLine.State = STATE_SECOND; Crosshair.AttachedLine.Point1.X = Crosshair.AttachedLine.Point2.X = Crosshair.AttachedBox.Point1.X; Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = Crosshair.AttachedBox.Point1.Y; Settings.Mode = Mode; AdjustAttachedObjects (); } else { if (Settings.Mode == ARC_MODE || Settings.Mode == LINE_MODE) SetLocalRef (0, 0, false); Crosshair.AttachedBox.State = STATE_FIRST; Crosshair.AttachedLine.State = STATE_FIRST; if (Mode == LINE_MODE && TEST_FLAG (AUTODRCFLAG, PCB)) { if (ResetConnections (true)) { IncrementUndoSerialNumber (); Draw (); } } } Settings.Mode = Mode; if (Mode == PASTEBUFFER_MODE) /* do an update on the crosshair range */ SetCrosshairRangeToBuffer (); else SetCrosshairRange (0, 0, PCB->MaxWidth, PCB->MaxHeight); recursing = false; /* force a crosshair grid update because the valid range * may have changed */ MoveCrosshairRelative (0, 0); notify_crosshair_change (true); }