From 03a641bc4400775fde4ffc8d67266d983cb67831 Mon Sep 17 00:00:00 2001 From: "ssteel@bitbucket.org" Date: Wed, 26 Feb 2014 00:16:24 -0700 Subject: [PATCH 1/3] changed to MouseHover for Bubble triggering on CustomElementDataProviders; added ability to set font sizes on Bubbles --- .../swt/widgets/notifications/BubbleExample.java | 3 ++- .../readytalk/swt/text/painter/TextPainter.java | 15 +++++++++++++++ .../swt/widgets/notifications/Bubble.java | 13 ++++++++++++- .../swt/widgets/notifications/BubbleRegistry.java | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/examples/java/com/readytalk/examples/swt/widgets/notifications/BubbleExample.java b/src/examples/java/com/readytalk/examples/swt/widgets/notifications/BubbleExample.java index 974512a..3b35fc1 100644 --- a/src/examples/java/com/readytalk/examples/swt/widgets/notifications/BubbleExample.java +++ b/src/examples/java/com/readytalk/examples/swt/widgets/notifications/BubbleExample.java @@ -63,7 +63,8 @@ public void widgetSelected(SelectionEvent e) { Button newFeatureButton = new Button(composite, SWT.PUSH); newFeatureButton.setText("A New Feature"); Bubble.createBubble(newFeatureButton, "This text explains a new, exciting feature!", BubbleTag.NEW) - .setCenteringEdge(CenteringEdge.RIGHT); + .setCenteringEdge(CenteringEdge.RIGHT) + .setFontHeight(10); Label labelExample = new Label(composite, SWT.NONE); labelExample.setText("A Short Label"); diff --git a/src/main/java/com/readytalk/swt/text/painter/TextPainter.java b/src/main/java/com/readytalk/swt/text/painter/TextPainter.java index d2a9bd5..562e182 100644 --- a/src/main/java/com/readytalk/swt/text/painter/TextPainter.java +++ b/src/main/java/com/readytalk/swt/text/painter/TextPainter.java @@ -211,6 +211,21 @@ private TextPainter setFont(final String name, final int height) { return this; } + /** + * Sets the font height (in px) of the default fonts painted by this painter. This includes + * normal, bold, italics and their combination. + * @param height : an int representing the height of the font in pixels + * @return {@link TextPainter} + */ + public TextPainter setDefaultFontHeight(final int height) { + font = FontFactory.getFont(this.parent.getDisplay(), height, SWT.NORMAL, font.getFontData()[0].name); + boldFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.BOLD, boldFont.getFontData()[0].name); + italicFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.ITALIC, italicFont.getFontData()[0].name); + underlineFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.UNDERLINE_LINK, underlineFont.getFontData()[0].name); + boldAndItalicFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.ITALIC|SWT.BOLD, boldAndItalicFont.getFontData()[0].name); + return this; + } + /** * Sets the boundary color. By default, it is set to (255, 30, 30). * Colors are managed by the color factory. diff --git a/src/main/java/com/readytalk/swt/widgets/notifications/Bubble.java b/src/main/java/com/readytalk/swt/widgets/notifications/Bubble.java index 581efc1..f1025ab 100644 --- a/src/main/java/com/readytalk/swt/widgets/notifications/Bubble.java +++ b/src/main/java/com/readytalk/swt/widgets/notifications/Bubble.java @@ -9,6 +9,7 @@ import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; @@ -91,7 +92,7 @@ private Bubble(Control parentControl, CustomElementDataProvider customElementDat private Bubble(Control parentControl, CustomElementDataProvider customElementDataProvider, String text, - boolean useBoldFont, + boolean useBoldFont, BubbleTag ... tags) throws IllegalArgumentException { super(parentControl, customElementDataProvider); @@ -145,6 +146,16 @@ private void registerBubble(PoppedOverItem poppedOverItem, BubbleTag ... tags) { bubbleRegistry.register(poppedOverItem.getControl(), this, tags); } } + + /** + * Sets the font height (in px) of the font painted by this Bubble. + * @param height + * @return {@link Bubble} + */ + public Bubble setFontHeight(int height) { + textPainter.setDefaultFontHeight(height); + return this; + } /** * Sets the VerticalLocation. VerticalLocation represents the relative visual location diff --git a/src/main/java/com/readytalk/swt/widgets/notifications/BubbleRegistry.java b/src/main/java/com/readytalk/swt/widgets/notifications/BubbleRegistry.java index 25d3056..3c2c2d1 100644 --- a/src/main/java/com/readytalk/swt/widgets/notifications/BubbleRegistry.java +++ b/src/main/java/com/readytalk/swt/widgets/notifications/BubbleRegistry.java @@ -289,7 +289,7 @@ public void handleEvent(Event event) { }; } - customElementDataProvider.getPaintedElement().addListener(SWT.MouseMove, mouseTrackListener); + customElementDataProvider.getPaintedElement().addListener(SWT.MouseHover, mouseTrackListener); } void removeMouseListener() { From 5b3d08b5dff82bfcb4a79d946ce719374bd64073 Mon Sep 17 00:00:00 2001 From: "ssteel@bitbucket.org" Date: Wed, 26 Feb 2014 00:21:01 -0700 Subject: [PATCH 2/3] correcting leading tab --- src/main/java/com/readytalk/swt/text/painter/TextPainter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readytalk/swt/text/painter/TextPainter.java b/src/main/java/com/readytalk/swt/text/painter/TextPainter.java index 562e182..a3ced95 100644 --- a/src/main/java/com/readytalk/swt/text/painter/TextPainter.java +++ b/src/main/java/com/readytalk/swt/text/painter/TextPainter.java @@ -218,7 +218,7 @@ private TextPainter setFont(final String name, final int height) { * @return {@link TextPainter} */ public TextPainter setDefaultFontHeight(final int height) { - font = FontFactory.getFont(this.parent.getDisplay(), height, SWT.NORMAL, font.getFontData()[0].name); + font = FontFactory.getFont(this.parent.getDisplay(), height, SWT.NORMAL, font.getFontData()[0].name); boldFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.BOLD, boldFont.getFontData()[0].name); italicFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.ITALIC, italicFont.getFontData()[0].name); underlineFont = FontFactory.getFont(this.parent.getDisplay(), height, SWT.UNDERLINE_LINK, underlineFont.getFontData()[0].name); From 23846fb26faf0be7aadfed482b9494348733743d Mon Sep 17 00:00:00 2001 From: "stan.steel" Date: Wed, 26 Feb 2014 09:53:43 -0700 Subject: [PATCH 3/3] updated version number --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8d8d644..27a61cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Project details group=com.readytalk -version=2.0.2 +version=2.1.0 # Optimize the build environment