summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f47e48f)
raw | patch | inline | side by side (parent: f47e48f)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 30 Aug 2008 21:26:28 +0000 (21:26 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 30 Aug 2008 21:26:28 +0000 (21:26 +0000) |
src/arc-context.cpp | patch | blob | history | |
src/context-fns.cpp | patch | blob | history | |
src/context-fns.h | patch | blob | history | |
src/rect-context.cpp | patch | blob | history |
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index f52e5b55d4efb218e1cbfe9c352e56e386605ecb..0b4904bdf722e4a5d1aa5b39bcf2ef41bf1faa7d 100644 (file)
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
ctrl_save = true;
state = state ^ GDK_CONTROL_MASK;
}
- NR::Rect r = Inkscape::snap_rectangular_box(desktop, ac->item, pt, ac->center, state);
+ Geom::Rect r = Inkscape::snap_rectangular_box(desktop, ac->item, pt, ac->center, state);
if (ctrl_save) {
state = state ^ GDK_CONTROL_MASK;
}
Geom::Point new_dir = pt * i2d - c;
new_dir[Geom::X] *= dir[Geom::Y] / dir[Geom::X];
double lambda = new_dir.length() / dir[Geom::Y];
- r = NR::Rect (c - lambda*dir, c + lambda*dir);
+ r = Geom::Rect (c - lambda*dir, c + lambda*dir);
}
} else {
/* with Alt+Ctrl (without Shift) we generate a perfect circle
with diameter click point <--> mouse pointer */
double l = dir.length();
Geom::Point d (l, l);
- r = NR::Rect (c - d, c + d);
+ r = Geom::Rect (c - d, c + d);
}
}
sp_arc_position_set(SP_ARC(ac->item),
- r.midpoint()[NR::X], r.midpoint()[NR::Y],
- r.dimensions()[NR::X] / 2, r.dimensions()[NR::Y] / 2);
+ r.midpoint()[Geom::X], r.midpoint()[Geom::Y],
+ r.dimensions()[Geom::X] / 2, r.dimensions()[Geom::Y] / 2);
- double rdimx = r.dimensions()[NR::X];
- double rdimy = r.dimensions()[NR::Y];
+ double rdimx = r.dimensions()[Geom::X];
+ double rdimy = r.dimensions()[Geom::Y];
GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric());
GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric());
if (state & GDK_CONTROL_MASK) {
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index 9acba28278013d710c5c44d55010c159f6722256..e6ebbe337c49669d28b1369c0ff3b338d90e0e12 100644 (file)
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
}
-NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
- NR::Point const &pt, NR::Point const ¢er, int state)
+Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
+ Geom::Point const &pt, Geom::Point const ¢er, int state)
{
- NR::Point p[2];
+ Geom::Point p[2];
bool const shift = state & GDK_SHIFT_MASK;
bool const control = state & GDK_CONTROL_MASK;
/* Control is down: we are constrained to producing integer-ratio rectangles */
/* Vector from the centre of the box to the point we are dragging to */
- NR::Point delta = pt - center;
+ Geom::Point delta = pt - center;
/* Round it so that we have an integer-ratio (or golden ratio) box */
- if (fabs(delta[NR::X]) > fabs(delta[NR::Y]) && (delta[NR::Y] != 0.0)) {
- double ratio = delta[NR::X] / delta[NR::Y];
+ if (fabs(delta[Geom::X]) > fabs(delta[Geom::Y]) && (delta[Geom::Y] != 0.0)) {
+ double ratio = delta[Geom::X] / delta[Geom::Y];
double ratioabs = fabs (ratio);
double sign = (ratio < 0 ? -1 : 1);
if (midpt_1_goldenratio < ratioabs && ratioabs < midpt_goldenratio_2) {
- delta[NR::X] = sign * goldenratio * delta[NR::Y];
+ delta[Geom::X] = sign * goldenratio * delta[Geom::Y];
} else {
- delta[NR::X] = floor(ratio + 0.5) * delta[NR::Y];
+ delta[Geom::X] = floor(ratio + 0.5) * delta[Geom::Y];
}
- } else if (delta[NR::X] != 0.0) {
- double ratio = delta[NR::Y] / delta[NR::X];
+ } else if (delta[Geom::X] != 0.0) {
+ double ratio = delta[Geom::Y] / delta[Geom::X];
double ratioabs = fabs (ratio);
double sign = (ratio < 0 ? -1 : 1);
if (midpt_1_goldenratio < ratioabs && ratioabs < midpt_goldenratio_2) {
- delta[NR::Y] = sign * goldenratio * delta[NR::X];
+ delta[Geom::Y] = sign * goldenratio * delta[Geom::X];
} else {
- delta[NR::Y] = floor(delta[NR::Y] / delta[NR::X] + 0.5) * delta[NR::X];
+ delta[Geom::Y] = floor(delta[Geom::Y] / delta[Geom::X] + 0.5) * delta[Geom::X];
}
}
@@ -210,19 +210,19 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);
p[1] = sp_desktop_dt2root_xy_point(desktop, p[1]);
- return NR::Rect(NR::Point(MIN(p[0][NR::X], p[1][NR::X]), MIN(p[0][NR::Y], p[1][NR::Y])),
- NR::Point(MAX(p[0][NR::X], p[1][NR::X]), MAX(p[0][NR::Y], p[1][NR::Y])));
+ return Geom::Rect(Geom::Point(MIN(p[0][Geom::X], p[1][Geom::X]), MIN(p[0][Geom::Y], p[1][Geom::Y])),
+ Geom::Point(MAX(p[0][Geom::X], p[1][Geom::X]), MAX(p[0][Geom::Y], p[1][Geom::Y])));
}
-NR::Point Inkscape::setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev)
+Geom::Point Inkscape::setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev)
{
ec->xp = static_cast<gint>(ev->button.x);
ec->yp = static_cast<gint>(ev->button.y);
ec->within_tolerance = true;
- NR::Point const p(ev->button.x, ev->button.y);
+ Geom::Point const p(ev->button.x, ev->button.y);
ec->item_to_select = sp_event_context_find_item(desktop, p, ev->button.state & GDK_MOD1_MASK, TRUE);
return ec->desktop->w2d(p);
}
diff --git a/src/context-fns.h b/src/context-fns.h
index 95574dd7615436967cd1074b1143f1dd8364402f..794f16c39ccfc3f4755b986da41688a95ae54e97 100644 (file)
--- a/src/context-fns.h
+++ b/src/context-fns.h
+#ifndef SEEN_CONTEXT_FNS_H
+#define SEEN_CONTEXT_FNS_H
+
+/*
+ * <description>
+ *
+ * Authors:
+ *
+ * Copyright (C)
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
#include <gdk/gdkevents.h>
-#include "libnr/nr-rect.h"
+#include <2geom/forward.h>
+
struct SPDesktop;
struct SPItem;
extern bool have_viable_layer(SPDesktop *desktop, MessageContext *message);
extern bool have_viable_layer(SPDesktop *desktop, MessageStack *message);
-::NR::Rect snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
- NR::Point const &pt, NR::Point const ¢er, int state);
-NR::Point setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev);
+Geom::Rect snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
+ Geom::Point const &pt, Geom::Point const ¢er, int state);
+Geom::Point setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev);
}
+#endif // !SEEN_CONTEXT_FNS_H
+
/*
Local Variables:
mode:c++
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index bbb809ef2be416d0c383f921f96db0777972137d..56d74d90152ec67eff2d0d76a910f54bd1e56d8f 100644 (file)
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
}
- NR::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state);
+ Geom::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state);
- sp_rect_position_set(SP_RECT(rc.item), r.min()[NR::X], r.min()[NR::Y], r.dimensions()[NR::X], r.dimensions()[NR::Y]);
+ sp_rect_position_set(SP_RECT(rc.item), r.min()[Geom::X], r.min()[Geom::Y], r.dimensions()[Geom::X], r.dimensions()[Geom::Y]);
if ( rc.rx != 0.0 ) {
sp_rect_set_rx (SP_RECT(rc.item), TRUE, rc.rx);
}
if ( rc.ry != 0.0 ) {
if (rc.rx == 0.0)
- sp_rect_set_ry (SP_RECT(rc.item), TRUE, CLAMP(rc.ry, 0, MIN(r.dimensions()[NR::X], r.dimensions()[NR::Y])/2));
+ sp_rect_set_ry (SP_RECT(rc.item), TRUE, CLAMP(rc.ry, 0, MIN(r.dimensions()[Geom::X], r.dimensions()[Geom::Y])/2));
else
- sp_rect_set_ry (SP_RECT(rc.item), TRUE, CLAMP(rc.ry, 0, r.dimensions()[NR::Y]));
+ sp_rect_set_ry (SP_RECT(rc.item), TRUE, CLAMP(rc.ry, 0, r.dimensions()[Geom::Y]));
}
// status text
- double rdimx = r.dimensions()[NR::X];
- double rdimy = r.dimensions()[NR::Y];
+ double rdimx = r.dimensions()[Geom::X];
+ double rdimy = r.dimensions()[Geom::Y];
GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric());
GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric());
if (state & GDK_CONTROL_MASK) {