Skip to content

Commit

Permalink
Add zoom 12.5%
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Feb 16, 2016
1 parent d30a7df commit cfd20b7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 35 deletions.
4 changes: 4 additions & 0 deletions include/AutomationEditor.h
Expand Up @@ -27,6 +27,7 @@
#define AUTOMATION_EDITOR_H

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

#include "Editor.h"
Expand Down Expand Up @@ -183,6 +184,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 @@ -248,6 +251,7 @@ protected slots:




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

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

Expand Down Expand Up @@ -269,6 +270,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 @@ -356,6 +358,8 @@ protected slots:
} ;




class PianoRollWindow : public Editor, SerializingObject
{
Q_OBJECT
Expand Down
7 changes: 7 additions & 0 deletions include/SongEditor.h
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 @@ -123,6 +125,8 @@ private slots:

ComboBoxModel* m_zoomingModel;

static const QVector<double> m_zoomLevels;

bool m_scrollBack;
bool m_smoothScroll;

Expand All @@ -132,6 +136,9 @@ private slots:

} ;




class SongEditorWindow : public Editor
{
Q_OBJECT
Expand Down
13 changes: 7 additions & 6 deletions src/gui/editors/AutomationEditor.cpp
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 @@ -1486,11 +1488,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 @@ -1912,8 +1914,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 @@ -2188,9 +2189,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
Expand Up @@ -172,6 +172,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 @@ -363,9 +366,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 @@ -3224,11 +3227,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 @@ -3822,8 +3825,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 @@ -3840,6 +3842,8 @@ void PianoRoll::quantizeChanged()
}




int PianoRoll::quantization() const
{
if( m_quantizeModel.value() == 0 )
Expand Down
45 changes: 22 additions & 23 deletions src/gui/editors/SongEditor.cpp
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 @@ -356,43 +356,40 @@ void SongEditor::keyPressEvent( QKeyEvent * _ke )



void SongEditor::wheelEvent( QWheelEvent * _we )
void SongEditor::wheelEvent( QWheelEvent * we )
{
if( gui->mainWindow()->isCtrlPressed() == true )
{
if( _we->delta() > 0 )
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() );
// and make sure, all TCO's are resized and relocated
realignTracks();
}
else if( gui->mainWindow()->isShiftPressed() == true || _we->orientation() == Qt::Horizontal )
else if( gui->mainWindow()->isShiftPressed() == true || we->orientation() == Qt::Horizontal )
{
m_leftRightScroll->setValue( m_leftRightScroll->value() -
_we->delta() / 30 );
we->delta() / 30 );
}
else
{
_we->ignore();
we->ignore();
return;
}
_we->accept();
we->accept();
}


Expand Down Expand Up @@ -597,22 +594,24 @@ 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) :
Editor(Engine::mixer()->audioDev()->supportsCapture()),
m_editor(new SongEditor(song))
Expand Down

0 comments on commit cfd20b7

Please sign in to comment.