=== modified file 'mixxx/src/library/librarymidicontrol.cpp'
--- mixxx/src/library/librarymidicontrol.cpp	2010-05-07 10:51:42 +0000
+++ mixxx/src/library/librarymidicontrol.cpp	2010-07-17 11:10:58 +0000
@@ -22,7 +22,9 @@
     m_pSelectPrevPlaylist = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectPrevPlaylist")));
     m_pLoadSelectedIntoFirstStopped = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","LoadSelectedIntoFirstStopped")));
     m_pSelectTrackKnob = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectTrackKnob")));
-
+    //active layer controls
+    m_pSelectNextLayer = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectNextLayer")));
+    m_pSelectPrevLayer = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Playlist]","SelectPrevLayer")));
 
     connect(m_pLoadSelectedTrackCh1, SIGNAL(valueChanged(double)), this, SLOT(slotLoadSelectedTrackCh1(double)));
     connect(m_pLoadSelectedTrackCh2, SIGNAL(valueChanged(double)), this, SLOT(slotLoadSelectedTrackCh2(double)));
@@ -32,6 +34,9 @@
     connect(m_pSelectNextPlaylist, SIGNAL(valueChanged(double)), this, SLOT(slotSelectNextPlaylist(double)));
     connect(m_pSelectPrevPlaylist, SIGNAL(valueChanged(double)), this, SLOT(slotSelectPrevPlaylist(double)));
     connect(m_pSelectTrackKnob, SIGNAL(valueChanged(double)), this, SLOT(slotSelectTrackKnob(double)));
+    connect(m_pSelectNextLayer, SIGNAL(valueChanged(double)),this,SLOT(slotSelectNextLayer(double)));
+    connect(m_pSelectPrevLayer, SIGNAL(valueChanged(double)),this,SLOT(slotSelectPrevLayer(double)));
+    m_bActiveLayer=1;
 }
         
 LibraryMIDIControl::~LibraryMIDIControl()
@@ -44,8 +49,37 @@
    delete m_pSelectPrevPlaylist;
    delete m_pLoadSelectedIntoFirstStopped;
    delete m_pSelectTrackKnob;
-}
-
+   delete m_pSelectNextLayer;
+   delete m_pSelectPrevLayer;
+}
+void LibraryMIDIControl::slotSelectNextLayer(double v)
+{   
+    if(v){
+        if(!m_bActiveLayer)
+        {
+            QWidget* testWidget = m_pLibraryWidget->getWidgetForMIDIControl();
+            if(!testWidget)
+            {
+                QWidget* destWidget = m_pSidebarWidget;
+                QApplication::postEvent(destWidget, new QKeyEvent(QEvent::KeyPress, (int)Qt::Key_Return, Qt::NoModifier, QString(), true));
+            }
+            else
+            {
+                m_bActiveLayer=1;
+            }
+        }
+        else{
+            QWidget* destWidget = m_pLibraryWidget->getWidgetForMIDIControl();
+            QApplication::postEvent(destWidget,  
+                                    new QKeyEvent(QEvent::KeyPress, (int)Qt::Key_Return,
+                                                  Qt::NoModifier, QString(), true));
+        }
+    }
+}
+void LibraryMIDIControl::slotSelectPrevLayer(double v)
+{
+    m_bActiveLayer=0;
+}
 void LibraryMIDIControl::slotLoadSelectedTrackCh1(double v)
 {
     QWidget* destWidget = m_pLibraryWidget->getWidgetForMIDIControl();
@@ -134,8 +168,14 @@
     int i = (int)v;
     //TODO: Make sure the logic in that while loop makes sense... it looks
     //      suspicious at first glance. - Albert Dec 8, 2009
-
-    QWidget* destWidget = m_pLibraryWidget->getWidgetForMIDIControl();
+    QWidget* destWidget;
+    if(m_bActiveLayer){
+        destWidget = m_pLibraryWidget->getWidgetForMIDIControl();
+    }
+    else
+    {
+        destWidget = m_pSidebarWidget;
+    }
     if (!destWidget) { //Some library panes may not want MIDI control. 
                        //(eg. Crates overview, which is just text...)
         return;

=== modified file 'mixxx/src/library/librarymidicontrol.h'
--- mixxx/src/library/librarymidicontrol.h	2009-12-11 06:10:55 +0000
+++ mixxx/src/library/librarymidicontrol.h	2010-07-17 10:41:29 +0000
@@ -19,8 +19,11 @@
         void slotSelectPrevTrack(double v); 
         void slotSelectNextPlaylist(double v); 
         void slotSelectPrevPlaylist(double v); 
-        void slotLoadSelectedIntoFirstStopped(double v); 
-        void slotSelectTrackKnob(double v); 
+        void slotLoadSelectedIntoFirstStopped(double v);
+        //active layer controls 
+        void slotSelectTrackKnob(double v);
+        void slotSelectNextLayer(double v);
+        void slotSelectPrevLayer(double v); 
     private:
         ControlObjectThreadMain* m_pLoadSelectedTrackCh1;
         ControlObjectThreadMain* m_pLoadSelectedTrackCh2;
@@ -30,9 +33,12 @@
         ControlObjectThreadMain* m_pSelectPrevPlaylist;
         ControlObjectThreadMain* m_pLoadSelectedIntoFirstStopped;
         ControlObjectThreadMain* m_pSelectTrackKnob;
+        ControlObjectThreadMain* m_pSelectNextLayer;
+        ControlObjectThreadMain* m_pSelectPrevLayer;
         WLibrary* m_pLibraryWidget;
         WLibrarySidebar* m_pSidebarWidget;
-        
+	// active layer handling
+        bool m_bActiveLayer; // 0 = sidebar, 1 = library
 };
 
 #endif //LIBRARYMIDICONTROL_H

