desktop-events.cpp revision 3b9b25de18b8fef19ad5ff06ae6e73f8cf30d914
/** @file
* @brief Event handlers for SPDesktop
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 1999-2010 Others
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <map>
#include <string>
#include "desktop.h"
#include "desktop-handles.h"
#include "dialogs/dialog-events.h"
#include "display/canvas-axonomgrid.h"
#include "display/canvas-grid.h"
#include "display/guideline.h"
#include "display/snap-indicator.h"
#include "document.h"
#include "event-context.h"
#include "helper/unit-menu.h"
#include "message-context.h"
#include "preferences.h"
#include "snap.h"
#include "sp-guide.h"
#include "sp-metrics.h"
#include "sp-namedview.h"
#include "tools-switch.h"
#include "widgets/desktop-widget.h"
static void init_extended();
/* Root item handler */
{
static bool watch = false;
static bool first = true;
if ( first ) {
watch = true;
}
first = false;
}
if ( watch ) {
}
}
{
static bool dragging = false;
gdk_window_get_geometry(GTK_WIDGET(dtw->canvas)->window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
case GDK_BUTTON_PRESS:
dragging = true;
// explicitly show guidelines; if I draw a guide, I want them on
// calculate the normal of the guidelines when dragged from the edges of rulers.
// guidelines normal to gridlines
} else {
}
}
if (horiz) {
if (wx < 50) {
} else {
}
} else {
if (wy < 50) {
} else {
}
}
}
break;
case GDK_MOTION_NOTIFY:
if (dragging) {
// We only have a temporary guide which is not stored in our document yet.
// Because the guide snapper only looks in the document for guides to snap to,
// we don't have to worry about a guide snapping to itself here
}
}
break;
case GDK_BUTTON_RELEASE:
// We only have a temporary guide which is not stored in our document yet.
// Because the guide snapper only looks in the document for guides to snap to,
// we don't have to worry about a guide snapping to itself here
}
dragging = false;
_("Create guide"));
}
}
default:
break;
}
return FALSE;
}
{
sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HRULER);
}
}
{
sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_VRULER);
}
}
//static bool reset_drag_origin = false; // when Ctrl is pressed while dragging, this is used to trigger resetting of the
// // drag origin to that location so that constrained movement is more intuitive
// Min distance from anchor to initiate rotation, measured in screenpixels
#define tol 40.0
{
static bool moved = false;
SPDesktop *desktop = static_cast<SPDesktop*>(gtk_object_get_data(GTK_OBJECT(item->canvas), "SPDesktop"));
case GDK_2BUTTON_PRESS:
}
break;
case GDK_BUTTON_PRESS:
// Due to the tolerance allowed when grabbing a guide, event_dt will generally
// be close to the guide but not just exactly on it. The drag origin calculated
// here must be exactly on the guide line though, otherwise
// small errors will occur once we snap, see
// with shift we rotate the guide
} else {
} else {
}
}
NULL,
}
}
break;
case GDK_MOTION_NOTIFY:
if (drag_type != SP_DRAG_NONE) {
sp_event_context_snap_delay_handler(desktop->event_context, (gpointer) item, data, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HANDLER);
// This is for snapping while dragging existing guidelines. New guidelines,
// which are dragged off the ruler, are being snapped in sp_dt_ruler_event
if (drag_type == SP_DRAG_MOVE_ORIGIN) {
// If we snap in guideConstrainedSnap() below, then motion_dt will
// be forced to be on the guide. If we don't snap however, then
// the origin should still be constrained to the guide. So let's do
// that explicitly first:
}
// cannot use shift here to disable snapping, because we already use it for rotating the guide
}
switch (drag_type) {
case SP_DRAG_TRANSLATE:
{
break;
}
case SP_DRAG_ROTATE:
{
if (snaps) {
}
}
break;
}
case SP_DRAG_MOVE_ORIGIN:
{
break;
}
case SP_DRAG_NONE:
break;
}
moved = true;
}
break;
case GDK_BUTTON_RELEASE:
if (moved) {
if (drag_type == SP_DRAG_MOVE_ORIGIN) {
// If we snap in guideConstrainedSnap() below, then motion_dt will
// be forced to be on the guide. If we don't snap however, then
// the origin should still be constrained to the guide. So let's
// do that explicitly first:
}
// cannot use shift here to disable snapping, because we already use it for rotating the guide
}
switch (drag_type) {
case SP_DRAG_TRANSLATE:
{
break;
}
case SP_DRAG_ROTATE:
{
if (snaps) {
}
}
break;
}
case SP_DRAG_MOVE_ORIGIN:
{
break;
}
case SP_DRAG_NONE:
break;
}
_("Move guide"));
} else {
/* Undo movement of any attached shapes. */
_("Delete guide"));
}
moved = false;
}
}
case GDK_ENTER_NOTIFY:
{
// set move or rotate cursor
}
desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description);
break;
}
case GDK_LEAVE_NOTIFY:
// restore event context's cursor
gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, desktop->event_context->cursor);
break;
case GDK_KEY_PRESS:
case GDK_Delete:
case GDK_KP_Delete:
case GDK_BackSpace:
{
break;
}
case GDK_Shift_L:
case GDK_Shift_R:
if (drag_type != SP_DRAG_MOVE_ORIGIN) {
break;
}
default:
// do nothing;
break;
}
break;
case GDK_KEY_RELEASE:
case GDK_Shift_L:
case GDK_Shift_R:
break;
default:
// do nothing;
break;
}
default:
break;
}
return ret;
}
//static std::map<GdkInputSource, std::string> switchMap;
static void init_extended()
{
if ( devices ) {
// g_message("Adding '%s' as [%d]", dev->name, dev->source);
// Set the initial tool for the device
case GDK_SOURCE_PEN:
break;
case GDK_SOURCE_ERASER:
break;
case GDK_SOURCE_CURSOR:
break;
default:
; // do not add
}
// } else if (dev->name) {
// g_message("Skippn '%s' as [%s]", dev->name, dev->source);
}
}
}
}
{
case GDK_MOTION_NOTIFY:
{
}
}
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
{
}
}
break;
case GDK_SCROLL:
{
}
}
break;
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
{
}
}
break;
default:
;
}
// The device switched. See if it is one we 'count'
//g_message("Changed device %s -> %s", lastName.c_str(), name.c_str());
// Save the tool currently selected for next time the input
// device shows up.
}
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :