/* ---------------------------------------------------------------------- * copies all selected and visible objects to the paste buffer * returns true if any objects have been removed */ void AddSelectedToBuffer (BufferType *Buffer, Coord X, Coord Y, bool LeaveSelected) { /* switch crosshair off because adding objects to the pastebuffer * may change the 'valid' area for the cursor */ if (!LeaveSelected) ExtraFlag = SELECTEDFLAG; notify_crosshair_change (false); Source = PCB->Data; Dest = Buffer->Data; SelectedOperation (&AddBufferFunctions, false, ALL_TYPES); /* set origin to passed or current position */ if (X || Y) { Buffer->X = X; Buffer->Y = Y; } else { Buffer->X = Crosshair.X; Buffer->Y = Crosshair.Y; } notify_crosshair_change (true); ExtraFlag = 0; }
int ActionFreeRotateBuffer(int argc, char **argv, Coord x, Coord y) { char *angle_s; if (argc < 1) angle_s = gui->prompt_for (_("Enter Rotation (degrees, CCW):"), "0"); else angle_s = argv[0]; notify_crosshair_change (false); FreeRotateBuffer(PASTEBUFFER, strtod(angle_s, 0)); notify_crosshair_change (true); return 0; }
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; }
/*! * \brief Move crosshair absolute. * * \return true if the crosshair was moved from its existing position. */ bool MoveCrosshairAbsolute (Coord X, Coord Y) { Coord old_x = Crosshair.X; Coord old_y = Crosshair.Y; FitCrosshairIntoGrid (X, Y); if (Crosshair.X != old_x || Crosshair.Y != old_y) { Coord new_x = Crosshair.X; Coord new_y = Crosshair.Y; /* back up to old position to notify the GUI * (which might want to erase the old crosshair) */ Crosshair.X = old_x; Crosshair.Y = old_y; notify_crosshair_change (false); /* Our caller notifies when it has done */ /* now move forward again */ Crosshair.X = new_x; Crosshair.Y = new_y; return true; } return false; }
void RestoreCrosshair (void) { static bool warned_old_api = false; if (!warned_old_api) { Message (_("WARNING: A plugin is using the deprecated API RestoreCrosshair().\n" " This API may be removed in a future release of PCB.\n")); warned_old_api = true; } notify_crosshair_change (true); notify_mark_change (true); }
/* --------------------------------------------------------------------------- * move crosshair absolute * return true if the crosshair was moved from its existing position */ bool MoveCrosshairAbsolute (Coord X, Coord Y) { Coord x, y, z; x = Crosshair.X; y = Crosshair.Y; FitCrosshairIntoGrid (X, Y); if (Crosshair.X != x || Crosshair.Y != y) { /* back up to old position to notify the GUI * (which might want to erase the old crosshair) */ z = Crosshair.X; Crosshair.X = x; x = z; z = Crosshair.Y; Crosshair.Y = y; notify_crosshair_change (false); /* Our caller notifies when it has done */ /* now move forward again */ Crosshair.X = x; Crosshair.Y = z; return (true); } return (false); }
/* --------------------------------------------------------------------------- * 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); }
/* Run a glib GMainLoop which intercepts key and mouse button events from | the top level loop. When a mouse or key is hit in the Output drawing | area, quit the loop so the top level loop can continue and use the | the mouse pointer coordinates at the time of the mouse button event. */ static gboolean run_get_location_loop (const gchar * message) { GMainLoop *loop; gulong button_handler, key_handler; gint oldObjState, oldLineState, oldBoxState; /* Make the text cue bold so it hides less and looks like command prompt */ GString *bold_message = g_string_new (message); g_string_prepend (bold_message, "<b>"); g_string_append (bold_message, "</b>"); ghid_status_line_set_text (bold_message->str); g_string_free (bold_message, TRUE); oldObjState = Crosshair.AttachedObject.State; oldLineState = Crosshair.AttachedLine.State; oldBoxState = Crosshair.AttachedBox.State; notify_crosshair_change (false); Crosshair.AttachedObject.State = STATE_FIRST; Crosshair.AttachedLine.State = STATE_FIRST; Crosshair.AttachedBox.State = STATE_FIRST; ghid_hand_cursor (); notify_crosshair_change (true); /* Stop the top level GMainLoop from getting user input from keyboard | and mouse so we can install our own handlers here. Also set the | control interface insensitive so all the user can do is hit a key | or mouse button in the Output drawing area. */ ghid_interface_input_signals_disconnect (); ghid_interface_set_sensitive (FALSE); got_location = TRUE; /* Will be unset by hitting most keys */ button_handler = g_signal_connect (G_OBJECT (gport->drawing_area), "button_press_event", G_CALLBACK (loop_button_press_cb), &loop); key_handler = g_signal_connect (G_OBJECT (gport->top_window), "key_press_event", G_CALLBACK (loop_key_press_cb), &loop); loop = g_main_loop_new (NULL, FALSE); GDK_THREADS_LEAVE (); g_main_loop_run (loop); GDK_THREADS_ENTER (); g_main_loop_unref (loop); g_signal_handler_disconnect (gport->drawing_area, button_handler); g_signal_handler_disconnect (gport->top_window, key_handler); ghid_interface_input_signals_connect (); /* return to normal */ ghid_interface_set_sensitive (TRUE); notify_crosshair_change (false); Crosshair.AttachedObject.State = oldObjState; Crosshair.AttachedLine.State = oldLineState; Crosshair.AttachedBox.State = oldBoxState; notify_crosshair_change (true); ghid_restore_cursor (); ghid_set_status_line_label (); return got_location; }