Cut, copy, paste

From Buzztrax

Jump to: navigation, search

We have cut/copy/paste and delete items in our main menu as well as in context menus. Delete is handled straight forward - it removes the object. Cut, copy and paste in contrast need to interact with the clipboard. This functionality is provided by gtk. We basically store our data together with a mime-type. The mime-type help to later recognize our clipboard data (when pasting).

The question is how far we want to take this?

Pasting in same song

Paste inserts only fragments into the same song, where they have been taken from.

sequence

  • copy and paste in one track:
    • if we have multiple tracks of the same machine we can paste into a different track
  • copy and paste multiple tracks:
    • if copy uses tracks{a,b,c}, the cursor must be at track{a} and have tracks{b,c} to the right when pasting

patterns

  • copy and paste of parameter with the same G_TYPE and the same range
  • copy from one voice to another

machine

  • copy a machine and paste it (duplicate/clone)
    • copy patterns too?

Clipboard data format

Ideally we have xml serialisation of our objects for the clipboard. Then delete can then also be undo'ed.

Serialisation

To copy a region in the pattern we call serialize_region(region) for the pattern object. We put the serialized object (xml) into the clipboard. Its origin (selection region will be offsetted to 0,0). To paste we deserialize an existing pattern and thus overlay the data. This needs and offset (cursor).

Therefore the serialisation API needs not just

  • bt_io_save(object,node);
  • bt_io_load(object,node);

but instead:

  • bt_io_save_region(object,region,node);
  • bt_io_load_region(object,position,node);

where

  • bt_io_load(object,node) == bt_io_load_region(object,NULL,node);
  • bt_io_save(object,node) == bt_io_save_region(object,NULL,node);

Region and Position need to be abstract base classes, where we need implementation for e.g.:

  • pattern,sequence: 2d region, 2d cursor position
  • machine-view: selection list,

Links

Support Us

Collaboration

GStreamer Logo
Become a Friend of GNOME
Linux Sound Logo
MediaWiki
Valgrind
GNU Library Public Licence
GNU Free Documentation License 1.2