Uninverted Qt TAS piano roll vertical scroll appearance. Code was getting unnecessarily complicated with that implementation.

This commit is contained in:
mjbudd77 2022-01-03 21:43:36 -05:00
parent ec663196c1
commit b04ddd3fbb
2 changed files with 70 additions and 74 deletions

View File

@ -989,11 +989,11 @@ void TasEditorWindow::buildPianoRollDisplay(void)
pianoRollFrame->setFrameShape( QFrame::Box ); pianoRollFrame->setFrameShape( QFrame::Box );
pianoRollVBar->setInvertedControls(false); pianoRollVBar->setInvertedControls(false);
pianoRollVBar->setInvertedAppearance(true); pianoRollVBar->setInvertedAppearance(false);
pianoRoll->setScrollBars( pianoRollHBar, pianoRollVBar ); pianoRoll->setScrollBars( pianoRollHBar, pianoRollVBar );
connect( pianoRollHBar, SIGNAL(valueChanged(int)), pianoRoll, SLOT(hbarChanged(int)) ); connect( pianoRollHBar, SIGNAL(valueChanged(int)), pianoRoll, SLOT(hbarChanged(int)) );
connect( pianoRollVBar, SIGNAL(valueChanged(int)), pianoRoll, SLOT(vbarChanged(int)) ); connect( pianoRollVBar, SIGNAL(valueChanged(int)), pianoRoll, SLOT(vbarChanged(int)) );
connect( pianoRollVBar, SIGNAL(actionTriggered(int)), pianoRoll, SLOT(vbarActionTriggered(int)) ); //connect( pianoRollVBar, SIGNAL(actionTriggered(int)), pianoRoll, SLOT(vbarActionTriggered(int)) );
grid->addWidget( pianoRoll , 0, 0 ); grid->addWidget( pianoRoll , 0, 0 );
grid->addWidget( pianoRollVBar, 0, 1 ); grid->addWidget( pianoRollVBar, 0, 1 );
@ -3752,7 +3752,7 @@ void PianoRollScrollBar::wheelEvent(QWheelEvent *event)
if (!numPixels.isNull()) if (!numPixels.isNull())
{ {
wheelPixelCounter += numPixels.y(); wheelPixelCounter -= numPixels.y();
//printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() ); //printf("numPixels: (%i,%i) \n", numPixels.x(), numPixels.y() );
if ( wheelPixelCounter >= pxLineSpacing ) if ( wheelPixelCounter >= pxLineSpacing )
@ -3774,7 +3774,7 @@ void PianoRollScrollBar::wheelEvent(QWheelEvent *event)
//QPoint numSteps = numDegrees / 15; //QPoint numSteps = numDegrees / 15;
//printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() ); //printf("numSteps: (%i,%i) \n", numSteps.x(), numSteps.y() );
//printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing ); //printf("numDegrees: (%i,%i) %i\n", numDegrees.x(), numDegrees.y(), pxLineSpacing );
wheelAngleCounter += numDegrees.y(); wheelAngleCounter -= numDegrees.y();
if ( wheelAngleCounter <= stepDeg ) if ( wheelAngleCounter <= stepDeg )
{ {
@ -4032,56 +4032,56 @@ void QPianoRoll::hbarChanged(int val)
update(); update();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void QPianoRoll::vbarActionTriggered(int act) //void QPianoRoll::vbarActionTriggered(int act)
{ //{
int val = vbar->value(); // int val = vbar->value();
//
if ( act == QAbstractSlider::SliderSingleStepAdd ) // if ( act == QAbstractSlider::SliderSingleStepAdd )
{ // {
val = val - vbar->singleStep(); // val = val - vbar->singleStep();
//
if ( val < 0 ) // if ( val < 0 )
{ // {
val = 0; // val = 0;
} // }
vbar->setSliderPosition(val); // vbar->setSliderPosition(val);
} // }
else if ( act == QAbstractSlider::SliderSingleStepSub ) // else if ( act == QAbstractSlider::SliderSingleStepSub )
{ // {
val = val + vbar->singleStep(); // val = val + vbar->singleStep();
//
if ( val >= maxLineOffset ) // if ( val >= maxLineOffset )
{ // {
val = maxLineOffset; // val = maxLineOffset;
} // }
vbar->setSliderPosition(val); // vbar->setSliderPosition(val);
} // }
else if ( act == QAbstractSlider::SliderPageStepAdd ) // else if ( act == QAbstractSlider::SliderPageStepAdd )
{ // {
val = val - vbar->pageStep(); // val = val - vbar->pageStep();
//
if ( val < 0 ) // if ( val < 0 )
{ // {
val = 0; // val = 0;
} // }
vbar->setSliderPosition(val); // vbar->setSliderPosition(val);
} // }
else if ( act == QAbstractSlider::SliderPageStepSub ) // else if ( act == QAbstractSlider::SliderPageStepSub )
{ // {
val = val + vbar->pageStep(); // val = val + vbar->pageStep();
//
if ( val >= maxLineOffset ) // if ( val >= maxLineOffset )
{ // {
val = maxLineOffset; // val = maxLineOffset;
} // }
vbar->setSliderPosition(val); // vbar->setSliderPosition(val);
} // }
//printf("ACT:%i\n", act); // //printf("ACT:%i\n", act);
} //}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void QPianoRoll::vbarChanged(int val) void QPianoRoll::vbarChanged(int val)
{ {
lineOffset = maxLineOffset - val; lineOffset = val;
if ( lineOffset < 0 ) if ( lineOffset < 0 )
{ {
@ -4338,8 +4338,6 @@ void QPianoRoll::ensureTheLineIsVisible( int lineNum )
{ {
if ( !lineIsVisible( lineNum ) ) if ( !lineIsVisible( lineNum ) )
{ {
int scrollOfs;
//printf("Seeking Frame %i\n", lineNum ); //printf("Seeking Frame %i\n", lineNum );
lineOffset = lineNum; lineOffset = lineNum;
@ -4348,13 +4346,11 @@ void QPianoRoll::ensureTheLineIsVisible( int lineNum )
{ {
lineOffset = 0; lineOffset = 0;
} }
scrollOfs = maxLineOffset - lineOffset; else if ( lineOffset > maxLineOffset )
if ( scrollOfs < 0 )
{ {
scrollOfs = 0; lineOffset = maxLineOffset;
} }
vbar->setValue( scrollOfs ); vbar->setValue( lineOffset );
update(); update();
} }
@ -4987,7 +4983,7 @@ void QPianoRoll::wheelEvent(QWheelEvent *event)
{ {
if (zDelta > 0) if (zDelta > 0)
{ {
ofs += (zDelta*6); ofs -= (zDelta*6);
if (ofs > maxLineOffset) if (ofs > maxLineOffset)
{ {
@ -4997,7 +4993,7 @@ void QPianoRoll::wheelEvent(QWheelEvent *event)
} }
else if (zDelta < 0) else if (zDelta < 0)
{ {
ofs += (zDelta*6); ofs -= (zDelta*6);
if (ofs < 0) if (ofs < 0)
{ {
@ -6134,6 +6130,9 @@ void QPianoRoll::paintEvent(QPaintEvent *event)
maxLineOffset = currMovieData.records.size() - nrow + 2; maxLineOffset = currMovieData.records.size() - nrow + 2;
vbar->setMinimum(0);
vbar->setMaximum(maxLineOffset);
if ( maxLineOffset < 0 ) if ( maxLineOffset < 0 )
{ {
vbar->hide(); vbar->hide();
@ -6146,7 +6145,7 @@ void QPianoRoll::paintEvent(QPaintEvent *event)
if ( taseditorConfig->followPlaybackCursor ) if ( taseditorConfig->followPlaybackCursor )
{ {
lineOffset = maxLineOffset - vbar->value(); lineOffset = vbar->value();
if ( playbackCursorPos != currFrameCounter ) if ( playbackCursorPos != currFrameCounter )
{ {
@ -6154,29 +6153,28 @@ void QPianoRoll::paintEvent(QPaintEvent *event)
playbackCursorPos = currFrameCounter; playbackCursorPos = currFrameCounter;
lineOffsetLowerLim = playbackCursorPos - nrow + 5; lineOffsetLowerLim = lineOffset;
lineOffsetUpperLim = playbackCursorPos + nrow; lineOffsetUpperLim = lineOffset + nrow - 2;
//if ( !lineIsVisible( playbackCursorPos ) ) if ( playbackCursorPos < lineOffsetLowerLim )
if ( lineOffset < lineOffsetLowerLim )
{ {
lineOffset = lineOffsetLowerLim; lineOffset = playbackCursorPos;
vbar->setValue( maxLineOffset - lineOffset ); vbar->setValue( lineOffset );
} }
else if ( lineOffset > lineOffsetUpperLim ) else if ( playbackCursorPos >= lineOffsetUpperLim )
{ {
lineOffset = lineOffsetUpperLim - nrow; lineOffset = playbackCursorPos - nrow + 3;
if ( lineOffset < 0 ) if ( lineOffset < 0 )
{ {
lineOffset = 0; lineOffset = 0;
} }
vbar->setValue( maxLineOffset - lineOffset ); vbar->setValue( lineOffset );
} }
} }
} }
else else
{ {
vbar->setValue( maxLineOffset - lineOffset ); vbar->setValue( lineOffset );
} }
if ( lineOffset < 0 ) if ( lineOffset < 0 )
@ -6187,8 +6185,6 @@ void QPianoRoll::paintEvent(QPaintEvent *event)
{ {
lineOffset = maxLineOffset; lineOffset = maxLineOffset;
} }
vbar->setMinimum(0);
vbar->setMaximum(maxLineOffset);
painter.fillRect( 0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Window) ); painter.fillRect( 0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Window) );

View File

@ -309,7 +309,7 @@ class QPianoRoll : public QWidget
public slots: public slots:
void hbarChanged(int val); void hbarChanged(int val);
void vbarChanged(int val); void vbarChanged(int val);
void vbarActionTriggered(int act); //void vbarActionTriggered(int act);
void setupMarkerDrag(void); void setupMarkerDrag(void);
}; };