Skip to content

Commit eabde30

Browse files
committed
Bug 576218 part2 - Over 99 tab indicator has lost the +
- all ToolItem#setXXX() methods need to call parent.layout(boolean) which makes the cached ToolBar size invalid. - Re-factoring in ToolBar Change-Id: I95d2786142a10ecbaea683d2ec5004484fee70f5 Signed-off-by: Niraj Modi <[email protected]> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/186277 Tested-by: Platform Bot <[email protected]>
1 parent 0bcf754 commit eabde30

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,15 @@ protected void checkSubclass () {
195195
@Override
196196
public void layout (boolean changed) {
197197
checkWidget ();
198+
clearSizeCache(changed);
199+
super.layout(changed);
200+
}
201+
202+
void clearSizeCache(boolean changed) {
198203
// If changed, discard the cached layout information
199204
if (changed) {
200205
_count = _wHint = _hHint = -1;
201206
}
202-
super.layout(changed);
203207
}
204208

205209
@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
@@ -686,6 +690,7 @@ public int indexOf (ToolItem item) {
686690
}
687691

688692
void layoutItems () {
693+
clearSizeCache(true);
689694
/*
690695
* Feature in Windows. When a tool bar has the style
691696
* TBSTYLE_LIST and has a drop down item, Window leaves

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ public void setControl (Control control) {
579579
if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
580580
}
581581
if ((style & SWT.SEPARATOR) == 0) return;
582+
parent.layout(true);
582583
this.control = control;
583584
/*
584585
* Feature in Windows. When a tool bar wraps, tool items
@@ -705,6 +706,7 @@ public void setDisabledImage (Image image) {
705706
checkWidget();
706707
if ((style & SWT.SEPARATOR) != 0) return;
707708
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
709+
parent.layout(isImageSizeChanged(disabledImage, image));
708710
disabledImage = image;
709711
updateImages (getEnabled () && parent.getEnabled ());
710712
}
@@ -730,6 +732,7 @@ public void setHotImage (Image image) {
730732
checkWidget();
731733
if ((style & SWT.SEPARATOR) != 0) return;
732734
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
735+
parent.layout(isImageSizeChanged(hotImage, image));
733736
hotImage = image;
734737
updateImages (getEnabled () && parent.getEnabled ());
735738
}
@@ -739,14 +742,18 @@ public void setImage (Image image) {
739742
checkWidget();
740743
if ((style & SWT.SEPARATOR) != 0) return;
741744
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
745+
parent.layout(isImageSizeChanged(super.image, image));
746+
super.setImage (image);
747+
updateImages (getEnabled () && parent.getEnabled ());
748+
}
749+
750+
boolean isImageSizeChanged(Image oldImage, Image image) {
742751
boolean changed = true;
743752
// check if image size really changed for old and new images
744-
if (super.image != null && !super.image.isDisposed() && image != null && !image.isDisposed()) {
745-
changed = !super.image.getBounds().equals(image.getBounds());
753+
if (oldImage != null && !oldImage.isDisposed() && image != null && !image.isDisposed()) {
754+
changed = !oldImage.getBounds().equals(image.getBounds());
746755
}
747-
parent.layout(changed);
748-
super.setImage (image);
749-
updateImages (getEnabled () && parent.getEnabled ());
756+
return changed;
750757
}
751758

752759
boolean setRadioSelection (boolean value) {

0 commit comments

Comments
 (0)