Change OverviewRect behavior

I’d like to be able to change the way that the overview rectangle behaves so it works more like Photoshop. Specifically:

  1. The shape of the rectangle is proportional to the shape of the observed document’s view.
  2. The size of the rectangle is controlled by a zoom factor - either the mouse wheel or a zoom factor control.
  3. Anytime the mouse is inside the rectangle, the “move” cursor appears and the user can drag the rectangle around using the left mouse button.
    Any hints on how to do this?
    Thanks,
    Mark
  1. is already true.
  2. you can implement by replacing the GoOverview.DefaultTool with your own tool inheriting from GoToolManager, that just overrides DoMouseWheel to do what you want. (By the way, this is already true in the observed GoView, but I assume you are talking about control-mouse-wheel behavior in the Overview window.)
  3. is caused by the GoOverviewRectangle being “hollow”. That was intentional. You can implement this by replacing the GoOverview.OverviewRect with your own GoOverviewRectangle-inheriting class that overrides ContainsPoint as follows:
    public override bool ContainsPoint(PointF p) {
    RectangleF rect = this.Bounds;
    float thickness = (float)4.0/this.View.DocScale;
    rect.Inflate(thickness, thickness);
    return rect.Contains§;
    }
    Alas, GoOverview.OverviewRect does not appear to be settable. I’m not sure why not. So you’ll need to override GoOverview.CreateOverviewRectangle to return a new instance of your rectangle class.

On a side note, the reason GoOverview.OverviewRect is not settable is because the overview rectangle is re-created each time InitializeLayersFromDocument is called, typically when GoOverview.Observed is set or when that view’s Document is replaced. Rather than trying to maintain the OverviewRect property at all the right times, it’s easiest to just override CreateOverviewRectangle.

Perfect! Thanks Walter.