juliankrispel / Pollock

A canvas-based application which paints by itself.
2 stars 1 forks source link

Towards dynamic GUI binding behavior #26

Open ulikk opened 10 years ago

ulikk commented 10 years ago

Problem 1: Public bound variables have to be glued manually to angular in ui.coffee in a separate list.

Idea 1:


Problem 2: Defaults allow only instantiation of simple Data types and no objects.

Idea 2:

  defaults:
    ctr
    upmode: 'discrete'
    value: NaN
    lastValue: NaN
    cycle: 
       _CLASS: 'RandomIntervalNumber'
       _PARAMETERS: [ 20, 100 ]
       mode: 'regular'
       interval: 5

Problem 3: There is too much "glue" code between UI and application

Idea 3: Create "meta information" channels, lets call them "Metachannel" so that the UI can automatically build gui controls

Example: Interchangeable Movements for brushes, each with different parameter set

[
  { type: textbox, channel: brushMinSize },
  { type: textbox, channel: brushMaxSize },
  ...
]
  public:
    _METACHANNEL: 'MovementParameters'
    brushMinSize:
       type: 'textbox'
       binding: 'sizem.value.min'
    brushMaxSize: 
      type: 'textbox'
      binding:'sizem.value.max'
    'movementChangeDirectionMin': 'delta._cycle.min'
    'movementChangeDirectionMax': 'delta._cycle.max'
juliankrispel commented 10 years ago

Regarding Problem 3:

I propose a kind of type system, we could simply solve this problem by using names of classes, i.e. TUPLE, INT, RANGE.

ulikk commented 10 years ago

Problem 1 has been committed with e83898dc382550f79acb58246a3323e955369619 and 341f998626591f7a5b899291fc1da41541553890

ulikk commented 10 years ago

For Problem 2 i propose a somewhat shorter form:

  defaults:
    ctr
    upmode: 'discrete'
    value: NaN
    lastValue: NaN
    cycle: 
       _CLASS: [ 'RandomIntervalNumber', [ 20, 100 ] ]
       mode: 'regular'
       interval: 5
ulikk commented 10 years ago

Problem 2 was solved by extending base functionality so that default members can contain callback functions that instantiate the appropriate object.

class Mutable extends Base
defaults:
    ctr: 1
    upmode: 'discrete'
    value: NaN
    lastValue: NaN
    cycle: -> new RandomIntervalNumber(new Range(20,100))
...

One can also override the default by supplying an appropriate object upon instantiation through the Initializer Object given to the constructor:

    @sizem = new Mutable
      value: new RandomIntervalNumber new Range(2, 15)
      upmode: 'linp'
      cycle: new RandomIntervalNumber new Range(20, 100)