feat(sdk): add registerColorMap/unregisterColorMap to toolbox host ABI#60
Merged
Merged
Conversation
Allow toolbox plugins to register named colormaps as callbacks. The host stores the callbacks in a registry; the chart renderer invokes them per data point to get a color string. This keeps scripting runtimes (Lua, Python) out of the core entirely. Contents: - register_colormap(name, eval_fn, user_ctx) in PJ_toolbox_host_vtable_t - unregister_colormap(name) - C++ wrapper: ToolboxHostView::registerColorMap / unregisterColorMap - ColorMapEntry registry in DatastoreToolboxHostState
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The ColorMap Editor plugin needs to evaluate a Lua function
ColorMap(v)per data point to determine the chart background color. In PJ 3.x this lived in the app directly. In the new plugin architecture, putting Lua in the core would be wrong — the scripting runtime should stay in the plugin.This PR adds a service provider pattern: the plugin registers named colormaps as callbacks, and the chart renderer invokes them without knowing what runs inside (Lua, Python, lookup table, etc.).
Summary
register_colormap(name, eval_fn, user_ctx)inPJ_toolbox_host_vtable_t— plugin registers a named callbackunregister_colormap(name)— plugin removes it when closingeval_fnsignature:const char*(double value, void* user_ctx)— returns CSS color stringToolboxHostView::registerColorMap/unregisterColorMapwith nullptr guardsColorMapEntryregistry inDatastoreToolboxHostStateTest plan
pj_datastore— no compile errors