|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2024 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the Eclipse Public License 2.0 which is available at |
@@ -222,43 +222,57 @@ protected void show() { |
222 | 222 |
|
223 | 223 | private class PopupHelperLightweightSystem extends LightweightSystem { |
224 | 224 |
|
225 | | - /** |
226 | | - * The scalable pane that is injected between the root figure and the contents |
227 | | - * of this viewport. |
228 | | - */ |
229 | | - private final ScalableLayeredPane scalablePane; |
230 | | - |
231 | | - private PopupHelperLightweightSystem() { |
232 | | - scalablePane = new ScalableLayeredPane(true); |
233 | | - scalablePane.setLayoutManager(new StackLayout()); |
234 | | - getRootFigure().add(scalablePane); |
235 | | - } |
236 | | - |
237 | | - /** |
238 | | - * Updates the scale factor of the scalable pane to the given value. |
239 | | - * |
240 | | - * @param scale The new scale factor. |
241 | | - */ |
242 | | - private void setScale(double scale) { |
243 | | - scalablePane.setScale(scale); |
244 | | - } |
245 | | - |
246 | 225 | @Override |
247 | 226 | public void setControl(Canvas c) { |
248 | 227 | if (c == null) { |
249 | 228 | return; |
250 | 229 | } |
251 | 230 |
|
252 | | - InternalDraw2dUtils.configureForAutoscalingMode(c, this::setScale); |
| 231 | + InternalDraw2dUtils.configureForAutoscalingMode(c, getRootFigure()::setScale); |
253 | 232 |
|
254 | 233 | super.setControl(c); |
255 | 234 | } |
256 | 235 |
|
257 | 236 | @Override |
258 | | - public void setContents(IFigure figure) { |
259 | | - scalablePane.removeAll(); |
260 | | - if (figure != null) { |
261 | | - scalablePane.add(figure); |
| 237 | + protected RootFigure createRootFigure() { |
| 238 | + RootFigure f = new ScalableRootFigure(); |
| 239 | + f.addNotify(); |
| 240 | + f.setOpaque(true); |
| 241 | + f.setLayoutManager(new StackLayout()); |
| 242 | + return f; |
| 243 | + } |
| 244 | + |
| 245 | + @Override |
| 246 | + public ScalableFigure getRootFigure() { |
| 247 | + return (ScalableFigure) super.getRootFigure(); |
| 248 | + } |
| 249 | + |
| 250 | + private class ScalableRootFigure extends RootFigure implements ScalableFigure { |
| 251 | + /** |
| 252 | + * The scalable pane that is injected between the root figure and the contents |
| 253 | + * of this viewport. |
| 254 | + */ |
| 255 | + private final ScalableLayeredPane scalablePane; |
| 256 | + |
| 257 | + private ScalableRootFigure() { |
| 258 | + scalablePane = new ScalableLayeredPane(true); |
| 259 | + scalablePane.setLayoutManager(new StackLayout()); |
| 260 | + super.add(scalablePane, null, 0); |
| 261 | + } |
| 262 | + |
| 263 | + @Override |
| 264 | + public void add(IFigure figure, Object constraint, int index) { |
| 265 | + scalablePane.add(figure, constraint, index); |
| 266 | + } |
| 267 | + |
| 268 | + @Override |
| 269 | + public double getScale() { |
| 270 | + return scalablePane.getScale(); |
| 271 | + } |
| 272 | + |
| 273 | + @Override |
| 274 | + public void setScale(double scale) { |
| 275 | + scalablePane.setScale(scale); |
262 | 276 | } |
263 | 277 | } |
264 | 278 | } |
|
0 commit comments