txoof / epdlib

Python library for creating and writing modular layouts for e-paper screens
GNU General Public License v3.0
16 stars 8 forks source link

setting a new resolution does not properly reset all the block properties #51

Closed txoof closed 8 months ago

txoof commented 1 year ago

This is primarily an issue when developing in jupyter notebook where all the objects remain in memory.

Something odd is going on when a new resolution is set that requires clearing all the objects out of memory before a new resolution can be set.

this is a developer quality-of-life improvement

txoof commented 1 year ago

This is likely due to how the block properties are set and updated. Ultimately this has something to do with how mutable objects are used in the calculation of the layout.

The problem is most likely in the Layout class and has something to do with values that are pulled from the constants file (which is not technically constant).

txoof commented 12 months ago

Updating the resolution never triggers a recalculation of the layout.

The _calculate_layout method only looks for blocks that do not have absolute coordinates and calculates them as needed and stores them in the _layout property. When resetting the resolution, _calculate_layout ignores all the existing blocks.

This can be solved by creating a new private property _master_layout and deepcopying the provided layout into this object. This is then treated as immutable and deep copied whenever _calculate_layout runs again.