jamie-pate/godot-control-data-binds

Add more flexibility to array_model when using BindItems and BindRepeat

Closed this issue · 0 comments

Problems:

Filtering array_model

Often you have an array of items but you don't want to show them all in the GUI...

BindItems and BindRepeat currently show the entire array of items, requiring a 'shadow model' that only has the visible items inside.

Dynamic array_model

Sometimes your array_model needs to be generated dynamically. For example it may be composed of array_a + array_b to generate array_ab. This requires extra glue function in your Component to generate the extra array_ab model that needs to get updated any time array_a or array_b is modified.

Proposal:

Allow the () suffix to call a Callable when specifying the array_model property of BindItems and BindRepeat classes.

E.G.: array_model = array_ab()

  • array_ab should be a Callable on the owner that takes no arguments.
  • Calls to this callable should be tracked. If new_result.hash() == old_result.hash() then return old_result to prevent extra change detection.