mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-09 05:01:57 +01:00
Changed lifetime management of UIHandle objects, no singletons...
... Rather, construct them during hit tests (also capturing more state sooner rather than at Click time, and adding some accessors for later use) This also fixes bug 1677 by other means and avoids similar problems. A cell may be implemented to re-use a previously hit handle object, not yet clicked, in a later hit test, by remembering a weak pointer, but TrackPanel holds the strong pointers that determine when the object is destroyed. And the objects will surely be destroyed after drag-release, or ESC key. For now they are also destroyed whenever not dragging, and hit-testing is re-invoked; that will be changed later, so that the re-use mentioned above becomes effective, but still they will be destroyed when the pointer moves from one cell to another.
This commit is contained in:
@@ -336,11 +336,7 @@ void NoteTrack::DrawLabelControls
|
||||
AColor::MIDIChannel(&dc, 0); // always return with gray color selected
|
||||
}
|
||||
|
||||
// Handles clicking within the midi controls rect (same as DrawLabelControls).
|
||||
// This is somewhat oddly written, as these aren't real buttons - they act
|
||||
// when the mouse goes down; you can't hold it pressed and move off of it.
|
||||
// Left-clicking toggles a single channel; right-clicking turns off all other channels.
|
||||
bool NoteTrack::LabelClick(const wxRect &rect, int mx, int my, bool right)
|
||||
int NoteTrack::FindChannel(const wxRect &rect, int mx, int my)
|
||||
{
|
||||
wxASSERT_MSG(rect.width % 4 == 0, "Midi channel control rect width must be divisible by 4");
|
||||
wxASSERT_MSG(rect.height % 4 == 0, "Midi channel control rect height must be divisible by 4");
|
||||
@@ -351,8 +347,17 @@ bool NoteTrack::LabelClick(const wxRect &rect, int mx, int my, bool right)
|
||||
int col = (mx - rect.x) / cellWidth;
|
||||
int row = (my - rect.y) / cellHeight;
|
||||
|
||||
int channel = row * 4 + col;
|
||||
return row * 4 + col;
|
||||
}
|
||||
|
||||
|
||||
// Handles clicking within the midi controls rect (same as DrawLabelControls).
|
||||
// This is somewhat oddly written, as these aren't real buttons - they act
|
||||
// when the mouse goes down; you can't hold it pressed and move off of it.
|
||||
// Left-clicking toggles a single channel; right-clicking turns off all other channels.
|
||||
bool NoteTrack::LabelClick(const wxRect &rect, int mx, int my, bool right)
|
||||
{
|
||||
auto channel = FindChannel(rect, mx, my);
|
||||
if (right)
|
||||
SoloVisibleChan(channel);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user