1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Bug 431690 - [visualizer] Use clipping when drawing strings

Change-Id: I342b1a430da450b45d62cea1469fbb62a3e9bc94
Signed-off-by: Xavier Raynaud <xavier.raynaud@kalray.eu>
Reviewed-on: https://git.eclipse.org/r/24201
Tested-by: Hudson CI
IP-Clean: Marc Dumais <marc.dumais@ericsson.com>
Tested-by: Marc Dumais <marc.dumais@ericsson.com>
Reviewed-by: William Swanson <traveler@tilera.com>
Reviewed-by: Marc Dumais <marc.dumais@ericsson.com>
This commit is contained in:
Xavier Raynaud 2014-04-01 10:16:42 +02:00 committed by Marc Dumais
parent af6a81e33d
commit f65493131c
7 changed files with 50 additions and 16 deletions

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
* Marc Dumais (Ericsson) - Bug 404894
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -154,7 +155,7 @@ public class MulticoreVisualizerCPU extends MulticoreVisualizerGraphicObject
int text_indent_y = 0;
int tx = m_bounds.x + m_bounds.width - text_indent_x;
int ty = m_bounds.y + m_bounds.height - text_indent_y;
GUIUtils.drawTextAligned(gc, Integer.toString(m_id), tx, ty, false, false);
GUIUtils.drawTextAligned(gc, Integer.toString(m_id), m_bounds, tx, ty, false, false);
}
}

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
* Marc Dumais (Ericsson) - Bug 404894
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -201,7 +202,7 @@ public class MulticoreVisualizerCore extends MulticoreVisualizerGraphicObject
int ty = m_bounds.y + text_indent;
// make sure we use the right color for core number, even if selected.
gc.setForeground(getCoreStateColor(true));
GUIUtils.drawTextAligned(gc, Integer.toString(m_id), tx, ty, false, true);
GUIUtils.drawTextAligned(gc, Integer.toString(m_id), m_bounds, tx, ty, false, true);
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013 Ericsson
* Copyright (c) 2013, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Marc Dumais (Ericsson) - Initial API and implementation (Bug 396268)
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -216,7 +217,7 @@ public class MulticoreVisualizerLoadMeter extends MulticoreVisualizerGraphicObje
gc.setForeground(IMulticoreVisualizerConstants.COLOR_LOAD_TEXT);
int tx = m_bounds.x;
int ty = m_bounds.y;
GUIUtils.drawTextAligned(gc, load, tx, ty, true, false);
GUIUtils.drawTextAligned(gc, load, m_bounds, tx, ty, true, false);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013 Ericsson
* Copyright (c) 2013, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Marc Dumais (Ericsson) - Initial API and implementation (Bug 405390)
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -54,7 +55,7 @@ public class MulticoreVisualizerStatusBar extends MulticoreVisualizerGraphicObje
gc.setForeground(IMulticoreVisualizerConstants.COLOR_STATUS_BAR_TEXT);
int tx = m_bounds.x;
int ty = m_bounds.y + 15;
GUIUtils.drawTextAligned(gc, m_statusMessage, tx, ty, true, false);
GUIUtils.drawTextAligned(gc, m_statusMessage, m_bounds, tx, ty, true, false);
}
}

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -176,7 +177,7 @@ public class MulticoreVisualizerThread extends MulticoreVisualizerGraphicObject
// draw TID
String displayTID = Integer.toString(m_thread.getTID());
GUIUtils.drawText(gc, displayTID, x + w + 4, y + 2);
GUIUtils.drawText(gc, displayTID, m_bounds, x + w + 4, y + 2);
// draw selection marker, if any
if (m_selected)

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson and others.
* Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.visualizer.examples.problemvisualizer;
@ -75,7 +76,7 @@ public class BarGraphicObject extends GraphicObject {
int text_indent = 6;
int tx = m_bounds.x + m_bounds.width - text_indent;
int ty = m_bounds.y + m_bounds.height - text_indent;
GUIUtils.drawTextAligned(gc, m_label, tx, ty, false, false);
GUIUtils.drawTextAligned(gc, m_label, m_bounds, tx, ty, false, false);
}
}

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* William R. Swanson (Tilera Corporation)
* Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.visualizer.ui.util;
@ -88,6 +89,15 @@ public class GUIUtils {
gc.drawText(text, x, y, SWT.DRAW_TRANSPARENT);
}
/** Draws transparent text, with the default alignment (top/left). */
static public void drawText(GC gc, String text, Rectangle clip, int x, int y)
{
Rectangle oldClip = gc.getClipping();
gc.setClipping(clip);
drawText(gc, text, x, y);
gc.setClipping(oldClip);
}
/** Draws transparent text, with the specified alignments. */
static public void drawTextAligned(GC gc, String text, int x, int y, boolean left, boolean top)
{
@ -101,7 +111,16 @@ public class GUIUtils {
gc.drawText(text, x - dx, y - dy, SWT.DRAW_TRANSPARENT);
}
}
/** Draws transparent text, with the specified alignments. */
static public void drawTextAligned(GC gc, String text, Rectangle clip, int x, int y, boolean left, boolean top)
{
Rectangle oldClip = gc.getClipping();
gc.setClipping(clip);
drawTextAligned(gc, text, x, y, left, top);
gc.setClipping(oldClip);
}
/** Draws transparent text, centered on the specified point. */
static public void drawTextCentered(GC gc, String text, int x, int y)
{
@ -110,8 +129,17 @@ public class GUIUtils {
gc.drawText(text, x - (int) Math.round(te.x / 2.0),
y - (int) Math.round(te.y / 2.0), SWT.DRAW_TRANSPARENT);
}
/** Draws transparent text, centered on the specified point. */
static public void drawTextCentered(GC gc, String text, Rectangle clip, int x, int y)
{
Rectangle oldClip = gc.getClipping();
gc.setClipping(clip);
drawTextCentered(gc, text, x, y);
gc.setClipping(oldClip);
}
// --- graphic methods ---
/** Shrinks rectangle by specified margin on all edges. */