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

Proposed fix 1416 Drag-and-drop of automatables to Automation Editor #1677

Merged
merged 4 commits into from
Jan 23, 2015
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class AutomationEditorWindow : public Editor
void setCurrentPattern(AutomationPattern* pattern);
const AutomationPattern* currentPattern();

virtual void dropEvent( QDropEvent * _de );
virtual void dragEnterEvent( QDragEnterEvent * _dee );

void open(AutomationPattern* pattern);

AutomationEditor* m_editor;
Expand Down
32 changes: 32 additions & 0 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
#include "PianoRoll.h"
#include "debug.h"
#include "MeterModel.h"
#include "StringPairDrag.h"
#include "ProjectJournal.h"


QPixmap * AutomationEditor::s_toolDraw = NULL;
Expand Down Expand Up @@ -2220,6 +2222,7 @@ AutomationEditorWindow::AutomationEditorWindow() :
setFocusPolicy( Qt::StrongFocus );
setFocus();
setWindowIcon( embed::getIconPixmap( "automation" ) );
setAcceptDrops( true );
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking here... it appears we generally link the toolbar as well per BBEditor.cpp#L56

}


Expand Down Expand Up @@ -2282,6 +2285,35 @@ const AutomationPattern* AutomationEditorWindow::currentPattern()
return m_editor->currentPattern();
}

void AutomationEditorWindow::dropEvent(QDropEvent *_de)
{
QString type = StringPairDrag::decodeKey( _de );
QString val = StringPairDrag::decodeValue( _de );
if( type == "automatable_model" )
{
AutomatableModel * mod = dynamic_cast<AutomatableModel *>(
Engine::projectJournal()->
journallingObject( val.toInt() ) );
if( mod != NULL )
{
if( m_editor->m_pattern->firstObject() )
{
m_editor->m_pattern->objectDestroyed( m_editor->m_pattern->firstObject()->id() );
}
m_editor->m_pattern->clear();
Copy link
Member

Choose a reason for hiding this comment

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

@diizy do we normally clear the pattern when we drag in a new item? Currently we can link one automation event to multiple similar controls, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently we can link one automation event to multiple similar controls, right?

Now i understand what the code is doing, changing this now

m_editor->m_pattern->addObject( mod );
Copy link
Member

Choose a reason for hiding this comment

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

:) extra space ---------------------^

setCurrentPattern( m_editor->m_pattern );
}
}

update();
}

void AutomationEditorWindow::dragEnterEvent(QDragEnterEvent *_dee)
{
StringPairDrag::processDragEnterEvent( _dee, "automatable_model" );
}

void AutomationEditorWindow::open(AutomationPattern* pattern)
{
setCurrentPattern(pattern);
Expand Down