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

Fixes bug from issue #6002 #6803

Merged
merged 2 commits into from
Aug 12, 2023
Merged

Conversation

IanCaio
Copy link
Contributor

@IanCaio IanCaio commented Aug 10, 2023

Since the refactoring of the Copy/Paste features, it was not possible to paste inside the BBEditor (now Pattern Editor), as reported on issue #6002. The reason for that is better explained in the issue discussion.

This PR fixes this by allowing pasting inside the Pattern Editor when the clipboard has a single Clip, which is what was allowed on the previous workflow, while at the same time avoiding the unexpected behavior of pasting multiple Clips that might invade the positions reserved for different Pattern Tracks.

Fixes #6002

	Since the refactoring of the Copy/Paste features, it was not
possible to paste inside the BBEditor (now Pattern Editor), as reported
on issue LMMS#6002. The reason for that is better explained in the issue
discussion.
	This PR fixes this by allowing pasting inside the Pattern Editor
when the clipboard has a single Clip, which is what was allowed on the
previous workflow, while at the same time avoiding the unexpected
behavior of pasting multiple Clips that might invade the positions
reserved for different Pattern Tracks.
@zonkmachine
Copy link
Member

when the clipboard has a single Clip,

only has a single clip... This works. The code is clear and the behavior acceptable. It's not likely to accidentally copy two patterns as you first need to turn on the selection mode in the song editor. The only time this could be confusing would be if your're trying to paste over a note clip that is already there and the one your pasting is similar. The original pattern will stay and there will be no clear confirmation if something has happened, which it hasn't. I think this is a good solution and it should be merged.

@superpaik
Copy link
Contributor

It works ok on win10/64b. It copies back and forth from inside the Pattern Editor and to/from the Song Editor, as in 1.2.2
The only difference is that in 1.2.2 the name of the "copied" track was also copied to the "pasted" one (see image from 1.2.2 version, the first pattern was copied onto the second one). To me, it is better not to copy it (as it is in this PR), but just so you know.
Code-wise, I see no problem.
imagen

@zonkmachine
Copy link
Member

o me, it is better not to copy it (as it is in this PR), but just so you know.

I agree that the name shouldn't be copied with the pattern. I wonder if it was dropped intentionally.

@IanCaio
Copy link
Contributor Author

IanCaio commented Aug 11, 2023

Interesting, after a quick test it seems the name is being copied and pasted, but not displayed when the clip only contains step notes (both on the SongEditor and the PatternEditor). I wonder if this is more related to the paintEvent of the clip, it seems so because after adding a regular note the name of the pattern is displayed on both editors. Also, changing the name manually on a clip that only has step notes changes the name but doesn't display it.

It's possible that #5902 might fix it since it changes a little bit of the paintEvent code, but I can't be sure. Does the name of the clip display even on clips that only have stepNotes on 1.2.2? If it does we'd have to investigate further what change caused this, but at least I noticed that the copying and pasting is actually copying the name of the clip and pasting it to the new one, so probably something unrelated to this PR. In the nightly build the clip name is also not displayed on clips containing step notes only, so it's another hint that this issue started before and is at least not related to this fix.

If nobody wishes to review, I plan to merge this tomorrow (if someone manifests interest in reviewing it too I can merge later though)

@zonkmachine
Copy link
Member

Does the name of the clip display even on clips that only have stepNotes on 1.2.2?

Yes indeed. I think it's just unnecessary noise on the pattern. I can understand naming a note clip but not a pattern on a drum machine.

@zonkmachine
Copy link
Member

If nobody wishes to review, I plan to merge this tomorrow (if someone manifests interest in reviewing it too I can merge later though)

👍

@IanCaio
Copy link
Contributor Author

IanCaio commented Aug 11, 2023

Investigating a bit, on 1.2.2 the name drawing is made on src/tracks/Pattern.cpp, as in:

        //Line 1052
        bool isDefaultName = m_pat->name() == m_pat->instrumentTrack()->name();

	if( !isDefaultName && m_staticTextName.text() != m_pat->name() )
	{
		m_staticTextName.setText( m_pat->name() );
	}
        // ... Line 1067
	if( !isDefaultName )
	{
		p.setPen( textShadowColor() );
		p.drawStaticText( textLeft + 1, textTop + 1, m_staticTextName );
		p.setPen( textColor() );
		p.drawStaticText( textLeft, textTop, m_staticTextName );
	}

While on the nightly it changes to this:

        // src/gui/clips/MidiClipView.cpp Line 432
	// Check whether we will paint a text box and compute its potential height
	// This is needed so we can paint the notes underneath it.
	bool const drawName = !m_clip->name().isEmpty();
	bool const drawTextBox = !beatClip && drawName;
	// ... Line 656
	// clip name
	if (drawTextBox)
	{
		paintTextLabel(m_clip->name(), p);
	}

and

        // src/gui/clips/PatternClipView.cpp Line 137
	// clip name
	paintTextLabel(m_patternClip->name(), p);

Which is a little confusing because I don't see the part of the PatternClipView::paintEvent that draws the step notes itself, so it makes me wonder how it's being called and where. But bottom point, the paint event changed a lot and on MidiClipView.cpp the conditional doesn't allow the stepnote clips to have its name displayed (because drawTextBox will be false. And on PatternClipView it's more confusing, I'm having the impression even for PatternClips the MidiClip::paintEvent is being used to draw it (which means PatternClipView::paintEvent might be obsolete code), since it even has logic to account for beatClips.

Anyways, sounds like a rabbit hole issue, which might require it's own debugging and proper fixing, but out of scope for this PR.

@zonkmachine
Copy link
Member

Anyways, sounds like a rabbit hole issue, which might require it's own debugging and proper fixing, but out of scope for this PR.

^This. Should perhaps have a ticket of it's own.

@IanCaio
Copy link
Contributor Author

IanCaio commented Aug 11, 2023

Anyways, sounds like a rabbit hole issue, which might require it's own debugging and proper fixing, but out of scope for this PR.

^This. Should perhaps have a ticket of it's own.

I'm facepalming right now: PatternClips are the clips that we add to BBTracks inside the SongEditor, to mark where the Pattern should be played in the song, so obviously there will be no notes being drawn there. The clips inside the BBEditor are all MidiClips, whether they contain regular notes or step notes, so all the drawing of those will be done by MidiClipView::paintEvent. So mistery solved, the way the paint event is written now makes it so beatClips (clips made of only step notes) don't have their name drawn.

@zonkmachine
Copy link
Member

the way the paint event is written now makes it so beatClips (clips made of only step notes) don't have their name drawn.

OK, good and problem solved!

@superpaik
Copy link
Contributor

Sounds perfect. Thanks!

@IanCaio IanCaio merged commit e87d44b into LMMS:master Aug 12, 2023
9 checks passed
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

Successfully merging this pull request may close these issues.

No Note copy/paste
4 participants