X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2FSubmodelComponent.java;h=8068e06c7c314972bf14ecf5d4413a9ded43d2f2;hb=3a9b1d1922b328b40bf17c6dfc0f4c3948c90158;hp=e62bea6206ba52c4eed1e8dd9015281b5ab10428;hpb=59794c0fc634d6833d60649295ab722aef68d00b;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java index e62bea62..8068e06c 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java @@ -45,7 +45,7 @@ public class SubmodelComponent extends GUIComponent this.label = label; this.submodelScale = 1; - this.maxVisibleRegionFillRatioForAlpha0 = 0.1; + this.maxVisibleRegionFillRatioForAlpha0 = 0.4; this.minVisibleRegionFillRatioForAlpha1 = 0.8; this.renderer = new LogicUIRenderer(submodelModifiable); @@ -147,15 +147,23 @@ public class SubmodelComponent extends GUIComponent alphaFactor = Math.max(0, Math.min(1, alphaFactor)); // we need to take the old alpha into account to support nested submodules better. int oldAlpha = gc.getAlpha(); - gc.setAlpha(Math.max(0, Math.min(255, (int) (oldAlpha * alphaFactor)))); - renderer.render(tgc, visibleRegion.translate(-posX, -posY, 1 / submodelScale)); - gc.setAlpha(Math.max(0, Math.min(255, (int) (oldAlpha * (1 - alphaFactor))))); - Font oldFont = gc.getFont(); - Font labelFont = new Font(oldFont.getName(), 6, oldFont.getStyle()); - gc.setFont(labelFont); - Point textExtent = gc.textExtent(label); - gc.drawText(label, posX + (getBounds().width - textExtent.x) / 2, posY + (getBounds().height - textExtent.y) / 2, true); - gc.setFont(oldFont); + int submodelAlpha = Math.max(0, Math.min(255, (int) (oldAlpha * alphaFactor))); + int labelAlpha = Math.max(0, Math.min(255, (int) (oldAlpha * (1 - alphaFactor)))); + if (submodelAlpha != 0) + { + gc.setAlpha(submodelAlpha); + renderer.render(tgc, visibleRegion.translate(-posX, -posY, 1 / submodelScale)); + } + if (labelAlpha != 0) + { + gc.setAlpha(labelAlpha); + Font oldFont = gc.getFont(); + Font labelFont = new Font(oldFont.getName(), 6, oldFont.getStyle()); + gc.setFont(labelFont); + Point textExtent = gc.textExtent(label); + gc.drawText(label, posX + (getBounds().width - textExtent.x) / 2, posY + (getBounds().height - textExtent.y) / 2, true); + gc.setFont(oldFont); + } conf.reset(gc); // draw the "bounding box" after all other operations to make interface pins look better gc.drawRectangle(getBounds()); @@ -166,6 +174,14 @@ public class SubmodelComponent extends GUIComponent return mapMin + (val - valMin) * (mapMax - mapMin) / (valMax - valMin); } + @Override + public boolean clicked(double x, double y) + { + // TODO + System.out.println(((x - getBounds().x) / submodelScale) + "|" + ((y - getBounds().y) / submodelScale)); + return true; + } + private static class PinMovable extends Pin { public PinMovable(GUIComponent component, int logicWidth, double relX, double relY)