Constraining properties



Hi Stefan,

as requested, I've prototyped a basic macro that helps with property setting by:

* constraining the property value (for int, float, enum)
* testing for value changes
* pushes undo (untested)
* emitting notification events
* actually setting the constrained value

Usage looks like this:

void
SongImpl::musical_tuning (MusicalTuning tuning)
{
  if (!prepared())
    {
      BseSong *self = as<BseSong*>();
      if (APPLY_IDL_PROPERTY (self->musical_tuning, tuning))
        {
          SfiRing *ring;
          for (ring = self->parts; ring; ring = sfi_ring_walk (ring, self->parts))
            bse_part_set_semitone_table ((BsePart*) ring->data, bse_semitone_table_from_tuning 
(self->musical_tuning));
        }
    }
}

You can find the code here:
        https://github.com/tim-janik/beast/tree/wip/constrain-properties

Please review the changes the branch introduces and let me know if that 
corresponds to the ideas you had about constraining properties.



-- 
Yours sincerely,
Tim Janik

https://testbit.eu/timj
Free software author.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]