mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 14:48:39 +02:00
LabelTrack::HandleClick rearranged
This commit is contained in:
parent
7060dc4088
commit
815d75b305
@ -1535,60 +1535,61 @@ void LabelTrack::HandleClick(const wxMouseEvent & evt,
|
|||||||
if (mLabels[mSelIndex]->changeInitialMouseXPos)
|
if (mLabels[mSelIndex]->changeInitialMouseXPos)
|
||||||
mInitialCursorPos = mCurrentCursorPos;
|
mInitialCursorPos = mCurrentCursorPos;
|
||||||
mDrawCursor = true;
|
mDrawCursor = true;
|
||||||
}
|
|
||||||
|
|
||||||
// reset the highlight indicator
|
// reset the highlight indicator
|
||||||
wxRect highlightedRect;
|
wxRect highlightedRect;
|
||||||
if (mSelIndex != -1) {
|
|
||||||
int xpos1, xpos2;
|
|
||||||
CalcHighlightXs(&xpos1, &xpos2);
|
|
||||||
|
|
||||||
wxASSERT(mFontHeight >= 0); // should have been set up while drawing
|
|
||||||
// the rectangle of highlighted area
|
|
||||||
highlightedRect = {
|
|
||||||
xpos1, mLabels[mSelIndex]->y - mFontHeight / 2,
|
|
||||||
(int)(xpos2 - xpos1 + 0.5), mFontHeight
|
|
||||||
};
|
|
||||||
|
|
||||||
// reset when left button is down
|
|
||||||
if (evt.LeftDown())
|
|
||||||
mLabels[mSelIndex]->highlighted = false;
|
|
||||||
// reset when right button is down outside text box
|
|
||||||
if (evt.RightDown())
|
|
||||||
{
|
{
|
||||||
if (!highlightedRect.Contains(evt.m_x, evt.m_y))
|
int xpos1, xpos2;
|
||||||
{
|
CalcHighlightXs(&xpos1, &xpos2);
|
||||||
mCurrentCursorPos = mInitialCursorPos = 0;
|
|
||||||
|
wxASSERT(mFontHeight >= 0); // should have been set up while drawing
|
||||||
|
// the rectangle of highlighted area
|
||||||
|
highlightedRect = {
|
||||||
|
xpos1, mLabels[mSelIndex]->y - mFontHeight / 2,
|
||||||
|
(int)(xpos2 - xpos1 + 0.5), mFontHeight
|
||||||
|
};
|
||||||
|
|
||||||
|
// reset when left button is down
|
||||||
|
if (evt.LeftDown())
|
||||||
mLabels[mSelIndex]->highlighted = false;
|
mLabels[mSelIndex]->highlighted = false;
|
||||||
|
// reset when right button is down outside text box
|
||||||
|
if (evt.RightDown())
|
||||||
|
{
|
||||||
|
if (!highlightedRect.Contains(evt.m_x, evt.m_y))
|
||||||
|
{
|
||||||
|
mCurrentCursorPos = mInitialCursorPos = 0;
|
||||||
|
mLabels[mSelIndex]->highlighted = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// set changeInitialMouseXPos flag
|
||||||
|
mLabels[mSelIndex]->changeInitialMouseXPos = true;
|
||||||
}
|
}
|
||||||
// set changeInitialMouseXPos flag
|
|
||||||
mLabels[mSelIndex]->changeInitialMouseXPos = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable displaying if right button is down outside text box
|
// disable displaying if right button is down outside text box
|
||||||
if (mSelIndex != -1 && evt.RightDown()
|
if (evt.RightDown()
|
||||||
&& !highlightedRect.Contains(evt.m_x, evt.m_y))
|
&& !highlightedRect.Contains(evt.m_x, evt.m_y))
|
||||||
mDragXPos = -1;
|
mDragXPos = -1;
|
||||||
|
|
||||||
// Middle click on GTK: paste from primary selection
|
// Middle click on GTK: paste from primary selection
|
||||||
#if defined(__WXGTK__) && (HAVE_GTK)
|
#if defined(__WXGTK__) && (HAVE_GTK)
|
||||||
if (evt.MiddleDown()) {
|
if (evt.MiddleDown()) {
|
||||||
// Check for a click outside of the selected label's text box; in this
|
// Check for a click outside of the selected label's text box; in this
|
||||||
// case PasteSelectedText() will start a NEW label at the click
|
// case PasteSelectedText() will start a NEW label at the click
|
||||||
// location
|
// location
|
||||||
if (mSelIndex != -1) {
|
|
||||||
if (!OverTextBox(mLabels[mSelIndex], evt.m_x, evt.m_y))
|
if (!OverTextBox(mLabels[mSelIndex], evt.m_x, evt.m_y))
|
||||||
mSelIndex = -1;
|
mSelIndex = -1;
|
||||||
double t = zoomInfo.PositionToTime(evt.m_x, r.x);
|
double t = zoomInfo.PositionToTime(evt.m_x, r.x);
|
||||||
*newSel = SelectedRegion(t, t);
|
*newSel = SelectedRegion(t, t);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__WXGTK__) && (HAVE_GTK)
|
||||||
|
if (evt.MiddleDown()) {
|
||||||
|
// Paste text, making a NEW label if none is selected.
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
PasteSelectedText(newSel->t0(), newSel->t1());
|
PasteSelectedText(newSel->t0(), newSel->t1());
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user