diff options
| author | Eric Williams | 2018-03-16 13:09:24 +0000 |
|---|---|---|
| committer | Eric Williams | 2018-03-19 15:45:20 +0000 |
| commit | 8c8ba9af9f98118ac41a3aace8a8fc570bbcd1e0 (patch) | |
| tree | 318bc2a65f1b1c160a90618140de92dc902d2903 | |
| parent | 1fe521f7b3388b35e525b25e31276ee275ae1ae1 (diff) | |
| download | eclipse.platform.swt-8c8ba9af9f98118ac41a3aace8a8fc570bbcd1e0.tar.gz eclipse.platform.swt-8c8ba9af9f98118ac41a3aace8a8fc570bbcd1e0.tar.xz eclipse.platform.swt-8c8ba9af9f98118ac41a3aace8a8fc570bbcd1e0.zip | |
Bug 531599: [Generic TP Editor] typo in Edit Software Site view when
launched from TP editor
Set the font only when/after a Button has its text set. Internal size
calculations for fonts are CSS based with GTK3.22+, and setting the font
before text is actually set can result in caching issues. The size then
reported is too small, resulting in clipped buttons.
Tested on GTK3.22 only, 3.20 is unaffected. No AllNonBrowser JUnit test
failures, and child Eclipse looks fine.
Change-Id: I5e8f45a9023ed88409cc1474c1b1c920a5ed72d9
Signed-off-by: Eric Williams <ericwill@redhat.com>
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java index f7b67e4c82..cddd2817ef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java @@ -910,10 +910,15 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize } @Override -void setFontDescription (long /*int*/ font) { - super.setFontDescription (font); - if (labelHandle != 0) setFontDescription (labelHandle, font); - if (imageHandle != 0) setFontDescription (imageHandle, font); +void setFontDescription (long /*int*/ fontDesc) { + // Don't set the font if we have no text set + if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0) && ((text != null && text.isEmpty()) || text == null)) { + return; + } else { + super.setFontDescription (fontDesc); + if (labelHandle != 0) setFontDescription (labelHandle, fontDesc); + if (imageHandle != 0) setFontDescription (imageHandle, fontDesc); + } } @Override @@ -1167,6 +1172,11 @@ public void setText (String string) { GTK.gtk_label_set_text_with_mnemonic (labelHandle, buffer); updateWidgetsVisibility(); _setAlignment (style); + // Now that text has been added, set the font. This ensures + // the Button's size is correctly calculated/updated. + if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { + setFontDescription(font == null ? defaultFont().handle : font.handle); + } } private void updateWidgetsVisibility() { |
