¿ªÔÆÌåÓý

Locked Re: Layout editor zoom issue- new insights #layouteditor


 

The grid drawing code uses LayoutEditor::getZoom() to scale the visible rectangle to the clipping region¡­ and getZoom uses:
?
? ? public double getZoom() {
? ? ? ? return getPaintScale(); ? ?//<== accessor for _paintScale
? ? }

Part of the problem is that the is no absolute scrollbar scale; it's set with a ratio (in the Editor base class for LayoutEditor):

? ? protected final void setPaintScale(double newScale) {
? ? ? ? double ratio = newScale / _paintScale;
? ? ? ? _paintScale = newScale;
? ? ? ? setScrollbarScale(ratio);
? ? }
?
? ? private void setScrollbarScale(double ratio) {
? ? ? ? //resize the panel to reflect scaling
? ? ? ? Dimension dim = _targetPanel.getSize();
? ? ? ? int tpWidth = (int) ((dim.width) * ratio);
? ? ? ? int tpHeight = (int) ((dim.height) * ratio);
? ? ? ? _targetPanel.setSize(tpWidth, tpHeight);
? ? ? ? log.debug("setScrollbarScale: ratio= {}, tpWidth= {}, tpHeight= {}", ratio, tpWidth, tpHeight);
? ? ? ? // compute new scroll bar positions to keep upper left same
? ? ? ? JScrollBar horScroll = _panelScrollPane.getHorizontalScrollBar();
? ? ? ? JScrollBar vertScroll = _panelScrollPane.getVerticalScrollBar();
? ? ? ? int hScroll = (int) (horScroll.getValue() * ratio);
? ? ? ? int vScroll = (int) (vertScroll.getValue() * ratio);
? ? ? ? // set scrollbars maximum range (otherwise setValue may fail);
? ? ? ? horScroll.setMaximum((int) ((horScroll.getMaximum()) * ratio));
? ? ? ? vertScroll.setMaximum((int) ((vertScroll.getMaximum()) * ratio));
? ? ? ? // set scroll bar positions
? ? ? ? horScroll.setValue(hScroll);
? ? ? ? vertScroll.setValue(vScroll);
? ? }
?
The setScrollbarScale method uses the ratio to scale the?_targetPanel (member variable of the Editor base class). It represents the scaled layout (unclipped).
Note: the?_panelScrollPane.getViewportBorderBounds() should return the (physical) bounds of the visible rectangle onscreen (sans all headers, margins & scrollbars).
It's basically what should be being used for the clipping region. Except that it's in the window (or screen? don't remember) coordinate space which is different than the clipping regions coordinate space.


Join [email protected] to automatically receive all group messages.