Commit 4437dea4 authored by Michael Schwarz's avatar Michael Schwarz
Browse files

Fixed tooltip size problem: was zero whenever displayed on 2nd screen

parent feaf6b51
......@@ -14,6 +14,9 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class MultipleTextTooltipBase{
//TODO: If the tooltip is on the secondary display, this causes havoc
private static final int MARGIN = 3;
private static final int MAX_HEIGHT = 300;
......@@ -61,9 +64,16 @@ public class MultipleTextTooltipBase{
return isVisible;
}
private void correctWindowSize() {
int maxWidth = Display.getCurrent().getPrimaryMonitor().getBounds().width
private void correctWindowSize() {
int maxWidth = Display.getCurrent().getPrimaryMonitor().getBounds().width
- 50 - offsetLeft;
if(maxWidth < 0){
int offsetCorrectedForMonitor = offsetLeft-Display.getCurrent().getMonitors()[1].getBounds().x;
maxWidth = Display.getCurrent().getMonitors()[1].getBounds().width
- 50 - offsetCorrectedForMonitor;
}
// Get the desired size for each label
int desired = 0;
......
......@@ -16,6 +16,8 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout;
public abstract class TooltipBase implements ITooltip{
//TODO: If the tooltip is on the secondary display, this causes havoc
private static final int MARGIN = 3;
private static final int MAX_HEIGHT = 300;
......@@ -65,6 +67,14 @@ public abstract class TooltipBase implements ITooltip{
private void correctWindowSize() {
int maxWidth = Display.getCurrent().getPrimaryMonitor().getBounds().width
- 50 - offsetLeft;
if(maxWidth < 0){
int offsetCorrectedForMonitor = offsetLeft-Display.getCurrent().getMonitors()[1].getBounds().x;
maxWidth = Display.getCurrent().getMonitors()[1].getBounds().width
- 50 - offsetCorrectedForMonitor;
}
Point labelSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = Math.min(labelSize.x, maxWidth) + MARGIN*2;
popup.setSize(width, 10);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment