I'm fairly new to PlayDate development so if this observation is off the mark please feel free to correct me.
I've been using the SDK GridView class in several of my classes and I often encounter issues with the way GridView calls the drawCell method. The current implementation requires that the callers drawCell method be defined as a method of the GridView class itself. To me this presents some serious limitations such as:
If using the GridView from within a class the 'self' address is not available in the drawCell method so all data required must be either global or file local.
The drawMethod is bound to the GridView class at compile time so it isn't possible to create a new GridView at runtime and replace the existing one.
I would not propose any changes to the current functioning of the existing GridView, there is probably a lot of code that depends on it.
A few things I would like to see to help with this situation are:
- a new method on GridView that accepts a callback function address that should be called instead of the GridView's drawCell method. This could be something like:
This value could be stored in the GridView class and called instead of the current drawCell if it was not nil.
- a new method on GridView that would allow a caller to store and retrieve a data value. This would allow a caller to store application specific information within the grid view. For example:
myData = gridView:getUserData()
I hope I’ve been able to present some of the limitations I’ve encountered with the current GrifView and I’ve tried to offer some possible enhancements to address them. Y’all probably have better ideas so I stand ready to learn.