08 June 2014

This week I have managed to write a working selection window along with a filter. I have also fixed some issues with text in range selections.

Selection Window and Filter

The work on the filter and window can be found in the following PR .

Selection Filter

The main goal in my proposal was to create a way to limit on which elements the actions work on. This is a filter of some sort. Most of the time the user uses the range selection, so it will primarily work for range selections.

This proved fairly easy. The range selection has a updateSelectedElements function, that goes through each segment in the range, and adds elements to the selection. Applying a filter in this function achieves the task. Unfortunately, most actions do not use the selected element list, they loop through the segments themselves, so the filter has to be applied there as well. So far I have worked on the copy-paste action.

The new selection filter object could be stored either in a Score or a MuseScore object. Switching scores in the MuseScore should change both the selection and the filter. Example: A user works on two scores, one where he only wants to copy notes, and the other where he wantes to copy all. Switching from score to score should keep this setting. That is why the filter is a part of a Score object.

Copy - Paste

A copy works by converting the selection to a xml mime format. On paste, it is converted back to elements, and added to the score. Unfortunately, the methods that created a mime format did not take into account the selected elements. Instead called the writeSegments function that is also used when saving a score. I had to thing of a way to filter these elements. I came up with 3 solutions to the problem. The first one was to make a copy of the selection, and remove elements from there. This way we do not interfere with the actual xml generation. The second solution was to change the xml generation function to include filters. Since the function calls write functions for each element, there would have to be an overload for each of these. The third solution would be create the mime of the whole selection range, and remove the filtered elements from the xml. That would require a xml parser, and would be a bit too complicated.

I have implemented the first solution. To do this I have written a cloneRange function, that calls clone on each segment of the range. It places the segments in a list, so all references are kept, and when the list goes out of scope, all the segments are destructed properly. I have written another function that takes the list, and removes elements from the segments, if they are filtered. This way we do not interfere with the xml generation, and the pasted selection does not include the filtered elements.


This action will be more straightforward. I haven’t started working on this yet, because I need to be able to filter out the chordrests. Most elements are tied to chordrests, so it is difficult to check the behavior when chordrests are removed too.

Overall the selection filter adds a lot of new possibilities. Here are some use cases:

  • Remove all dynamics from a range
  • Copy notes without ornaments
  • Move the first voice of a selection an interval higher
  • Apply a certain attribute to elements via inspector

If you have more suggestions about the action that could use a filter, fell free to contact me.

Selection Window

This new widget allows changing of the filter. It is a dock widget, so you can have it docked on the left/right, or placed anywhere else. The default shortcut for showing a selection window is F6. As of now the selection window looks like this:


I am thinking about joining the first 4 checkboxes to be on the same line, but that might not be to intuitive. If you have any suggestions to the look and structure of the selection window, feel free to email me, or write a message over IRC.

Here is a screen shot of the window and filter in action:


Text in selection

When making filters for lyrics, I have noticed that selections are not consistent for text elements. For example selecting the first bar in the Promenade score highlights the tempo text, but pressing delete does not remove it along with the notes. The following PRs aim to fix these issues:

A decision had to be made to choose which elements should belong to the selection. After discussing it over IRC, we decided to remove all text with a system flag, to not be included in the selection. Those are: tempo text, system text and rehearsal mark. The other text elements are included in the selection, and are copied and removed along with the selection. The text can still be selected, it’s just not part of a range selection.

Problems - Figured Bass

When looking over text selection, along with the copy paste actions, I noticed that figured base is not pasted. After looking over the mime data that is created when the elements are copied, it looks like the element is copied correctly. I created a simple score with a note and a figured base text. Upon saving and reloading the score, the f.b. does not appear. It looks like the element is created. Furthermore, the element is successfully added to the annotation list. It looks like a problem with drawing itself, but I have not looked into it yet. I will try to solve this by Monday, to wrap up the work on text in selection, so that I can continue on with the filters.

Tasks in the upcoming week

I plan to fix the figured bass issue, and continue working on the filter. I also plan to add the filter for lyrics and figured bass. After that my next goal is to allow the user to select and copy only one voice from a measure.