// mOutlineOverlay and mEmptyOverlay are initialized lazily
mHoverOverlay = new HoverOverlay(mHScale, mVScale);
mHoverOverlay.create(display);
- mSelectionOverlay = new SelectionOverlay();
+ mSelectionOverlay = new SelectionOverlay(this);
mSelectionOverlay.create(display);
mImageOverlay = new ImageOverlay(this, mHScale, mVScale);
mIncludeOverlay = new IncludeOverlay(this);
* The {@link SelectionOverlay} paints the current selection as an overlay.
*/
public class SelectionOverlay extends Overlay {
+ private final LayoutCanvas mCanvas;
+
/**
* Constructs a new {@link SelectionOverlay} tied to the given canvas.
+ *
+ * @param canvas the associated canvas
*/
- public SelectionOverlay() {
+ public SelectionOverlay(LayoutCanvas canvas) {
+ mCanvas = canvas;
}
/**
List<String> infos = rulesEngine.callGetSelectionHint(parentNode, node);
if (infos != null && infos.size() > 0) {
gcWrapper.useStyle(DrawingStyle.HELP);
- int x = b.x + 10;
- int y = b.y + b.h + 10;
+ double scale = mCanvas.getScale();
+
+ // Compute the location to display the help. This is done in
+ // layout coordinates, so we need to apply the scale in reverse
+ // when making pixel margins
+ // TODO: We could take the Canvas dimensions into account to see
+ // where there is more room.
+ // TODO: The scrollbars should take the presence of hint text
+ // into account.
+ int x, y;
+ if (b.w > b.h) {
+ x = (int) (b.x + 3 / scale);
+ y = (int) (b.y + b.h + 10 / scale);
+ } else {
+ x = (int) (b.x + b.w + 10 / scale);
+ y = (int) (b.y + 3 / scale);
+ }
gcWrapper.drawBoxedStrings(x, y, infos);
}
}