Fixing frames coordinates and preventing overlap of data and frames (additional feature: center alignment) #3594
Conversation
…ames, still need fixing for data and frame contents
…nto fix/cse-layout-machine
integrate the toggle better into existing code, added datawidth to the center alignment calculations, and improved methods comment descriptions
out ghostX code in Binding.tsx into a helper function
now not readonly, and shifts for center alignment.
…n build - Replaced private 'name' property with private '_name' backing field. - Added public getter/setter for 'name' to allow external layout updates while maintaining compatibility with FrameCreationAnimation. - Fixes TS2341 privacy errors in CI build.
| // Update Text to new position | ||
| (this.key as any)._x = this.x(); | ||
| (this.key as any)._y = this.y() + this.keyYOffset; | ||
|
|
There was a problem hiding this comment.
These lines synchronize the Text object's coordinates with the Binding's updated positions. If we were to remove those lines, the text labels (the variable names) will stay at their initial coordinates while the frame boxes move away from them
There was a problem hiding this comment.
Got it, perhaps the setter approach would be good then to make it clear, otherwise just by looking at this file it doesn't seem very clear to someone who has not worked on the CSE machine before
| (this.text as any)._x = this.x(); | ||
| (this.text as any)._y = this.y(); |
There was a problem hiding this comment.
Is there a way to avoid typecast?
There was a problem hiding this comment.
To avoid the typecast, we can add public setters for _x and _y within the Text class.
There was a problem hiding this comment.
Let's do that in a future PR after your midterm, thanks!
Description
This PR introduces a fixed-coordinate layout system for the CSE Machine to prevent visual drifting when scrubbing through the execution timeline. By caching the coordinates of environment frames at the last step, this ensures that frames and data objects remain completely stationary throughout the program's execution.
Additionally, this PR introduces two key visual improvements:
This aligns with the pedagogical goal of achieving completely stationary frames, providing a more consistent and less confusing visual tracing experience for students.
Note on Known Issues / Out of Scope (Discussed & Approved by Prof):
The following behaviors are known and have been explicitly scoped out of this PR to be handled separately or prioritized as intended behaviors:
Type of change
How to test
Test Snippet (Frames, Strings, and Nested Lists):
Fixed_Layout_Center_Demo.mp4
Checklist