Skip to content

Commit

Permalink
Merge pull request #94 from sesteel/master
Browse files Browse the repository at this point in the history
Changed to MouseHover for Bubble triggering on CustomElementDataProvider...
  • Loading branch information
sesteel committed Feb 26, 2014
2 parents acd4f36 + 23846fb commit aaea55d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project details
group=com.readytalk
version=2.0.2
version=2.1.0


# Optimize the build environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/readytalk/swt/text/painter/TextPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public void handleEvent(Event event) {
};
}

customElementDataProvider.getPaintedElement().addListener(SWT.MouseMove, mouseTrackListener);
customElementDataProvider.getPaintedElement().addListener(SWT.MouseHover, mouseTrackListener);
}

void removeMouseListener() {
Expand Down

0 comments on commit aaea55d

Please sign in to comment.