desktop-events.cpp revision 59e144f01d1f19fbb5bf62edc65e083272d8a1b4
/** @file
* @brief Event handlers for SPDesktop
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
*
* 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;
static bool snap_window_temporarily_open = false;
gdk_window_get_geometry(GTK_WIDGET(dtw->canvas)->window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
case GDK_BUTTON_PRESS:
dragging = true;
// FIXME: The snap delay mechanism won't work here, because it has been implemented for the event context. Dragging
// guides off the ruler will send event to the ruler and not to the context, which bypasses sp_event_context_snap_delay_handler
// The snap manager will not notice the difference, so it'll check if the snap delay has been activated (This check
// is only needed for catching coding errors, i.e. to warn if the snap window has not been implemented properly
// in some context)
// A dt_ruler_event might be emitted when dragging a guide off the rulers while drawing a Bezier curve
// In such a situation, we're already in that specific context and the snap delay is already active. We should
// not set the snap delay to active again, because that will trigger a similar warning to the one above
snap_window_temporarily_open = 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;
// See the comments in GDK_BUTTON_PRESS
if (snap_window_temporarily_open) {
snap_window_temporarily_open = false;
}
_("Create guide"));
}
// A dt_ruler_event might be emitted when dragging a guide of the rulers while drawing a Bezier curve
// In such a situation, we're already in that specific context and the snap delay is already active. We should
// interfere with that context and we should therefore leave the snap delay status as it is. So although it might
// have been set to active above on GDK_BUTTON_PRESS, we should not set it back to inactive here. That must be
// done by the context
}
default:
break;
}
return FALSE;
}
{
}
{
}
/* Guides */
enum SPGuideDragType {
SP_DRAG_TRANSLATE_CONSTRAINED, // Is not being used currently!
};
// 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:
break;
}
// 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
// the click was on the guide 'anchor'
} else {
NULL,
}
}
break;
case GDK_MOTION_NOTIFY:
if (drag_type != SP_DRAG_NONE) {
// 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 it the origin should still be constrained to the guide
// So let's do that explicitly first:
} else {
}
switch (drag_type) {
case SP_DRAG_TRANSLATE:
{
break;
}
case SP_DRAG_TRANSLATE_CONSTRAINED: // Is not being used currently!
{
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 it the origin should still be constrained to the guide
// So let's do that explicitly first:
} else {
}
switch (drag_type) {
case SP_DRAG_TRANSLATE:
{
break;
}
case SP_DRAG_TRANSLATE_CONSTRAINED: // Is not being used currently!
{
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
if (Geom::L2(guide->point_on_line - event_dt) < tol/desktop->current_zoom() || !(event->crossing.state & GDK_SHIFT_MASK)) {
// the click was on the guide 'anchor'
} else {
}
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;
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 :