diff --git a/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java b/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java index 5168b0e3c..f3a32b31c 100644 --- a/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java +++ b/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java @@ -36,6 +36,7 @@ public class ResolveGenerics { * Key uses to store the args for the generic circuits */ public static final String GEN_ARGS_KEY = "genArgs"; + private static final String SETTINGS_KEY = "settings"; private final HashMap<String, Statement> map; private final HashMap<Args, CircuitHolder> circuitMap; private final Circuit circuit; @@ -163,6 +164,7 @@ private Context createContext(Circuit circuit, ArrayList<VisualElement> newCompo Context context = new Context(); if (circuit.getOrigin() != null) context.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin()); + context.declareVar(SETTINGS_KEY, new SubstituteLibrary.AllowSetAttributes(circuit.getAttributes())); context.declareFunc("addWire", new AddWire(newWires)); context.declareFunc("addComponent", new AddComponent(newComponents, args)); return context; @@ -308,7 +310,7 @@ private static void addVal(StringBuilder sb, String key, Object val, HashSet<Str return; } - if (!key.equals(Context.BASE_FILE_KEY)) { + if (!key.equals(Context.BASE_FILE_KEY) && !key.equals(SETTINGS_KEY)) { contentSet.add(key); sb.append(key).append(":="); if (val instanceof String) { diff --git a/src/main/java/de/neemann/digital/draw/shapes/LayoutShape.java b/src/main/java/de/neemann/digital/draw/shapes/LayoutShape.java index 78cc3305c..96fb09ff5 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/LayoutShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/LayoutShape.java @@ -102,8 +102,8 @@ public LayoutShape(ElementTypeDescriptionCustom custom, ElementAttributes elemen } } - height = left.max(right.max(custom.getAttributes().get(Keys.HEIGHT))); - width = top.max(bottom.max(custom.getAttributes().get(Keys.WIDTH))); + height = left.max(right.max(circuit.getAttributes().get(Keys.HEIGHT))); + width = top.max(bottom.max(circuit.getAttributes().get(Keys.WIDTH))); HashMap<String, PinPos> map = new HashMap<>(); top.createPosition(map, new Vector(0, 0), width);