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

Simplify zoom and snap calculations, remove TextFloat #1

Merged
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
19 changes: 6 additions & 13 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class SongEditor : public TrackContainerView
void saveSettings( QDomDocument& doc, QDomElement& element ) override;
void loadSettings( const QDomElement& element ) override;

IntModel* zoomingLinearModelSlider() const;
ComboBoxModel *snappingModel() const;
float getSnapSize() const;
QString getSnapSizeString() const;
Expand Down Expand Up @@ -116,12 +115,14 @@ private slots:

private:
void keyPressEvent( QKeyEvent * ke ) override;
void keyReleaseEvent(QKeyEvent* ke) override;
void wheelEvent( QWheelEvent * we ) override;

bool allowRubberband() const override;
bool knifeMode() const override;

int calculatePixelsPerBar() const;
int calculateZoomSliderValue(int pixelsPerBar) const;

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

Expand All @@ -142,8 +143,7 @@ private slots:

PositionLine * m_positionLine;

IntModel* m_zoomingLinearModel;
int m_zoomingLogValue;
IntModel* m_zoomingModel;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it back to zoomingModel, since there is only one now.

ComboBoxModel* m_snappingModel;
bool m_proportionalSnap;

Expand All @@ -158,15 +158,14 @@ private slots:
QPoint m_mousePos;
int m_rubberBandStartTrackview;
TimePos m_rubberbandStartTimePos;
int m_currentZoomingValue;
int m_rubberbandPixelsPerBar; //!< pixels per bar when selection starts
int m_trackHeadWidth;
bool m_selectRegion;
int m_iniBar = -1;

friend class SongEditorWindow;

signals:
void zoomingValueChanged( float );
void pixelsPerBarChanged(float);
} ;


Expand Down Expand Up @@ -198,10 +197,6 @@ protected slots:

void updateSnapLabel();

void showZoomingSliderFloat();
void updateZoomingSliderFloat(int new_val);
void hideZoomingSliderFloat();

signals:
void playTriggered();
void resized();
Expand All @@ -224,8 +219,6 @@ protected slots:

QAction* m_insertBarAction;
QAction* m_removeBarAction;

TextFloat * m_zoomStatus;
};

} // namespace gui
Expand Down
5 changes: 2 additions & 3 deletions src/gui/clips/ClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ClipView::ClipView( Clip * clip,

connect( m_clip, SIGNAL(lengthChanged()),
this, SLOT(updateLength()));
connect(getGUI()->songEditor()->m_editor->zoomingLinearModelSlider(), SIGNAL(dataChanged()), this, SLOT(updateLength()));
connect(getGUI()->songEditor()->m_editor, &SongEditor::pixelsPerBarChanged, this, &ClipView::updateLength);
connect( m_clip, SIGNAL(positionChanged()),
this, SLOT(updatePosition()));
connect( m_clip, SIGNAL(destroyedClip()), this, SLOT(close()));
Expand Down Expand Up @@ -314,8 +314,7 @@ void ClipView::updateLength()
}
else
{
// 3 is the minimun width needed to paint a clip
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the border width is 2 pixels so minimum width of a clip would be 5. But it works even if pixelsPerBar is 1. So I don't see a need to enforce a minimum here... Just don't let zoom get to small. Or am I missing something?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was needed for clips that do not start or end at beat times (Alt+mouse, to move start or end of the clip) and an "extreme" zoom in (clip disappears). It happens with your code as well. I think we should reintroduce that control again.

setFixedWidth(std::max(static_cast<int>(m_clip->length() * pixelsPerBar() / TimePos::ticksPerBar() + 1), 3));
setFixedWidth(static_cast<int>(m_clip->length() * pixelsPerBar() / TimePos::ticksPerBar() + 1));
}
m_trackView->trackContainerView()->update();
}
Expand Down
Loading