Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control-drag on the score to *add* to a previous selections of notes #91

Open
revad opened this issue Mar 21, 2024 · 1 comment
Open

Comments

@revad
Copy link

revad commented Mar 21, 2024

#77 fixes the selection of notes to play by dragging the mouse across the score. But you cannot select a passage that starts on one line and continues into the next. I mentioned this problem here:
#90 (comment)

This patch allows you do do that by holding down the control/command key while dragging, which will add or merge the new selection and the previous one.

The changes are all to music_score_panel.py
Note that changes are also required to music_score_panel.py for python 3.10:
#77 (comment)

At ~line 50, after the initialisations:

#DR2
        self.previous_selection = set()

Amend function OnLeftButtonDown to start:

    def OnLeftButtonDown(self, event):
        if event.LeftDown():
            self.SetFocus()
            page = self.current_page
            old_selection = page.selected_indices.copy()
#DR2
            self.previous_selection = old_selection

            page.clear_note_selection()

Amend function OnMouseMotion to start:

    def OnMouseMotion(self, event):
        page = self.current_page
        if self.HasCapture():
            if self.drag_start_x is not None and self.drag_start_y is not None:
#DR2
                add_selection = event.ControlDown() or event.CmdDown()

                x, y = self.get_xy_of_mouse_event(event)
                self.drag_rect = (min(self.drag_start_x, x), min(self.drag_start_y, y), abs(self.drag_start_x-x), abs(self.drag_start_y-y))
                rect = wx.Rect(*map(int, self.drag_rect))
                old_selection = page.selected_indices.copy()
                page.select_notes(rect)
                if old_selection != page.selected_indices and self.OnNoteSelectionChangedDesc:
#DR2
                    if add_selection:
                         page.selected_indices = self.previous_selection.union(page.selected_indices)                        

                    self.OnNoteSelectionChangedDesc(page.selected_indices)
                self.redraw()
@revad
Copy link
Author

revad commented Mar 28, 2024

Video showing how to add to a selection
out.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant