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

Rubberband fix for selecting large area in Songeditor #5003

Merged
merged 20 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class SongEditor : public TrackContainerView

public slots:
void scrolled( int new_pos );
void selectRegionFromPixels(int xStart, int xEnd);
void stopSelectRegion();
void updateRubberband();

void setEditMode( EditMode mode );
void setEditModeDraw();
Expand All @@ -85,6 +88,9 @@ public slots:

protected:
virtual void closeEvent( QCloseEvent * ce );
virtual void mousePressEvent(QMouseEvent * me);
virtual void mouseMoveEvent(QMouseEvent * me);
virtual void mouseReleaseEvent(QMouseEvent * me);

private slots:
void setHighQuality( bool );
Expand All @@ -109,6 +115,9 @@ private slots:

virtual bool allowRubberband() const;

int trackIndexFromSelectionPoint(int yPos);
int indexOfTrackView(const TrackView* tv);


Song * m_song;

Expand All @@ -135,6 +144,14 @@ private slots:
bool m_smoothScroll;

EditMode m_mode;
QPoint m_origin;
QPoint m_scrollPos;
QPoint m_mousePos;
int m_rubberBandStartTrackview;
MidiTime m_rubberbandStartMidipos;
int m_currentZoomingValue;
int m_trackHeadWidth;
bool m_selectRegion;

friend class SongEditorWindow;

Expand Down
12 changes: 7 additions & 5 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ class TrackContentObjectView : public selectableObject, public ModelView
{
return m_tco;
}

Reflexe marked this conversation as resolved.
Show resolved Hide resolved
inline TrackView * getTrackView()
{
return m_trackView;
}

// qproperty access func
QColor mutedColor() const;
QColor mutedBackgroundColor() const;
Expand All @@ -229,7 +235,7 @@ class TrackContentObjectView : public selectableObject, public ModelView
// access needsUpdate member variable
bool needsUpdate();
void setNeedsUpdate( bool b );

public slots:
virtual bool close();
void cut();
Expand All @@ -256,10 +262,6 @@ public slots:

float pixelsPerTact();

inline TrackView * getTrackView()
{
return m_trackView;
}

DataFile createTCODataFiles(const QVector<TrackContentObjectView *> & tcos) const;

Expand Down
14 changes: 4 additions & 10 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,21 @@ public slots:

virtual void dropEvent( QDropEvent * _de );
virtual void dragEnterEvent( QDragEnterEvent * _dee );
///
/// \brief selectRegionFromPixels
/// \param x
/// \param y
/// Use the rubber band to select TCO from all tracks using x, y pixels
void selectRegionFromPixels(int xStart, int xEnd);

///
/// \brief stopRubberBand
/// Removes the rubber band from display when finished with.
void stopRubberBand();


protected:
static const int DEFAULT_PIXELS_PER_TACT = 16;

virtual void mousePressEvent( QMouseEvent * _me );
virtual void mouseMoveEvent( QMouseEvent * _me );
virtual void mouseReleaseEvent( QMouseEvent * _me );

virtual void resizeEvent( QResizeEvent * );

MidiTime m_currentPosition;
RubberBand *rubberBand() const;


private:
Expand Down Expand Up @@ -187,7 +181,7 @@ public slots:
float m_ppt;

RubberBand * m_rubberBand;
QPoint m_origin;



signals:
Expand Down
53 changes: 8 additions & 45 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
m_trackViews(),
m_scrollArea( new scrollArea( this ) ),
m_ppt( DEFAULT_PIXELS_PER_TACT ),
m_rubberBand( new RubberBand( m_scrollArea ) ),
m_origin()
m_rubberBand( new RubberBand( m_scrollArea ) )
{
m_tc->setHook( this );
//keeps the direction of the widget, undepended on the locale
Expand Down Expand Up @@ -346,12 +345,8 @@ void TrackContainerView::dragEnterEvent( QDragEnterEvent * _dee )
arg( Track::SampleTrack ) );
}

void TrackContainerView::selectRegionFromPixels(int xStart, int xEnd)
{
m_rubberBand->setEnabled( true );
m_rubberBand->show();
m_rubberBand->setGeometry( min( xStart, xEnd ), 0, max( xStart, xEnd ) - min( xStart, xEnd ), std::numeric_limits<int>::max() );
}



void TrackContainerView::stopRubberBand()
{
Expand Down Expand Up @@ -427,50 +422,18 @@ void TrackContainerView::dropEvent( QDropEvent * _de )



void TrackContainerView::mousePressEvent( QMouseEvent * _me )
{
if( allowRubberband() == true )
{
m_origin = m_scrollArea->mapFromParent( _me->pos() );
m_rubberBand->setEnabled( true );
m_rubberBand->setGeometry( QRect( m_origin, QSize() ) );
m_rubberBand->show();
}
QWidget::mousePressEvent( _me );
}




void TrackContainerView::mouseMoveEvent( QMouseEvent * _me )
{
if( rubberBandActive() == true )
{
m_rubberBand->setGeometry( QRect( m_origin,
m_scrollArea->mapFromParent( _me->pos() ) ).
normalized() );
}
QWidget::mouseMoveEvent( _me );
}




void TrackContainerView::mouseReleaseEvent( QMouseEvent * _me )
void TrackContainerView::resizeEvent( QResizeEvent * _re )
{
m_rubberBand->hide();
m_rubberBand->setEnabled( false );
QWidget::mouseReleaseEvent( _me );
realignTracks();
QWidget::resizeEvent( _re );
}





void TrackContainerView::resizeEvent( QResizeEvent * _re )
RubberBand *TrackContainerView::rubberBand() const
{
realignTracks();
QWidget::resizeEvent( _re );
return m_rubberBand;
}


Expand Down
Loading