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

Add finer zoom, 12.5% #2517

Merged
merged 1 commit into from
May 31, 2016
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
4 changes: 4 additions & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define AUTOMATION_EDITOR_H

#include <QtCore/QMutex>
#include <QVector>
#include <QWidget>

#include "Editor.h"
Expand Down Expand Up @@ -186,6 +187,8 @@ protected slots:
ComboBoxModel m_zoomingYModel;
ComboBoxModel m_quantizeModel;

static const QVector<double> m_zoomXLevels;

FloatModel * m_tensionModel;

QMutex m_patternMutex;
Expand Down Expand Up @@ -252,6 +255,7 @@ protected slots:




class AutomationEditorWindow : public Editor
{
Q_OBJECT
Expand Down
4 changes: 4 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef PIANO_ROLL_H
#define PIANO_ROLL_H

#include <QVector>
#include <QWidget>
#include <QInputDialog>

Expand Down Expand Up @@ -292,6 +293,7 @@ protected slots:
ComboBoxModel m_scaleModel;
ComboBoxModel m_chordModel;

static const QVector<double> m_zoomLevels;

Pattern* m_pattern;
QScrollBar * m_leftRightScroll;
Expand Down Expand Up @@ -386,6 +388,8 @@ protected slots:
} ;




class PianoRollWindow : public Editor, SerializingObject
{
Q_OBJECT
Expand Down
7 changes: 7 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#ifndef SONG_EDITOR_H
#define SONG_EDITOR_H

#include <QVector>

#include "Editor.h"
#include "TrackContainerView.h"

Expand Down Expand Up @@ -124,6 +126,8 @@ private slots:

ComboBoxModel* m_zoomingModel;

static const QVector<double> m_zoomLevels;

bool m_scrollBack;
bool m_smoothScroll;

Expand All @@ -133,6 +137,9 @@ private slots:

} ;




class SongEditorWindow : public Editor
{
Q_OBJECT
Expand Down
13 changes: 7 additions & 6 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ QPixmap * AutomationEditor::s_toolMove = NULL;
QPixmap * AutomationEditor::s_toolYFlip = NULL;
QPixmap * AutomationEditor::s_toolXFlip = NULL;

const QVector<double> AutomationEditor::m_zoomXLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f };



Expand Down Expand Up @@ -1491,11 +1493,11 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
int x = m_zoomingXModel.value();
if( we->delta() > 0 )
{
x++;
x--;
}
if( we->delta() < 0 )
{
x--;
x++;
}
x = qBound( 0, x, m_zoomingXModel.size() - 1 );
m_zoomingXModel.setValue( x );
Expand Down Expand Up @@ -1917,8 +1919,7 @@ void AutomationEditor::updatePosition(const MidiTime & t )

void AutomationEditor::zoomingXChanged()
{
const QString & zfac = m_zoomingXModel.currentText();
m_ppt = zfac.left( zfac.length() - 1 ).toInt() * DEFAULT_PPT / 100;
m_ppt = m_zoomXLevels[m_zoomingXModel.value()] * DEFAULT_PPT;

assert( m_ppt > 0 );

Expand Down Expand Up @@ -2208,9 +2209,9 @@ AutomationEditorWindow::AutomationEditorWindow() :
m_zoomingXComboBox = new ComboBox( zoomToolBar );
m_zoomingXComboBox->setFixedSize( 80, 22 );

for( int i = 0; i < 6; ++i )
for( float const & zoomLevel : m_editor->m_zoomXLevels )
{
m_editor->m_zoomingXModel.addItem( QString::number( 25 << i ) + "%" );
m_editor->m_zoomingXModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
}
m_editor->m_zoomingXModel.setValue( m_editor->m_zoomingXModel.findText( "100%" ) );

Expand Down
16 changes: 10 additions & 6 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ PianoRoll::PianoRollKeyTypes PianoRoll::prKeyOrder[] =

const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DefaultStepsPerTact;

const QVector<double> PianoRoll::m_zoomLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f };


PianoRoll::PianoRoll() :
m_nemStr( QVector<QString>() ),
Expand Down Expand Up @@ -350,9 +353,9 @@ PianoRoll::PianoRoll() :
SLOT( verScrolled( int ) ) );

// setup zooming-stuff
for( int i = 0; i < 6; ++i )
for( float const & zoomLevel : m_zoomLevels )
{
m_zoomingModel.addItem( QString::number( 25 << i ) + "%" );
m_zoomingModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
}
m_zoomingModel.setValue( m_zoomingModel.findText( "100%" ) );
connect( &m_zoomingModel, SIGNAL( dataChanged() ),
Expand Down Expand Up @@ -3255,11 +3258,11 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
int z = m_zoomingModel.value();
if( we->delta() > 0 )
{
z++;
z--;
}
if( we->delta() < 0 )
{
z--;
z++;
}
z = qBound( 0, z, m_zoomingModel.size() - 1 );
// update combobox with zooming-factor
Expand Down Expand Up @@ -3853,8 +3856,7 @@ void PianoRoll::updatePositionAccompany( const MidiTime & t )

void PianoRoll::zoomingChanged()
{
const QString & zfac = m_zoomingModel.currentText();
m_ppt = zfac.left( zfac.length() - 1 ).toInt() * DEFAULT_PR_PPT / 100;
m_ppt = m_zoomLevels[m_zoomingModel.value()] * DEFAULT_PR_PPT;

assert( m_ppt > 0 );

Expand All @@ -3871,6 +3873,8 @@ void PianoRoll::quantizeChanged()
}




int PianoRoll::quantization() const
{
if( m_quantizeModel.value() == 0 )
Expand Down
36 changes: 18 additions & 18 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void positionLine::paintEvent( QPaintEvent * pe )
p.fillRect( rect(), QColor( 255, 255, 255, 153 ) );
}


const QVector<double> SongEditor::m_zoomLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f, 16.0f };


SongEditor::SongEditor( Song * song ) :
Expand Down Expand Up @@ -242,10 +243,9 @@ SongEditor::SongEditor( Song * song ) :
this, SLOT( updateScrollBar( int ) ) );

// Set up zooming model
for( int i = 0; i < 7; ++i )
for( float const & zoomLevel : m_zoomLevels )
{
m_zoomingModel->addItem(
QString::number( 25 << i ) + "%" );
m_zoomingModel->addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
}
m_zoomingModel->setInitValue(
m_zoomingModel->findText( "100%" ) );
Expand Down Expand Up @@ -360,22 +360,20 @@ void SongEditor::wheelEvent( QWheelEvent * we )
{
if( gui->mainWindow()->isCtrlPressed() == true )
{
int z = m_zoomingModel->value();

if( we->delta() > 0 )
{
setPixelsPerTact( (int) qMin( pixelsPerTact() * 2,
256.0f ) );
z--;
}
else if( pixelsPerTact() >= 8 )
if( we->delta() < 0 )
{
setPixelsPerTact( (int) pixelsPerTact() / 2 );
z++;
}
z = qBound( 0, z, m_zoomingModel->size() - 1 );
// update combobox with zooming-factor
m_zoomingModel->setValue(
m_zoomingModel->findText(
QString::number(
static_cast<int>( pixelsPerTact() *
100 / DEFAULT_PIXELS_PER_TACT ) ) +
"%" ) );
m_zoomingModel->setValue( z );

// update timeline
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerTact( pixelsPerTact() );
Expand Down Expand Up @@ -593,23 +591,25 @@ void SongEditor::updatePosition( const MidiTime & t )

void SongEditor::zoomingChanged()
{
const QString & zfac = m_zoomingModel->currentText();
setPixelsPerTact( zfac.left( zfac.length() - 1 ).toInt() *
DEFAULT_PIXELS_PER_TACT / 100 );
setPixelsPerTact( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_PER_TACT );

m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerTact( pixelsPerTact() );
realignTracks();
}




bool SongEditor::allowRubberband() const
{
return m_mode == SelectMode;
}


SongEditorWindow::SongEditorWindow( Song* song ) :


SongEditorWindow::SongEditorWindow(Song* song) :
Editor(Engine::mixer()->audioDev()->supportsCapture()),
m_editor(new SongEditor(song))
{
Expand Down