diff options
author | Scott Moreau <oreaus@gmail.com> | 2010-02-22 08:44:47 -0700 |
---|---|---|
committer | Scott Moreau <oreaus@gmail.com> | 2010-02-22 11:06:09 -0700 |
commit | 37332a37b4ee93c23e10be06af73b36c18ceb396 (patch) | |
tree | 965665f5b0823146f5860a076519e3dd6eb81bee | |
parent | 618676e2b02309fbe4af4214fe33de9b9428412b (diff) | |
download | compiz-core-doc-37332a37b4ee93c23e10be06af73b36c18ceb396.tar.gz compiz-core-doc-37332a37b4ee93c23e10be06af73b36c18ceb396.tar.bz2 |
Add option to use initial click point as center for drawing shapes.
-rw-r--r-- | plugins/annotate/annotate.xml.in | 5 | ||||
-rw-r--r-- | plugins/annotate/src/annotate.cpp | 42 |
2 files changed, 28 insertions, 19 deletions
diff --git a/plugins/annotate/annotate.xml.in b/plugins/annotate/annotate.xml.in index 4eee3ab..11f932e 100644 --- a/plugins/annotate/annotate.xml.in +++ b/plugins/annotate/annotate.xml.in @@ -48,6 +48,11 @@ <_short>Clear</_short> <_long>Clear</_long> </option> + <option name="draw_shapes_from_center" type="bool"> + <_short>Draw shapes from center</_short> + <_long>Uses the initial click point as the center of shapes.</_long> + <default>true</default> + </option> <option name="fill_color" type="color"> <_short>Annotate Fill Color</_short> <_long>Fill color for annotations</_long> diff --git a/plugins/annotate/src/annotate.cpp b/plugins/annotate/src/annotate.cpp index 1f1e852..05fd6b9 100644 --- a/plugins/annotate/src/annotate.cpp +++ b/plugins/annotate/src/annotate.cpp @@ -784,31 +784,35 @@ AnnoScreen::handleMotionEvent (int xRoot, break; case RectangleMode: - if ((xRoot < initialPointerX) && (yRoot < initialPointerY)) - rectangle.setGeometry (xRoot, yRoot, - initialPointerX - xRoot, - initialPointerY - yRoot); - else if (yRoot < initialPointerY) - rectangle.setGeometry (initialPointerX, yRoot, - xRoot - initialPointerX, - initialPointerY - yRoot); - else if (xRoot < initialPointerX) - rectangle.setGeometry (xRoot, initialPointerY, - initialPointerX - xRoot, - yRoot - initialPointerY); + if (optionGetDrawShapesFromCenter ()) + rectangle.setGeometry (initialPointerX - + abs (xRoot - initialPointerX), + initialPointerY - + abs (yRoot - initialPointerY), + (abs (xRoot - initialPointerX)) * 2, + (abs (yRoot - initialPointerY)) * 2); else - rectangle.setGeometry (initialPointerX, initialPointerY, - xRoot - initialPointerX, - yRoot - initialPointerY); + rectangle.setGeometry (MIN(initialPointerX, xRoot), + MIN(initialPointerY, yRoot), + abs (xRoot - initialPointerX), + abs (yRoot - initialPointerY)); damageRect = rectangle; break; case EllipseMode: - ellipse.center.setX (initialPointerX + - (xRoot - initialPointerX) / 2); - ellipse.center.setY (initialPointerY + - (yRoot - initialPointerY) / 2); + if (optionGetDrawShapesFromCenter ()) + { + ellipse.center.setX (initialPointerX); + ellipse.center.setY (initialPointerY); + } + else + { + ellipse.center.setX (initialPointerX + + (xRoot - initialPointerX) / 2); + ellipse.center.setY (initialPointerY + + (yRoot - initialPointerY) / 2); + } ellipse.radiusX = abs (xRoot - ellipse.center.x ()); ellipse.radiusY = abs (yRoot - ellipse.center.y ()); |