Viewer/Selector Drawing Logic
Finding: The methods draw_tileset_viewer and draw_supertile_selector are extremely similar. Both contain loops that calculate grid coordinates, determine the position of an item, create an image from a cache, and draw a selection border. The primary differences are the item dimensions and the data source.
Impact: If we want to change how selection borders are drawn or how items are laid out, we have to make the exact same change in multiple places, which is error-prone. This could be refactored into a single, generic _draw_grid_view method.
Viewer/Selector Event Handling
Finding: The event handlers for mouse clicks, drags, and releases (handle_tileset_click, handle_supertile_selector_click, handle_viewer_drag_motion, handle_viewer_drag_release) are duplicated for the different selector canvases. They all perform the same core logic for initiating a drag, showing a drop indicator, or finalizing a selection/move/swap operation.
Impact: This is a significant amount of repeated code that makes adding new features (like multi-select) much more difficult.
Viewer/Selector Drawing Logic
Finding: The methods draw_tileset_viewer and draw_supertile_selector are extremely similar. Both contain loops that calculate grid coordinates, determine the position of an item, create an image from a cache, and draw a selection border. The primary differences are the item dimensions and the data source.
Impact: If we want to change how selection borders are drawn or how items are laid out, we have to make the exact same change in multiple places, which is error-prone. This could be refactored into a single, generic _draw_grid_view method.
Viewer/Selector Event Handling
Finding: The event handlers for mouse clicks, drags, and releases (handle_tileset_click, handle_supertile_selector_click, handle_viewer_drag_motion, handle_viewer_drag_release) are duplicated for the different selector canvases. They all perform the same core logic for initiating a drag, showing a drop indicator, or finalizing a selection/move/swap operation.
Impact: This is a significant amount of repeated code that makes adding new features (like multi-select) much more difficult.