Referencing #36.
Until recently subcircuits had very strict dimensions and positions and little could be done to move the node positions. As of now, subcircuits have flexible dimensions and node positions can be changed.
Moving forward, the design pattern has to be considered to ensure extensibility and ease for both development and the users.
Some of the features are to be considered to be implemented on the subcircuit layout.
This would open a whole range of exciting possibilities. If the initial design is good, implementing these features will be easy. However, it is tricky as all LEDs and other output elements need not be part of the subcircuit. Providing a feature for the user to easily pick and chose his features will be difficult. Storing and manipulating the data from the development point of view is tricky too.
@blane1257 @HypheX and thoughts? comments?
This all sounds pretty great. Also, I love the text idea! perhaps it could have a few options for color, font, and size, too.
This all sounds pretty great. Also, I love the text idea! perhaps it could have a few options for color, font, and size, too.
Yes this can be done too
I agree with blane, it sounds great! Can't wait for these features, I am "hyped".
I'll look into making some assets
Can I be marked as an "asignee"?
surface elements such as buttons and LEDs should be individually togglable if possible
Could the input/output elements just have an extra property that tells if they show up in the layout or not?
We also need to consider if their labels show up or not; I can think of cases where we would want to and in cases where we would not want to.
The size of the leds might also be important; in a project like this https://circuitverse.org/users/1935/projects/5010, I would love to have the LEDs in the "4-pixel cell" circuit, but they would need to be big enough to fill the layout, since the number of inputs dictates the size of the layout.
@fpintos These are valid points. This particular issue will take at least 3 months to implement correctly!
@satu0king Hi I am interested in this project and I intend to be part of this one through GSoC .Can You Guide me please What is your primary Idea to do this project . I mentioned one of My own in the proposal But It will really help me a lot if you guide me here.....Thanks
Hi @SubhajitCode ,
I have not put too much thought on this one yet, but my gut feeling is that we need to extend how we handle layoutProperties to other elements, augmenting CircuitElement to draw itself while in a sub-circuit.
If you search for 'layoutProperties' in the JavaScript files you'll see how they are specific to Input and Output elements. Files like data.js and layout.js have code that assumes only Input and Output have layoutProperties.
One idea would be to extend CircuitElement with a couple of extra properties:
@fpintos my Idea is also close to you except
I would like to look at this from a user experience point of view before we go forward with any implementation.
How does the user build the IC layout?
I see two approaches:
For now, let's concentrate on (1), since it is what we have today.
In Circuit-First, how does the circuit designer chooses which elements show up in IC layout?
There are 3 types of elements to consider:
(1) and (2) are trivial. (3) is what we're trying to solve in this issue. The key point is that such elements can be optionally included in the layout.
To me, if something is optional it means you don't have to think about it until you need it.
In the _circuit-first_ user experience this translates to two requirements:
Using a single LED as an example:
With these in mind, there are two ways to implement these requirements:
Given the user experience requirements above, I'm inclined to use the first approach, of extending the base class. I think using derived classes in this case will make it a lot more complicated to keep the UI simple.
All that being said, I'm open to head different approaches around how the user interface of this feature should work.
@fpintos
I got Your Point
I now agree putting an checkbox is the better way to go
1 st way seems to be the easy way to implement
I think we need to introduce another flag isInSubcircuit which will be false when the element is in its Circuit so that it will be rendered normally when we push it in the layout_buffer its will be set true so that when we render from subcircuit it will render as it should in subcircuit that is through customdraw
thanks for your valuable input
I will change my proposal accordingly
Thanks again ---Subhajit
@fpintos
Thank You for your inputs. @mohammedsafwat please go through this.
I had a similar idea in mind. To reiterate some things, there will be 3 types of elements
As @fpintos mentioned, (type 1) is already present. I would recommend not changing this code in order to avoid breaking things related to this. Moreover, type 1 has different needs from type 3 so a separate implementation is preferable.
Use canShowInSubCircuit in class prototype(s) as a boolean to display in the property menu as @fpintos explained. That means for type 1 and type 2 elements, this will be set False. Only for type 3 will this be set true.
Use showInSubCircuit as a boolean --> If true then subcircuit will render it.
Circuit-First approach is better as around 70% of the users just use a single circuit, 25% of the users use multiple circuits and only 5% of the users edit the layouts.
I agree with @fpintos that extending base-class is preferable. I would like to add some more details to that.
We can use the same structure as Input/Output. I have added the label attributes. It is better to maintain all state within the circuit elements itself because if the circuit element is deleted, copied etc, it will automatically be handled.
layoutProperties = {
x: 0,
y: get_next_position(0, scope),
id: generateId(),
displayLabel:true,
labelDirection:"Top"
}
Add functions subcircuitClick(), subcircuitHover(), subcircuitKey() etc to CircuitElement base class, these methods will be called when the user clicks, hovers or types a key when the corresponding element on the subcircuit is focussed.
The subcircuit currently does a lot of work when circuits are reloaded/saved/updated -> check reset() function. This is because we need to handle wire connections updates, node property updates etc. However, as type 2 elements don't interact with other elements, this is not necessary. Instead, we can simply scan through all circuit elements when reset() is called and cache the same.
As for the UI, this is tricky. Of course the current circuitElement sidebar on the left should be disabled completely or replaced with a different one. An ideal UI would be such that all the optional elements in the circuit are present neatly somewhere in the page. The user can drag each optional element and place it in the subcircuit wherever he or she needs it. This might be difficult to implement. A simpler method would be to add a checkbox in the property menu and when checked, it will display in the subcircuit and the user can position the same.

I think this is the best UI possible but might be tricky to implement.
@fpintos any inputs on this?
I like the way that looks! I think I mentioned something like this before, but the user should also be able to insert text, which could support either markdown or html, and maybe users could have some basic graphical options, like lines and boxes. Something similar could be implemented with the current text tool.
I like the way that looks! I think I mentioned something like this before, but the user should also be able to insert text, which could support either markdown or html, and maybe users could have some basic graphical options, like lines and boxes. Something similar could be implemented with the current text tool.
Yes I agree. The current text tool should be extended to be a full-fledged markdown based text editor. However, I don't think the subcircuit text tool needs to be this complicated, it is expected to be used only for annotation.
maybe users could have some basic graphical options, like lines and boxes
Yes this could be useful.
I like the way that looks! I think I mentioned something like this before, but the user should also be able to insert text, which could support either markdown or html, and maybe users could have some basic graphical options, like lines and boxes. Something similar could be implemented with the current text tool.
Supporting markdown is a good idea, but let's treat this as a separate issue, least it feature-creeps into the sub-layout issue.
No activity on this issue for a prolonged duration, will be closed if no further activities in next 7 days
Do not close
Most helpful comment
I would like to look at this from a user experience point of view before we go forward with any implementation.
How does the user build the IC layout?
I see two approaches:
For now, let's concentrate on (1), since it is what we have today.
In Circuit-First, how does the circuit designer chooses which elements show up in IC layout?
There are 3 types of elements to consider:
(1) and (2) are trivial. (3) is what we're trying to solve in this issue. The key point is that such elements can be optionally included in the layout.
To me, if something is optional it means you don't have to think about it until you need it.
In the _circuit-first_ user experience this translates to two requirements:
Using a single LED as an example:
With these in mind, there are two ways to implement these requirements:
Given the user experience requirements above, I'm inclined to use the first approach, of extending the base class. I think using derived classes in this case will make it a lot more complicated to keep the UI simple.
All that being said, I'm open to head different approaches around how the user interface of this feature should work.