summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/align-and-distribute.cpp18
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp5
-rw-r--r--src/ui/dialog/inkscape-preferences.h1
-rw-r--r--src/ui/tool/control-point-selection.cpp8
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp4
-rw-r--r--src/ui/tool/path-manipulator.cpp6
-rw-r--r--src/ui/tool/transform-handle-set.cpp27
-rw-r--r--src/ui/tools/calligraphic-tool.cpp1
-rw-r--r--src/ui/tools/flood-tool.cpp10
-rw-r--r--src/ui/tools/measure-tool.cpp7
-rw-r--r--src/ui/tools/select-tool.cpp11
-rw-r--r--src/ui/tools/spray-tool.cpp6
-rw-r--r--src/ui/tools/text-tool.cpp3
-rw-r--r--src/ui/tools/tweak-tool.cpp7
-rw-r--r--src/ui/widget/page-sizer.cpp2
15 files changed, 77 insertions, 39 deletions
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 7ad8a5e18..b21fd2956 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -130,7 +130,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
- const Coeffs &a = _allCoeffs[index];
+ Coeffs a = _allCoeffs[index]; // copy
SPItem *focus = nullptr;
Geom::OptRect b = Geom::OptRect();
Selection::CompareSize horiz = (a.mx0 != 0.0) || (a.mx1 != 0.0)
@@ -168,6 +168,13 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
b = focus->desktopPreferredBounds();
g_return_if_fail(b);
+ if (horiz == Selection::HORIZONTAL && desktop->is_yaxisdown()) {
+ a.my0 = 1. - a.my0;
+ a.my1 = 1. - a.my1;
+ a.sy0 = 1. - a.sy0;
+ a.sy1 = 1. - a.sy1;
+ }
+
// Generate the move point from the selected bounding box
Geom::Point mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
@@ -303,6 +310,13 @@ private :
++second;
if (second == selected.end()) return;
+ double kBegin = _kBegin;
+ double kEnd = _kEnd;
+ if (_orientation == Geom::Y && desktop->is_yaxisdown()) {
+ kBegin = 1. - kBegin;
+ kEnd = 1. - kEnd;
+ }
+
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getBool("/tools/bounding_box");
std::vector< BBoxSort > sorted;
@@ -312,7 +326,7 @@ private :
SPItem *item = *it;
Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds();
if (bbox) {
- sorted.emplace_back(item, *bbox, _orientation, _kBegin, _kEnd);
+ sorted.emplace_back(item, *bbox, _orientation, kBegin, kEnd);
}
}
//sort bbox by anchors
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index ecf470d21..bb15d771d 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -771,6 +771,11 @@ void InkscapePreferences::initPageUI()
_("Selects whether the dockbar switcher will show text labels, icons, or both"), false);
}
+ _ui_yaxisdown.init( _("Origin at upper left with y-axis pointing down (requires restart)"), "/options/yaxisdown", false);
+ _page_ui.add_line( false, "", _ui_yaxisdown, "",
+ _("When off, origin is at lower left corner and y-axis points up"), true);
+
+
// Theme
_page_theme.add_group_header(_("Theme changes"));
{
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 55ea35f63..d0b51fa83 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -385,6 +385,7 @@ protected:
UI::Widget::PrefSpinButton _misc_recent;
UI::Widget::PrefCheckButton _ui_partialdynamic;
UI::Widget::ZoomCorrRulerSlider _ui_zoom_correction;
+ UI::Widget::PrefCheckButton _ui_yaxisdown;
//Spellcheck
UI::Widget::PrefCombo _spell_language;
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp
index 8f7a1761b..27105b8cf 100644
--- a/src/ui/tool/control-point-selection.cpp
+++ b/src/ui/tool/control-point-selection.cpp
@@ -662,11 +662,11 @@ bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_contex
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
case GDK_KEY_KP_8:
- return _keyboardMove(event->key, Geom::Point(0, 1));
+ return _keyboardMove(event->key, Geom::Point(0, -_desktop->yaxisdir()));
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
case GDK_KEY_KP_2:
- return _keyboardMove(event->key, Geom::Point(0, -1));
+ return _keyboardMove(event->key, Geom::Point(0, _desktop->yaxisdir()));
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
case GDK_KEY_KP_6:
@@ -678,9 +678,9 @@ bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_contex
// rotates
case GDK_KEY_bracketleft:
- return _keyboardRotate(event->key, 1);
+ return _keyboardRotate(event->key, -_desktop->yaxisdir());
case GDK_KEY_bracketright:
- return _keyboardRotate(event->key, -1);
+ return _keyboardRotate(event->key, _desktop->yaxisdir());
// scaling
case GDK_KEY_less:
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index b80a1e675..dd700d9b3 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -595,11 +595,11 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G
// rotation
case GDK_KEY_bracketleft:
case GDK_KEY_braceleft:
- pm.rotateHandle(n, which, 1, one_pixel);
+ pm.rotateHandle(n, which, -_desktop->yaxisdir(), one_pixel);
break;
case GDK_KEY_bracketright:
case GDK_KEY_braceright:
- pm.rotateHandle(n, which, -1, one_pixel);
+ pm.rotateHandle(n, which, _desktop->yaxisdir(), one_pixel);
break;
// adjust length
case GDK_KEY_period:
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 2369a75d4..a00f065d8 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1445,16 +1445,14 @@ void PathManipulator::_updateOutline()
// linear segment that starts at the time value of 0.5 and extends for 10 pixels
// at an angle 150 degrees from the unit tangent. This creates the appearance
// of little 'harpoons' that show the direction of the subpaths.
+ auto rot_scale_w2d = Geom::Rotate(210.0 / 180.0 * M_PI) * Geom::Scale(10.0) * _desktop->w2d();
Geom::PathVector arrows;
for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) {
Geom::Path &path = *i;
for (Geom::Path::iterator j = path.begin(); j != path.end_default(); ++j) {
Geom::Point at = j->pointAt(0.5);
Geom::Point ut = j->unitTangentAt(0.5);
- // rotate the point
- ut *= Geom::Rotate(150.0 / 180.0 * M_PI);
- Geom::Point arrow_end = _desktop->w2d(
- _desktop->d2w(at) + Geom::unit_vector(_desktop->d2w(ut)) * 10.0);
+ Geom::Point arrow_end = at + (Geom::unit_vector(_desktop->d2w(ut)) * rot_scale_w2d);
Geom::Path arrow(at);
arrow.appendNew<Geom::LineSegment>(arrow_end);
diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp
index 382654dad..b0da4f026 100644
--- a/src/ui/tool/transform-handle-set.cpp
+++ b/src/ui/tool/transform-handle-set.cpp
@@ -243,8 +243,8 @@ double ScaleHandle::_last_scale_y = 1.0;
class ScaleCornerHandle : public ScaleHandle {
public:
- ScaleCornerHandle(TransformHandleSet &th, unsigned corner) :
- ScaleHandle(th, corner_to_anchor(corner), _corner_to_pixbuf(corner)),
+ ScaleCornerHandle(TransformHandleSet &th, unsigned corner, unsigned d_corner) :
+ ScaleHandle(th, corner_to_anchor(d_corner), _corner_to_pixbuf(d_corner)),
_corner(corner)
{}
@@ -330,8 +330,8 @@ private:
*/
class ScaleSideHandle : public ScaleHandle {
public:
- ScaleSideHandle(TransformHandleSet &th, unsigned side)
- : ScaleHandle(th, side_to_anchor(side), _side_to_pixbuf(side))
+ ScaleSideHandle(TransformHandleSet &th, unsigned side, unsigned d_side)
+ : ScaleHandle(th, side_to_anchor(d_side), _side_to_pixbuf(side))
, _side(side)
{}
protected:
@@ -409,8 +409,8 @@ private:
*/
class RotateHandle : public TransformHandle {
public:
- RotateHandle(TransformHandleSet &th, unsigned corner)
- : TransformHandle(th, corner_to_anchor(corner), _corner_to_pixbuf(corner))
+ RotateHandle(TransformHandleSet &th, unsigned corner, unsigned d_corner)
+ : TransformHandle(th, corner_to_anchor(d_corner), _corner_to_pixbuf(d_corner))
, _corner(corner)
{}
protected:
@@ -491,8 +491,8 @@ double RotateHandle::_last_angle = 0;
class SkewHandle : public TransformHandle {
public:
- SkewHandle(TransformHandleSet &th, unsigned side)
- : TransformHandle(th, side_to_anchor(side), _side_to_pixbuf(side))
+ SkewHandle(TransformHandleSet &th, unsigned side, unsigned d_side)
+ : TransformHandle(th, side_to_anchor(d_side), _side_to_pixbuf(side))
, _side(side)
{}
@@ -707,11 +707,14 @@ TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group)
sp_canvas_item_hide(_trans_outline);
_trans_outline->setDashed(true);
+ bool y_inverted = !d->is_yaxisdown();
for (unsigned i = 0; i < 4; ++i) {
- _scale_corners[i] = new ScaleCornerHandle(*this, i);
- _scale_sides[i] = new ScaleSideHandle(*this, i);
- _rot_corners[i] = new RotateHandle(*this, i);
- _skew_sides[i] = new SkewHandle(*this, i);
+ unsigned d_c = y_inverted ? i : 3 - i;
+ unsigned d_s = y_inverted ? i : 6 - i;
+ _scale_corners[i] = new ScaleCornerHandle(*this, i, d_c);
+ _scale_sides[i] = new ScaleSideHandle(*this, i, d_s);
+ _rot_corners[i] = new RotateHandle(*this, i, d_c);
+ _skew_sides[i] = new SkewHandle(*this, i, d_s);
}
_center = new RotationCenter(*this);
// when transforming, update rotation center position
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 50c5f413a..b4017e5e7 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -288,6 +288,7 @@ bool CalligraphicTool::apply(Geom::Point p) {
// 1b. fixed dc->angle (absolutely flat nib):
double const radians = ( (this->angle - 90) / 180.0 ) * M_PI;
Geom::Point ang1 = Geom::Point(-sin(radians), cos(radians));
+ ang1.y() *= -this->desktop->yaxisdir();
a1 = atan2(ang1);
}
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 1d1930a4e..de57d4500 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -765,8 +765,8 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo
unsigned int width = (int)ceil(screen.width() * zoom_scale * padding);
unsigned int height = (int)ceil(screen.height() * zoom_scale * padding);
- Geom::Point origin(screen.min()[Geom::X],
- document->getHeight().value("px") - screen.height() - screen.min()[Geom::Y]);
+ Geom::Point origin = screen.corner(desktop->is_yaxisdown() ? 0 : 3)
+ * desktop->doc2dt();
origin[Geom::X] += (screen.width() * ((1 - padding) / 2));
origin[Geom::Y] += (screen.height() * ((1 - padding) / 2));
@@ -876,7 +876,11 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo
}
for (unsigned int i = 0; i < fill_points.size(); i++) {
- Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, document->getHeight().value("px") + (fill_points[i][Geom::Y] / zoom_scale)) * affine;
+ Geom::Point pw = fill_points[i]
+ * Geom::Scale(1. / zoom_scale)
+ * desktop->doc2dt().withoutTranslation()
+ * desktop->doc2dt()
+ * affine;
pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X]));
pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y]));
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index a305fa350..75335ce1a 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -862,6 +862,13 @@ void MeasureTool::setGuide(Geom::Point origin,double angle, const char *label)
if(!namedview) {
return;
}
+
+ // <sodipodi:guide> stores inverted y-axis coordinates
+ if (desktop->is_yaxisdown()) {
+ origin[Geom::Y] = doc->getHeight().value("px") - origin[Geom::Y];
+ angle *= -1.0;
+ }
+
origin *= affine;
//measure angle
Inkscape::XML::Node *guide;
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 92ae7558b..6e8d631df 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -906,6 +906,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px
gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000, "px");
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
+ auto const y_dir = desktop->yaxisdir();
switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Left: // move selection left
@@ -935,6 +936,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Up:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
+ mul *= -y_dir;
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -981,6 +983,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Down:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
+ mul *= -y_dir;
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -1038,9 +1041,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
selection->rotateScreen(mul*1);
} else if (MOD__CTRL(event)) {
- selection->rotate(90);
+ selection->rotate(-90 * y_dir);
} else if (snaps) {
- selection->rotate(180.0/snaps);
+ selection->rotate(-180.0/snaps * y_dir);
}
ret = TRUE;
@@ -1051,9 +1054,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
selection->rotateScreen(-1*mul);
} else if (MOD__CTRL(event)) {
- selection->rotate(-90);
+ selection->rotate(90 * y_dir);
} else if (snaps) {
- selection->rotate(-180.0/snaps);
+ selection->rotate(180.0/snaps * y_dir);
}
ret = TRUE;
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index c56bceda4..0cad1382e 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -969,7 +969,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale));
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
// Move the cursor p
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation()));
Inkscape::GC::release(copy);
if(picker){
sp_desktop_apply_css_recursive(item_copied, css, true);
@@ -1013,7 +1013,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation()));
// Union and duplication
set->clear();
@@ -1101,7 +1101,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation()));
if(picker){
sp_desktop_apply_css_recursive(item_copied, css, true);
}
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 713d72a40..8542b1b6f 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -623,7 +623,8 @@ bool TextTool::root_handler(GdkEvent* event) {
// Cursor height is defined by the new text object's font size; it needs to be set
// artificially here, for the text object does not exist yet:
double cursor_height = sp_desktop_get_font_size_tool(desktop);
- this->cursor->setCoords(p1, p1 + Geom::Point(0, cursor_height));
+ auto const y_dir = desktop->yaxisdir();
+ this->cursor->setCoords(p1, p1 - Geom::Point(0, y_dir * cursor_height));
if (this->imc) {
GdkRectangle im_cursor;
Geom::Point const top_left = SP_EVENT_CONTEXT(this)->desktop->get_display_area().corner(3);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 060131b49..d0b8209f0 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -397,7 +397,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (a->contains(p)) x = 0;
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * vector;
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation()));
did = true;
}
}
@@ -411,7 +411,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) *
(reverse? (a->midpoint() - p) : (p - a->midpoint()));
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation()));
did = true;
}
}
@@ -426,7 +426,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (a->contains(p)) x = 0;
if (x < 1) {
Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * Geom::Point(cos(dp)*dr, sin(dp)*dr);
- sp_item_move_rel(item, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+ sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation()));
did = true;
}
}
@@ -452,6 +452,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (a->contains(p)) x = 0;
if (x < 1) {
double angle = (reverse? force : -force) * 0.05 * (cos(M_PI * x) + 1) * M_PI;
+ angle *= -selection->desktop()->yaxisdir();
sp_item_rotate_rel(item, Geom::Rotate(angle));
did = true;
}
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 58af30fc9..aede866b1 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -527,7 +527,7 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool
doc->setWidthAndHeight (w, h, changeSize);
// The origin for the user is in the lower left corner; this point should remain stationary when
// changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this
- if (changeSize) {
+ if (changeSize && !SP_ACTIVE_DESKTOP->is_yaxisdown()) {
Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px"))));
doc->getRoot()->translateChildItems(vert_offset);
}