[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [albireo-dev] size/layout management
|
Gordon Hirsch wrote:
> > We lose this optimization if we hook into
> > RepaintManager.addInvalidComponent.
>
> How would the optimization be lost? Nothing would change about how the
> RepaintManager works. We'd simply be updating the cached AWT size on
> every addInvalidComponent() call.
Yeah, it all depends what you do in the addInvalidComponent() override.
I was assuming that one would call validate() immediately - then the
optimization is lost. But, as you say, if only some sizes are updated,
it's not a problem.
> I'm beginning to think that we should allow the client to be involved in
> the handling of size updates.
Yes, I agree. It's a customization per instance, so here I provide an
overridable method instead of a shared singleton for all SwingControl
instances.
But I think the layout() call by default is needed, otherwise the
RelayoutExample does not work.
Bruno
Index: src/org/eclipse/albireo/core/SwingControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/SwingControl.java,v
retrieving revision 1.22
diff -c -3 -r1.22 SwingControl.java
*** src/org/eclipse/albireo/core/SwingControl.java 8 Feb 2008 22:07:07 -0000 1.22
--- src/org/eclipse/albireo/core/SwingControl.java 8 Feb 2008 22:42:07 -0000
***************
*** 390,396 ****
if (!isDisposed()) {
try {
inhibitSizePropagationToAWT = true;
! getParent().layout();
} finally {
inhibitSizePropagationToAWT = false;
}
--- 390,396 ----
if (!isDisposed()) {
try {
inhibitSizePropagationToAWT = true;
! controlResized();
} finally {
inhibitSizePropagationToAWT = false;
}
***************
*** 465,472 ****
// This is called by the layout when it wants to know the size preferences
// of this control.
/**
! * Overridden to use the preferred, minimum, and maxiomum sizes of
* the embedded Swing component.
*/
public Point computeSize(int widthHint, int heightHint, boolean changed) {
assert Display.getCurrent() != null; // On SWT event thread
--- 465,474 ----
// This is called by the layout when it wants to know the size preferences
// of this control.
/**
! * Overridden to use the preferred, minimum, and maximum sizes of
* the embedded Swing component.
+ * <p>
+ * This method is part of the size propagation from AWT to SWT.
*/
public Point computeSize(int widthHint, int heightHint, boolean changed) {
assert Display.getCurrent() != null; // On SWT event thread
***************
*** 499,508 ****
--- 501,525 ----
}
}
+ /**
+ * Called when the size of this control changed.
+ * <p>
+ * This method is part of the size propagation from AWT to SWT.
+ * It is called on the SWT event thread.
+ * <p>
+ * The default implementation calls {@link Composite#layout()} on
+ * the parent control. You can override this method.
+ */
+ public void controlResized() {
+ getParent().layout();
+ }
+
// This is called by the layout when it assigns a size and position to this
// Control.
/**
* Overridden to propagate the size to the embedded Swing component.
+ * <p>
+ * This method is part of the size propagation from SWT to AWT.
*/
public void setBounds(Rectangle rect) {
handleSetBounds(rect.width, rect.height);
***************
*** 510,515 ****
--- 527,534 ----
}
/**
* Overridden to propagate the size to the embedded Swing component.
+ * <p>
+ * This method is part of the size propagation from SWT to AWT.
*/
public void setBounds(int x, int y, int width, int height) {
handleSetBounds(width, height);