mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 430804 (add tooltip infrastructure in visualizer)
Change-Id: I99180f6dc13260d87b513f0e6459598db0310a17 Signed-off-by: Xavier Raynaud <xavier.raynaud@kalray.eu> Reviewed-on: https://git.eclipse.org/r/23668 Reviewed-by: Marc Dumais <marc.dumais@ericsson.com> IP-Clean: Marc Dumais <marc.dumais@ericsson.com> Tested-by: Marc Dumais <marc.dumais@ericsson.com>
This commit is contained in:
parent
d844a16e83
commit
50f5d7cd6f
3 changed files with 39 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Tilera Corporation and others.
|
* Copyright (c) 2012, 2014 Tilera Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,14 +7,18 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* William R. Swanson (Tilera Corporation)
|
* William R. Swanson (Tilera Corporation)
|
||||||
|
* Xavier Raynaud (Kalray) - Bug 430804
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.visualizer.ui.canvas;
|
package org.eclipse.cdt.visualizer.ui.canvas;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -43,6 +47,22 @@ public class GraphicCanvas extends BufferedCanvas
|
||||||
public GraphicCanvas(Composite parent) {
|
public GraphicCanvas(Composite parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
m_objects = new ArrayList<IGraphicObject>();
|
m_objects = new ArrayList<IGraphicObject>();
|
||||||
|
Listener mouseListener = new Listener() {
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SWT.MouseEnter:
|
||||||
|
case SWT.MouseMove:
|
||||||
|
IGraphicObject obj = getGraphicObject(event.x, event.y);
|
||||||
|
if (obj != null) {
|
||||||
|
String tooltip = obj.getTooltip(event.x, event.y);
|
||||||
|
setToolTipText(tooltip);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addListener(SWT.MouseMove, mouseListener);
|
||||||
|
addListener(SWT.MouseEnter, mouseListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dispose method. */
|
/** Dispose method. */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Tilera Corporation and others.
|
* Copyright (c) 2012, 2014 Tilera Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* William R. Swanson (Tilera Corporation)
|
* William R. Swanson (Tilera Corporation)
|
||||||
|
* Xavier Raynaud (Kalray) - Bug 430804
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.visualizer.ui.canvas;
|
package org.eclipse.cdt.visualizer.ui.canvas;
|
||||||
|
@ -275,4 +276,9 @@ public class GraphicObject
|
||||||
*/
|
*/
|
||||||
public void paintDecorations(GC gc) {
|
public void paintDecorations(GC gc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTooltip(int x, int y) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2012 Tilera Corporation and others.
|
* Copyright (c) 2012, 2014 Tilera Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* William R. Swanson (Tilera Corporation)
|
* William R. Swanson (Tilera Corporation)
|
||||||
|
* Xavier Raynaud (Kalray) - Bug 430804
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.visualizer.ui.canvas;
|
package org.eclipse.cdt.visualizer.ui.canvas;
|
||||||
|
@ -31,6 +32,15 @@ public interface IGraphicObject
|
||||||
* If decorations is true, paints optional "decorations" layer.
|
* If decorations is true, paints optional "decorations" layer.
|
||||||
*/
|
*/
|
||||||
public void paint(GC gc, boolean decorations);
|
public void paint(GC gc, boolean decorations);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tooltip to display when mouse stays on this object.
|
||||||
|
* It may return <code>null</code> if there is nothing to display.
|
||||||
|
* @param x the x coordinate
|
||||||
|
* @param y the y coordinate
|
||||||
|
* @return the tooltip to display on this object.
|
||||||
|
*/
|
||||||
|
public String getTooltip(int x, int y);
|
||||||
|
|
||||||
/** Returns true if object has decorations to paint. */
|
/** Returns true if object has decorations to paint. */
|
||||||
public boolean hasDecorations();
|
public boolean hasDecorations();
|
||||||
|
|
Loading…
Add table
Reference in a new issue