projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a GUIComponent resize listener
[Mograsim.git]
/
net.mograsim.logic.ui
/
src
/
net
/
mograsim
/
logic
/
ui
/
LogicUIRenderer.java
diff --git
a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java
b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java
index
a2be5ba
..
7858a70
100644
(file)
--- a/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java
+++ b/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIRenderer.java
@@
-22,21
+22,34
@@
public class LogicUIRenderer
public void render(GeneralGC gc, Rectangle visibleRegion)
{
public void render(GeneralGC gc, Rectangle visibleRegion)
{
+ gc.setAntialias(SWT.ON);
+ gc.setClipping(visibleRegion);
gc.setLineWidth(.5);
gc.setLineWidth(.5);
- model.getWires().forEach(w -> w.render(gc));
+ model.getWires().forEach(w ->
+ {
+ Rectangle bounds = w.getBounds();
+ double lw = gc.getLineWidth();
+ if (visibleRegion.intersects(bounds.x - lw, bounds.y - lw, bounds.width + lw + lw, bounds.height + lw + lw))
+ w.render(gc);
+ });
model.getComponents().forEach(c -> renderComponent(gc, c, visibleRegion));
}
private static void renderComponent(GeneralGC gc, GUIComponent component, Rectangle visibleRegion)
{
model.getComponents().forEach(c -> renderComponent(gc, c, visibleRegion));
}
private static void renderComponent(GeneralGC gc, GUIComponent component, Rectangle visibleRegion)
{
- component.render(gc, visibleRegion);
- if (DRAW_PINS)
+ Rectangle bounds = component.getBounds();
+ double lw = gc.getLineWidth();
+ if (visibleRegion.intersects(bounds.x - lw, bounds.y - lw, bounds.width + lw + lw, bounds.height + lw + lw))
{
{
-
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_CYAN)
);
-
for (Pin p : component.getPins()
)
+
component.render(gc, visibleRegion
);
+
if (DRAW_PINS
)
{
{
- Point pos = p.getPos();
- gc.fillOval(pos.x - 1, pos.y - 1, 2, 2);
+ gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_CYAN));
+ for (Pin p : component.getPins().values())
+ {
+ Point pos = p.getPos();
+ gc.fillOval(pos.x - 1, pos.y - 1, 2, 2);
+ }
}
}
}
}
}
}