summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 73bd3f9)
raw | patch | inline | side by side (parent: 73bd3f9)
author | JazzyNico <nicoduf@yahoo.fr> | |
Thu, 23 Sep 2010 16:12:29 +0000 (18:12 +0200) | ||
committer | JazzyNico <nicoduf@yahoo.fr> | |
Thu, 23 Sep 2010 16:12:29 +0000 (18:12 +0200) |
src/ui/dialog/transformation.cpp | patch | blob | history |
index 1cab38d98151d11efa90839cc84a8ebcc2d51217..1ceed50a77febb3cfe8860973d627fccd2af4ad8 100644 (file)
#include "selection-chemistry.h"
#include "verbs.h"
#include "preferences.h"
+#include "sp-namedview.h"
#include "sp-item-transform.h"
#include "macros.h"
#include "sp-item.h"
Transformation::layoutPageMove()
{
_units_move.setUnitType(UNIT_TYPE_LINEAR);
+
+ // Setting default unit to document unit
+ SPDesktop *dt = getDesktop();
+ SPNamedView *nv = sp_desktop_namedview(dt);
+ if (nv->doc_units) {
+ _units_move.setUnit(nv->doc_units->abbr);
+ }
+
_scalar_move_horizontal.initScalar(-1e6, 1e6);
_scalar_move_horizontal.setDigits(3);
_scalar_move_horizontal.setIncrements(0.1, 1.0);
double x = bbox->min()[Geom::X];
double y = bbox->min()[Geom::Y];
- _scalar_move_horizontal.setValue(x, "px");
- _scalar_move_vertical.setValue(y, "px");
+ double conversion = _units_move.getConversion("px");
+ _scalar_move_horizontal.setValue(x / conversion);
+ _scalar_move_vertical.setValue(y / conversion);
}
} else {
// do nothing, so you can apply the same relative move to many objects in turn
double x = _scalar_move_horizontal.getValue("px");
double y = _scalar_move_vertical.getValue("px");
+ double conversion = _units_move.getConversion("px");
+
//g_message("onMoveRelativeToggled: %f, %f px\n", x, y);
Geom::OptRect bbox = selection->bounds();
if (bbox) {
if (_check_move_relative.get_active()) {
// From absolute to relative
- _scalar_move_horizontal.setValue(x - bbox->min()[Geom::X], "px");
- _scalar_move_vertical.setValue( y - bbox->min()[Geom::Y], "px");
+ _scalar_move_horizontal.setValue((x - bbox->min()[Geom::X]) / conversion);
+ _scalar_move_vertical.setValue(( y - bbox->min()[Geom::Y]) / conversion);
} else {
// From relative to absolute
- _scalar_move_horizontal.setValue(bbox->min()[Geom::X] + x, "px");
- _scalar_move_vertical.setValue( bbox->min()[Geom::Y] + y, "px");
+ _scalar_move_horizontal.setValue((bbox->min()[Geom::X] + x) / conversion);
+ _scalar_move_vertical.setValue(( bbox->min()[Geom::Y] + y) / conversion);
}
}