Fix empty MIDI clips not displaying name#7836
Conversation
|
Why exactly do beat clips not render titles? |
|
My guess is because it would obscure the clip, which is not a problem for melody clips since you edit them by opening the piano roll. |
|
I should add that beat clips not rendering titles is explicitly defined in MidiClipView. So at least it's not a bug, though afaik it's not documented what the reasoning is. |
|
I find it a bit strange. Why can't a beat clip (a MIDI clip) show titles? All clips are meant to have titles, hence their Maybe it might be worth investigating this sometime later, but I suppose it is fine for now if for some reason this was the intention. @bratpeki can you test this PR to see if it fixes the issue you reported? |
|
Hi, sorry, been busy! I can checks, yes. |
|
Code-wise question, what the **** is a |
|
I reverted the change that causes this, thank you for testing. I missed it because it doesn't happen to the kicker plugin for some reason. The thing is, I made the change because empty midi clips being grey is also a bug. It happens because new clips are beat clips by default, until a note gets added and the type is checked. This can be checked by trying to name a newly created clip, the name will not render. This doesn't happen with other clips. |
|
I'd argue the gray clips are a nifty functionality, helping us differentiate between empty clips and clips with content.
My pleasure! Thank you for writing the PR. We'll get to the bottom of this, for sure.
Very odd. Why do they turn gray after deleting all notes then? Do they turn back into
Still curious about this! 🤔 |
My question as well. Does this mean the fix is actually moving that logic into the parent |
Beat clips don't render titles. checkType() always sets type to beat when there are no notes, so titles don't render on empty MIDI clips either.
|
I see, thank you! Sorry for not getting back to you, I'm a bit backlogged. Will write soon, I hope. |
|
I'm not sure I can add suggestions to lines not touched by the PR from the github website, but here is a diff against master: diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp
index 73a8435b2..5c6ed948d 100644
--- a/src/tracks/MidiClip.cpp
+++ b/src/tracks/MidiClip.cpp
@@ -28,6 +28,7 @@
#include <algorithm>
#include <QDomElement>
+#include "ConfigManager.h"
#include "GuiApplication.h"
#include "InstrumentTrack.h"
#include "MidiClipView.h"
@@ -42,13 +43,18 @@ namespace lmms
MidiClip::MidiClip( InstrumentTrack * _instrument_track ) :
Clip( _instrument_track ),
m_instrumentTrack( _instrument_track ),
- m_clipType( Type::BeatClip ),
+ m_clipType(m_instrumentTrack->trackContainer() == Engine::patternStore() ?
Type::BeatClip : Type::MelodyClip),
m_steps( TimePos::stepsPerBar() )
{
if (_instrument_track->trackContainer() == Engine::patternStore())
{
resizeToFirstTrack();
}
+ // If users have legacysebb enabled, that means they wish MidiClips to defau
lt to BeatClips, even in the song editor.
+ if (ConfigManager::inst()->value("ui", "legacysebb", "0").toInt())
+ {
+ setType(Type::BeatClip);
+ }
init();
}
@@ -416,10 +422,22 @@ void MidiClip::setType( Type _new_clip_type )
void MidiClip::checkType()
{
- // If all notes are StepNotes, we have a BeatClip
- const auto beatClip = std::all_of(m_notes.begin(), m_notes.end(), [](auto no
te) { return note->type() == Note::Type::Step; });
+ const auto onlyStepNotes = std::all_of(m_notes.begin(), m_notes.end(), [](au
to note) { return note->type() == Note::Type::Step; });
- setType(beatClip ? Type::BeatClip : Type::MelodyClip);
+ // For midi clips in the pattern editor, default to a BeatClip unless there
are non-step notes in the clip
+ // This allows users to open clips in the piano roll and add green notes to
make it a MelodyClip, but also
+ // allows them to remove all those notes and have it return to being a BeatC
lip.
+ if (m_instrumentTrack->trackContainer() == Engine::patternStore())
+ {
+ setType(onlyStepNotes ? Type::BeatClip : Type::MelodyClip);
+ }
+ else if (!m_notes.empty())
+ {
+ // For the song editor, the type should default to a MelodyClip, exc
ept for users who
+ // have legacysebb enabled, where empty clips default to BeatClips.
+ // For the sake of those users, only update the clip type if there a
re notes within it
+ setType(onlyStepNotes ? Type::BeatClip : Type::MelodyClip);
+ }
}
Essentially, |
|
Okay, so I've been investigating this today. Here's what I've got. 1: The initial issue was that I didn't know empty MIDI clips are actually 2: The issue with the original implementation is that it invalidates 2.1: Also, if that change is made, BB clips break. #7836 (comment) 3: Your proposed fix makes all newly created MIDI clips I found a very simple fix! diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp
index 17604eb19..2dc727b6f 100644
--- a/src/gui/clips/MidiClipView.cpp
+++ b/src/gui/clips/MidiClipView.cpp
@@ -602,8 +602,7 @@ void MidiClipView::paintEvent( QPaintEvent * )
// 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;
+ bool const drawTextBox = !m_clip->name().isEmpty();
// TODO Warning! This might cause problems if ClipView::paintTextLabel changes
int textBoxHeight = 0;@regulus79 would we be okay with a merge like this? Here's the end result:
|






Beat clips don't render titles. checkType() always sets type to beat when there are no notes, so titles don't render on empty MIDI clips either.
I changed the default type of MidiClips on construction to MelodyClip, otherwise the name would still not show until you start adding notes. I tested to make sure this doesn't cause the opposite issue for beat clips. If you name a new beat clip before adding any notes, it will still correctly not show the name title.
Fixes #7808