Skip to content

feat(sdk): add registerColorMap/unregisterColorMap to toolbox host ABI#60

Merged
pabloinigoblasco merged 2 commits into
developmentfrom
feat/colormap-service-provider-gh
Apr 16, 2026
Merged

feat(sdk): add registerColorMap/unregisterColorMap to toolbox host ABI#60
pabloinigoblasco merged 2 commits into
developmentfrom
feat/colormap-service-provider-gh

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

@pabloinigoblasco pabloinigoblasco commented Apr 16, 2026

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) in PJ_toolbox_host_vtable_t — plugin registers a named callback
  • unregister_colormap(name) — plugin removes it when closing
  • eval_fn signature: const char*(double value, void* user_ctx) — returns CSS color string
  • C++ wrapper: ToolboxHostView::registerColorMap / unregisterColorMap with nullptr guards
  • ColorMapEntry registry in DatastoreToolboxHostState

Test plan

  • Build pj_datastore — no compile errors
  • Register a colormap from a toolbox plugin — host stores the callback
  • Unregister — callback removed
  • Existing toolbox host tests still pass

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
@pabloinigoblasco pabloinigoblasco merged commit 8f2f4b9 into development Apr 16, 2026
2 checks passed
@pabloinigoblasco pabloinigoblasco deleted the feat/colormap-service-provider-gh branch May 4, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant