diff --git a/src/desktop.cpp b/src/desktop.cpp
index 1ee24f9c6d35854c73c20714dd1e1450dbf52103..1f2baccbba2ed61559eb7d0ef70362dd9832accf 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
static void _reconstruction_start(SPDesktop * desktop);
static void _reconstruction_finish(SPDesktop * desktop);
static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop);
-static void _update_snap_distances (SPDesktop *desktop);
/**
* Return new desktop object.
bool SPDesktop::isWithinViewport (SPItem *item) const
{
Geom::Rect const viewport = get_display_area();
- boost::optional<Geom::Rect> const bbox = sp_item_bbox_desktop(item);
+ Geom::OptRect const bbox = sp_item_bbox_desktop(item);
if (bbox) {
return viewport.contains(*bbox);
} else {
// FIXME: This 2geom idiom doesn't allow us to declare dbox const
Geom::Rect viewbox = canvas->getViewbox();
- viewbox.expandBy(border);
+ viewbox.expandBy(-border);
double scale = _d2w.descrim();
double newscale;
\param enable Whether we're going in or out of quick zoom
*/
-void
+void
SPDesktop::zoom_quick (bool enable)
{
if (enable == _quick_zoom_enabled) {
if (!zoomed) {
SPItem * singleItem = selection->singleItem();
if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) {
- SPNodeContext * ncontext = SP_NODE_CONTEXT(event_context);
- Inkscape::NodePath::Path * nodepath = ncontext->shape_editor->get_nodepath();
+ Inkscape::NodePath::Path * nodepath = event_context->shape_editor->get_nodepath();
// printf("I've got a nodepath, crazy\n");
Geom::Rect nodes;
}
if (!zoomed) {
- boost::optional<Geom::Rect> const d = selection->bounds();
- if (d && !d->isEmpty() && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
+ Geom::OptRect const d = selection->bounds();
+ if (d && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
set_display_area(*d, 10);
zoomed = true;
- }
+ }
}
if (!zoomed) {
Geom::Rect d(Geom::Point(0, 0),
Geom::Point(sp_document_width(doc()), sp_document_height(doc())));
- // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it?
- if (d.isEmpty()) {
+ if (d.minExtent() < 1.0) {
return;
}
void
SPDesktop::zoom_selection()
{
- boost::optional<Geom::Rect> const d = selection->bounds();
+ Geom::OptRect const d = selection->bounds();
- // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 0.1; is it safe to ignore it?
- if ( !d || d->isEmpty() ) {
+ if ( !d || d->minExtent() < 0.1 ) {
return;
}
SPItem *docitem = SP_ITEM (sp_document_root (doc()));
g_return_if_fail (docitem != NULL);
- boost::optional<Geom::Rect> d = sp_item_bbox_desktop(docitem);
+ Geom::OptRect d = sp_item_bbox_desktop(docitem);
/* Note that the second condition here indicates that
** there are no items in the drawing.
*/
- // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it?
- if ( !d || d->isEmpty() ) {
+ if ( !d || d->minExtent() < 0.1 ) {
return;
}
bool SPDesktop::onDeleteUI (GdkEventAny*)
{
- if(shutdown())
+ if(shutdown())
return true;
destroyWidget();
}
}
-void SPDesktop::toggleSnapping()
+void SPDesktop::toggleSnapGlobal()
{
bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally();
Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- /* Recalculate snap distances */
- /* FIXME: why is the desktop getting involved in setting up something
- ** that is entirely to do with the namedview?
- */
- _update_snap_distances (desktop);
-
/* Show/hide page background */
if (nv->pagecolor & 0xff) {
sp_canvas_item_show (desktop->table);
}
}
-/**
- * Callback to reset snapper's distances.
- */
-static void
-_update_snap_distances (SPDesktop *desktop)
-{
- SPUnit const &px = sp_unit_get_by_id(SP_UNIT_PX);
-
- SPNamedView &nv = *desktop->namedview;
-
- //tell all grid snappers
- for ( GSList const *l = nv.grids; l != NULL; l = l->next) {
- Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
- grid->snapper->setSnapperTolerance(sp_convert_distance_full(nv.gridtolerance,
- *nv.gridtoleranceunit,
- px));
- }
-
- nv.snap_manager.guide.setSnapperTolerance(sp_convert_distance_full(nv.guidetolerance,
- *nv.guidetoleranceunit,
- px));
- nv.snap_manager.object.setSnapperTolerance(sp_convert_distance_full(nv.objecttolerance,
- *nv.objecttoleranceunit,
- px));
-}
-
-
Geom::Matrix SPDesktop::w2d() const
{
return _w2d;
return _doc2dt;
}
+Geom::Matrix SPDesktop::dt2doc() const
+{
+ // doc2dt is its own inverse
+ return _doc2dt;
+}
+
Geom::Point SPDesktop::doc2dt(Geom::Point const &p) const
{
return p * _doc2dt;
Geom::Point SPDesktop::dt2doc(Geom::Point const &p) const
{
- return p * _doc2dt.inverse();
+ return p * dt2doc();
}