selector.cpp revision 711dce178e9e5938adb42db657ad8a98bd1e15f4
/** @file
* Selector component (click and rubberband)
*/
/* Authors:
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2009 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "control-point.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "display/sodipodi-ctrlrect.h"
#include "ui/tools/tool-base.h"
#include "preferences.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/selector.h"
#include <gdk/gdkkeysyms.h>
namespace Inkscape {
namespace UI {
/** A hidden control point used for rubberbanding and selection.
* It uses a clever hack: the canvas item is hidden and only receives events when they
* are passed to it using Selector's event() function. When left mouse button
* is pressed, it grabs events and handles drags and clicks in the usual way. */
class SelectorPoint : public ControlPoint {
public:
_selector(s),
_cancel(false)
{
setVisible(false);
SP_TYPE_CTRLRECT, NULL));
}
~SelectorPoint() {
}
return _eventHandler(ec, e);
}
protected:
{
_cancel = true;
return true;
}
}
private:
virtual bool grabbed(GdkEventMotion *) {
_cancel = false;
return false;
}
if (_cancel) return;
}
if (_cancel) return;
}
return true;
}
bool _cancel;
};
: Manipulator(d)
{
_dragger->setVisible(false);
}
{
delete _dragger;
}
{
// The hidden control point will capture all events after it obtains the grab,
// but it relies on this function to initiate it. If we pass only first button
// press events here, it won't interfere with any other event handling.
case GDK_BUTTON_PRESS:
// Do not pass button presses other than left button to the control point.
// This way middle click and right click can be handled in ToolBase.
}
break;
default: break;
}
return false;
}
} // namespace UI
} // namespace Inkscape
/*
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:fileencoding=utf-8:textwidth=99 :