traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/sheetcanvas AudioClipView.cpp Audi...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/sheetcanvas AudioClipView.cpp Audi...
Date: Mon, 21 Jan 2008 16:17:32 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       08/01/21 16:17:31

Added files:
        src/sheetcanvas: AudioClipView.cpp AudioClipView.h 
                         ClipsViewPort.cpp ClipsViewPort.h 
                         cmake_install.cmake CMakeLists.txt Cursors.cpp 
                         Cursors.h CurveNodeView.cpp CurveNodeView.h 
                         CurveView.cpp CurveView.h 
                         FadeContextDialogView.cpp 
                         FadeContextDialogView.h FadeView.cpp FadeView.h 
                         libtraversosheetcanvas.h LineView.h Makefile 
                         MarkerView.cpp MarkerView.h PanelLed.cpp 
                         PanelLed.h PluginChainView.cpp 
                         PluginChainView.h PluginView.cpp PluginView.h 
                         PositionIndicator.cpp PositionIndicator.h 
                         precompile.h SheetView.cpp SheetView.h 
                         SheetWidget.cpp SheetWidget.h songcanvas.pri 
                         songcanvas.pro TimeLineView.cpp TimeLineView.h 
                         TimeLineViewPort.cpp TimeLineViewPort.h 
                         TrackPanelView.cpp TrackPanelView.h 
                         TrackPanelViewPort.cpp TrackPanelViewPort.h 
                         TrackView.cpp TrackView.h ViewItem.cpp 
                         ViewItem.h 
        src/sheetcanvas/dialogs: AudioClipEditDialog.cpp 
                                 AudioClipEditDialog.h 
        src/sheetcanvas/ui: AudioClipEditDialog.ui 

Log message:
        and back again, re-imported from src/traverso/songcanvas. Renamed Song, 
SongWidget and SongView to Sheet, SheetWidget and SheetView.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/AudioClipView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/AudioClipView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ClipsViewPort.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ClipsViewPort.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/cmake_install.cmake?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/CMakeLists.txt?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/Cursors.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/Cursors.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/CurveNodeView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/CurveNodeView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/CurveView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/CurveView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/FadeContextDialogView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/FadeContextDialogView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/FadeView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/FadeView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/libtraversosheetcanvas.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/LineView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/Makefile?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/MarkerView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/MarkerView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PanelLed.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PanelLed.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PluginChainView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PluginChainView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PluginView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PluginView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PositionIndicator.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PositionIndicator.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/precompile.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetWidget.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetWidget.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/songcanvas.pri?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/songcanvas.pro?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TimeLineView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TimeLineView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TimeLineViewPort.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TimeLineViewPort.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackPanelView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackPanelView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackPanelViewPort.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackPanelViewPort.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackView.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/TrackView.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ViewItem.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ViewItem.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/dialogs/AudioClipEditDialog.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/dialogs/AudioClipEditDialog.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ui/AudioClipEditDialog.ui?cvsroot=traverso&rev=1.1

Patches:
Index: AudioClipView.cpp
===================================================================
RCS file: AudioClipView.cpp
diff -N AudioClipView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ AudioClipView.cpp   21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,1014 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include <QPainter>
+#include <QPainterPath>
+#include <QFont>
+#include <QGraphicsSimpleTextItem>
+
+#include "AudioClipView.h"
+#include "SheetView.h"
+#include "TrackView.h"
+#include "FadeView.h"
+#include "CurveView.h"
+#include "PositionIndicator.h"
+
+#include "AudioClip.h"
+#include "ReadSource.h"
+#include "InputEngine.h"
+#include "ContextPointer.h"
+#include "Sheet.h"
+#include "ResourcesManager.h"
+#include "ProjectManager.h"
+#include "Peak.h"
+#include "Information.h"
+#include "Themer.h"
+#include <Config.h>
+#include <FadeCurve.h>
+#include <Curve.h>
+#include <Interface.h>
+#include "PluginChain.h"
+
+#include <QFileDialog>
+#include "dialogs/AudioClipEditDialog.h"
+#include "Fade.h"
+#include "AudioDevice.h"
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+AudioClipView::AudioClipView(SheetView* sv, TrackView* parent, AudioClip* clip 
)
+       : ViewItem(parent, clip)
+       , m_tv(parent)
+       , m_clip(clip)
+       , m_dragging(false)
+{
+       PENTERCONS;
+       
+       setZValue(parent->zValue() + 1);
+       
+       m_sv = sv;
+       m_sheet = m_clip->get_sheet();
+       
+       m_clipInfo = new QGraphicsSimpleTextItem(this);
+       m_clipInfo->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+       m_clipInfo->setPos(1, 0);
+       m_clipInfo->setCursor(themer()->get_cursor("AudioClip"));
+
+       load_theme_data();
+       create_brushes();
+       create_clipinfo_string();
+
+       m_waitingForPeaks = false;
+       m_progress = 0;
+       m_posIndicator = 0;
+       
+       if (FadeCurve* curve = m_clip->get_fade_in()) {
+               add_new_fadeview(curve);
+       }
+       if (FadeCurve* curve = m_clip->get_fade_out()) {
+               add_new_fadeview(curve);
+       }
+       
+       curveView = new CurveView(m_sv, this, 
m_clip->get_plugin_chain()->get_fader()->get_curve());
+       // CurveViews don't 'get' their start offset, it's only a property for 
AudioClips..
+       // So to be sure the CurveNodeViews start offset get updated as well,
+       // we call curveviews calculate_bounding_rect() function!
+       curveView->set_start_offset(m_clip->get_source_start_location());
+       curveView->calculate_bounding_rect();
+       connect(curveView, SIGNAL(curveModified()), m_sv, 
SLOT(stop_follow_play_head()));
+       
+       connect(m_clip, SIGNAL(muteChanged()), this, SLOT(repaint()));
+       connect(m_clip, SIGNAL(stateChanged()), this, 
SLOT(clip_state_changed()));
+       connect(m_clip, SIGNAL(lockChanged()), this, SLOT(repaint()));
+       connect(m_clip, SIGNAL(fadeAdded(FadeCurve*)), this, 
SLOT(add_new_fadeview( FadeCurve*)));
+       connect(m_clip, SIGNAL(fadeRemoved(FadeCurve*)), this, 
SLOT(remove_fadeview( FadeCurve*)));
+       connect(m_clip, SIGNAL(positionChanged(Snappable*)), this, 
SLOT(position_changed()));
+       
+       connect(m_sheet, SIGNAL(modeChanged()), this, SLOT(repaint()));
+       
+       if (m_clip->recording_state() == AudioClip::RECORDING) {
+               start_recording();
+               connect(m_clip, SIGNAL(recordingFinished(AudioClip*)), this, 
SLOT(finish_recording()));
+       }
+       
+//     setFlags(ItemIsSelectable | ItemIsMovable);
+       setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+       setAcceptsHoverEvents(true);
+       setCursor(themer()->get_cursor("AudioClip"));
+}
+
+AudioClipView::~ AudioClipView()
+{
+       PENTERDES;
+}
+
+void AudioClipView::paint(QPainter* painter, const QStyleOptionGraphicsItem 
*option, QWidget *widget)
+{
+       PENTER2;
+       Q_UNUSED(widget);
+       
+//     printf("AudioClipView:: %s PAINT :: exposed rect is: x=%f, y=%f, w=%f, 
h=%f\n", QS_C(m_clip->get_name()), option->exposedRect.x(), 
option->exposedRect.y(), option->exposedRect.width(), 
option->exposedRect.height());
+       
+       int xstart = qRound(option->exposedRect.x());
+       int pixelcount = qRound(option->exposedRect.width());
+       if (pixelcount == 0) {
+               PWARN("AudioClipView::paint : Exposed rectangle has 0 width 
????");
+               return;
+       }
+       
+       painter->save();
+       painter->setClipRect(m_boundingRect);
+       
+       if (m_clip->is_readsource_invalid()) {
+               painter->fillRect(xstart, 0, pixelcount, m_height, 
themer()->get_color("AudioClip:invalidreadsource"));
+               draw_clipinfo_area(painter, xstart, pixelcount);
+               painter->setPen(themer()->get_color("AudioClip:contour"));
+               painter->drawRect(xstart, 0, pixelcount, m_height - 1);
+               painter->setPen(Qt::black);
+               painter->setFont( 
themer()->get_font("AudioClip:fontscale:title") );
+               painter->drawText(30, 0, 300, m_height, Qt::AlignVCenter, 
tr("Click to reset AudioFile !"));
+               painter->restore();
+               return;
+       }
+       
+       bool mousehover = (option->state & QStyle::State_MouseOver) || 
m_dragging;
+       
+       if (m_drawbackground) {
+               if (m_clip->recording_state() == AudioClip::RECORDING) {
+                       painter->fillRect(xstart, 0, pixelcount+1, m_height, 
m_brushBgRecording);
+               } else {
+                       if (m_clip->is_muted()) {
+                               if (mousehover) painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBgMutedHover);
+                               else            painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBgMuted);
+                       } else if (m_clip->is_selected()) {
+                               if (mousehover) painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBgSelectedHover);
+                               else            painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBgSelected);
+                       } else {
+                               if (mousehover) painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBgHover);
+                               else            painter->fillRect(xstart, 0, 
pixelcount+1, m_height, m_brushBg);
+                       }
+               }
+       }
+       
+       if (m_clip->is_muted()) {
+               m_waveBrush = m_brushFgMuted;
+       } else {
+               if (m_sheet->get_mode() == Sheet::EDIT) {
+                       if (mousehover) m_waveBrush = m_brushFgHover;
+                       else            m_waveBrush = m_brushFg;
+               } else {
+                       if (mousehover) m_waveBrush = m_brushFgEditHover;
+                       else            m_waveBrush = m_brushFgEdit;
+               }
+       }
+       
+       int channels = m_clip->get_channels();
+
+       if (channels > 0) {
+               if (m_waitingForPeaks) {
+                       PMESG("Waiting for peaks!");
+                       // Hmm, do we paint here something?
+                       // Progress info, I think so....
+                       painter->setPen(Qt::black);
+                       QRect r(10, 0, 150, m_height);
+                       painter->setFont( 
themer()->get_font("AudioClip:fontscale:title") );
+                       QString si;
+                       si.setNum((int)m_progress);
+                       if (m_progress == 100) m_progress = 0;
+                       QString buildProcess = "Building Peaks: " + si + "%";
+                       painter->drawText(r, Qt::AlignVCenter, buildProcess);
+               
+               } else if (m_clip->recording_state() == 
AudioClip::NO_RECORDING) {
+//                     PROFILE_START;
+                       draw_peaks(painter, option->exposedRect.x(), 
pixelcount);
+//                     PROFILE_END("draw peaks");
+               }
+       }
+       
+       // Draw the contour
+       painter->setPen(themer()->get_color("AudioClip:contour"));
+       QRectF rect(0, 0, m_boundingRect.width() - 1, m_height - 0.5);
+//     painter->drawRect(rect);
+       painter->drawLine(0, 0, 0, m_height);
+       QLineF line(m_boundingRect.width()-0.5, 0, m_boundingRect.width()-0.5, 
m_height);
+       painter->drawLine(line);
+       if (m_height > m_mimimumheightforinfoarea) {
+               draw_clipinfo_area(painter, xstart, pixelcount);
+       }
+       
+       // Paint a pixmap if the clip is locked
+       if (m_clip->is_locked()) {
+               int center = (int)(m_clip->get_length() / (2 * 
m_sv->timeref_scalefactor));
+               painter->drawPixmap(center - 8, m_height - 20, 
find_pixmap(":/lock"));
+       }
+
+       if (m_dragging) {
+               m_posIndicator->set_value(timeref_to_text(TimeRef(x() * 
m_sv->timeref_scalefactor), m_sv->timeref_scalefactor));
+       }
+       
+       painter->restore();
+}
+
+void AudioClipView::draw_peaks(QPainter* p, qreal xstart, int pixelcount)
+{
+       PENTER2;
+       // when painting with a path, I _have_ to use path.lineTo()
+       // which looks ugly when only parts of the clip is repainted
+       // when using a different color for the brush then the outline.
+       // Painting 2 more pixels makes it getting clipped away.....
+       pixelcount += 2;
+       
+       // boundary checking, important for microview only, macroview needs the 
additional
+       // pixels to paint the waveform correctly
+       if ((xstart + pixelcount) > m_boundingRect.width()) {
+               pixelcount = qRound(m_boundingRect.width() - xstart);
+       }
+       
+       Peak* peak = m_clip->get_peak();
+       if (!peak) {
+               PERROR("No Peak object available for clip %s", 
QS_C(m_clip->get_name()));
+               return;
+       }
+       
+       bool microView = m_sheet->get_hzoom() > 32 ? 0 : 1;
+       TimeRef clipstartoffset = m_clip->get_source_start_location();
+       int channels = m_clip->get_channels();
+       int peakdatacount = microView ? pixelcount : pixelcount * 2;
+       float* pixeldata[channels];
+       float curveDefaultValue = 1.0;
+       int mixcurvedata = 0;
+       mixcurvedata |= curveView->has_nodes();
+       int offset = (int)(m_clip->get_source_start_location() / 
m_sv->timeref_scalefactor);
+               
+       if (!mixcurvedata) {
+               curveDefaultValue = curveView->get_default_value();
+       }
+       
+       int highbit;
+       unsigned long nearestpow2 = 
nearest_power_of_two(long(m_sheet->get_hzoom()), highbit);
+       if (nearestpow2 == 0) {
+               nearestpow2 = 1;
+       }
+       // Load peak data for all channels, if no peakdata is returned
+       // for a certain Peak object, schedule it for loading.
+       for (int chan=0; chan < channels; ++chan) {
+               
+               int availpeaks = peak->calculate_peaks( chan,
+                               &pixeldata[chan],
+                               m_sheet->get_hzoom(),
+                               TimeRef(xstart * m_sv->timeref_scalefactor) + 
clipstartoffset,
+                               peakdatacount);
+               
+               if (peakdatacount != availpeaks) {
+//                     PWARN("peakdatacount != availpeaks (%d, %d)", 
peakdatacount, availpeaks);
+               }
+
+               if (availpeaks == Peak::NO_PEAK_FILE) {
+                       connect(peak, SIGNAL(progress(int)), this, 
SLOT(update_progress_info(int)));
+                       connect(peak, SIGNAL(finished()), this, SLOT 
(peak_creation_finished()));
+                       m_waitingForPeaks = true;
+                       peak->start_peak_loading();
+                       return;
+               }
+               
+               if (availpeaks == Peak::PERMANENT_FAILURE || availpeaks == 
Peak::NO_PEAKDATA_FOUND) {
+                       return;
+               }               
+               
+//             pixelcount = std::min(pixelcount, availpeaks);
+       }
+       
+       
+       float curvemixdown[peakdatacount];
+       if (mixcurvedata) {
+               mixcurvedata |= curveView->get_vector(qRound(xstart) + offset, 
peakdatacount, curvemixdown);
+       }
+       
+       for (int i = 0; i < m_fadeViews.size(); ++i) {
+               FadeView* view = m_fadeViews.at(i);
+               float fademixdown[peakdatacount];
+               int fademix = 0;
+               
+               if (mixcurvedata) {
+                       fademix = view->get_vector(qRound(xstart), 
peakdatacount, fademixdown);
+               } else {
+                       fademix = view->get_vector(qRound(xstart), 
peakdatacount, curvemixdown);
+               }
+               
+               if (mixcurvedata && fademix) {
+                       for (int j=0; j<peakdatacount; ++j) {
+                               curvemixdown[j] *= fademixdown[j];
+                       }
+               }
+               
+               mixcurvedata |= fademix;
+       }
+       
+       // Load the Peak data into the pixeldata float buffers
+       // ClassicView uses both positive and negative values,
+       // rectified view: pick the highest value of both
+       // Merged view: calculate highest value for all channels, 
+       // and store it in the first channels pixeldata.
+       if (!microView) {
+               if (!m_classicView) {
+                       for (int chan=0; chan < channels; chan++) {
+                               for (int i=0, j=0; i < (pixelcount*2); i+=2, 
++j) {
+                                       pixeldata[chan][j] = - 
fabs(f_max(pixeldata[chan][i], - pixeldata[chan][i+1]));
+                               }
+                       }
+               }
+               
+               if (m_mergedView) {
+                       for (int chan=1; chan < channels; chan++) {
+                               for (int i = 0; i < (pixelcount*2); ++i) {
+                                       pixeldata[0][i] = f_max(pixeldata[chan 
- 1][i], pixeldata[chan][i]);
+                               }
+                       }
+               }
+               
+       }
+       
+       if (mixcurvedata) {
+               int curvemixdownpos;
+               for (int chan=0; chan < channels; chan++) {
+                       curvemixdownpos = 0;
+                       if (m_classicView) {
+                               for (int i = 0; i < (pixelcount*2); ++i) {
+                                       pixeldata[chan][i++] *= 
curvemixdown[curvemixdownpos];
+                                       pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
+                                       curvemixdownpos++;
+                               }
+                       } else {
+                               for (int i = 0; i < pixelcount; i++) {
+                                       pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
+                                       curvemixdownpos++;
+                               }
+                       }
+               }
+       }
+       
+
+       for (int chan=0; chan < channels; chan++) {
+               p->save();
+               
+               // calculate the height of the area available for peak drawing 
+               // and if the infoarea is displayed, translate the painter
+               // drawing by dy = m_infoAreaheight
+               int height;
+               
+               if (m_height >= m_mimimumheightforinfoarea) {
+                       p->setMatrix(matrix().translate(0, m_infoAreaHeight), 
true);
+                       height = (m_height - m_infoAreaHeight) / channels;
+               } else {
+                       height = m_height / channels;
+               }
+       
+               
+               float scaleFactor = ( (float) height * 0.90 / 2) * 
m_clip->get_gain() * curveDefaultValue;
+               float ytrans;
+               
+
+               // Draw channel seperator horizontal lines, if needed.
+               if (channels >= 2 && ! m_mergedView && m_classicView && chan 
>=1 ) {
+                       p->save();
+                       
+                       if (m_clip->is_selected()) {
+                               
p->setPen(themer()->get_color("AudioClip:channelseperator:selected"));
+                       } else {
+                               
p->setPen(themer()->get_color("AudioClip:channelseperator"));
+                       }
+               
+                       ytrans = height * chan;
+                       p->setMatrix(matrix().translate(0, ytrans), true);
+                       p->drawLine(qRound(xstart), 0, qRound(xstart) + 
pixelcount, 0);
+                       p->restore();
+               }
+               
+               // Microview, paint waveform as polyline
+               if (microView) {
+               
+                       m_polygon.clear();
+                       m_polygon.reserve(pixelcount);
+                       
+                       int bufferPos = 0;
+                       
+                       if (m_mergedView) {
+                               ytrans = (height / 2) * channels;
+                       } else {
+                               ytrans = (height / 2) + (chan * height);
+                       }
+                       
+                       p->setMatrix(matrix().translate(0, ytrans), true);
+                       
+                       if (m_clip->is_selected()) {
+                               
p->setPen(themer()->get_color("AudioClip:channelseperator:selected"));
+                       } else {
+                               
p->setPen(themer()->get_color("AudioClip:channelseperator"));
+                       }
+                       
+                       p->drawLine(qRound(xstart), 0, qRound(xstart) + 
pixelcount, 0);
+                       
+                       for (int x = qRound(xstart); x < 
(pixelcount+qRound(xstart)); x++) {
+                               m_polygon.append( QPointF(x, -scaleFactor * 
pixeldata[chan][bufferPos++]) );
+                       }
+                       
+                       if 
(themer()->get_property("AudioClip:wavemicroview:antialiased", 0).toInt()) {
+                               p->setRenderHints(QPainter::Antialiasing);
+                       }
+                       
+                       
p->setPen(themer()->get_color("AudioClip:wavemicroview"));
+                       p->drawPolyline(m_polygon);
+               
+               // Macroview, paint waveform with painterpath
+               } else {
+                       if (m_fillwave) {
+                               p->setBrush(m_waveBrush);
+                       }
+
+                       if (m_sheet->get_mode() == Sheet::EDIT) {
+                               
p->setPen(themer()->get_color("AudioClip:wavemacroview:outline"));
+                       } else  {
+                               
p->setPen(themer()->get_color("AudioClip:wavemacroview:outline:curvemode"));
+                       }
+                       if (m_clip->is_muted()) {
+                               
p->setPen(themer()->get_color("AudioClip:wavemacroview:outline:muted"));
+                       }
+                               
+                       scaleFactor = ( (float) height * 0.90 / 
(Peak::MAX_DB_VALUE * 2)) * m_clip->get_gain() * curveDefaultValue;
+                       
+                       if (m_mergedView) {
+                               if (m_classicView) {
+                                       ytrans = (height / 2) * channels;
+                                       scaleFactor *= channels;
+                               } else {
+                                       ytrans = height * channels;
+                                       scaleFactor *= channels;
+                               }
+                       }
+                       
+                       // we add one start/stop point so reserve some more...
+                       int bufferpos = 0;
+
+                       if (m_classicView) {
+                               
+                               if (m_mergedView) {
+                                       ytrans = (height / 2) * channels;
+                               } else {
+                                       ytrans = (height / 2) + (chan * height);
+                               }
+                       
+                               p->setMatrix(matrix().translate(xstart, 
ytrans).scale(1, scaleFactor), true);
+                               
+                               if (!m_paintWithOutline) {
+                                       p->setPen(Qt::NoPen);
+                               }
+                               
+                               m_polygon.clear();
+                               m_polygon.reserve(pixelcount*2);
+                               
+                               for (int x = 0; x < pixelcount; x++) {
+                                       m_polygon.append( QPointF(x, - 
pixeldata[chan][bufferpos]) );
+                                       bufferpos+=2;
+                               }
+                               
+                               bufferpos -= 1;
+                               
+                               for (int x = pixelcount - 1; x >= 0; x--) {
+                                       m_polygon.append( QPointF(x, 
pixeldata[chan][bufferpos]) );
+                                       bufferpos-=2;
+                               }
+                               
+                               QPainterPath path;
+                               path.addPolygon(m_polygon);
+                               
+                               p->drawPath(path);
+
+/*                             } else {
+                                       for (int x = 0; x < pixelcount; x++) {
+                                               int ytop = -1 * 
(int)(pixeldata[chan][bufferpos++]);
+                                               int ymin = 
(int)(pixeldata[chan][bufferpos++]);
+                                               p->drawLine(x, ytop, x, ymin);
+                                       }
+                               }*/
+                       
+                               // Draw 'the' -INF line
+                               p->setPen(minINFLineColor);
+                               p->drawLine(0, 0, pixelcount, 0);
+                       
+                       } else {
+                               scaleFactor =  (float) height * 0.95 * 
m_clip->get_gain() / Peak::MAX_DB_VALUE * curveDefaultValue;
+                               ytrans = height + (chan * height);
+               
+                               if (m_mergedView) {
+                                       ytrans = height * channels;
+                                       scaleFactor *= channels;
+                               }
+
+                               p->setMatrix(matrix().translate(xstart, 
ytrans).scale(1, scaleFactor), true);
+                               
+                               if (!m_paintWithOutline) {
+                                       p->setPen(Qt::NoPen);
+                               }
+                                       
+                               m_polygon.clear();
+                               m_polygon.reserve(pixelcount + 2);
+                               
+                               for (int x=0; x<pixelcount; x++) {
+                                       m_polygon.append( QPointF(x, 
pixeldata[chan][bufferpos++]) );
+                               }
+                               
+                               m_polygon.append(QPointF(pixelcount, 0));
+                               
+                               QPainterPath path;
+                               path.addPolygon(m_polygon);
+                               path.lineTo(0, 0);
+                               
+                               p->drawPath(path);
+                       }
+                       
+               }
+               
+               p->restore();
+               
+               if (m_mergedView) {
+                       break;
+               }
+       }
+}
+
+void AudioClipView::draw_clipinfo_area(QPainter* p, int xstart, int pixelcount)
+{
+       // fill info area bg
+       p->fillRect(xstart + 1, 1, pixelcount, m_infoAreaHeight, 
themer()->get_color("AudioClip:clipinfobackground:inactive"));
+}
+
+void AudioClipView::create_brushes()
+{
+       // make sure the brushes are made from solid colors (not gradients) if 
top and bottom color are equal
+
+       // create brushes for background states
+       QColor bg_colRecTop = 
themer()->get_color("AudioClip:background:recording:top");
+       QColor bg_colRecBottom = 
themer()->get_color("AudioClip:background:recording:Bottom");
+       if (bg_colRecTop == bg_colRecBottom) {
+               m_brushBgRecording = QBrush(bg_colRecTop);
+       } else {
+               QLinearGradient bg_gradientRec(QPoint(0, 0), QPoint(0, 
m_height));
+               bg_gradientRec.setSpread(QGradient::RepeatSpread);
+               bg_gradientRec.setColorAt(0, bg_colRecTop);
+               bg_gradientRec.setColorAt(1, bg_colRecBottom);
+               m_brushBgRecording = QBrush(bg_gradientRec);
+       }
+
+       QColor bg_colMutedTop = 
themer()->get_color("AudioClip:background:muted:top");
+       QColor bg_colMutedBottom = 
themer()->get_color("AudioClip:background:muted:bottom");
+       if (bg_colMutedTop == bg_colMutedBottom) {
+               m_brushBgMuted = QBrush(bg_colMutedTop);
+       } else {
+               QLinearGradient bg_gradientMuted(QPoint(0, 0), QPoint(0, 
m_height));
+               bg_gradientMuted.setSpread(QGradient::RepeatSpread);
+               bg_gradientMuted.setColorAt(0, bg_colMutedTop);
+               bg_gradientMuted.setColorAt(1, bg_colMutedBottom);
+               m_brushBgMuted = QBrush(bg_gradientMuted);
+       }
+
+       QColor bg_colMutedHoverTop = 
themer()->get_color("AudioClip:background:muted:mousehover:top");
+       QColor bg_colMutedHoverBottom = 
themer()->get_color("AudioClip:background:muted:mousehover:bottom");
+       if (bg_colMutedHoverTop == bg_colMutedHoverBottom) {
+               m_brushBgMutedHover = QBrush(bg_colMutedHoverTop);
+       } else {
+               QLinearGradient bg_gradientMutedHover(QPoint(0, 0), QPoint(0, 
m_height));
+               bg_gradientMutedHover.setSpread(QGradient::RepeatSpread);
+               bg_gradientMutedHover.setColorAt(0, bg_colMutedHoverTop);
+               bg_gradientMutedHover.setColorAt(1, bg_colMutedHoverBottom);
+               m_brushBgMutedHover = QBrush(bg_gradientMutedHover);
+       }
+
+       QColor bg_colSelectedTop = 
themer()->get_color("AudioClip:background:selected:top");
+       QColor bg_colSelectedBottom = 
themer()->get_color("AudioClip:background:selected:bottom");
+       if (bg_colSelectedTop == bg_colSelectedBottom) {
+               m_brushBgSelected = QBrush(bg_colSelectedTop);
+       } else {
+               QLinearGradient bg_gradientSelected(QPoint(0, 0), QPoint(0, 
m_height));
+               bg_gradientSelected.setSpread(QGradient::RepeatSpread);
+               bg_gradientSelected.setColorAt(0, bg_colSelectedTop);
+               bg_gradientSelected.setColorAt(1, bg_colSelectedBottom);
+               m_brushBgSelected = QBrush(bg_gradientSelected);
+       }
+
+       QColor bg_colSelectedHoverTop = 
themer()->get_color("AudioClip:background:selected:mousehover:top");
+       QColor bg_colSelectedHoverBottom = 
themer()->get_color("AudioClip:background:selected:mousehover:bottom");
+       if (bg_colSelectedHoverTop == bg_colSelectedHoverBottom) {
+               m_brushBgSelectedHover = QBrush(bg_colSelectedHoverTop);
+       } else {
+               QLinearGradient bg_gradientSelectedHover(QPoint(0, 0), 
QPoint(0, m_height));
+               bg_gradientSelectedHover.setSpread(QGradient::RepeatSpread);
+               bg_gradientSelectedHover.setColorAt(0, bg_colSelectedHoverTop);
+               bg_gradientSelectedHover.setColorAt(1, 
bg_colSelectedHoverBottom);
+               m_brushBgSelectedHover = QBrush(bg_gradientSelectedHover);
+       }
+
+       QColor bg_colTop = themer()->get_color("AudioClip:background:top");
+       QColor bg_colBottom = 
themer()->get_color("AudioClip:background:bottom");
+       if (bg_colTop == bg_colBottom) {
+               m_brushBg = QBrush(bg_colTop);
+       } else {
+               QLinearGradient bg_gradient(QPoint(0, 0), QPoint(0, m_height));
+               bg_gradient.setSpread(QGradient::RepeatSpread);
+               bg_gradient.setColorAt(0, bg_colTop);
+               bg_gradient.setColorAt(1, bg_colBottom);
+               m_brushBg = QBrush(bg_gradient);
+       }
+
+       QColor bg_colHoverTop = 
themer()->get_color("AudioClip:background:mousehover:top");
+       QColor bg_colHoverBottom = 
themer()->get_color("AudioClip:background:mousehover:bottom");
+       if (bg_colHoverTop == bg_colHoverBottom) {
+               m_brushBgHover = QBrush(bg_colHoverTop);
+       } else {
+               QLinearGradient bg_gradientHover(QPoint(0, 0), QPoint(0, 
m_height));
+               bg_gradientHover.setSpread(QGradient::RepeatSpread);
+               bg_gradientHover.setColorAt(0, bg_colHoverTop);
+               bg_gradientHover.setColorAt(1, bg_colHoverBottom);
+               m_brushBgHover = QBrush(bg_gradientHover);
+       }
+
+       // Foreground (Waveforms)
+       QColor fg_colTop = 
themer()->get_color("AudioClip:wavemacroview:brush:top");
+       QColor fg_colBottom = 
themer()->get_color("AudioClip:wavemacroview:brush:bottom");
+       if (fg_colTop == fg_colBottom) {
+               m_brushFg = QBrush(fg_colTop);
+       } else {
+               QLinearGradient fg_gradient(QPoint(0, 0), QPoint(0, m_height));
+               fg_gradient.setSpread(QGradient::RepeatSpread);
+               fg_gradient.setColorAt(0, fg_colTop);
+               fg_gradient.setColorAt(1, fg_colBottom);
+               m_brushFg = QBrush(fg_gradient);
+       }
+
+       QColor fg_colHoverTop = 
themer()->get_color("AudioClip:wavemacroview:brush:hover:top");
+       QColor fg_colHoverBottom = 
themer()->get_color("AudioClip:wavemacroview:brush:hover:bottom");
+       if (fg_colHoverTop == fg_colHoverBottom) {
+               m_brushFgHover = QBrush(fg_colHoverTop);
+       } else {
+               QLinearGradient fg_gradientHover(QPoint(0, 0), QPoint(0, 
m_height));
+               fg_gradientHover.setSpread(QGradient::RepeatSpread);
+               fg_gradientHover.setColorAt(0, fg_colHoverTop);
+               fg_gradientHover.setColorAt(1, fg_colHoverBottom);
+               m_brushFgHover = QBrush(fg_gradientHover);
+       }
+
+       QColor fg_colEditTop = 
themer()->get_color("AudioClip:wavemacroview:brush:curvemode:top");
+       QColor fg_colEditBottom = 
themer()->get_color("AudioClip:wavemacroview:brush:curvemode:bottom");
+       if (fg_colEditTop == fg_colEditBottom) {
+               m_brushFgEdit = QBrush(fg_colEditTop);
+       } else {
+               QLinearGradient fg_gradientEdit(QPoint(0, 0), QPoint(0, 
m_height));
+               fg_gradientEdit.setSpread(QGradient::RepeatSpread);
+               fg_gradientEdit.setColorAt(0, fg_colEditTop);
+               fg_gradientEdit.setColorAt(1, fg_colEditBottom);
+               m_brushFgEdit = QBrush(fg_gradientEdit);
+       }
+
+       QColor fg_colEditHoverTop = 
themer()->get_color("AudioClip:wavemacroview:brush:curvemode:hover:top");
+       QColor fg_colEditHoverBottom = 
themer()->get_color("AudioClip:wavemacroview:brush:curvemode:hover:bottom");
+       if (fg_colEditHoverTop == fg_colEditHoverBottom) {
+               m_brushFgEditHover = QBrush(fg_colEditHoverTop);
+       } else {
+               QLinearGradient fg_gradientEditHover(QPoint(0, 0), QPoint(0, 
m_height));
+               fg_gradientEditHover.setSpread(QGradient::RepeatSpread);
+               fg_gradientEditHover.setColorAt(0, fg_colEditHoverTop);
+               fg_gradientEditHover.setColorAt(1, fg_colEditHoverBottom);
+               m_brushFgEditHover = QBrush(fg_gradientEditHover);
+       }
+
+       QColor fg_colMutedTop = 
themer()->get_color("AudioClip:wavemacroview:brush:muted:top");
+       QColor fg_colMutedBottom = 
themer()->get_color("AudioClip:wavemacroview:brush:muted:bottom");
+       if (fg_colMutedTop == fg_colMutedBottom) {
+               m_brushFgMuted = QBrush(fg_colMutedTop);
+       } else {
+               QLinearGradient fg_gradientMuted(QPoint(0, 0), QPoint(0, 
m_height));
+               fg_gradientMuted.setSpread(QGradient::RepeatSpread);
+               fg_gradientMuted.setColorAt(0, fg_colMutedTop);
+               fg_gradientMuted.setColorAt(1, fg_colMutedBottom);
+               m_brushFgMuted = QBrush(fg_gradientMuted);
+       }
+}
+
+void AudioClipView::create_clipinfo_string()
+{
+       PENTER;
+       QString sclipGain = "Gain: "+ 
coefficient_to_dbstring(m_clip->get_gain());
+       m_clipinfoString = m_clip->get_name()  + "    " + sclipGain + "   " + 
QString::number(m_clip->get_rate()) +  " Hz";
+       m_clipInfo->setText(m_clipinfoString);
+}
+
+void AudioClipView::update_progress_info( int progress )
+{
+//     if (progress > m_progress) {
+//     }
+       m_progress = progress;
+       update(10, 0, 150, m_height);
+}
+
+void AudioClipView::peak_creation_finished()
+{
+       m_waitingForPeaks = false;
+       update();
+}
+
+AudioClip * AudioClipView::get_clip( )
+{
+       return m_clip;
+}
+
+void AudioClipView::add_new_fadeview( FadeCurve * fade )
+{
+       PENTER;
+       FadeView* view = new FadeView(m_sv, this, fade);
+       m_fadeViews.append(view);
+       connect(view, SIGNAL(fadeModified()), m_sv, 
SLOT(stop_follow_play_head()));
+#if QT_VERSION < 0x040300
+       scene()->addItem(view);
+#endif
+}
+
+void AudioClipView::remove_fadeview( FadeCurve * fade )
+{
+       for (int i = 0; i < m_fadeViews.size(); ++i) {
+               FadeView* view = m_fadeViews.at(i);
+               if (view->get_fade() == fade) {
+                       m_fadeViews.takeAt(i);
+                       scene()->removeItem(view);
+                       delete view;
+                       break;
+               }
+       }
+}
+
+void AudioClipView::calculate_bounding_rect()
+{
+       PENTER4;
+       prepareGeometryChange();
+//     printf("AudioClipView::calculate_bounding_rect()\n");
+       set_height(m_tv->get_height());
+       m_boundingRect = QRectF(0, 0, (m_clip->get_length() / 
m_sv->timeref_scalefactor), m_height);
+       update_start_pos();
+       ViewItem::calculate_bounding_rect();
+       
+       foreach(PainterPathCache* cache, m_pathCache) {
+               cache->xstart = -1;
+               cache->length = -1;
+       }
+}
+
+
+void AudioClipView::repaint( )
+{
+       update(m_boundingRect);
+}
+
+void AudioClipView::set_height( int height )
+{
+       m_height = height;
+       create_brushes();
+       if (m_height < m_mimimumheightforinfoarea) {
+               m_clipInfo->hide();
+       } else {
+               m_clipInfo->show();
+       }
+}
+
+int AudioClipView::get_childview_y_offset() const
+{
+       return (m_height >= m_mimimumheightforinfoarea) ? m_infoAreaHeight : 0;
+}
+
+void AudioClipView::update_start_pos()
+{
+//     printf("AudioClipView::update_start_pos()\n");
+       setPos(m_clip->get_track_start_location() / m_sv->timeref_scalefactor, 
m_tv->get_childview_y_offset());
+}
+
+Command * AudioClipView::fade_range()
+{
+       Q_ASSERT(m_sheet);
+       int x = (int) (cpointer().on_first_input_event_scene_x() - 
scenePos().x());
+
+       if (x < (m_boundingRect.width() / 2)) {
+               return clip_fade_in();
+       } else {
+               return clip_fade_out();
+       }
+
+       return 0;
+}
+
+Command * AudioClipView::clip_fade_in( )
+{
+       if (! m_clip->get_fade_in()) {
+               // This implicitely creates the fadecurve
+               m_clip->set_fade_in(1);
+       }
+       return new FadeRange(m_clip, m_clip->get_fade_in(), 
m_sv->timeref_scalefactor);
+}
+
+Command * AudioClipView::clip_fade_out( )
+{
+       if (! m_clip->get_fade_out()) {
+               m_clip->set_fade_out(1);
+       }
+       return new FadeRange(m_clip, m_clip->get_fade_out(), 
m_sv->timeref_scalefactor);
+}
+
+Command * AudioClipView::reset_fade()
+{
+       Q_ASSERT(m_sheet);
+       int x = (int) (cpointer().on_first_input_event_scene_x() - 
scenePos().x());
+
+       if (x < (m_boundingRect.width() / 2)) {
+               return m_clip->reset_fade_in();
+       } else {
+               return m_clip->reset_fade_out();
+       }
+
+       return 0;
+}
+
+void AudioClipView::position_changed()
+{
+       // Update the curveview start offset, only needed for left edge dragging
+       // but who cares :)
+       // the calculate_bounding_rect() will update AudioClipViews children, so
+       // the CurveView and it's nodes get updated as well, no need to set
+       // the start offset for those manually!
+       curveView->set_start_offset(m_clip->get_source_start_location());
+       calculate_bounding_rect();
+       update();
+}
+
+void AudioClipView::load_theme_data()
+{
+       m_drawbackground = themer()->get_property("AudioClip:drawbackground", 
1).toInt();
+       m_infoAreaHeight = themer()->get_property("AudioClip:infoareaheight", 
16).toInt();
+       m_usePolygonPeakDrawing = 
themer()->get_property("AudioClip:polygonpeakdrawing", 0).toInt();
+       m_mimimumheightforinfoarea = 
themer()->get_property("AudioClip:mimimumheightforinfoarea", 45).toInt();
+       m_classicView = ! config().get_property("Themer", 
"paintaudiorectified", false).toBool();
+       m_mergedView = config().get_property("Themer", 
"paintstereoaudioasmono", false).toBool();
+       m_fillwave = themer()->get_property("AudioClip:fillwave", 1).toInt();
+       minINFLineColor = themer()->get_color("AudioClip:channelseperator");
+       m_paintWithOutline = config().get_property("Themer", 
"paintwavewithoutline", true).toBool();
+       m_clipInfo->setFont(themer()->get_font("AudioClip:fontscale:title"));
+       calculate_bounding_rect();
+}
+
+
+void AudioClipView::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
+{
+       Q_UNUSED(event)
+                       if (ie().is_holding()) {
+               return;
+                       }
+       
+                       update(m_boundingRect);
+}
+
+
+Command * AudioClipView::select_fade_in_shape( )
+{
+       Interface::instance()->select_fade_in_shape();
+       
+       return 0;
+}
+
+Command * AudioClipView::select_fade_out_shape( )
+{
+       Interface::instance()->select_fade_out_shape();
+       
+       return 0;
+}
+
+void AudioClipView::start_recording()
+{
+       m_oldRecordingPos = TimeRef();
+       connect(&m_recordingTimer, SIGNAL(timeout()), this, 
SLOT(update_recording()));
+       m_recordingTimer.start(750);
+}
+
+void AudioClipView::finish_recording()
+{
+       m_recordingTimer.stop();
+       prepareGeometryChange();
+       m_boundingRect = QRectF(0, 0, (m_clip->get_length() / 
m_sv->timeref_scalefactor), m_height);
+       curveView->calculate_bounding_rect();
+       update();
+}
+
+void AudioClipView::update_recording()
+{
+       if (m_clip->recording_state() != AudioClip::RECORDING) {
+               return;
+       }
+       
+       TimeRef newPos = m_clip->get_length();
+       m_boundingRect = QRectF(0, 0, (newPos / m_sv->timeref_scalefactor), 
m_height);
+       
+       int updatewidth = int((newPos - m_oldRecordingPos) / 
m_sv->timeref_scalefactor);
+       QRect updaterect = QRect(int(m_oldRecordingPos / 
m_sv->timeref_scalefactor) - 1, 0, updatewidth, m_height);
+       update(updaterect);
+       m_oldRecordingPos = newPos;
+}
+
+void AudioClipView::set_dragging(bool dragging)
+{
+       if (dragging) {
+               if (! m_posIndicator) {
+                       m_posIndicator = new PositionIndicator(this);
+                       m_posIndicator->set_position(2, 
get_childview_y_offset() + 1);
+               }
+       } else {
+               if (m_posIndicator) {
+                       scene()->removeItem(m_posIndicator);
+                       delete m_posIndicator;
+                       m_posIndicator = 0;
+               }
+       }
+       
+       m_dragging = dragging;
+       update();
+}
+
+Command * AudioClipView::set_audio_file()
+{
+       if (m_clip->is_readsource_invalid()) {
+               ReadSource* rs = m_clip->get_readsource();
+               if ( ! rs ) {
+                       return ie().failure();
+               }
+               
+               QString filename = QFileDialog::getOpenFileName(0,
+                               tr("Reset Audio File for Clip: 
%1").arg(m_clip->get_name()),
+                                  rs->get_filename(),
+                                                  tr("All files (*);;Audio 
files (*.wav *.flac)"));
+               
+               if (filename.isEmpty()) {
+                       info().information(tr("No file selected!"));
+                       return ie().failure();
+               }
+               
+               if (rs->set_file(filename) < 0) {
+                       return ie().failure();
+               }
+                       
+               resources_manager()->set_source_for_clip(m_clip, rs);
+               
+               info().information(tr("Succesfully set AudioClip file to 
%1").arg(filename));
+               
+               return ie().succes();
+       }
+       
+       return ie().did_not_implement();
+}
+
+void AudioClipView::set_trackview(TrackView * view)
+{
+       if (m_posIndicator) {
+               m_posIndicator->update();
+       }
+       m_tv = view;
+       setParentItem(m_tv);
+}
+
+Command * AudioClipView::edit_properties()
+{
+       AudioClipEditDialog editdialog(m_clip, Interface::instance());
+       
+       editdialog.exec();
+       
+       return 0;
+}
+
+void AudioClipView::clip_state_changed()
+{
+       create_clipinfo_string();
+       update();
+}
+

Index: AudioClipView.h
===================================================================
RCS file: AudioClipView.h
diff -N AudioClipView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ AudioClipView.h     21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,186 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef AUDIO_CLIP_VIEW_H
+#define AUDIO_CLIP_VIEW_H
+
+#include "ViewItem.h"
+#include <defines.h>
+#include <QList>
+#include <QTimer>
+#include <QPolygonF>
+
+class AudioClip;
+class Sheet;
+class FadeCurve;
+class CurveView;
+class SheetView;
+class TrackView;
+class FadeView;
+class Peak;
+class PositionIndicator;
+class QGraphicsSimpleTextItem;
+
+class AudioClipView : public ViewItem
+{
+       Q_OBJECT
+       Q_CLASSINFO("fade_range", tr("Closest: Adjust Length"))
+       Q_CLASSINFO("clip_fade_in", tr("In: Adjust Length"))
+       Q_CLASSINFO("clip_fade_out", tr("Out: Adjust Length"))
+       Q_CLASSINFO("select_fade_in_shape", tr("In: Select Preset"));
+       Q_CLASSINFO("select_fade_out_shape", tr("Out: Select Preset"));
+       Q_CLASSINFO("reset_fade", tr("Closest: Delete"));
+       Q_CLASSINFO("set_audio_file", tr("Reset Audio File"));
+       Q_CLASSINFO("edit_properties", tr("Edit Properties"));
+
+public:
+       AudioClipView(SheetView* view, TrackView* parent, AudioClip* clip);
+       ~AudioClipView();
+
+       enum {Type = UserType + 1};
+       int type() const;
+
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       
+       void set_height(int height);
+       
+       AudioClip* get_clip();
+       int get_height() const;
+       int get_childview_y_offset() const;
+       
+       void calculate_bounding_rect();
+       
+       TrackView* get_trackview() const {return m_tv;}
+       void set_trackview(TrackView* view);
+       void set_dragging(bool dragging);
+       
+       void load_theme_data();
+       
+protected:
+       void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
+
+private:
+       TrackView*      m_tv;
+       QList<FadeView*> m_fadeViews;
+       AudioClip*      m_clip;
+       Sheet*          m_sheet;
+       CurveView*      curveView;
+       PositionIndicator* m_posIndicator;
+       QPolygonF m_polygon;
+       QGraphicsSimpleTextItem* m_clipInfo;
+       
+       struct PainterPathCache {
+               QPainterPath pathtop;
+               QPainterPath pathbottom;
+               int xstart;
+               int length;
+       };
+       
+       QList<PainterPathCache* > m_pathCache;
+
+       QTimer m_recordingTimer;
+
+       float m_progress;
+       int m_peakloadingcount;
+
+       bool m_waitingForPeaks;
+       bool m_mergedView;
+       bool m_classicView;
+       bool m_dragging;
+       bool m_paintWithOutline;
+       int m_height;
+       int m_infoAreaHeight;
+       int m_mimimumheightforinfoarea;
+       int m_usePolygonPeakDrawing;
+       TimeRef m_oldRecordingPos;
+       
+       // theme data
+       int m_drawbackground;
+       int m_fillwave;
+       QColor m_backgroundColorTop;
+       QColor m_backgroundColorBottom;
+       QColor m_backgroundColorMouseHoverTop;
+       QColor m_backgroundColorMouseHoverBottom;
+       QColor minINFLineColor;
+       QBrush m_waveBrush;
+       QBrush m_brushBgRecording;
+       QBrush m_brushBgMuted;
+       QBrush m_brushBgMutedHover;
+       QBrush m_brushBgSelected;
+       QBrush m_brushBgSelectedHover;
+       QBrush m_brushBg;
+       QBrush m_brushBgHover;
+       QBrush m_brushFg;
+       QBrush m_brushFgHover;
+       QBrush m_brushFgMuted;
+       QBrush m_brushFgEdit;
+       QBrush m_brushFgEditHover;
+
+       QString m_clipinfoString;
+
+       void create_clipinfo_string();
+
+       void draw_clipinfo_area(QPainter* painter, int xstart, int pixelcount);
+       void draw_peaks(QPainter* painter, qreal xstart, int pixelcount);
+       void create_brushes();
+
+       friend class FadeView;
+
+public slots:
+       void add_new_fadeview(FadeCurve* fade);
+       void remove_fadeview(FadeCurve* fade);
+       void repaint();
+       void update_start_pos();
+       void position_changed();
+       
+       Command* fade_range();
+       Command* clip_fade_in();
+       Command* clip_fade_out();
+       Command* select_fade_in_shape();
+       Command* select_fade_out_shape();
+       Command* reset_fade();
+       Command* set_audio_file();
+       Command* edit_properties();
+       
+private slots:
+       void update_progress_info(int progress);
+       void peak_creation_finished();
+       void start_recording();
+       void finish_recording();
+       void update_recording();
+       void clip_state_changed();
+};
+
+
+inline int AudioClipView::get_height() const {
+       int height;
+       (m_height > m_mimimumheightforinfoarea) ? height = m_height - 
m_infoAreaHeight : height = m_height;
+       return height;
+}
+
+inline int AudioClipView::type() const {return Type;}
+
+
+
+#endif
+
+//eof

Index: ClipsViewPort.cpp
===================================================================
RCS file: ClipsViewPort.cpp
diff -N ClipsViewPort.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ ClipsViewPort.cpp   21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,221 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "ClipsViewPort.h"
+
+#include "SheetWidget.h"
+#include "SheetView.h"
+#include "TrackView.h"
+#include "ViewItem.h"
+#include <libtraversocore.h>
+#include <Import.h>
+#include <CommandGroup.h>
+#include "RemoveClip.h"
+
+#include "AudioDevice.h"
+
+#include <QScrollBar>
+#include <QSet>
+#include <QPaintEngine>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+               
+#include <Debugger.h>
+               
+ClipsViewPort::ClipsViewPort(QGraphicsScene* scene, SheetWidget* sw)
+       : ViewPort(scene, sw)
+{
+
+       m_sw = sw;
+       viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
+       
+//     setViewportUpdateMode(SmartViewportUpdate);
+       setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+void ClipsViewPort::get_pointed_context_items(QList<ContextItem* > &list)
+{
+       QList<QGraphicsItem *> itemlist = 
items(cpointer().on_first_input_event_x(), cpointer().on_first_input_event_y());
+       foreach(QGraphicsItem* item, itemlist) {
+               if (ViewItem::is_viewitem(item)) {
+                       list.append((ViewItem*)item);
+               }
+       }
+       list.append(m_sw->get_sheetview());
+}
+
+void ClipsViewPort::resizeEvent( QResizeEvent * e )
+{
+       ViewPort::resizeEvent(e);
+       m_sw->get_sheetview()->update_scrollbars();
+}
+
+
+void ClipsViewPort::paintEvent(QPaintEvent * e)
+{
+       QGraphicsView::paintEvent(e);
+}
+
+
+void ClipsViewPort::dragEnterEvent( QDragEnterEvent * event )
+{
+       m_imports.clear();
+       m_resourcesImport.clear();
+       
+       // let's see if the D&D was from the resources bin.
+       if 
(event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
+               QByteArray encodedData = 
event->mimeData()->data("application/x-qabstractitemmodeldatalist");
+               QDataStream stream(&encodedData, QIODevice::ReadOnly);
+               int r, c;
+               QMap<int, QVariant> v;
+               
+               while (!stream.atEnd()) {
+                       stream >> r >> c >> v;
+                       qint64 id = v.value(Qt::UserRole).toLongLong();
+                       if (!id) {
+                               continue;
+                       }
+                       m_resourcesImport.append(id);
+               }
+       }
+       
+       // and who knows, it could have been a D&D drop from a filemanager...
+       if (event->mimeData()->hasUrls()) {
+
+               foreach(QUrl url, event->mimeData()->urls()) {
+                       QString fileName = url.toLocalFile();
+                       
+                       if (fileName.isEmpty()) {
+                               continue;
+                       }
+                       
+                       Import* import = new Import(fileName);
+                       m_imports.append(import);
+                       
+                       // If a readsource fails to init, the D&D should be
+                       // marked as failed, cleanup allready created imports,
+                       // and clear the import list.
+                       if (import->create_readsource() == -1) {
+                               foreach(Import* import, m_imports) {
+                                       delete import;
+                               }
+                               m_imports.clear();
+                               break;
+                       }
+               }
+       }
+       
+       if (m_imports.size() || m_resourcesImport.size()) {
+               event->acceptProposedAction();
+       }
+}
+
+void ClipsViewPort::dropEvent(QDropEvent* event )
+{
+       PENTER;
+       Q_UNUSED(event)
+       
+       if (!importTrack) {
+               return;
+       }
+
+       CommandGroup* group = new CommandGroup(m_sw->get_sheet(), 
+                      tr("Import %n audiofile(s)", "", m_imports.size() + 
m_resourcesImport.size()), true);
+       
+       TimeRef startpos = TimeRef(mapFromGlobal(QCursor::pos()).x() * 
m_sw->get_sheetview()->timeref_scalefactor);
+       
+       foreach(qint64 id, m_resourcesImport) {
+               AudioClip* clip = resources_manager()->get_clip(id);
+               if (clip) {
+                       bool hadSheet = clip->has_sheet();
+                       clip->set_sheet(m_sw->get_sheet());
+                       clip->set_track(importTrack);
+                       if (!hadSheet) {
+                               clip->set_state(clip->get_dom_node());
+                       }
+                       clip->set_track_start_location(startpos);
+                       startpos = clip->get_track_end_location();
+                       AddRemoveClip* arc = new AddRemoveClip(clip, 
AddRemoveClip::ADD);
+                       group->add_command(arc);
+                       continue;
+               }
+               ReadSource* source = resources_manager()->get_readsource(id);
+               if (source) {
+                       clip = 
resources_manager()->new_audio_clip(source->get_short_name());
+                       resources_manager()->set_source_for_clip(clip, source);
+                       clip->set_sheet(importTrack->get_sheet());
+                       clip->set_track(importTrack);
+                       clip->set_track_start_location(startpos);
+                       startpos = clip->get_track_end_location();
+                       AddRemoveClip* arc = new AddRemoveClip(clip, 
AddRemoveClip::ADD);
+                       group->add_command(arc);
+               }
+       }
+       
+       bool firstItem = true;
+       foreach(Import* import, m_imports) {
+               import->set_track(importTrack);
+               if (firstItem) {
+                       // Place first item at cursor, others at end of track.
+                       import->set_position(startpos);
+                       firstItem = false;
+               }
+               group->add_command(import);
+       }
+
+       Command::process_command(group);
+}
+
+void ClipsViewPort::dragMoveEvent( QDragMoveEvent * event )
+{
+       Q_UNUSED(event)
+                       
+       Project* project = pm().get_project();
+       if (!project) {
+               return;
+       }
+       
+       Sheet* sheet = project->get_current_sheet();
+       
+       if (!sheet) {
+               return;
+       }
+       
+       importTrack = 0;
+       
+       // hmmm, code below is candidate for improvements...?
+       
+       // no mouse move events during D&D move events...
+       // So we need to calculate the scene pos ourselves.
+       QPointF mouseposTosScene = mapFromGlobal(QCursor::pos());
+       
+       QList<QGraphicsItem *> itemlist = items((int)mouseposTosScene.x(), 
(int)mouseposTosScene.y());
+       foreach(QGraphicsItem* obj, itemlist) {
+               TrackView* tv = dynamic_cast<TrackView*>(obj);
+               if (tv) {
+                       importTrack = tv->get_track();
+                       return;
+               }
+       }
+}
+

Index: ClipsViewPort.h
===================================================================
RCS file: ClipsViewPort.h
diff -N ClipsViewPort.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ ClipsViewPort.h     21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,60 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef CLIPS_VIEW_PORT_H
+#define CLIPS_VIEW_PORT_H
+
+#include <QGraphicsScene>
+#include <QGraphicsItem>
+#include <QStyleOptionGraphicsItem>
+
+#include "ViewPort.h"
+
+class SheetWidget;
+class Import;
+               
+class ClipsViewPort : public ViewPort
+{
+       Q_OBJECT
+
+public:
+       ClipsViewPort(QGraphicsScene* scene, SheetWidget* sw);
+       ~ClipsViewPort() {};
+       
+        void get_pointed_context_items(QList<ContextItem* > &list);
+
+protected:
+        void resizeEvent(QResizeEvent* e);
+       void paintEvent( QPaintEvent* e);
+       void dragEnterEvent(QDragEnterEvent *event);
+       void dropEvent(QDropEvent *event);
+       void dragMoveEvent(QDragMoveEvent *event);
+private:
+       SheetWidget*    m_sw;
+       QList<Import*>  m_imports;
+       QList<qint64 >  m_resourcesImport;
+       Track*          importTrack;
+};
+
+
+#endif
+
+//eof

Index: cmake_install.cmake
===================================================================
RCS file: cmake_install.cmake
diff -N cmake_install.cmake
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ cmake_install.cmake 21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,34 @@
+# Install script for directory: 
/home/remon/projecten/traversodevelopment/traverso/src/traverso/songcanvas
+
+# Set the install prefix
+IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  SET(CMAKE_INSTALL_PREFIX "/usr/local")
+ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
+STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+IF(NOT CMAKE_INSTALL_CONFIG_NAME)
+  IF(BUILD_TYPE)
+    STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+  ELSE(BUILD_TYPE)
+    SET(CMAKE_INSTALL_CONFIG_NAME "RELEASE")
+  ENDIF(BUILD_TYPE)
+  MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME)
+
+# Set the component getting installed.
+IF(NOT CMAKE_INSTALL_COMPONENT)
+  IF(COMPONENT)
+    MESSAGE(STATUS "Install component: \"${COMPONENT}\"")
+    SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+  ELSE(COMPONENT)
+    SET(CMAKE_INSTALL_COMPONENT)
+  ENDIF(COMPONENT)
+ENDIF(NOT CMAKE_INSTALL_COMPONENT)
+
+# Install shared libraries without execute permission?
+IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+  SET(CMAKE_INSTALL_SO_NO_EXE "1")
+ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+

Index: CMakeLists.txt
===================================================================
RCS file: CMakeLists.txt
diff -N CMakeLists.txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ CMakeLists.txt      21 Jan 2008 16:17:27 -0000      1.1
@@ -0,0 +1,84 @@
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/src/commands
+${CMAKE_SOURCE_DIR}/src/common
+${CMAKE_SOURCE_DIR}/src/core
+${CMAKE_SOURCE_DIR}/src/engine
+${CMAKE_SOURCE_DIR}/src/plugins
+${CMAKE_SOURCE_DIR}/src/plugins/native
+${CMAKE_SOURCE_DIR}/src/plugins/LV2
+${CMAKE_SOURCE_DIR}/src/3rdparty/slv2
+${CMAKE_SOURCE_DIR}/src/traverso
+${CMAKE_SOURCE_DIR}/src/traverso/dialogs
+${QT_QTGUI_INCLUDE_DIR}
+${QT_QTXML_INCLUDE_DIR}
+)
+
+IF(HAVE_OPENGL)
+INCLUDE_DIRECTORIES(
+${QT_QTOPENGL_INCLUDE_DIR}
+)
+ENDIF(HAVE_OPENGL)
+
+SET(TRAVERSO_SONGCANVAS_SOURCES
+AudioClipView.cpp
+ClipsViewPort.cpp
+Cursors.cpp
+CurveNodeView.cpp
+CurveView.cpp
+FadeContextDialogView.cpp
+FadeView.cpp
+MarkerView.cpp
+PluginChainView.cpp
+PluginView.cpp
+PositionIndicator.cpp
+SheetView.cpp
+SheetWidget.cpp
+TimeLineView.cpp
+TimeLineViewPort.cpp
+TrackPanelView.cpp
+TrackPanelViewPort.cpp
+TrackView.cpp
+ViewItem.cpp
+dialogs/AudioClipEditDialog.cpp
+)
+
+SET(TRAVERSO_SONGCANVAS_MOC_CLASSES
+AudioClipView.h
+ClipsViewPort.h
+Cursors.h
+CurveNodeView.h
+FadeView.h
+MarkerView.h
+PluginChainView.h
+PluginView.h
+PositionIndicator.h
+TrackView.h
+ViewItem.h
+dialogs/AudioClipEditDialog.h
+CurveView.h
+SheetView.h
+SheetWidget.h
+TrackPanelView.h
+TimeLineView.h
+LineView.h
+)
+
+SET(TRAVERSO_SONGCANVAS_UI_FILES
+ui/AudioClipEditDialog.ui
+)
+
+QT4_WRAP_CPP(TRAVERSO_SONGCANVAS_MOC_SOURCES 
${TRAVERSO_SONGCANVAS_MOC_CLASSES})
+QT4_WRAP_UI(TRAVERSO_SONGCANVAS_UI_SOURCES ${TRAVERSO_SONGCANVAS_UI_FILES})
+
+
+SET(TRAVERSO_SONGCANVAS_LIBRARY "traversosheetcanvas")
+
+ADD_LIBRARY(${TRAVERSO_SONGCANVAS_LIBRARY} STATIC 
+       ${TRAVERSO_SONGCANVAS_SOURCES} 
+       ${TRAVERSO_SONGCANVAS_MOC_SOURCES} 
+       ${TRAVERSO_SONGCANVAS_UI_SOURCES}
+)
+
+IF(USE_PCH)
+    ADD_DEPENDENCIES(traversosheetcanvas precompiled_headers)
+ENDIF(USE_PCH)

Index: Cursors.cpp
===================================================================
RCS file: Cursors.cpp
diff -N Cursors.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Cursors.cpp 21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,315 @@
+/*
+    Copyright (C) 2005-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#include "Cursors.h"
+#include "SheetView.h"
+#include "ClipsViewPort.h"
+#include "AudioDevice.h"
+#include <QPen>
+#include <Sheet.h>
+#include <Config.h>
+#include <Themer.h>
+#include <QScrollBar>
+               
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+#define ANIME_DURATION         1000
+#define AUTO_SCROLL_MARGIN     0.05  // autoscroll when within 5% of the clip 
view port
+
+
+PlayHead::PlayHead(SheetView* sv, Sheet* sheet, ClipsViewPort* vp)
+       : ViewItem(0, sheet)
+       , m_sheet(sheet)
+       , m_vp(vp)
+{
+       m_sv = sv;
+       check_config();
+       connect(&(config()), SIGNAL(configChanged()), this, 
SLOT(check_config()));
+       
+       // TODO: Make duration scale with scalefactor? (nonlinerly?)
+       m_animation.setDuration(ANIME_DURATION);
+       m_animation.setCurveShape(QTimeLine::SineCurve);
+       
+       connect(m_sheet, SIGNAL(transferStarted()), this, SLOT(play_start()));
+       connect(m_sheet, SIGNAL(transferStopped()), this, SLOT(play_stop()));
+       
+       connect(&m_playTimer, SIGNAL(timeout()), this, SLOT(update_position()));
+       
+       connect(&m_animation, SIGNAL(frameChanged(int)), this, 
SLOT(set_animation_value(int)));
+       connect(&m_animation, SIGNAL(finished()), this, 
SLOT(animation_finished()));
+       
+       setFlag(QGraphicsItem::ItemIgnoresTransformations);
+       setZValue(99);
+}
+
+PlayHead::~PlayHead( )
+{
+        PENTERDES2;
+}
+
+void PlayHead::check_config( )
+{
+       m_mode = (PlayHeadMode) config().get_property("PlayHead", "Scrollmode", 
ANIMATED_FLIP_PAGE).toInt();
+       m_follow = config().get_property("PlayHead", "Follow", true).toBool();
+}
+
+void PlayHead::paint( QPainter * painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget )
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       QColor color;
+       
+       if (m_sheet->is_transport_rolling()) {
+               color = themer()->get_color("Playhead:active");
+       } else {
+               color = themer()->get_color("Playhead:inactive");
+       }
+       
+       painter->fillRect(0, 0, (int)m_boundingRect.width(), 
(int)m_boundingRect.height(), color);
+}
+
+void PlayHead::play_start()
+{
+       show();
+
+       m_followDisabled = false;
+
+       m_playTimer.start(20);
+       
+       if (m_animation.state() == QTimeLine::Running) {
+               m_animation.stop();
+               m_animation.setCurrentTime(0);
+       }
+}
+
+void PlayHead::play_stop()
+{
+       m_playTimer.stop();
+
+       if (m_animation.state() == QTimeLine::Running) {
+               m_animation.stop();
+               m_animation.setCurrentTime(0);
+       }
+
+       update();
+}
+
+void PlayHead::disable_follow()
+{
+       m_followDisabled = true;
+}
+
+void PlayHead::enable_follow()
+{
+       m_followDisabled = false;
+       // This function is called after the sheet finished a seek action.
+       // if the sheet is still playing, update our position, and start moving 
again!
+       if (m_sheet->is_transport_rolling()) {
+               play_start();
+       }
+}
+
+void PlayHead::update_position()
+{
+       QPointF newPos(m_sheet->get_transport_location() / 
m_sv->timeref_scalefactor, 1);
+       qreal playBufferTimePositionCompensation = 0;
+       if (m_sheet->is_transport_rolling()) {
+               playBufferTimePositionCompensation = 
audiodevice().get_buffer_latency() / m_sv->timeref_scalefactor;
+       }
+       qreal newXPos = newPos.x() - playBufferTimePositionCompensation;
+       if (newXPos < 0.0) {
+               newXPos = 0.0;
+       }
+       newPos.setX(newXPos);
+       
+       if (int(newPos.x()) != int(pos().x()) && (m_animation.state() != 
QTimeLine::Running)) {
+               setPos(newPos);
+       } else {
+               return;
+       }
+       
+       if ( ! m_follow || m_followDisabled || ! 
m_sheet->is_transport_rolling()) {
+               return;
+       }
+       
+       int vpWidth = m_vp->viewport()->width();
+       
+       if (m_mode == CENTERED) {
+               m_sv->set_hscrollbar_value(int(scenePos().x()) - (int)(0.5 * 
vpWidth));
+               return;
+       }
+        
+       QPoint vppoint = m_vp->mapFromScene(pos());
+       
+       if (vppoint.x() < 0 || (vppoint.x() > vpWidth)) {
+               
+               // If the playhead is _not_ in the viewports range, center it 
in the middle!
+               m_sv->set_hscrollbar_value(int(scenePos().x()) - (int)(0.5 * 
vpWidth));
+       
+       } else if (vppoint.x() > ( vpWidth * (1.0 - AUTO_SCROLL_MARGIN) )) {
+               
+               // If the playhead is in the viewports range, and is nearing 
the end
+               // either start the animated flip page, or flip the page and 
place the 
+               // playhead cursor ~ 1/10 from the left viewport border
+               if (m_mode == ANIMATED_FLIP_PAGE) {
+                       if (m_animation.state() != QTimeLine::Running) {
+                               m_animFrameRange = (int)(vpWidth * (1.0 - 
(AUTO_SCROLL_MARGIN * 2)));
+                               m_totalAnimValue = 0;
+                               m_animation.setFrameRange(0, m_animFrameRange);
+                               calculate_total_anim_frames();
+                               m_animationScrollStartPos = 
m_sv->hscrollbar_value();
+                               //during the animation, we stop the play update 
timer
+                               // to avoid unnecessary update/paint events
+                               play_stop();
+                               m_animation.start();
+                       }
+               } else {
+                       m_sv->set_hscrollbar_value((int) (int(scenePos().x()) - 
(AUTO_SCROLL_MARGIN * vpWidth)) );
+               }
+       }
+}
+
+
+void PlayHead::set_animation_value(int value)
+{
+       QPointF newPos(m_sheet->get_transport_location() / 
m_sv->timeref_scalefactor, 0);
+       // calculate the motion distance of the playhead.
+       qreal deltaX = newPos.x() - pos().x();
+       
+       // calculate the animation x diff.
+       int diff = (int)(0.5 + ((float)(value) / m_totalAnimFrames) * 
m_animFrameRange);
+       m_totalAnimValue += (int)(diff + deltaX);
+       int newXPos = (int)(m_animationScrollStartPos + m_totalAnimValue);
+       
+       if (newPos != pos()) {
+               setPos(newPos);
+       }
+       
+       m_sv->set_hscrollbar_value(newXPos);
+}
+
+void PlayHead::calculate_total_anim_frames()
+{
+       int count = (ANIME_DURATION / 40);
+       m_totalAnimFrames = 0;
+       for (int i=0; i<count; ++i) {
+               m_totalAnimFrames += m_animation.frameForTime(i*40);
+       }
+}
+
+
+void PlayHead::animation_finished()
+{
+       if (m_sheet->is_transport_rolling()) {
+               play_start();
+       }
+}
+
+
+void PlayHead::set_bounding_rect( QRectF rect )
+{
+       m_boundingRect = rect;
+}
+
+bool PlayHead::is_active()
+{
+       return m_playTimer.isActive();
+}
+
+void PlayHead::set_active(bool active)
+{
+       if (active) {
+               play_start();
+       } else {
+               play_stop();
+       }
+}
+
+void PlayHead::set_mode( PlayHeadMode mode )
+{
+       m_mode = mode;
+}
+
+void PlayHead::toggle_follow( )
+{
+       m_follow = ! m_follow;
+}
+
+
+
+/**************************************************************/
+/*                    WorkCursor                              */
+/**************************************************************/
+
+
+WorkCursor::WorkCursor(SheetView* sv, Sheet* sheet)
+       : ViewItem(0, sheet)
+       , m_sheet(sheet)
+       , m_sv(sv)
+{
+       setFlag(QGraphicsItem::ItemIgnoresTransformations);
+       setZValue(100);
+}
+
+WorkCursor::~WorkCursor( )
+{
+        PENTERDES2;
+}
+
+void WorkCursor::paint( QPainter * painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget )
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       if (m_pix.height() != int(m_boundingRect.height())) {
+               update_background();
+       }
+       
+       painter->drawPixmap(0, 0, int(m_boundingRect.width()), 
int(m_boundingRect.height()), m_pix);
+}
+
+void WorkCursor::update_position()
+{
+       setPos(m_sheet->get_work_location() / m_sv->timeref_scalefactor, 1);
+}
+
+void WorkCursor::set_bounding_rect( QRectF rect )
+{
+       m_boundingRect = rect;
+}
+
+void WorkCursor::update_background()
+{
+       m_pix = QPixmap(int(m_boundingRect.width()), 
int(m_boundingRect.height()));
+       m_pix.fill(Qt::transparent);
+       QPainter p(&m_pix);
+       QPen pen;
+       pen.setWidth(4);
+       pen.setStyle(Qt::DashDotLine);
+       pen.setColor(themer()->get_color("Workcursor:default"));
+       p.setPen(pen);
+       p.drawLine(0, 0, int(m_boundingRect.width()), 
int(m_boundingRect.height()));
+}
+
+
+

Index: Cursors.h
===================================================================
RCS file: Cursors.h
diff -N Cursors.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Cursors.h   21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,111 @@
+/*
+    Copyright (C) 2005-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef CURSORS_H
+#define CURSORS_H
+
+#include "ViewItem.h"
+#include <QTimer>
+#include <QTimeLine>
+
+class Sheet;
+class SheetView;
+class ClipsViewPort;
+               
+class PlayHead : public ViewItem
+{
+        Q_OBJECT
+
+public:
+        PlayHead(SheetView* sv, Sheet* sheet, ClipsViewPort* vp);
+        ~PlayHead();
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void set_bounding_rect(QRectF rect);
+       
+       bool is_active();
+       void set_active(bool active);
+       
+       enum PlayHeadMode {
+               FLIP_PAGE,
+               CENTERED,
+               ANIMATED_FLIP_PAGE
+       };
+       
+       void set_mode(PlayHeadMode mode);
+       void toggle_follow();
+
+private:
+       Sheet*          m_sheet;
+        QTimer         m_playTimer;
+        QTimeLine      m_animation;
+        ClipsViewPort* m_vp;
+        bool           m_follow;
+       bool            m_followDisabled;
+        PlayHeadMode   m_mode;
+        int            m_animationScrollStartPos;
+       int             m_animFrameRange;
+       int             m_totalAnimFrames;
+       int             m_totalAnimValue;
+       
+       void calculate_total_anim_frames();
+
+private slots:
+       void check_config();
+        void play_start();
+        void play_stop();
+        void set_animation_value(int);
+        void animation_finished();
+        
+public slots:
+        void update_position();
+        void enable_follow();  // enable/disable follow only do anything if 
following is
+        void disable_follow(); // enabled in the config
+};
+
+
+
+class WorkCursor : public ViewItem
+{
+        Q_OBJECT
+
+public:
+        WorkCursor(SheetView* sv, Sheet* sheet);
+        ~WorkCursor();
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void set_bounding_rect(QRectF rect);
+
+private:
+       Sheet*          m_sheet;
+       SheetView*      m_sv;
+       QPixmap         m_pix;
+       
+       void update_background();
+
+public slots:
+        void update_position();
+};
+
+
+#endif
+
+//eof

Index: CurveNodeView.cpp
===================================================================
RCS file: CurveNodeView.cpp
diff -N CurveNodeView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ CurveNodeView.cpp   21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,141 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "CurveNodeView.h"
+#include "SheetView.h"
+
+#include <QPainter>
+#include <QPen>
+#include <CurveNode.h>
+#include <Themer.h>
+#include <Curve.h>
+#include "CurveView.h"
+
+#include <Debugger.h>
+
+CurveNodeView::CurveNodeView( SheetView * sv, CurveView* curveview, CurveNode 
* node, Curve* guicurve)
+       : ViewItem(curveview, 0)
+       , CurveNode(guicurve, node->get_when(), node->get_value())
+       , m_node(node)
+{
+       PENTERCONS;
+       m_sv = sv;
+       m_curveview = curveview;
+       int size = themer()->get_property("CurveNode:diameter", 6).toInt();
+       setCursor(themer()->get_cursor("CurveNode"));
+       m_boundingRect = QRectF(0, 0, size, size);
+       load_theme_data();
+       
+       connect(m_node->m_curve, SIGNAL(nodePositionChanged()), this, 
SLOT(update_pos()));
+}
+
+CurveNodeView::~ CurveNodeView( )
+{
+       PENTERDES;
+}
+
+void CurveNodeView::paint( QPainter * painter, const QStyleOptionGraphicsItem 
* option, QWidget * widget )
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       painter->save();
+       
+       QPen pen;
+       pen.setColor(m_color);
+       
+       QPointF mapped = mapToParent(QPointF(0, 0));
+       int x = (int) mapped.x();
+       int y = (int) mapped.y();
+       int heightadjust = 0;
+       int widthadjust = 0;
+       
+       if ( (y + m_boundingRect.height()) > (int) 
m_parentViewItem->boundingRect().height() ) {
+               heightadjust = y - 
(int)m_parentViewItem->boundingRect().height() + (int) m_boundingRect.height();
+       }
+       
+       if ( (x + m_boundingRect.width()) > (int) 
m_parentViewItem->boundingRect().width() ) {
+               widthadjust = x - (int) 
m_parentViewItem->boundingRect().width() + (int) m_boundingRect.width();
+       }
+               
+//     printf("widthadjust is %d, heightadjust = %d\n", widthadjust, 
heightadjust);
+       if (x > 0) x = 0;
+       if (y > 0) y = 0;
+       
+       QRectF rect = m_boundingRect.adjusted(- x, - y, - widthadjust, 
-heightadjust);
+       painter->setClipRect(rect);
+       painter->setRenderHint(QPainter::Antialiasing);
+       painter->setPen(pen);
+       
+       QPainterPath path;
+       path.addEllipse(m_boundingRect);
+       
+       painter->fillPath(path, QBrush(m_color));
+       
+       painter->restore();
+} 
+
+
+void CurveNodeView::calculate_bounding_rect()
+{
+       update_pos();
+}
+
+
+void CurveNodeView::set_color(QColor color)
+{
+       m_color = color;
+}
+
+void CurveNodeView::update_pos( )
+{
+       qreal halfwidth = (m_boundingRect.width() / 2);
+       qreal parentheight = m_parentViewItem->boundingRect().height();
+       qreal when = ((TimeRef(m_node->get_when()) - 
m_curveview->get_start_offset()) / m_sv->timeref_scalefactor) - halfwidth;
+       qreal value = parentheight - (m_node->get_value() * parentheight + 
halfwidth);
+       setPos(when, value);
+               
+       set_when_and_value((m_node->get_when() / m_sv->timeref_scalefactor), 
m_node->get_value());
+}
+
+void CurveNodeView::set_selected( )
+{
+       int size = themer()->get_property("CurveNode:diameter", 6).toInt();
+       m_boundingRect.setWidth(size + 1);
+       m_boundingRect.setHeight(size + 1);
+       update_pos();
+}
+
+void CurveNodeView::reset_size( )
+{
+       int size = themer()->get_property("CurveNode:diameter", 6).toInt();
+       m_boundingRect.setWidth(size);
+       m_boundingRect.setHeight(size);
+       update_pos();
+}
+
+void CurveNodeView::load_theme_data()
+{
+       m_color = themer()->get_color("CurveNode:default");
+       calculate_bounding_rect();
+}
+
+

Index: CurveNodeView.h
===================================================================
RCS file: CurveNodeView.h
diff -N CurveNodeView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ CurveNodeView.h     21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,61 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef CURVE_NODE_VIEW_H
+#define CURVE_NODE_VIEW_H
+
+#include "ViewItem.h"
+
+#include <CurveNode.h>
+
+class CurveView;
+
+class CurveNodeView : public ViewItem, public CurveNode
+{
+       Q_OBJECT
+
+public:
+       CurveNodeView(SheetView* sv, CurveView* curveview, CurveNode* node, 
Curve* guicurve);
+       ~CurveNodeView();
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+       void set_selected();
+       void reset_size();
+       
+       void set_color(QColor color);
+       void load_theme_data();
+       CurveNode* get_curve_node() const {return m_node;}
+       
+private:
+       CurveView*      m_curveview;
+       CurveNode*      m_node;
+       QColor          m_color;
+
+public slots:
+       void update_pos();
+};
+
+#endif
+
+//eof
+ 
+ 

Index: CurveView.cpp
===================================================================
RCS file: CurveView.cpp
diff -N CurveView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ CurveView.cpp       21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,666 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "CurveView.h"
+#include "SheetView.h"
+#include "CurveNodeView.h"
+#include "ClipsViewPort.h"
+#include <Themer.h>
+#include "AudioDevice.h"
+               
+#include <Curve.h>
+#include <CurveNode.h>
+#include <ContextPointer.h>
+#include <Sheet.h>
+#include <InputEngine.h>
+
+#include <AddRemove.h>
+#include "CommandGroup.h"
+
+#include <Debugger.h>
+
+
+#define NODE_SOFT_SELECTION_DISTANCE 40
+       
+DragNode::DragNode(CurveNode* node,
+       CurveView* curveview,
+       qint64 scalefactor,
+       TimeRef rangeMin,
+       TimeRef rangeMax,
+       const QString& des)
+       : Command(curveview->get_context(), des)
+       , d(new Private)
+{
+       m_node = node;
+       d->rangeMin = rangeMin;
+       d->rangeMax = rangeMax;
+       d->curveView = curveview;
+       d->scalefactor = scalefactor;
+       d->verticalOnly = false;
+}
+
+void DragNode::set_vertical_only()
+{
+       d->verticalOnly = true;
+}
+
+int DragNode::prepare_actions()
+{
+       return 1;
+}
+
+int DragNode::finish_hold()
+{
+       delete d;
+       return 1;
+}
+
+void DragNode::cancel_action()
+{
+       delete d;
+       undo_action();
+}
+
+int DragNode::begin_hold()
+{
+       m_origWhen = m_newWhen = m_node->get_when();
+       m_origValue = m_newValue = m_node->get_value();
+       
+       d->mousepos = QPoint(cpointer().on_first_input_event_x(), 
cpointer().on_first_input_event_y());
+       return 1;
+}
+
+
+int DragNode::do_action()
+{
+       m_node->set_when_and_value(m_newWhen, m_newValue);
+       return 1;
+}
+
+int DragNode::undo_action()
+{
+       m_node->set_when_and_value(m_origWhen, m_origValue);
+       return 1;
+}
+
+void DragNode::move_up(bool )
+{
+       m_newValue = m_newValue + ( 1 / d->curveView->boundingRect().height());
+       calculate_and_set_node_values();
+}
+
+void DragNode::move_down(bool )
+{
+       m_newValue = m_newValue - ( 1 / d->curveView->boundingRect().height());
+       calculate_and_set_node_values();
+}
+
+void DragNode::set_cursor_shape(int useX, int useY)
+{
+       cpointer().get_viewport()->set_holdcursor(":/cursorHoldLrud");
+}
+
+int DragNode::jog()
+{
+       QPoint mousepos = cpointer().pos();
+       
+       int dx, dy;
+       dx = mousepos.x() - d->mousepos.x();
+       dy = mousepos.y() - d->mousepos.y();
+       
+       d->mousepos = mousepos;
+       
+       if (!d->verticalOnly) {
+               m_newWhen = m_newWhen + dx * d->scalefactor;
+       }
+       m_newValue = m_newValue - ( dy / d->curveView->boundingRect().height());
+       
+       TimeRef startoffset = d->curveView->get_start_offset();
+       if ( ((TimeRef(m_newWhen) - startoffset) / d->scalefactor) > 
d->curveView->boundingRect().width()) {
+               m_newWhen = double(d->curveView->boundingRect().width() * 
d->scalefactor + startoffset.universal_frame());
+       }
+       if ((TimeRef(m_newWhen) - startoffset) < TimeRef()) {
+               m_newWhen = startoffset.universal_frame();
+       }
+       
+       return calculate_and_set_node_values();
+}
+
+int DragNode::calculate_and_set_node_values()
+{
+       if (m_newValue < 0.0) {
+               m_newValue = 0.0;
+       }
+       if (m_newValue > 1.0) {
+               m_newValue = 1.0;
+       }
+       if (m_newWhen < 0.0) {
+               m_newWhen = 0.0;
+       }
+       
+       if (m_newWhen < d->rangeMin) {
+               m_newWhen = double(d->rangeMin.universal_frame());
+       } else if (d->rangeMax != qint64(-1) && m_newWhen > d->rangeMax) {
+               m_newWhen = double(d->rangeMax.universal_frame());
+       }
+
+       // NOTE: this obviously only makes sense when the Node == GainEnvelope 
Node
+       // Use a delegate (or something similar) in the future that set's the 
correct value.
+       float dbFactor = coefficient_to_dB(m_newValue);
+       
cpointer().get_viewport()->set_holdcursor_text(QByteArray::number(dbFactor, 
'f', 2).append(" dB"));
+       cpointer().get_viewport()->set_holdcursor_pos(d->mousepos +
+                       
QPoint(d->curveView->get_sheetview()->hscrollbar_value(),
+                       d->curveView->get_sheetview()->vscrollbar_value()) -
+                       QPoint(16, 16));
+       
+       return do_action();
+}
+
+
+               
+CurveView::CurveView(SheetView* sv, ViewItem* parentViewItem, Curve* curve)
+       : ViewItem(parentViewItem, curve)
+       , m_curve(curve)
+{
+       setZValue(parentViewItem->zValue() + 1);
+       
+       m_sv = sv;
+       load_theme_data();
+       
+       m_blinkColorDirection = 1;
+       m_blinkingNode = 0;
+       m_startoffset = TimeRef();
+       m_guicurve = new Curve(0);
+       m_guicurve->set_sheet(sv->get_sheet());
+       
+       apill_foreach(CurveNode* node, CurveNode, m_curve->get_nodes()) {
+               add_curvenode_view(node);
+       }
+       
+       connect(&m_blinkTimer, SIGNAL(timeout()), this, 
SLOT(update_blink_color()));
+       connect(m_curve, SIGNAL(nodeAdded(CurveNode*)), this, 
SLOT(add_curvenode_view(CurveNode*)));
+       connect(m_curve, SIGNAL(nodeRemoved(CurveNode*)), this, 
SLOT(remove_curvenode_view(CurveNode*)));
+       connect(m_curve, SIGNAL(nodePositionChanged()), this, 
SLOT(node_moved()));
+       connect(m_sv->get_sheet(), SIGNAL(modeChanged()), this, 
SLOT(set_view_mode()));
+       
+       setAcceptsHoverEvents(true);
+       
+       set_view_mode();
+}
+
+CurveView::~ CurveView( )
+{
+       m_guicurve->clear_curve();
+       delete m_guicurve;
+}
+
+static bool smallerpoint(const QPointF& left, const QPointF& right) {
+       return left.x() < right.x();
+}
+
+void CurveView::paint( QPainter * painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget )
+{
+       Q_UNUSED(widget);
+       PENTER2;
+       
+       
+       int xstart = (int) option->exposedRect.x();
+       int pixelcount = (int) option->exposedRect.width()+1;
+       int height = int(m_boundingRect.height());
+       int offset = int(m_startoffset / m_sv->timeref_scalefactor);
+       
+       QPen pen;
+       
+       if (m_sv->get_sheet()->get_mode() == Sheet::EFFECTS) {
+               pen.setColor(themer()->get_color("Curve:active"));
+       } else {
+               pen.setColor(themer()->get_color("Curve:inactive"));
+       }
+       
+       painter->save();
+       painter->setPen(pen);
+       painter->setClipRect(m_boundingRect);
+       
+       
+       if (m_nodeViews.size() == 1) {
+               int y = int(height - (m_nodeViews.first()->value * height));
+               painter->drawLine(xstart, y, xstart + pixelcount, y);
+               painter->restore();
+               return;
+       }
+       
+       if (m_nodeViews.first()->when > xstart) {
+               int y = int(height - (m_nodeViews.first()->value * height));
+               int length = int(m_nodeViews.first()->when) - xstart - offset;
+               if (length > 0) {
+                       painter->drawLine(xstart, y, xstart + length, y);
+                       xstart += length;
+                       pixelcount -= length;
+               }
+               if (pixelcount <= 0) {
+                       painter->restore();
+                       return;
+               }
+       }
+       
+       if (m_nodeViews.last()->when < (xstart + pixelcount + offset)) {
+               int y = int(height - (m_nodeViews.last()->value * height));
+               int x = int(m_nodeViews.last()->when) - offset;
+               int length = (xstart + pixelcount) - 
int(m_nodeViews.last()->when) + offset;
+               if (length > 0) {
+                       painter->drawLine(x, y, x + length - 1, y);
+                       pixelcount -= length;
+               }
+               if (pixelcount <= 0) {
+                       painter->restore();
+                       return;
+               }
+       }
+       
+       
+       // Path's need an additional pixel righ/left to be painted correctly.
+       // FadeView get_curve adjusts for this, if changing these 
+       // values, also change the adjustment in FadeView::get_curve() !!!
+       pixelcount += 2;
+       xstart -= 1;
+       if (xstart < 0) {
+               xstart = 0;
+       }
+       
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       QPolygonF polygon;
+       float vector[pixelcount];
+       
+//     printf("range: %d\n", (int)m_nodeViews.last()->pos().x());
+       m_guicurve->get_vector(xstart + offset,
+                               xstart + pixelcount + offset,
+                               vector,
+                               pixelcount);
+       
+       for (int i=0; i<pixelcount; i++) {
+               polygon <<  QPointF(xstart + i, height - (vector[i] * height) );
+       }
+       
+       // Depending on the zoom level, curve nodes can end up to be aligned 
+       // vertically at the exact same x position. The curve line won't be 
painted
+       // by the routine above (it doesn't catch the second node position 
obviously)
+       // so we add curvenodes _always_ to solve this problem easily :-)
+       apill_foreach(CurveNodeView* view, CurveNodeView, m_nodeViews) {
+               qreal x = view->x();
+               if ( (x > xstart) && x < (xstart + pixelcount)) {
+                       polygon <<  QPointF( x + view->boundingRect().width() / 
2,
+                               (height - (view->get_curve_node()->get_value() 
* height)) );
+               }
+       }
+       
+       // Which means we have to sort the polygon *sigh* (rather cpu costly, 
but what can I do?)
+       qSort(polygon.begin(), polygon.end(), smallerpoint);
+       
+/*     for (int i=0; i<polygon.size(); ++i) {
+               printf("polygin %d, x=%d, y=%d\n", i, (int)polygon.at(i).x(), 
(int)polygon.at(i).y());
+       }*/
+       
+       QPainterPath path;
+       path.addPolygon(polygon);
+       
+       painter->drawPath(path);
+       
+       if (xstart <= 100) {
+               
painter->setFont(themer()->get_font("CurveView:fontscale:label"));
+               painter->drawText(10, (int)(m_boundingRect.height() - 14), 
"Gain Curve");
+       }
+       
+       painter->restore();
+}
+
+int CurveView::get_vector(int xstart, int pixelcount, float* arg)
+{
+       if (m_guicurve->get_nodes().size() == 1 && 
((CurveNode*)m_guicurve->get_nodes().first())->value == 1.0) {
+               return 0;
+       }
+       
+       m_guicurve->get_vector(xstart, xstart + pixelcount, arg, pixelcount);
+       
+       return 1;
+}
+
+void CurveView::add_curvenode_view(CurveNode* node)
+{
+       CurveNodeView* nodeview = new CurveNodeView(m_sv, this, node, 
m_guicurve);
+#if QT_VERSION < 0x040300
+       m_sv->scene()->addItem(nodeview);
+#endif
+       m_nodeViews.append(nodeview);
+       
+       AddRemove* cmd = (AddRemove*) m_guicurve->add_node(nodeview, false);
+       cmd->set_instantanious(true);
+       Command::process_command(cmd);
+       
+       qSort(m_nodeViews.begin(), m_nodeViews.end(), Curve::smallerNode);
+       
+       update_softselected_node(cpointer().pos());
+       update();
+}
+
+void CurveView::remove_curvenode_view(CurveNode* node)
+{
+       apill_foreach(CurveNodeView* nodeview, CurveNodeView, m_nodeViews) {
+               if (nodeview->get_curve_node() == node) {
+                       m_nodeViews.removeAll(nodeview);
+                       if (nodeview == m_blinkingNode) {
+                               update_softselected_node(cpointer().pos());
+                       }
+                       AddRemove* cmd = (AddRemove*) 
m_guicurve->remove_node(nodeview, false);
+                       cmd->set_instantanious(true);
+                       Command::process_command(cmd);
+                       
+                       scene()->removeItem(nodeview);
+                       delete nodeview;
+                       update();
+                       return;
+               }
+       }
+}
+
+void CurveView::calculate_bounding_rect()
+{
+       int y  = m_parentViewItem->get_childview_y_offset();
+       m_boundingRect = QRectF(0, 0, m_parentViewItem->boundingRect().width(), 
m_parentViewItem->get_height());
+       setPos(0, y);
+       ViewItem::calculate_bounding_rect();
+}
+
+void CurveView::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
+{
+       Q_UNUSED(event);
+       
+       m_blinkTimer.start(40);
+}
+
+void CurveView::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
+{
+       Q_UNUSED(event);
+       
+       if (ie().is_holding()) {
+               event->ignore();
+               return;
+       }
+       
+       m_blinkTimer.stop();
+       if (m_blinkingNode) {
+               
m_blinkingNode->set_color(themer()->get_color("CurveNode:default"));
+               m_blinkingNode->reset_size();
+               m_blinkingNode = 0;
+       }
+}
+       
+       
+void CurveView::hoverMoveEvent ( QGraphicsSceneHoverEvent * event )
+{
+       QPoint point((int)event->pos().x(), (int)event->pos().y());
+       
+       update_softselected_node(point);
+
+       if (m_blinkingNode) {
+               setCursor(themer()->get_cursor("CurveNode"));
+       } else {
+               setCursor(themer()->get_cursor("AudioClip"));
+       }
+//     printf("mouse x,y pos %d,%d\n", point.x(), point.y());
+       
+//     printf("\n");
+}
+
+
+void CurveView::update_softselected_node( QPoint pos , bool force)
+{
+       if (ie().is_holding() && !force) {
+               return;
+       }
+       
+       CurveNodeView* prevNode = m_blinkingNode;
+       m_blinkingNode = m_nodeViews.first();
+       
+       if (! m_blinkingNode)
+               return;
+       
+       foreach(CurveNodeView* nodeView, m_nodeViews) {
+               
+               QPoint nodePos((int)nodeView->pos().x(), 
(int)nodeView->pos().y());
+//             printf("node x,y pos %d,%d\n", nodePos.x(), nodePos.y());
+               
+               int nodeDist = (pos - nodePos).manhattanLength();
+               int blinkNodeDist = (pos - QPoint((int)m_blinkingNode->x(), 
(int)m_blinkingNode->y())).manhattanLength();
+               
+               if (nodeDist < blinkNodeDist) {
+                       m_blinkingNode = nodeView;
+               }
+       }
+
+       if ((pos - QPoint(4, 4) - QPoint((int)m_blinkingNode->x(), 
(int)m_blinkingNode->y())).manhattanLength() > NODE_SOFT_SELECTION_DISTANCE) {
+               m_blinkingNode = 0;
+       }
+       
+       if (prevNode && (prevNode != m_blinkingNode) ) {
+               prevNode->set_color(themer()->get_color("CurveNode:default"));
+               prevNode->update();
+               prevNode->reset_size();
+               if (m_blinkingNode) {
+                       m_blinkingNode->set_selected();
+               }
+       }
+       if (!prevNode && m_blinkingNode) {
+               m_blinkingNode->set_selected();
+               m_blinkDarkness = 100;
+       }
+}
+
+
+void CurveView::update_blink_color()
+{
+       if (!m_blinkingNode) {
+               return;
+       }
+       
+       m_blinkDarkness += (6 * m_blinkColorDirection);
+       
+       if (m_blinkDarkness >= 100) {
+               m_blinkColorDirection *= -1;
+               m_blinkDarkness = 100;
+       } else if (m_blinkDarkness <= 40) {
+               m_blinkColorDirection *= -1;
+               m_blinkDarkness = 40;
+       }
+       
+       QColor blinkColor = themer()->get_color("CurveNode:blink");
+       
+       m_blinkingNode->set_color(blinkColor.light(m_blinkDarkness));
+       
+       m_blinkingNode->update();
+}
+
+
+Command* CurveView::add_node()
+{
+       PENTER;
+       QPointF point = mapFromScene(cpointer().scene_pos());
+
+       emit curveModified();
+       
+       double when = point.x() * double(m_sv->timeref_scalefactor) + 
m_startoffset.universal_frame();
+       double value = (m_boundingRect.height() - point.y()) / 
m_boundingRect.height();
+       
+       CurveNode* node = new CurveNode(m_curve, when, value);
+       
+       return m_curve->add_node(node);
+}
+
+
+Command* CurveView::remove_node()
+{
+       PENTER;
+
+       QPointF 
origPos(mapFromScene(QPoint(cpointer().on_first_input_event_scene_x(), 
cpointer().on_first_input_event_scene_y())));
+
+       emit curveModified();
+
+       update_softselected_node(QPoint((int)origPos.x(), (int)origPos.y()), 
true);
+
+       if (m_blinkingNode) {
+               CurveNode* node = m_blinkingNode->get_curve_node();
+               m_blinkingNode = 0;
+               return m_curve->remove_node(node);
+       }
+       return ie().did_not_implement();
+}
+
+Command* CurveView::drag_node()
+{
+       PENTER;
+
+       QPointF 
origPos(mapFromScene(QPoint(cpointer().on_first_input_event_scene_x(), 
cpointer().on_first_input_event_scene_y())));
+
+       update_softselected_node(QPoint((int)origPos.x(), (int)origPos.y()), 
true);
+       
+       if (m_blinkingNode) {
+               TimeRef min(qint64(0));
+               TimeRef max(qint64(-1));
+               APILinkedList nodeList = m_curve->get_nodes();
+               CurveNode* node = m_blinkingNode->get_curve_node();
+               int index = nodeList.indexOf(node);
+               
+               emit curveModified();
+               
+               if (index > 0) {
+                       min = 
qint64(((CurveNode*)nodeList.at(index-1))->get_when() + 1);
+               }
+               if (nodeList.size() > (index + 1)) {
+                       max = 
qint64(((CurveNode*)nodeList.at(index+1))->get_when() - 1);
+               }
+               return new DragNode(m_blinkingNode->get_curve_node(), this, 
m_sv->timeref_scalefactor, min, max, tr("Drag Node"));
+       }
+       return ie().did_not_implement();
+}
+
+
+Command * CurveView::drag_node_vertical_only()
+{
+       DragNode* drag = qobject_cast<DragNode*>(drag_node());
+       
+       if (!drag) {
+               return 0;
+       }
+       
+       drag->set_vertical_only();
+       
+       return drag;
+}
+
+
+void CurveView::node_moved( )
+{
+       if (!m_blinkingNode) {
+               update();
+               return;
+       }
+
+       CurveNodeView* prev = 0;
+       CurveNodeView* next = 0;
+       
+       int index = m_nodeViews.indexOf(m_blinkingNode);
+       int xleft = (int) m_blinkingNode->x(), xright = (int) 
m_blinkingNode->x();
+       int leftindex = index;
+       int count = 0;
+       
+       if (m_blinkingNode == m_nodeViews.first()) {
+               xleft = 0;
+       } else {
+               while ( leftindex > 0 && count < 2) {
+                       leftindex--;
+                       count++;
+               }
+               prev = m_nodeViews.at(leftindex);
+       }       
+       
+       
+       count = 0;
+       int rightindex = index;
+       
+       if (m_blinkingNode == m_nodeViews.last()) {
+               xright = (int) m_boundingRect.width();
+       } else {
+               while (rightindex < (m_nodeViews.size() - 1) && count < 2) {
+                       rightindex++;
+                       count++;
+               }
+               next = m_nodeViews.at(rightindex);
+       }
+       
+       
+       if (prev) xleft = (int) prev->x();
+       if (next) xright = (int) next->x();
+       
+       
+       update(xleft, 0, xright - xleft + 3, m_boundingRect.height());
+}
+
+void CurveView::set_view_mode()
+{
+       if (m_sv->get_sheet()->get_mode() == Sheet::EFFECTS) {
+               show();
+       } else {
+               hide();
+       }
+}
+
+void CurveView::load_theme_data()
+{
+       calculate_bounding_rect();
+}
+
+void CurveView::set_start_offset(const TimeRef& offset)
+{
+       m_startoffset = offset;
+}
+
+bool CurveView::has_nodes() const
+{
+       return m_guicurve->get_nodes().size() > 1 ? true : false;
+}
+
+float CurveView::get_default_value()
+{
+       return ((CurveNode*)m_guicurve->get_nodes().first())->value;
+}
+
+Command * CurveView::remove_all_nodes()
+{
+       CommandGroup* group = new CommandGroup(m_curve, tr("Clear Nodes"));
+
+       apill_foreach(CurveNode* node, CurveNode, m_curve->get_nodes()) {
+               group->add_command(m_curve->remove_node(node));
+       }
+
+       return group;
+
+}
+

Index: CurveView.h
===================================================================
RCS file: CurveView.h
diff -N CurveView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ CurveView.h 21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,151 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef CURVE_VIEW_H
+#define CURVE_VIEW_H
+
+#include "ViewItem.h"
+#include "Command.h"
+
+#include <QTimer>
+
+class Curve;
+class CurveNode;
+class CurveNodeView;
+class QPoint;
+class CurveView;
+
+class DragNode : public Command
+{
+       Q_OBJECT
+       Q_CLASSINFO("move_up", tr("Move Up"));
+       Q_CLASSINFO("move_down", tr("Move Down"));
+       
+public:
+       DragNode(CurveNode* node,
+               CurveView* curveview,
+               qint64 scalefactor,
+               TimeRef rangeMin,
+               TimeRef rangeMax,
+               const QString& des);
+
+       int prepare_actions();
+       int do_action();
+       int undo_action();
+       int finish_hold();
+       void cancel_action();
+       int begin_hold();
+       int jog();
+       void set_cursor_shape(int useX, int useY);
+       void set_vertical_only();
+
+private :
+       class   Private {
+               public:
+                       CurveView*      curveView;
+                       qint64          scalefactor;
+                       TimeRef         rangeMin;
+                       TimeRef         rangeMax;
+                       QPoint          mousepos;
+                       bool            verticalOnly;
+       };
+
+       Private* d;
+       CurveNode* m_node;
+       double  m_origWhen;
+       double  m_origValue;
+       double  m_newWhen;
+       double  m_newValue;
+       
+       int calculate_and_set_node_values();
+
+
+public slots:
+       void move_up(bool autorepeat);
+       void move_down(bool autorepeat);
+};
+
+
+class CurveView : public ViewItem
+{
+       Q_OBJECT
+       Q_CLASSINFO("add_node", tr("New node"))
+       Q_CLASSINFO("remove_node", tr("Remove node"))
+       Q_CLASSINFO("remove_all_nodes", tr("Remove all Nodes"))
+       Q_CLASSINFO("drag_node", tr("Move node"))
+       Q_CLASSINFO("drag_node_vertical_only", tr("Move node (vertical only)"))
+
+public:
+       CurveView(SheetView* sv, ViewItem* parentViewItem, Curve* curve);
+       ~CurveView();
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       int get_vector(int xstart, int pixelcount, float *arg);
+       bool has_nodes() const;
+       float get_default_value();
+       void calculate_bounding_rect();
+       void load_theme_data();
+       
+       void set_start_offset(const TimeRef& offset);
+       const TimeRef& get_start_offset() const {return m_startoffset;}
+       
+
+protected:
+       void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
+       void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
+       void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
+
+private:
+       Curve*          m_curve;
+       Curve*          m_guicurve;
+       QTimer          m_blinkTimer;
+       CurveNodeView*  m_blinkingNode;
+       int             m_blinkDarkness;
+       int             m_blinkColorDirection;
+       QList<CurveNodeView*>   m_nodeViews;
+       TimeRef         m_startoffset;
+       
+       void update_softselected_node(QPoint pos, bool force = false);
+
+public slots:
+       Command* add_node();
+       Command* remove_node();
+       Command* remove_all_nodes();
+       Command* drag_node();
+       Command* drag_node_vertical_only();
+       
+private slots:
+       void add_curvenode_view(CurveNode* node);
+       void remove_curvenode_view(CurveNode* node);
+       void node_moved();
+       void set_view_mode();
+       void update_blink_color();
+       
+signals :
+       // emit from the gui so that we can stop following the playhead only
+       // when the user manually edits, not on undo/redo
+       void curveModified();
+};
+
+#endif
+
+//eof
+ 

Index: FadeContextDialogView.cpp
===================================================================
RCS file: FadeContextDialogView.cpp
diff -N FadeContextDialogView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ FadeContextDialogView.cpp   21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,162 @@
+/*
+Copyright (C) 2006 Remon Sijrier, Nicola Doebelin
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: FadeContextDialogView.cpp,v 1.1 2008/01/21 16:17:28 r_sijrier Exp $
+*/
+
+#include "FadeContextDialogView.h"
+
+#include "ViewPort.h"
+#include "Themer.h"
+#include "FadeCurve.h"
+#include "CurveNode.h"
+#include "Command.h"
+#include <ContextPointer.h>
+
+#include <QPainterPath>
+
+#include <Debugger.h>
+
+static const int GRID_LINES            = 4;
+static const float RASTER_SIZE         = 0.05;
+static const int DOT_SIZE              = 6;
+static const QString DOT_COLOR         = "#78817B";
+static const QString INACTIVE_COLOR    = "#A6B2A9";
+
+
+FadeContextDialogView::FadeContextDialogView(ViewPort* viewPort, FadeCurve* 
fadeCurve)
+       : ViewItem(0, fadeCurve), m_vp(viewPort), m_fade(fadeCurve)
+{
+       connect(m_vp, SIGNAL(resized()), this, SLOT(resize()));
+       connect(m_fade, SIGNAL(stateChanged()), this, 
SLOT(schedule_for_repaint()));
+}
+
+
+FadeContextDialogView::~FadeContextDialogView()
+{}
+
+
+void FadeContextDialogView::paint(QPainter *painter, const 
QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+/*
+       // Draw the background pixmap
+       painter->drawPixmap(0, 0, background);
+
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       // Calculate and draw control points
+       int h = m_vp->height() - 1;
+       int w = m_vp->width() - 1;
+       QList<QPointF> points = m_fade->get_control_points();
+       QPoint p1(int(points.at(1).x() * w + 0.5), h - int(points.at(1).y() * h 
+ 0.5));
+       QPoint p2(w - int((1.0 - points.at(2).x()) * w + 0.5), int((1.0 - 
points.at(2).y()) * h + 0.5));
+
+       painter->setPen(QColor(DOT_COLOR));
+       painter->setBrush(QColor(DOT_COLOR));
+       
+       if (m_fade->get_fade_type() == FadeCurve::FadeOut) {
+               p1.setX(w - int((1 - points.at(2).x()) * w + 0.5));
+               p1.setY(h - int((1 - points.at(2).y()) * h + 0.5));
+               p2.setX(int((points.at(1).x()) * w + 0.5));
+               p2.setY(int((points.at(1).y()) * h + 0.5));
+               painter->drawLine(w, h, p1.x(), p1.y());
+               painter->drawLine(0, 0, p2.x(), p2.y());
+       } else {
+               painter->drawLine(0, h, p1.x(), p1.y());
+               painter->drawLine(w, 0, p2.x(), p2.y());
+       }
+       
+       painter->drawEllipse(p1.x() - DOT_SIZE/2, p1.y() - DOT_SIZE/2, 
DOT_SIZE, DOT_SIZE);
+       painter->drawEllipse(p2.x() - DOT_SIZE/2, p2.y() - DOT_SIZE/2, 
DOT_SIZE, DOT_SIZE);
+
+
+       QPolygonF polygon;
+       float value[2];
+       int step = 0;
+       int height = m_vp->height();
+       
+       int zoom = (int) m_fade->get_range() / m_vp->width();
+       
+       // Populate the polygon with enough points to draw a smooth curve.
+       // using a 2 pixel resolution, is sufficient enough
+       for (int i=0; i < m_vp->width(); i+=2) {
+               m_fade->get_vector(i * zoom, i * zoom + 1, value, 2);
+               polygon << QPointF( step, height - (value[1] * height) );
+               step += 2;
+       }
+
+       // Always add the uppermost point in the polygon path 
+       // since the above routine potentially does not include it.
+       polygon << QPointF(m_vp->width(), 0);
+       
+       // Draw the curve
+       QPainterPath path;
+       path.moveTo(0, m_vp->height());
+       path.addPolygon(polygon);
+       path.lineTo(0, 0);
+       path.closeSubpath();
+       
+       painter->setPen(Qt::NoPen);
+       painter->setBrush(QColor(255, 0, 255, 80));
+       
+       painter->drawPath(path);        
+*/
+}
+
+
+
+
+void FadeContextDialogView::create_background( )
+{
+       if (background.size() != m_vp->size()) {
+               background = QPixmap(m_vp->width(), m_vp->height());
+       }
+
+       QPainter painter(&background);
+       
+//     painter->setRenderHint(QPainter::Antialiasing);
+
+       // Background color
+       painter.fillRect(0, 0, m_vp->width(), m_vp->height(), 
themer()->get_color("CLIP_BG_DEFAULT"));
+
+       // grid lines
+       painter.setPen(QColor(INACTIVE_COLOR));
+       for (int i = 0; i <= GRID_LINES; i++) {
+               float d = (float)i / (float)GRID_LINES;
+               int x = (int)(m_vp->width() * d);
+               int y = (int)(m_vp->height() * d);
+               painter.drawLine(x, 0, x, m_vp->height());
+               painter.drawLine(0, y, m_vp->width(), y);
+       }
+
+}
+
+
+
+/******** SLOTS ***************/
+
+void FadeContextDialogView::resize( )
+{
+       create_background();
+}
+
+
+
+
+//eof

Index: FadeContextDialogView.h
===================================================================
RCS file: FadeContextDialogView.h
diff -N FadeContextDialogView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ FadeContextDialogView.h     21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,63 @@
+/*
+Copyright (C) 2006 Remon Sijrier, Nicola Doebelin
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: FadeContextDialogView.h,v 1.1 2008/01/21 16:17:28 r_sijrier Exp $
+*/
+
+#ifndef FADE_CONTEXT_DIALOG_VIEW_H
+#define FADE_CONTEXT_DIALOG_VIEW_H
+
+#include "ViewItem.h"
+
+#include <QPixmap>
+#include "Command.h"
+
+class ViewPort;
+class FadeCurve;
+
+class FadeContextDialogView : public ViewItem
+{
+       Q_OBJECT
+       
+public:
+       FadeContextDialogView(ViewPort* viewPort, FadeCurve* fadeCurve);
+       ~FadeContextDialogView();
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+        
+       QRect draw(QPainter& p);
+
+       float roundFloat(float f);
+
+private:
+       void create_background();
+       
+       QPixmap         background;
+       ViewPort*       m_vp;
+       FadeCurve*      m_fade;
+
+private slots:
+        void resize();
+};
+
+
+#endif
+
+//eof
+ 

Index: FadeView.cpp
===================================================================
RCS file: FadeView.cpp
diff -N FadeView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ FadeView.cpp        21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,297 @@
+/*
+Copyright (C) 2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: FadeView.cpp,v 1.1 2008/01/21 16:17:28 r_sijrier Exp $
+*/
+
+#include "FadeView.h"
+
+#include <QPainter>
+
+#include "FadeCurve.h"
+#include "AudioClipView.h"
+#include "FadeContextDialog.h"
+#include "SheetView.h"
+#include "Interface.h"
+#include <Themer.h>
+#include <Fade.h>
+#include <InputEngine.h>
+#include <AddRemove.h>
+
+#include <Sheet.h>
+#include <Utils.h>
+
+#include <Debugger.h>
+
+static const int DOT_SIZE              = 6;
+static const QString DOT_COLOR         = "#78817B";
+
+FadeView::FadeView(SheetView* sv, AudioClipView* parent, FadeCurve * fadeCurve 
)
+       : ViewItem(parent, fadeCurve)
+       , m_fadeCurve(fadeCurve)
+{
+       PENTERCONS;
+       m_sv = sv;
+       m_holdactive = false;
+       m_guicurve = new Curve(0);
+       m_guicurve->set_sheet(m_sv->get_sheet());
+       
+       
+       apill_foreach(CurveNode* node, CurveNode, m_fadeCurve->get_nodes()) {
+               CurveNode* guinode = new CurveNode(m_guicurve, 
+                               node->get_when() / m_sv->timeref_scalefactor,
+                               node->get_value());
+               AddRemove* cmd = (AddRemove*) m_guicurve->add_node(guinode, 
false);
+               cmd->set_instantanious(true);
+               Command::process_command(cmd);
+       }
+       
+       load_theme_data();
+       setAcceptsHoverEvents(true);
+       setCursor(themer()->get_cursor("Fade"));
+       
+       connect(m_fadeCurve, SIGNAL(stateChanged()), this, 
SLOT(state_changed()));
+       connect(m_fadeCurve, SIGNAL(rangeChanged()), this, 
SLOT(state_changed()));
+}
+
+
+FadeView::~ FadeView( )
+{
+       PENTERDES;
+       delete m_guicurve;
+}
+
+
+void FadeView::paint(QPainter *painter, const QStyleOptionGraphicsItem 
*option, QWidget *widget)
+{
+       Q_UNUSED(widget);
+       
+       
+       int pixelcount = (int) option->exposedRect.width();
+       
+       if (pixelcount == 0) {
+               return;
+       }
+       
+       pixelcount += 1;
+       
+       QPolygonF polygon;
+       int xstart = (int)option->exposedRect.x();
+       int vector_start = xstart;
+       int height = (int)m_boundingRect.height();
+       float vector[pixelcount];
+       
+       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut && 
m_guicurve->get_range() > m_parentViewItem->boundingRect().width()) {
+               vector_start += (int) (m_guicurve->get_range() - 
m_parentViewItem->boundingRect().width());
+       }
+       
+       m_guicurve->get_vector(vector_start, vector_start + pixelcount, vector, 
pixelcount);
+       
+       for (int i=0; i<pixelcount; i++) {
+               polygon <<  QPointF(xstart + i, height - (vector[i] * height) );
+       }
+       
+       
+       painter->save();
+       
painter->setClipRect(m_boundingRect.intersect(m_parentViewItem->boundingRect()));
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       QPainterPath path;
+       
+       path.addPolygon(polygon);
+       path.lineTo(xstart + 1 + pixelcount, 0);
+       path.lineTo(xstart + 1, 0);
+       path.closeSubpath();
+       
+       painter->setPen(Qt::NoPen);
+       
+       QColor color = m_fadeCurve->is_bypassed() ? 
+                       themer()->get_color("Fade:bypassed") :
+                       themer()->get_color("Fade:default");
+       
+       if (option->state & QStyle::State_MouseOver) {
+               color.setAlpha(color.alpha() + 10);
+       }
+       
+       painter->setBrush(color);
+       painter->drawPath(path);        
+
+
+       if (m_holdactive) {
+               // Calculate and draw control points
+               int h = (int) m_boundingRect.height() - 1;
+               int w = (int) m_boundingRect.width() - 1;
+               QList<QPointF> points = m_fadeCurve->get_control_points();
+               QPoint p1(int(points.at(1).x() * w + 0.5), h - 
int(points.at(1).y() * h + 0.5));
+               QPoint p2(w - int((1.0 - points.at(2).x()) * w + 0.5), int((1.0 
- points.at(2).y()) * h + 0.5));
+       
+               painter->setPen(QColor(DOT_COLOR));
+               painter->setBrush(QColor(DOT_COLOR));
+               
+               if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
+                       p1.setX(w - int((1 - points.at(2).x()) * w + 0.5));
+                       p1.setY(h - int((1 - points.at(2).y()) * h + 0.5));
+                       p2.setX(int((points.at(1).x()) * w + 0.5));
+                       p2.setY(int((points.at(1).y()) * h + 0.5));
+                       painter->drawLine(w, h, p1.x(), p1.y());
+                       painter->drawLine(0, 0, p2.x(), p2.y());
+               } else {
+                       painter->drawLine(0, h, p1.x(), p1.y());
+                       painter->drawLine(w, 0, p2.x(), p2.y());
+               }
+               
+               painter->drawEllipse(p1.x() - DOT_SIZE/2, p1.y() - DOT_SIZE/2, 
DOT_SIZE, DOT_SIZE);
+               painter->drawEllipse(p2.x() - DOT_SIZE/2, p2.y() - DOT_SIZE/2, 
DOT_SIZE, DOT_SIZE);
+       }
+       
+       painter->restore();
+}
+
+int FadeView::get_vector(int xstart, int pixelcount, float * arg)
+{
+       // If boundingrect width is smaller then a pixel, don't even try
+       if (m_boundingRect.width() < 1.0) {
+               return 0;
+       }
+       
+       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
+               
+               // If the fade widt is larger the the clipview, add the 
difference,
+               // since the 'start' of the fadeview lies beyond the left edge 
of the clip!
+               if (m_boundingRect.width() > 
m_parentViewItem->boundingRect().width()) {
+                       xstart += (int)(m_boundingRect.width() - 
m_parentViewItem->boundingRect().width());
+               }
+               
+               // map the xstart position to the fadeviews x position
+               int mappedx = (int)mapFromParent(QPoint(xstart, 0)).x();
+               int x = mappedx;
+               float* p = arg;
+               
+               // check if the xstart lies before 'our' first pixel
+               if (mappedx < 0) {
+                       x = 0;
+                       // substract the difference from the pixelcount
+                       pixelcount += mappedx;
+                       
+                       // point to the mapped location of the buffer.
+                       p = arg - mappedx;
+                       
+                       // and if pixelcount is 0, there is nothing to do!
+                       if (pixelcount <= 0) {
+                               return 0;
+                       }
+                       
+                       // Any pixels outside of our range shouldn't alter the 
waveform,
+                       // so let's assign 1 to them!
+                       for (int i=0; i < - mappedx; ++i) {
+                               arg[i] = 1;
+                       }
+               }
+
+               m_guicurve->get_vector(x, x + pixelcount, p, pixelcount);
+               
+               return 1;
+       }
+       
+       if (xstart < m_boundingRect.width()) {
+               m_guicurve->get_vector(xstart, xstart + pixelcount, arg, 
pixelcount);
+               return 1;
+       }
+       
+       return 0;
+}
+
+void FadeView::calculate_bounding_rect()
+{
+       APILinkedList guinodes = m_guicurve->get_nodes();
+       APILinkedList nodes = m_fadeCurve->get_nodes();
+       
+       APILinkedListNode* node = nodes.first();
+       APILinkedListNode* guinode = guinodes.first();
+       
+       while (node) {
+               CurveNode* cnode = (CurveNode*)node;
+               CurveNode* cguinode = (CurveNode*)guinode;
+               
+               cguinode->set_when_and_value(cnode->get_when() / 
m_sv->timeref_scalefactor, cnode->get_value());
+               
+               node = node->next;
+               guinode = guinode->next;
+       }
+       
+       double range = m_guicurve->get_range();
+       m_boundingRect = QRectF( 0, 0, range, m_parentViewItem->get_height() );
+       
+       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
+               int diff = 0;
+               if (m_boundingRect.width() > 
m_parentViewItem->boundingRect().width()) {
+                       diff = (int)(m_boundingRect.width() - 
m_parentViewItem->boundingRect().width());
+               }
+               setPos(m_parentViewItem->boundingRect().width() - 
m_boundingRect.width() + diff, 
+                      m_parentViewItem->get_childview_y_offset());
+       } else {
+               setPos(0, m_parentViewItem->get_childview_y_offset());
+       }
+}
+
+
+void FadeView::state_changed( )
+{
+       PENTER;
+       prepareGeometryChange();
+       calculate_bounding_rect();
+       update();
+       
+       emit fadeModified();
+}
+
+
+Command* FadeView::bend()
+{
+       return new FadeBend(this);
+}
+
+Command* FadeView::strength()
+{
+       return new FadeStrength(this);
+}
+
+Command* FadeView::select_fade_shape()
+{
+       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeIn) {
+               Interface::instance()->select_fade_in_shape();
+       }
+       else {
+               Interface::instance()->select_fade_out_shape();
+       }
+       return 0;
+}
+
+void FadeView::set_holding(bool hold)
+{
+       m_holdactive = hold;
+       update(m_boundingRect);
+}
+
+
+void FadeView::load_theme_data()
+{
+       calculate_bounding_rect();
+}
+

Index: FadeView.h
===================================================================
RCS file: FadeView.h
diff -N FadeView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ FadeView.h  21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,78 @@
+/*
+Copyright (C) 2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: FadeView.h,v 1.1 2008/01/21 16:17:28 r_sijrier Exp $
+*/
+
+#ifndef FADE_VIEW_H
+#define FADE_VIEW_H
+
+#include "ViewItem.h"
+
+class Curve;
+class FadeCurve;
+class FadeContextDialog;
+class AudioClipView;
+
+class FadeView : public ViewItem
+{
+       Q_OBJECT
+       
+       Q_CLASSINFO("bend", tr("Adjust Bend"))
+       Q_CLASSINFO("strength", tr("Adjust Strength"))
+       Q_CLASSINFO("select_fade_shape", tr("Select Preset"))
+       
+public:
+       FadeView(SheetView* sv, AudioClipView* parent, FadeCurve* fadeCuve);
+       ~FadeView();
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       int get_vector(int xstart, int pixelcount, float * arg);
+       void calculate_bounding_rect();
+       void set_holding(bool hold);
+       
+       FadeCurve* get_fade() const {return m_fadeCurve;}
+       
+       void load_theme_data();
+
+private:
+       FadeCurve*      m_fadeCurve;
+       Curve*          m_guicurve;
+       bool            m_holdactive;
+       
+public slots:
+       void state_changed();
+       
+       Command* bend();
+       Command* strength();
+       Command* select_fade_shape();
+//     Command* edit_properties();
+
+signals :
+       // emit from the gui so that we can stop following the playhead only
+       // when the user manually edits, not on undo/redo
+       void fadeModified();
+};
+
+
+#endif
+
+//eof
+
+

Index: libtraversosheetcanvas.h
===================================================================
RCS file: libtraversosheetcanvas.h
diff -N libtraversosheetcanvas.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libtraversosheetcanvas.h    21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,16 @@
+#include "AudioClipView.h"
+#include "ClipsViewPort.h"
+#include "Cursors.h"
+#include "CurveNodeView.h"
+#include "CurveView.h"
+#include "FadeView.h"
+#include "MarkerView.h"
+#include "PluginView.h"
+#include "PluginChainView.h"
+#include "SheetView.h"
+#include "TimeLineView.h"
+#include "TimeLineViewPort.h"
+#include "TrackView.h"
+#include "TrackPanelView.h"
+#include "TrackPanelViewPort.h"
+#include "ViewItem.h"

Index: LineView.h
===================================================================
RCS file: LineView.h
diff -N LineView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ LineView.h  21 Jan 2008 16:17:28 -0000      1.1
@@ -0,0 +1,50 @@
+/*
+Copyright (C) 2006-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef LINE_VIEW_H
+#define LINE_VIEW_H
+
+#include "ViewItem.h"
+
+class LineView : public ViewItem
+{
+       Q_OBJECT
+public:
+               
+       LineView(ViewItem* parent) : ViewItem(parent, 0) 
+       {
+               setZValue(parent->zValue() + 1);
+               m_boundingRect = QRectF(0, 0, 1, 
parent->boundingRect().height());
+       }
+       void set_bounding_rect(QRectF rect) {m_boundingRect = rect;}
+       void set_color(QColor color) {m_color = color;}
+       void paint(QPainter* painter, const QStyleOptionGraphicsItem*, 
QWidget*) 
+       {
+               painter->setPen(m_color);
+               QLineF line(0, 0, 0, m_boundingRect.height());
+               painter->drawLine(line);
+       }
+       
+private:
+       QColor m_color;
+};
+
+#endif

Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Makefile    21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,541 @@
+#############################################################################
+# Makefile for building: libtraversosongcanvas.a
+# Generated by qmake (2.01a) (Qt 4.3.3) on: Mon Dec 31 10:28:56 2007
+# Project:  songcanvas.pro
+# Template: lib
+# Command: /usr/bin/qmake -unix QMAKE_CXX=apg++ QMAKE_CC=apgcc -o Makefile 
songcanvas.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC            = apgcc
+CXX           = apg++
+DEFINES       = -DJACK_SUPPORT -DALSA_SUPPORT -DLV2_SUPPORT 
-DMP3_ENCODE_SUPPORT -DMP3_DECODE_SUPPORT -DSTATIC_BUILD -DUSE_MLOCK 
-DQT_NO_DEBUG -DSSE_OPTIMIZATIONS -DUSE_XMMINTRIN -DARCH_X86 
-DRELAYTOOL_PRESENT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB
+CFLAGS        = -pipe -O2 -fPIC -D_REENTRANT -Wall -W $(DEFINES)
+CXXFLAGS      = -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -fPIC 
-mmmx -march=i686 -msse -mfpmath=sse -fPIC -D_REENTRANT -Wall -W $(DEFINES)
+INCPATH       = -I/usr/local/Trolltech/Qt-4.3.3/mkspecs/linux-g++ -I. 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtCore 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtCore 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtGui 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtGui 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtXml 
-I/usr/local/Trolltech/Qt-4.3.3/include/QtXml 
-I/usr/local/Trolltech/Qt-4.3.3/include -I../../core -I../../common 
-I../../traverso -I../../traverso/dialogs -I../../engine -I../../commands 
-I../../commands/build -I../../plugins -I../../plugins/native -I. 
-I../../plugins/LV2 -I../../3rdparty/slv2 -Ibuild -Ibuild
+AR            = ar cqs
+RANLIB        = 
+QMAKE         = /usr/bin/qmake
+TAR           = tar -cf
+COMPRESS      = gzip -9f
+COPY          = cp -f
+SED           = sed
+COPY_FILE     = $(COPY)
+COPY_DIR      = $(COPY) -r
+INSTALL_FILE  = install -m 644 -p
+INSTALL_DIR   = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE      = rm -f
+SYMLINK       = ln -sf
+DEL_DIR       = rmdir
+MOVE          = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR         = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR   = build/
+
+####### Files
+
+SOURCES       = AudioClipView.cpp \
+               ClipsViewPort.cpp \
+               Cursors.cpp \
+               CurveNodeView.cpp \
+               CurveView.cpp \
+               FadeContextDialogView.cpp \
+               FadeView.cpp \
+               MarkerView.cpp \
+               PluginChainView.cpp \
+               PluginView.cpp \
+               SongView.cpp \
+               SongWidget.cpp \
+               TimeLineView.cpp \
+               TimeLineViewPort.cpp \
+               TrackPanelView.cpp \
+               TrackPanelViewPort.cpp \
+               TrackView.cpp \
+               ViewItem.cpp \
+               dialogs/AudioClipEditDialog.cpp build/moc_AudioClipView.cpp \
+               build/moc_ClipsViewPort.cpp \
+               build/moc_Cursors.cpp \
+               build/moc_CurveNodeView.cpp \
+               build/moc_CurveView.cpp \
+               build/moc_FadeContextDialogView.cpp \
+               build/moc_FadeView.cpp \
+               build/moc_MarkerView.cpp \
+               build/moc_PluginChainView.cpp \
+               build/moc_PluginView.cpp \
+               build/moc_SongView.cpp \
+               build/moc_SongWidget.cpp \
+               build/moc_TimeLineView.cpp \
+               build/moc_TrackPanelView.cpp \
+               build/moc_TrackView.cpp \
+               build/moc_ViewItem.cpp \
+               build/moc_LineView.cpp \
+               build/moc_AudioClipEditDialog.cpp
+OBJECTS       = build/AudioClipView.o \
+               build/ClipsViewPort.o \
+               build/Cursors.o \
+               build/CurveNodeView.o \
+               build/CurveView.o \
+               build/FadeContextDialogView.o \
+               build/FadeView.o \
+               build/MarkerView.o \
+               build/PluginChainView.o \
+               build/PluginView.o \
+               build/SongView.o \
+               build/SongWidget.o \
+               build/TimeLineView.o \
+               build/TimeLineViewPort.o \
+               build/TrackPanelView.o \
+               build/TrackPanelViewPort.o \
+               build/TrackView.o \
+               build/ViewItem.o \
+               build/AudioClipEditDialog.o \
+               build/moc_AudioClipView.o \
+               build/moc_ClipsViewPort.o \
+               build/moc_Cursors.o \
+               build/moc_CurveNodeView.o \
+               build/moc_CurveView.o \
+               build/moc_FadeContextDialogView.o \
+               build/moc_FadeView.o \
+               build/moc_MarkerView.o \
+               build/moc_PluginChainView.o \
+               build/moc_PluginView.o \
+               build/moc_SongView.o \
+               build/moc_SongWidget.o \
+               build/moc_TimeLineView.o \
+               build/moc_TrackPanelView.o \
+               build/moc_TrackView.o \
+               build/moc_ViewItem.o \
+               build/moc_LineView.o \
+               build/moc_AudioClipEditDialog.o
+DIST          = /usr/local/Trolltech/Qt-4.3.3/mkspecs/common/g++.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/common/unix.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/common/linux.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/qconfig.pri \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_functions.prf 
\
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_config.prf \
+               
/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/exclusive_builds.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_pre.prf \
+               ../../base.pri \
+               ../../libbase.pri \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/release.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_post.prf 
\
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/static.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/staticlib.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/unix/thread.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/moc.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/warn_on.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/resources.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/uic.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/yacc.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/lex.prf \
+               songcanvas.pro
+QMAKE_TARGET  = traversosongcanvas
+DESTDIR       = ../../../lib/
+TARGET        = libtraversosongcanvas.a
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile ../../../lib/$(TARGET) 
+
+staticlib: ../../../lib/$(TARGET)
+
+../../../lib/$(TARGET): build/ui_AudioClipEditDialog.h $(OBJECTS) $(OBJCOMP) 
+       @$(CHK_DIR_EXISTS) ../../../lib/ || $(MKDIR) ../../../lib/ 
+       -$(DEL_FILE) $(TARGET)
+       $(AR) $(TARGET) $(OBJECTS)
+       -$(DEL_FILE) ../../../lib/$(TARGET)
+       -$(MOVE) $(TARGET) ../../../lib/
+
+
+Makefile: songcanvas.pro  
/usr/local/Trolltech/Qt-4.3.3/mkspecs/linux-g++/qmake.conf 
/usr/local/Trolltech/Qt-4.3.3/mkspecs/common/g++.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/common/unix.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/common/linux.conf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/qconfig.pri \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_functions.prf 
\
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_config.prf \
+               
/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/exclusive_builds.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_pre.prf \
+               ../../base.pri \
+               ../../libbase.pri \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/release.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_post.prf 
\
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/static.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/staticlib.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/unix/thread.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/moc.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/warn_on.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/resources.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/uic.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/yacc.prf \
+               /usr/local/Trolltech/Qt-4.3.3/mkspecs/features/lex.prf \
+               /usr/local/Trolltech/Qt-4.3.3/lib/libQtXml.prl \
+               /usr/local/Trolltech/Qt-4.3.3/lib/libQtCore.prl \
+               /usr/local/Trolltech/Qt-4.3.3/lib/libQtGui.prl
+       $(QMAKE) -unix QMAKE_CXX=apg++ QMAKE_CC=apgcc -o Makefile songcanvas.pro
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/common/g++.conf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/common/unix.conf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/common/linux.conf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/qconfig.pri:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_functions.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt_config.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/exclusive_builds.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_pre.prf:
+../../base.pri:
+../../libbase.pri:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/release.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/default_post.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/static.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/staticlib.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/qt.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/unix/thread.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/moc.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/warn_on.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/resources.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/uic.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/yacc.prf:
+/usr/local/Trolltech/Qt-4.3.3/mkspecs/features/lex.prf:
+/usr/local/Trolltech/Qt-4.3.3/lib/libQtXml.prl:
+/usr/local/Trolltech/Qt-4.3.3/lib/libQtCore.prl:
+/usr/local/Trolltech/Qt-4.3.3/lib/libQtGui.prl:
+qmake:  FORCE
+       @$(QMAKE) -unix QMAKE_CXX=apg++ QMAKE_CC=apgcc -o Makefile 
songcanvas.pro
+
+dist: 
+       @$(CHK_DIR_EXISTS) build/traversosongcanvas1.0.0 || $(MKDIR) 
build/traversosongcanvas1.0.0 
+       $(COPY_FILE) --parents $(SOURCES) $(DIST) 
build/traversosongcanvas1.0.0/ && $(COPY_FILE) --parents AudioClipView.h 
ClipsViewPort.h Cursors.h CurveNodeView.h CurveView.h FadeContextDialogView.h 
FadeView.h libtraversosongcanvas.h MarkerView.h PluginChainView.h PluginView.h 
precompile.h SongView.h SongWidget.h TimeLineView.h TimeLineViewPort.h 
TrackPanelView.h TrackPanelViewPort.h TrackView.h ViewItem.h LineView.h 
dialogs/AudioClipEditDialog.h build/traversosongcanvas1.0.0/ && $(COPY_FILE) 
--parents AudioClipView.cpp ClipsViewPort.cpp Cursors.cpp CurveNodeView.cpp 
CurveView.cpp FadeContextDialogView.cpp FadeView.cpp MarkerView.cpp 
PluginChainView.cpp PluginView.cpp SongView.cpp SongWidget.cpp TimeLineView.cpp 
TimeLineViewPort.cpp TrackPanelView.cpp TrackPanelViewPort.cpp TrackView.cpp 
ViewItem.cpp dialogs/AudioClipEditDialog.cpp build/traversosongcanvas1.0.0/ && 
$(COPY_FILE) --parents ui/AudioClipEditDialog.ui build/traversosongcanvas1.0.0/ 
&& (cd `dirname build/traversosongcanvas1.0.0` && $(TAR) 
traversosongcanvas1.0.0.tar traversosongcanvas1.0.0 && $(COMPRESS) 
traversosongcanvas1.0.0.tar) && $(MOVE) `dirname 
build/traversosongcanvas1.0.0`/traversosongcanvas1.0.0.tar.gz . && $(DEL_FILE) 
-r build/traversosongcanvas1.0.0
+
+
+clean:compiler_clean 
+       -$(DEL_FILE) $(OBJECTS)
+       -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+       -$(DEL_FILE) $(TARGET) 
+       -$(DEL_FILE) Makefile
+
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: build/moc_AudioClipView.cpp 
build/moc_ClipsViewPort.cpp build/moc_Cursors.cpp build/moc_CurveNodeView.cpp 
build/moc_CurveView.cpp build/moc_FadeContextDialogView.cpp 
build/moc_FadeView.cpp build/moc_MarkerView.cpp build/moc_PluginChainView.cpp 
build/moc_PluginView.cpp build/moc_SongView.cpp build/moc_SongWidget.cpp 
build/moc_TimeLineView.cpp build/moc_TrackPanelView.cpp build/moc_TrackView.cpp 
build/moc_ViewItem.cpp build/moc_LineView.cpp build/moc_AudioClipEditDialog.cpp
+compiler_moc_header_clean:
+       -$(DEL_FILE) build/moc_AudioClipView.cpp build/moc_ClipsViewPort.cpp 
build/moc_Cursors.cpp build/moc_CurveNodeView.cpp build/moc_CurveView.cpp 
build/moc_FadeContextDialogView.cpp build/moc_FadeView.cpp 
build/moc_MarkerView.cpp build/moc_PluginChainView.cpp build/moc_PluginView.cpp 
build/moc_SongView.cpp build/moc_SongWidget.cpp build/moc_TimeLineView.cpp 
build/moc_TrackPanelView.cpp build/moc_TrackView.cpp build/moc_ViewItem.cpp 
build/moc_LineView.cpp build/moc_AudioClipEditDialog.cpp
+build/moc_AudioClipView.cpp: ViewItem.h \
+               AudioClipView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
AudioClipView.h -o build/moc_AudioClipView.cpp
+
+build/moc_ClipsViewPort.cpp: ClipsViewPort.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
ClipsViewPort.h -o build/moc_ClipsViewPort.cpp
+
+build/moc_Cursors.cpp: ViewItem.h \
+               Cursors.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) Cursors.h 
-o build/moc_Cursors.cpp
+
+build/moc_CurveNodeView.cpp: ViewItem.h \
+               CurveNodeView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
CurveNodeView.h -o build/moc_CurveNodeView.cpp
+
+build/moc_CurveView.cpp: ViewItem.h \
+               CurveView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) CurveView.h 
-o build/moc_CurveView.cpp
+
+build/moc_FadeContextDialogView.cpp: ViewItem.h \
+               FadeContextDialogView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
FadeContextDialogView.h -o build/moc_FadeContextDialogView.cpp
+
+build/moc_FadeView.cpp: ViewItem.h \
+               FadeView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) FadeView.h 
-o build/moc_FadeView.cpp
+
+build/moc_MarkerView.cpp: ViewItem.h \
+               MarkerView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
MarkerView.h -o build/moc_MarkerView.cpp
+
+build/moc_PluginChainView.cpp: ViewItem.h \
+               PluginChainView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
PluginChainView.h -o build/moc_PluginChainView.cpp
+
+build/moc_PluginView.cpp: ViewItem.h \
+               PluginView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
PluginView.h -o build/moc_PluginView.cpp
+
+build/moc_SongView.cpp: ViewItem.h \
+               SongView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) SongView.h 
-o build/moc_SongView.cpp
+
+build/moc_SongWidget.cpp: ViewItem.h \
+               SongWidget.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
SongWidget.h -o build/moc_SongWidget.cpp
+
+build/moc_TimeLineView.cpp: ViewItem.h \
+               TimeLineView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
TimeLineView.h -o build/moc_TimeLineView.cpp
+
+build/moc_TrackPanelView.cpp: ViewItem.h \
+               TrackPanelView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
TrackPanelView.h -o build/moc_TrackPanelView.cpp
+
+build/moc_TrackView.cpp: ViewItem.h \
+               TrackView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) TrackView.h 
-o build/moc_TrackView.cpp
+
+build/moc_ViewItem.cpp: ViewItem.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) ViewItem.h 
-o build/moc_ViewItem.cpp
+
+build/moc_LineView.cpp: ViewItem.h \
+               LineView.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) LineView.h 
-o build/moc_LineView.cpp
+
+build/moc_AudioClipEditDialog.cpp: build/ui_AudioClipEditDialog.h \
+               dialogs/AudioClipEditDialog.h
+       /usr/local/Trolltech/Qt-4.3.3/bin/moc $(DEFINES) $(INCPATH) 
dialogs/AudioClipEditDialog.h -o build/moc_AudioClipEditDialog.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+       -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all: build/ui_AudioClipEditDialog.h
+compiler_uic_clean:
+       -$(DEL_FILE) build/ui_AudioClipEditDialog.h
+build/ui_AudioClipEditDialog.h: ui/AudioClipEditDialog.ui
+       /usr/local/Trolltech/Qt-4.3.3/bin/uic ui/AudioClipEditDialog.ui -o 
build/ui_AudioClipEditDialog.h
+
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean compiler_uic_clean 
+
+####### Compile
+
+build/AudioClipView.o: AudioClipView.cpp AudioClipView.h \
+               ViewItem.h \
+               SongView.h \
+               TrackView.h \
+               FadeView.h \
+               CurveView.h \
+               PositionIndicator.h \
+               dialogs/AudioClipEditDialog.h \
+               build/ui_AudioClipEditDialog.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/AudioClipView.o 
AudioClipView.cpp
+
+build/ClipsViewPort.o: ClipsViewPort.cpp ClipsViewPort.h \
+               SongWidget.h \
+               ViewItem.h \
+               SongView.h \
+               TrackView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/ClipsViewPort.o 
ClipsViewPort.cpp
+
+build/Cursors.o: Cursors.cpp Cursors.h \
+               ViewItem.h \
+               SongView.h \
+               ClipsViewPort.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/Cursors.o Cursors.cpp
+
+build/CurveNodeView.o: CurveNodeView.cpp CurveNodeView.h \
+               ViewItem.h \
+               SongView.h \
+               CurveView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/CurveNodeView.o 
CurveNodeView.cpp
+
+build/CurveView.o: CurveView.cpp CurveView.h \
+               ViewItem.h \
+               SongView.h \
+               CurveNodeView.h \
+               ClipsViewPort.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/CurveView.o CurveView.cpp
+
+build/FadeContextDialogView.o: FadeContextDialogView.cpp 
FadeContextDialogView.h \
+               ViewItem.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/FadeContextDialogView.o 
FadeContextDialogView.cpp
+
+build/FadeView.o: FadeView.cpp FadeView.h \
+               ViewItem.h \
+               AudioClipView.h \
+               SongView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/FadeView.o FadeView.cpp
+
+build/MarkerView.o: MarkerView.cpp MarkerView.h \
+               ViewItem.h \
+               SongView.h \
+               LineView.h \
+               ClipsViewPort.h \
+               PositionIndicator.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/MarkerView.o MarkerView.cpp
+
+build/PluginChainView.o: PluginChainView.cpp PluginChainView.h \
+               ViewItem.h \
+               TrackView.h \
+               SongView.h \
+               ClipsViewPort.h \
+               PluginView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/PluginChainView.o 
PluginChainView.cpp
+
+build/PluginView.o: PluginView.cpp PluginView.h \
+               ViewItem.h \
+               TrackView.h \
+               PluginChainView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/PluginView.o PluginView.cpp
+
+build/SongView.o: SongView.cpp SongView.h \
+               ViewItem.h \
+               SongWidget.h \
+               TrackView.h \
+               TrackPanelView.h \
+               Cursors.h \
+               ClipsViewPort.h \
+               TimeLineViewPort.h \
+               TimeLineView.h \
+               TrackPanelViewPort.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/SongView.o SongView.cpp
+
+build/SongWidget.o: SongWidget.cpp SongWidget.h \
+               ViewItem.h \
+               TrackPanelViewPort.h \
+               ClipsViewPort.h \
+               TimeLineViewPort.h \
+               SongView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/SongWidget.o SongWidget.cpp
+
+build/TimeLineView.o: TimeLineView.cpp TimeLineView.h \
+               ViewItem.h \
+               SongView.h \
+               MarkerView.h \
+               TimeLineViewPort.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/TimeLineView.o 
TimeLineView.cpp
+
+build/TimeLineViewPort.o: TimeLineViewPort.cpp TimeLineViewPort.h \
+               SongView.h \
+               ViewItem.h \
+               SongWidget.h \
+               TimeLineView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/TimeLineViewPort.o 
TimeLineViewPort.cpp
+
+build/TrackPanelView.o: TrackPanelView.cpp TrackPanelView.h \
+               ViewItem.h \
+               TrackView.h \
+               SongView.h \
+               TrackPanelViewPort.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/TrackPanelView.o 
TrackPanelView.cpp
+
+build/TrackPanelViewPort.o: TrackPanelViewPort.cpp TrackPanelViewPort.h \
+               SongWidget.h \
+               ViewItem.h \
+               SongView.h \
+               TrackPanelView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/TrackPanelViewPort.o 
TrackPanelViewPort.cpp
+
+build/TrackView.o: TrackView.cpp TrackView.h \
+               ViewItem.h \
+               AudioClipView.h \
+               PluginChainView.h \
+               TrackPanelViewPort.h \
+               SongView.h \
+               TrackPanelView.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/TrackView.o TrackView.cpp
+
+build/ViewItem.o: ViewItem.cpp ViewItem.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/ViewItem.o ViewItem.cpp
+
+build/AudioClipEditDialog.o: dialogs/AudioClipEditDialog.cpp 
dialogs/AudioClipEditDialog.h \
+               build/ui_AudioClipEditDialog.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/AudioClipEditDialog.o 
dialogs/AudioClipEditDialog.cpp
+
+build/moc_AudioClipView.o: build/moc_AudioClipView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_AudioClipView.o 
build/moc_AudioClipView.cpp
+
+build/moc_ClipsViewPort.o: build/moc_ClipsViewPort.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_ClipsViewPort.o 
build/moc_ClipsViewPort.cpp
+
+build/moc_Cursors.o: build/moc_Cursors.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_Cursors.o 
build/moc_Cursors.cpp
+
+build/moc_CurveNodeView.o: build/moc_CurveNodeView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_CurveNodeView.o 
build/moc_CurveNodeView.cpp
+
+build/moc_CurveView.o: build/moc_CurveView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_CurveView.o 
build/moc_CurveView.cpp
+
+build/moc_FadeContextDialogView.o: build/moc_FadeContextDialogView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_FadeContextDialogView.o 
build/moc_FadeContextDialogView.cpp
+
+build/moc_FadeView.o: build/moc_FadeView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_FadeView.o 
build/moc_FadeView.cpp
+
+build/moc_MarkerView.o: build/moc_MarkerView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_MarkerView.o 
build/moc_MarkerView.cpp
+
+build/moc_PluginChainView.o: build/moc_PluginChainView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_PluginChainView.o 
build/moc_PluginChainView.cpp
+
+build/moc_PluginView.o: build/moc_PluginView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_PluginView.o 
build/moc_PluginView.cpp
+
+build/moc_SongView.o: build/moc_SongView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_SongView.o 
build/moc_SongView.cpp
+
+build/moc_SongWidget.o: build/moc_SongWidget.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_SongWidget.o 
build/moc_SongWidget.cpp
+
+build/moc_TimeLineView.o: build/moc_TimeLineView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_TimeLineView.o 
build/moc_TimeLineView.cpp
+
+build/moc_TrackPanelView.o: build/moc_TrackPanelView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_TrackPanelView.o 
build/moc_TrackPanelView.cpp
+
+build/moc_TrackView.o: build/moc_TrackView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_TrackView.o 
build/moc_TrackView.cpp
+
+build/moc_ViewItem.o: build/moc_ViewItem.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_ViewItem.o 
build/moc_ViewItem.cpp
+
+build/moc_LineView.o: build/moc_LineView.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_LineView.o 
build/moc_LineView.cpp
+
+build/moc_AudioClipEditDialog.o: build/moc_AudioClipEditDialog.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_AudioClipEditDialog.o 
build/moc_AudioClipEditDialog.cpp
+
+####### Install
+
+install:   FORCE
+
+uninstall:   FORCE
+
+FORCE:
+

Index: MarkerView.cpp
===================================================================
RCS file: MarkerView.cpp
diff -N MarkerView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ MarkerView.cpp      21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,182 @@
+/*
+    Copyright (C) 2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#include "MarkerView.h"
+#include "SheetView.h"
+#include "LineView.h"
+#include "Themer.h"
+#include "ClipsViewPort.h"
+#include "PositionIndicator.h"
+
+#include <QFont>
+#include <QFontMetrics>
+#include <QColor>
+#include <Sheet.h>
+#include <Marker.h>
+#include <Utils.h>
+#include <QDebug>
+
+MarkerView::MarkerView(Marker* marker, SheetView* sv, ViewItem* parentView)
+       : ViewItem(parentView, marker)
+       , m_dragging(false)
+{
+       m_sv = sv;
+       m_marker = marker;
+       m_line = new LineView(this);
+       set_active(false);
+       m_posIndicator = 0;
+
+       QFontMetrics fm(themer()->get_font("Timeline:marker"));
+       m_ascent = fm.ascent();
+       m_width = fm.width("NI"); // use any two letters to set the width of 
the marker indicator
+       m_line->setPos(m_width / 2, m_ascent);
+       
+       setFlag(QGraphicsItem::ItemIgnoresTransformations);
+
+       load_theme_data();
+       
+       
+       connect(m_marker, SIGNAL(positionChanged(Snappable*)), this, 
SLOT(update_position()));
+       connect(m_marker, SIGNAL(descriptionChanged()), this, 
SLOT(update_drawing()));
+}
+
+void MarkerView::paint(QPainter * painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget)
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       painter->save();
+       
+       int xstart = (int)option->exposedRect.x();
+       int clipx = (int)mapToParent(xstart, 0).x();
+       if (clipx < 0) {
+               painter->setClipRect(-clipx, 0, (int)m_boundingRect.width(), 
(int)m_boundingRect.height());
+       }
+
+       painter->setRenderHint(QPainter::Antialiasing);
+       painter->setFont(themer()->get_font("Timeline:fontscale:marker"));
+       
+       painter->setPen(QColor(Qt::black));
+       painter->setBrush(m_fillColor);
+
+       const QPointF pts[3] = {
+                       QPointF(0, 0),
+                       QPointF(m_width + 0.5, 0),
+                       QPointF((m_width+ 0.5)/2, m_ascent) };
+
+       painter->drawPolygon(pts, 3);
+       painter->drawText(m_width + 1, m_ascent, m_marker->get_description());
+
+       if (m_dragging) {
+               m_posIndicator->set_value(timeref_to_text(TimeRef((x() + 
m_width / 2) * m_sv->timeref_scalefactor), m_sv->timeref_scalefactor));
+       }
+
+       painter->restore();
+}
+
+void MarkerView::calculate_bounding_rect()
+{
+       prepareGeometryChange();
+       update_position();
+       
+       QFontMetrics fm(themer()->get_font("Timeline:fontscale:marker"));
+       int descriptionwidth = fm.width(m_marker->get_description()) + 1;
+
+       m_line->set_bounding_rect(QRectF(0, 0, 1, 
m_sv->get_clips_viewport()->sceneRect().height()));
+       m_line->setPos(m_width / 2, m_ascent);
+       m_boundingRect = QRectF(-1, 0, m_width + descriptionwidth, m_ascent);
+}
+
+void MarkerView::update_position()
+{
+       // markerwidth / 2 == center of markerview !
+       setPos((m_marker->get_when() / m_sv->timeref_scalefactor) - (m_width / 
2), 0);
+}
+
+int MarkerView::position()
+{
+       return (int)(pos().x() + m_width / 2);
+}
+
+void MarkerView::set_position(int i)
+{
+       setPos(i - m_width / 2, 0);
+}
+
+void MarkerView::load_theme_data()
+{
+       if (m_marker->get_type() == Marker::ENDMARKER) {
+               m_fillColor = themer()->get_color("Marker:end");
+       } else {
+               m_fillColor = themer()->get_color("Marker:default");
+       }
+       calculate_bounding_rect();
+}
+
+void MarkerView::set_active(bool b)
+{
+       m_active = b;
+
+       if (b) {
+               if (m_marker->get_type() == Marker::ENDMARKER) {
+                       m_fillColor = themer()->get_color("Marker:blinkend");
+               } else {
+                       m_fillColor = themer()->get_color("Marker:blink");
+               }
+               m_line->set_color(QColor(0, 0, 0, 140));
+       } else {
+               if (m_marker->get_type() == Marker::ENDMARKER) {
+                       m_fillColor = themer()->get_color("Marker:end");
+               } else {
+                       m_fillColor = themer()->get_color("Marker:default");
+               }
+               m_line->set_color(QColor(0, 0, 0, 45));
+       }
+
+       m_line->update();
+       update();
+}
+
+void MarkerView::update_drawing()
+{
+       calculate_bounding_rect();
+       update();
+}
+
+void MarkerView::set_dragging(bool dragging)
+{
+       if (dragging) {
+               if (! m_posIndicator) {
+                       m_posIndicator = new PositionIndicator(this);
+                       scene()->addItem(m_posIndicator);
+                       m_posIndicator->set_position(15, 0);
+               }
+       } else {
+               if (m_posIndicator) {
+                       scene()->removeItem(m_posIndicator);
+                       delete m_posIndicator;
+                       m_posIndicator = 0;
+               }
+       }
+       
+       m_dragging = dragging;
+}
+

Index: MarkerView.h
===================================================================
RCS file: MarkerView.h
diff -N MarkerView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ MarkerView.h        21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,68 @@
+/*
+    Copyright (C) 2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef MARKER_VIEW_H
+#define MARKER_VIEW_H
+
+#include "ViewItem.h"
+
+class Marker;
+class SheetView;
+class LineView;
+class QColor;
+class PositionIndicator;
+
+class MarkerView : public ViewItem
+{
+       Q_OBJECT
+       
+public:
+       MarkerView(Marker* marker, SheetView* sv, ViewItem* parent);
+       ~MarkerView() {}
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+       void load_theme_data();
+       void set_active(bool);
+       int position();
+       void set_position(int);
+       void set_dragging(bool dragging);
+       
+       Marker* get_marker() const {return m_marker;}
+       
+private:
+       Marker* m_marker;
+       LineView* m_line;
+       QColor  m_fillColor;
+       bool    m_active;
+       bool    m_dragging;
+       PositionIndicator* m_posIndicator;
+       int     m_ascent;
+       int     m_width;
+       
+private slots:
+       void update_position();
+       void update_drawing();
+};
+
+#endif
+
+//eof

Index: PanelLed.cpp
===================================================================
RCS file: PanelLed.cpp
diff -N PanelLed.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PanelLed.cpp        21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,82 @@
+/*
+    Copyright (C) 2005-2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: PanelLed.cpp,v 1.1 2008/01/21 16:17:29 r_sijrier Exp $
+*/
+
+#include "PanelLed.h"
+
+#include <QPainter>
+
+#include "TrackPanelView.h"
+#include <Utils.h>
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+const int LED_Y = 18;
+const int LED_WIDTH = 35;
+const int LED_HEIGHT = 14;
+
+
+PanelLed::PanelLed(TrackPanelView* parent, int xpos, char* on, char* off )
+       : QObject(parent),  m_xpos(xpos), onType(on), offType(off)
+{
+        m_isOn = false;
+}
+
+PanelLed::~PanelLed( )
+{
+        PENTERDES2;
+}
+
+void PanelLed::paint(QPainter *painter)
+{
+
+       if (m_isOn) {
+               painter->drawPixmap(m_xpos, LED_Y, find_pixmap(onType));
+       } else {
+               painter->drawPixmap(m_xpos, LED_Y, find_pixmap(offType));
+       }
+}
+
+void PanelLed::ison_changed( bool isOn )
+{
+        PENTER2;
+        m_isOn = isOn;
+}
+
+void PanelLed::set_on_type( char * type )
+{
+        onType = type;
+}
+
+void PanelLed::set_of_type( char * type )
+{
+        offType = type;
+}
+
+
+void PanelLed::set_xpos( int x )
+{
+        m_xpos = x;
+}
+
+//eof

Index: PanelLed.h
===================================================================
RCS file: PanelLed.h
diff -N PanelLed.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PanelLed.h  21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,59 @@
+/*
+    Copyright (C) 2005-2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: PanelLed.h,v 1.1 2008/01/21 16:17:29 r_sijrier Exp $
+*/
+
+#ifndef PANEL_LED_VIEW_H
+#define PANEL_LED_VIEW_H
+
+#include <QObject>
+#include <QString>
+
+class TrackPanelView;
+
+class PanelLed : public QObject
+{
+        Q_OBJECT
+
+public:
+        PanelLed(TrackPanelView* view, int xpos, char* on, char* off);
+        ~PanelLed();
+
+       void paint(QPainter *painter);
+
+        void set_on_type(char* type);
+        void set_of_type(char* type);
+        void set_xpos(int x);
+
+private:
+        int m_xpos;
+        bool m_isOn;
+        QString onType;
+        QString offType;
+
+
+public slots:
+        void ison_changed(bool isOn);
+};
+
+
+#endif
+
+//eof

Index: PluginChainView.cpp
===================================================================
RCS file: PluginChainView.cpp
diff -N PluginChainView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PluginChainView.cpp 21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,152 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier
+
+    This file is part of Traverso
+
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "PluginChainView.h"
+
+#include <QScrollBar>
+
+#include "TrackView.h"
+#include "SheetView.h"
+#include "ClipsViewPort.h"
+#include "PluginView.h"
+#include "Themer.h"
+#include <PluginChain.h>
+#include <Plugin.h>
+
+#include <Track.h>
+#include "Sheet.h"
+
+#if defined (LV2_SUPPORT)
+#include <LV2Plugin.h>
+#endif
+#include <PluginChain.h>
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+
+PluginChainView::PluginChainView(SheetView* sv, ViewItem* parent, PluginChain* 
chain)
+       : ViewItem(parent, parent)
+       , m_pluginchain(chain)
+{
+       PENTERCONS;
+       
+       setZValue(parent->zValue() + 2);
+       m_sv = sv;
+       calculate_bounding_rect();
+       
+#if QT_VERSION < 0x040300
+       parent->scene()->addItem(this);
+#endif
+       
+       foreach(Plugin* plugin, chain->get_plugin_list()) {
+               add_new_pluginview(plugin);
+       }
+       
+       connect(chain, SIGNAL(pluginAdded(Plugin*)), this, 
SLOT(add_new_pluginview(Plugin*)));
+       connect(chain, SIGNAL(pluginRemoved(Plugin*)), this, 
SLOT(remove_pluginview(Plugin*)));
+       connect(m_sv->get_clips_viewport()->horizontalScrollBar(), 
SIGNAL(valueChanged(int)),
+               this, SLOT(scrollbar_value_changed(int)));
+       connect(m_sv->get_sheet(), SIGNAL(modeChanged()), this, 
SLOT(set_view_mode()));
+       
+       set_view_mode();
+}
+
+PluginChainView::~PluginChainView( )
+{
+        PENTERDES2;
+}
+
+void PluginChainView::add_new_pluginview( Plugin * plugin )
+{
+       PluginView* view = new PluginView(this, m_pluginchain, plugin, 
m_pluginViews.size());
+#if QT_VERSION < 0x040300
+       scene()->addItem(view);
+#endif
+       
+       int x = 6;
+       foreach(PluginView* view, m_pluginViews) {
+               x += (int)view->boundingRect().width() + 6;
+       }
+       
+       view->setPos(x, m_boundingRect.height() - 
view->boundingRect().height());
+       
+       m_pluginViews.append(view);
+       
+       show();
+}
+
+void PluginChainView::remove_pluginview( Plugin * plugin )
+{
+       foreach(PluginView* view, m_pluginViews) {
+               if (view->get_plugin() == plugin) {
+                       m_pluginViews.removeAll(view);
+                       delete view;
+               }
+       }
+
+       for (int i=0; i<m_pluginViews.size(); ++i) {
+               m_pluginViews.at(i)->set_index(i);
+       }
+       
+       int x = 6;
+       foreach(PluginView* view, m_pluginViews) {
+               view->setPos(x, m_boundingRect.height() - 
view->boundingRect().height());
+               x += (int)view->boundingRect().width() + 6;
+       }
+       
+       if (!m_pluginViews.size()) {
+               hide();
+       }
+       
+       m_parentViewItem->update();
+}
+
+void PluginChainView::paint( QPainter * painter, const 
QStyleOptionGraphicsItem * option, QWidget * widget )
+{
+       Q_UNUSED(painter);
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+}
+
+void PluginChainView::scrollbar_value_changed(int value)
+{
+       setPos(value, y());
+}
+
+void PluginChainView::set_view_mode()
+{
+       if (m_sv->get_sheet()->get_mode() == Sheet::EFFECTS) {
+               show();
+       } else {
+               hide();
+       }
+}
+
+void PluginChainView::calculate_bounding_rect()
+{
+       int y = (int)(m_parentViewItem->boundingRect().height());
+       m_boundingRect = QRectF(0, 0, 0, y);
+       setPos(pos().x(), - 2);
+       ViewItem::calculate_bounding_rect();
+}
+

Index: PluginChainView.h
===================================================================
RCS file: PluginChainView.h
diff -N PluginChainView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PluginChainView.h   21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,62 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier
+
+    This file is part of Traverso
+
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef PLUGIN_CHAIN_VIEW_H
+#define PLUGIN_CHAIN_VIEW_H
+
+
+#include "ViewItem.h"
+#include <QString>
+
+class SheetView;
+class Plugin;
+class PluginChain;
+class PluginView;
+
+class PluginChainView : public ViewItem
+{
+        Q_OBJECT
+
+public:
+        PluginChainView(SheetView* sv, ViewItem* parent, PluginChain* chain);
+        ~PluginChainView();
+
+        void paint(QPainter* painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+
+private:
+       PluginChain* m_pluginchain;
+        QList<PluginView* >    m_pluginViews;
+
+public slots:
+        void add_new_pluginview(Plugin* plugin);
+        void remove_pluginview(Plugin* plugin);
+       void scrollbar_value_changed(int value);
+       
+private slots:
+       void set_view_mode();
+
+};
+
+#endif
+
+//eof
+

Index: PluginView.cpp
===================================================================
RCS file: PluginView.cpp
diff -N PluginView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PluginView.cpp      21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,147 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "PluginView.h"
+
+#include <QPainter>
+
+#include "TrackView.h"
+#include "PluginChainView.h"
+#include "Interface.h"
+
+#include <Themer.h>
+#include <Plugin.h>
+#include <PluginChain.h>
+#include <Track.h>
+#include <Utils.h>
+
+#include <PluginPropertiesDialog.h>
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+PluginView::PluginView(PluginChainView* parent, PluginChain* chain, Plugin* 
plugin, int index)
+       : ViewItem(parent, plugin)
+       , m_pluginchain(chain)
+       , m_plugin(plugin)
+       , m_index(index)
+{
+       PENTERCONS;
+       
+       m_propertiesDialog = 0;
+
+       setZValue(parent->zValue() + 2);
+       
+       m_name = plugin->get_name();
+       
+       QFontMetrics fm(themer()->get_font("Plugin:fontscale:name"));
+       m_textwidth = fm.width(m_name);
+       
+       calculate_bounding_rect();
+       
+       setAcceptsHoverEvents(true);
+       setCursor(themer()->get_cursor("Plugin"));
+       
+       connect(m_plugin, SIGNAL(bypassChanged()), this, SLOT(repaint()));
+}
+
+PluginView::~PluginView( )
+{
+       PENTERDES2;
+       if (m_propertiesDialog) {
+               delete m_propertiesDialog;
+       }
+}
+
+void PluginView::paint(QPainter* painter, const QStyleOptionGraphicsItem 
*option, QWidget *widget)
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       QColor color;
+       if (m_plugin->is_bypassed()) {
+               color = themer()->get_color("Plugin:background:bypassed");
+       } else {
+               color = themer()->get_color("Plugin:background");
+       }
+
+       int height, width;
+       if (option->state & QStyle::State_MouseOver) {
+               height = (int)m_boundingRect.height() + 1;
+               width = (int)m_boundingRect.width() + 1;
+               color = color.light(120);
+       } else {
+               height = (int)m_boundingRect.height();
+               width = (int)m_boundingRect.width();
+       }
+       
+       QBrush brush(color);
+       QRect rect(0, 0, width, height); 
+       painter->fillRect(rect, brush);
+       painter->setPen(themer()->get_color("Plugin:text"));
+       painter->setFont(themer()->get_font("Plugin:fontscale:name"));
+       painter->drawText(rect, Qt::AlignCenter, m_name);
+}
+
+
+Command * PluginView::edit_properties( )
+{
+       if (! m_propertiesDialog) {
+               m_propertiesDialog = new 
PluginPropertiesDialog(Interface::instance(), m_plugin);
+               m_propertiesDialog->setWindowTitle(m_name);
+       } 
+       m_propertiesDialog->show();
+       return (Command*) 0;
+}
+
+Command* PluginView::remove_plugin()
+{
+       return m_pluginchain->remove_plugin(m_plugin);
+}
+
+Plugin * PluginView::get_plugin( )
+{
+       return m_plugin;
+}
+
+void PluginView::set_index(int index)
+{
+       m_index = index;
+}
+
+void PluginView::repaint( )
+{
+       update();
+}
+
+void PluginView::calculate_bounding_rect()
+{
+       int height = 25;
+       int parentheight = (int)m_parentViewItem->boundingRect().height();
+       if (parentheight < 30) {
+               height = parentheight - 4;
+       }
+       int y = parentheight - height;
+       m_boundingRect = QRectF(0, 0, m_textwidth + 8, height);
+       setPos(x(), y);
+}
+

Index: PluginView.h
===================================================================
RCS file: PluginView.h
diff -N PluginView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PluginView.h        21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,73 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier
+
+    This file is part of Traverso
+
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef PLUGIN_VIEW_H
+#define PLUGIN_VIEW_H
+
+
+#include "ViewItem.h"
+#include <QString>
+
+class PluginPropertiesDialog;
+
+class TrackView;
+class PluginChainView;
+class Plugin;
+class PluginChain;
+
+class PluginView : public ViewItem
+{
+        Q_OBJECT
+       Q_CLASSINFO("edit_properties", tr("Edit..."))
+       Q_CLASSINFO("remove_plugin", tr("Remove"))
+
+public:
+       PluginView(PluginChainView* pcv, PluginChain* chain, Plugin* plugin, 
int index);
+        ~PluginView();
+
+       Plugin* get_plugin();
+        void set_index(int index);
+
+        void paint(QPainter* painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+
+private:
+       PluginChain*    m_pluginchain;
+       Plugin*         m_plugin;
+
+        int            m_index;
+       int             m_textwidth;
+        QString                m_name;
+       
+        PluginPropertiesDialog* m_propertiesDialog;
+
+public slots:
+       Command* edit_properties();
+        Command* remove_plugin();
+        
+private slots:
+       void repaint();
+};
+
+#endif
+
+//eof
+

Index: PositionIndicator.cpp
===================================================================
RCS file: PositionIndicator.cpp
diff -N PositionIndicator.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PositionIndicator.cpp       21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,71 @@
+/*
+    Copyright (C) 2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#include "PositionIndicator.h"
+
+#include "SheetView.h"
+
+#include <QColor>
+#include <Utils.h>
+
+PositionIndicator::PositionIndicator(ViewItem* parentView)
+       : ViewItem(parentView, 0)
+{
+       calculate_bounding_rect();
+       setFlag(QGraphicsItem::ItemIgnoresTransformations);
+       setZValue(100);
+}
+
+void PositionIndicator::paint(QPainter * painter, const 
QStyleOptionGraphicsItem * option, QWidget * widget)
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       painter->drawPixmap(0, 0, m_background);
+       painter->drawText(m_boundingRect, Qt::AlignVCenter, m_value);
+}
+
+void PositionIndicator::calculate_bounding_rect()
+{
+       prepareGeometryChange();
+       m_boundingRect = QRectF(0, 0, 70, 14);
+       
+       m_background = QPixmap((int)m_boundingRect.width(), 
(int)m_boundingRect.height());
+       m_background.fill(QColor(Qt::transparent));
+       
+       QPainter painter(&m_background);
+       painter.setRenderHint(QPainter::Antialiasing);
+       painter.setBrush(QColor(255, 255, 255));
+       painter.setPen(Qt::NoPen);
+       int rounding = 10;
+       painter.drawRoundRect(0, 0, (int)m_boundingRect.width(), 
(int)m_boundingRect.height(), rounding, rounding);
+}
+
+void PositionIndicator::set_position(int x, int y)
+{
+       setPos(x, y);
+}
+
+void PositionIndicator::set_value(const QString & value)
+{
+       m_value = value;
+}
+

Index: PositionIndicator.h
===================================================================
RCS file: PositionIndicator.h
diff -N PositionIndicator.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ PositionIndicator.h 21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,49 @@
+/*
+    Copyright (C) 2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef POSITION_INDICATOR_H
+#define POSITION_INDICATOR_H
+
+#include "ViewItem.h"
+#include <QPixmap>
+
+class PositionIndicator : public ViewItem
+{
+       Q_OBJECT
+       
+public:
+       PositionIndicator(ViewItem* parent);
+       ~PositionIndicator() {}
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+       void set_position(int x, int y);
+       
+       void set_value(const QString& value);
+       
+private:
+       QString m_value;
+       QPixmap m_background;
+};
+
+#endif
+
+//eof

Index: precompile.h
===================================================================
RCS file: precompile.h
diff -N precompile.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ precompile.h        21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,26 @@
+#include <qcoreapplication.h>
+#include <qlist.h>
+#include <qvariant.h>  // All moc genereated code has this include
+#include <qobject.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qtextcodec.h>
+
+#include <qapplication.h>
+#include <qbitmap.h>
+#include <qcursor.h>
+#include <qdesktopwidget.h>
+#include <qevent.h>
+#include <qimage.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qstyle.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+#include <qgraphicsscene.h>
+#include <qgraphicsview.h>
+#include <qgraphicsitem.h>
+#include <stdlib.h>

Index: SheetView.cpp
===================================================================
RCS file: SheetView.cpp
diff -N SheetView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ SheetView.cpp       21 Jan 2008 16:17:29 -0000      1.1
@@ -0,0 +1,734 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-11  USA.
+
+*/
+
+
+#include <QScrollBar>
+#include <libtraversocore.h>
+
+#include "SheetView.h"
+#include "SheetWidget.h"
+#include "TrackView.h"
+#include "TrackPanelView.h"
+#include "Cursors.h"
+#include "ClipsViewPort.h"
+#include "TimeLineViewPort.h"
+#include "TimeLineView.h"
+#include "TrackPanelViewPort.h"
+#include "Themer.h"
+#include "AddRemove.h"
+
+#include <Zoom.h>
+#include <Scroll.h>
+#include <PlayHeadMove.h>
+#include <WorkCursorMove.h>
+
+#include "AudioDevice.h"
+               
+#include <Debugger.h>
+
+class Shuttle : public Command
+{
+public :
+       Shuttle(SheetView* sv) : Command("Shuttle"), m_sv(sv) {}
+
+       int begin_hold() {
+               m_sv->update_shuttle_factor();
+               m_sv->start_shuttle(true);
+               return 1;
+       }
+
+       int finish_hold() {
+               m_sv->start_shuttle(false);
+               return 1;
+       }
+       
+       int jog() {
+               m_sv->update_shuttle_factor();
+               return 1;
+       }
+
+private :
+       SheetView*      m_sv;
+};
+
+
+static bool smallerTrackView(const TrackView* left, const TrackView* right )
+{
+       return left->get_track()->get_sort_index() < 
right->get_track()->get_sort_index();
+}
+
+SheetView::SheetView(SheetWidget* sheetwidget, 
+       ClipsViewPort* viewPort,
+       TrackPanelViewPort* tpvp,
+       TimeLineViewPort* tlvp,
+       Sheet* sheet)
+       : ViewItem(0, sheet)
+{
+       setZValue(1);
+       
+       m_sheet = sheet;
+       m_clipsViewPort = viewPort;
+       m_tpvp = tpvp;
+       m_tlvp = tlvp;
+       m_vScrollBar = sheetwidget->m_vScrollBar;
+       m_hScrollBar = sheetwidget->m_hScrollBar;
+       m_actOnPlayHead = true;
+       
+       m_clipsViewPort->scene()->addItem(this);
+       
+       m_playCursor = new PlayHead(this, m_sheet, m_clipsViewPort);
+       m_workCursor = new WorkCursor(this, m_sheet);
+       connect(m_sheet, SIGNAL(workingPosChanged()), m_workCursor, 
SLOT(update_position()));
+       connect(m_sheet, SIGNAL(transferStarted()), this, 
SLOT(follow_play_head()));
+       connect(m_sheet, SIGNAL(transportPosSet()), this, 
SLOT(follow_play_head()));
+       connect(m_sheet, SIGNAL(workingPosChanged()), this, 
SLOT(stop_follow_play_head()));
+       
+       m_clipsViewPort->scene()->addItem(m_playCursor);
+       m_clipsViewPort->scene()->addItem(m_workCursor);
+       
+       m_clipsViewPort->setSceneRect(0, 0, MAX_CANVAS_WIDTH, 
MAX_CANVAS_HEIGHT);
+       m_tlvp->setSceneRect(0, -TIMELINE_HEIGHT, MAX_CANVAS_WIDTH, 0);
+       m_tpvp->setSceneRect(-200, 0, 0, MAX_CANVAS_HEIGHT);
+       
+       // Set up the viewports scale factor, and our timeref_scalefactor / 
m_peakCacheZoomFactor
+       // Needed for our childs TrackView, AudioClipView etc which are created 
below.
+       scale_factor_changed();
+       
+       sheet_mode_changed();
+       
+       foreach(Track* track, m_sheet->get_tracks()) {
+               add_new_trackview(track);
+       }
+       
+       connect(m_sheet, SIGNAL(hzoomChanged()), this, 
SLOT(scale_factor_changed()));
+       connect(m_sheet, SIGNAL(tempFollowChanged(bool)), this, 
SLOT(set_follow_state(bool)));
+       connect(m_sheet, SIGNAL(trackAdded(Track*)), this, 
SLOT(add_new_trackview(Track*)));
+       connect(m_sheet, SIGNAL(trackRemoved(Track*)), this, 
SLOT(remove_trackview(Track*)));
+       connect(m_sheet, SIGNAL(lastFramePositionChanged()), this, 
SLOT(update_scrollbars()));
+       connect(m_sheet, SIGNAL(modeChanged()), this, 
SLOT(sheet_mode_changed()));
+       connect(&m_shuttletimer, SIGNAL(timeout()), this, SLOT 
(update_shuttle()));
+       connect(m_hScrollBar, SIGNAL(sliderMoved(int)), this, 
SLOT(stop_follow_play_head()));
+       connect(m_hScrollBar, SIGNAL(actionTriggered(int)), this, 
SLOT(hscrollbar_action(int)));
+       connect(m_hScrollBar, SIGNAL(valueChanged(int)), this, 
SLOT(hscrollbar_value_changed(int)));
+       connect(m_vScrollBar, SIGNAL(valueChanged(int)), 
m_clipsViewPort->verticalScrollBar(), SLOT(setValue(int)));
+       
+       load_theme_data();
+       
+       int x, y;
+       m_sheet->get_scrollbar_xy(x, y);
+       set_hscrollbar_value(x);
+       set_vscrollbar_value(y);
+       
+       m_shuttleCurve = new Curve(0);
+       m_shuttleCurve->set_sheet(m_sheet);
+       m_dragShuttleCurve = new Curve(0);
+       m_dragShuttleCurve->set_sheet(m_sheet);
+       
+       // Use these variables to fine tune the scroll behavior
+       float whens[7] = {0.0, 0.2, 0.3, 0.4, 0.6, 0.9, 1.2};
+       float values[7] = {0.0, 0.15, 0.3, 0.8, 0.95, 1.5, 8.0};
+       
+       // Use these variables to fine tune the scroll during drag behavior
+       float dragWhens[7] =  {0.0, 0.9, 0.94, 0.98, 1.0, 1.1, 1.3};
+       float dragValues[7] = {0.0, 0.0, 0.2,  0.5,  0.85,  1.1,  2.0};
+       
+       for (int i=0; i<7; ++i) {
+               AddRemove* cmd = (AddRemove*) m_dragShuttleCurve->add_node(new 
CurveNode(m_dragShuttleCurve, dragWhens[i], dragValues[i]), false);
+               cmd->set_instantanious(true);
+               Command::process_command(cmd);
+               
+               cmd = (AddRemove*) m_shuttleCurve->add_node(new 
CurveNode(m_shuttleCurve, whens[i], values[i]), false);
+               cmd->set_instantanious(true);
+               Command::process_command(cmd);
+       }
+       
+}
+
+SheetView::~SheetView()
+{
+       delete m_dragShuttleCurve;
+       delete m_shuttleCurve;
+}
+               
+void SheetView::scale_factor_changed( )
+{
+       timeref_scalefactor = qint64(m_sheet->get_hzoom() * 
(UNIVERSAL_SAMPLE_RATE / 44100));
+       m_tlvp->scale_factor_changed();
+       
+//     int highbit;
+//     unsigned long nearestpow2 = 
nearest_power_of_two(long(m_sheet->get_hzoom()), highbit);
+//     if (nearestpow2 == 0) {
+//             nearestpow2 = 1;
+//     }
+//     qreal xscale = nearestpow2 / m_sheet->get_hzoom();
+//     QMatrix matrix;
+//     matrix.scale(xscale, 1);
+//     m_clipsViewPort->setScene(0);
+//     m_clipsViewPort->setMatrix(matrix);
+//     m_clipsViewPort->setScene(scene());
+
+       layout_tracks();
+       
+/*     printf("nearestpow2 %ld, highbit %d \n", nearestpow2, highbit);
+       printf("sheet hzoom %f\n", m_sheet->get_hzoom());
+       printf("xscale %f\n", xscale);*/
+}
+
+void SheetView::sheet_mode_changed()
+{
+       int mode = m_sheet->get_mode();
+       m_clipsViewPort->set_current_mode(mode);
+       m_tlvp->set_current_mode(mode);
+       m_tpvp->set_current_mode(mode);
+}
+
+TrackView* SheetView::get_trackview_under( QPointF point )
+{
+       TrackView* view = 0;
+       QList<QGraphicsItem*> views = 
m_clipsViewPort->items(m_clipsViewPort->mapFromScene(point));
+       
+       for (int i=0; i<views.size(); ++i) {
+               view = dynamic_cast<TrackView*>(views.at(i));
+               if (view) {
+                       return view;
+               }
+       }
+       return  0;
+       
+}
+
+void SheetView::add_new_trackview(Track* track)
+{
+       TrackView* view = new TrackView(this, track);
+       m_trackViews.append(view);
+       
+       int sortIndex = track->get_sort_index();
+       
+       if (sortIndex < 0) {
+               sortIndex = m_trackViews.size();
+               track->set_sort_index(sortIndex);
+       } else {
+               foreach(TrackView* view, m_trackViews) {
+                       if (view->get_track()->get_sort_index() == sortIndex) {
+                               sortIndex = m_trackViews.size();
+                               track->set_sort_index(sortIndex);
+                               break;
+                       }
+               }
+       }
+       
+       qSort(m_trackViews.begin(), m_trackViews.end(), smallerTrackView);
+       
+       for(int i=0; i<m_trackViews.size(); ++i) {
+               m_trackViews.at(i)->get_track()->set_sort_index(i);
+       }
+       
+       if (m_trackViews.size() > 1) {
+               int height = 
m_trackViews.at(m_trackViews.size()-2)->get_track()->get_height();
+               
m_trackViews.at(m_trackViews.size()-1)->get_track()->set_height(height);
+       }
+       
+       layout_tracks();
+}
+
+void SheetView::remove_trackview(Track* track)
+{
+       foreach(TrackView* view, m_trackViews) {
+               if (view->get_track() == track) {
+                       TrackPanelView* tpv = view->get_trackpanel_view();
+                       scene()->removeItem(tpv);
+                       scene()->removeItem(view);
+                       m_trackViews.removeAll(view);
+                       delete view;
+                       delete tpv;
+                       break;
+               }
+       }
+       
+       for(int i=0; i<m_trackViews.size(); ++i) {
+               m_trackViews.at(i)->get_track()->set_sort_index(i);
+       }
+       
+       layout_tracks();
+}
+
+void SheetView::update_scrollbars()
+{
+       int width = (int)(m_sheet->get_last_location() / timeref_scalefactor) - 
(m_clipsViewPort->width() / 4);
+       
+       m_hScrollBar->setRange(0, width);
+       m_hScrollBar->setSingleStep(m_clipsViewPort->width() / 10);
+       m_hScrollBar->setPageStep(m_clipsViewPort->width());
+       
+       m_vScrollBar->setRange(0, m_sceneHeight - m_clipsViewPort->height() / 
2);
+       m_vScrollBar->setSingleStep(m_clipsViewPort->height() / 10);
+       m_vScrollBar->setPageStep(m_clipsViewPort->height());
+       
+       m_playCursor->set_bounding_rect(QRectF(0, 0, 2, m_vScrollBar->maximum() 
+ m_clipsViewPort->height()));
+       m_playCursor->update_position();
+       m_workCursor->set_bounding_rect(QRectF(0, 0, 1, m_vScrollBar->maximum() 
+ m_clipsViewPort->height()));
+       m_workCursor->update_position();
+       
+       set_snap_range(m_hScrollBar->value());
+}
+
+void SheetView::hscrollbar_value_changed(int value)
+{
+       // This slot is called when the hscrollbar value changes,
+       // which can be due shuttling or playhead scrolling the page.
+       // In that very case, we do NOT set the hscrollbar value AGAIN
+       // but in case of a non-shuttle command, we call ie().jog to give the 
+       // command the opportunity to update (Gain-cursor position for example) 
+       // itself for the changed viewport / mouse coordinates.
+       // FIXME This is NOT a solution to set hold-cursors at the correct
+       // position in the viewport when it's scrolled programatically !!!!!
+       if (ie().is_holding()) {
+               Shuttle* s = dynamic_cast<Shuttle*>(ie().get_holding_command());
+               Zoom* z = dynamic_cast<Zoom*>(ie().get_holding_command());
+               if (!(s || z)) {
+                       ie().jog();
+               }
+       } else {
+               m_clipsViewPort->horizontalScrollBar()->setValue(value);
+       }
+       
+       set_snap_range(m_hScrollBar->value());
+}
+
+void SheetView::vzoom(qreal factor)
+{
+       PENTER;
+       for (int i=0; i<m_trackViews.size(); ++i) {
+               TrackView* view = m_trackViews.at(i);
+               Track* track = view->get_track();
+               int height = track->get_height();
+               height = (int) (height * factor);
+               if (height > m_trackMaximumHeight) {
+                       height = m_trackMaximumHeight;
+               } else if (height < m_trackMinimumHeight) {
+                       height = m_trackMinimumHeight;
+               }
+               track->set_height(height);
+       }
+       
+       layout_tracks();
+}
+
+void SheetView::hzoom(qreal factor)
+{
+       PENTER;
+       m_sheet->set_hzoom(m_sheet->get_hzoom() * factor);
+       center();
+}
+
+
+void SheetView::layout_tracks()
+{
+       int verticalposition = m_trackTopIndent;
+       for (int i=0; i<m_trackViews.size(); ++i) {
+               TrackView* view = m_trackViews.at(i);
+               view->calculate_bounding_rect();
+               view->move_to(0, verticalposition);
+               verticalposition += (view->get_track()->get_height() + 
m_trackSeperatingHeight);
+       }
+       
+       m_sceneHeight = verticalposition;
+       update_scrollbars();
+}
+
+
+Command* SheetView::center()
+{
+       PENTER2;
+       TimeRef centerX;
+       if (m_sheet->is_transport_rolling() && m_actOnPlayHead) { 
+               centerX = m_sheet->get_transport_location();
+       } else {
+               centerX = m_sheet->get_work_location();
+       }
+       
+       int x = qRound(centerX / timeref_scalefactor);
+       set_hscrollbar_value(x - m_clipsViewPort->width() / 2);
+       return (Command*) 0;
+}
+
+
+void SheetView::stop_follow_play_head()
+{
+       m_sheet->set_temp_follow_state(false);
+}
+
+
+void SheetView::follow_play_head()
+{
+       m_sheet->set_temp_follow_state(true);
+}
+
+
+void SheetView::set_follow_state(bool state)
+{
+       if (state) {
+               m_actOnPlayHead = true;
+               m_playCursor->enable_follow();
+               m_playCursor->setPos(m_sheet->get_transport_location() / 
timeref_scalefactor, 0);
+       } else {
+               m_actOnPlayHead = false;
+               m_playCursor->disable_follow();
+       }
+}
+
+
+Command* SheetView::shuttle()
+{
+       return new Shuttle(this);
+}
+
+
+void SheetView::start_shuttle(bool start, bool drag)
+{
+       if (start) {
+               m_shuttletimer.start(40);
+               m_dragShuttle = drag;
+               m_shuttleYfactor = m_shuttleXfactor = 0;
+               stop_follow_play_head();
+       } else {
+               m_shuttletimer.stop();
+       }
+}
+
+void SheetView::set_shuttle_factor_values(int x, int y)
+{
+       m_shuttleXfactor = x;
+       m_shuttleYfactor = y;
+}
+
+
+void SheetView::update_shuttle_factor()
+{
+       float vec[2];
+       int direction = 1;
+       
+       float normalizedX = (float) cpointer().x() / m_clipsViewPort->width();
+       
+       if (normalizedX < 0.5) {
+               normalizedX = 0.5 - normalizedX;
+               normalizedX *= 2;
+               direction = -1;
+       } else if (normalizedX > 0.5) {
+               normalizedX = normalizedX - 0.5;
+               normalizedX *= 2;
+               if (normalizedX > 1.0) {
+                       normalizedX *= 1.15;
+               }
+       }
+       
+       if (m_dragShuttle) {
+               m_dragShuttleCurve->get_vector(normalizedX, normalizedX + 0.01, 
vec, 2);
+       } else {
+               m_shuttleCurve->get_vector(normalizedX, normalizedX + 0.01, 
vec, 2);
+       }
+       
+       if (direction > 0) {
+               m_shuttleXfactor = (int) (vec[0] * 30);
+       } else {
+               m_shuttleXfactor = (int) (vec[0] * -30);
+       }
+       
+       direction = 1;
+       float normalizedY = (float) cpointer().y() / m_clipsViewPort->height();
+       
+       if (normalizedY < 0) normalizedY = 0;
+       if (normalizedY > 1) normalizedY = 1;
+       
+       if (normalizedY > 0.35 && normalizedY < 0.65) {
+               normalizedY = 0;
+       } else if (normalizedY < 0.5) {
+               normalizedY = 0.5 - normalizedY;
+               direction = -1;
+       } else if (normalizedY > 0.5) {
+               normalizedY = normalizedY - 0.5;
+       }
+       
+       normalizedY *= 2;
+       
+       if (m_dragShuttle) {
+               m_dragShuttleCurve->get_vector(normalizedY, normalizedY + 0.01, 
vec, 2);
+       } else {
+               m_shuttleCurve->get_vector(normalizedY, normalizedY + 0.01, 
vec, 2);
+       }
+       
+       int yscale;
+       
+       if (m_trackViews.size()) {
+               yscale = int(mean_track_height() / 10);
+       } else {
+               yscale = int(m_clipsViewPort->viewport()->height() / 10);
+       }
+       
+       if (direction > 0) {
+               m_shuttleYfactor = (int) (vec[0] * yscale);
+       } else {
+               m_shuttleYfactor = (int) (vec[0] * -yscale);
+       }
+       
+       if (m_dragShuttle) {
+               m_shuttleYfactor *= 4;
+       }
+}
+
+int SheetView::mean_track_height()
+{
+       int total =0;
+       int mean = 0;
+       
+       foreach(TrackView* view, m_trackViews) {
+               total += view->get_height();
+       }
+       
+       mean = total / m_trackViews.size();
+       
+       return mean;
+}
+
+void SheetView::update_shuttle()
+{
+       int x = m_clipsViewPort->horizontalScrollBar()->value() + 
m_shuttleXfactor;
+       set_hscrollbar_value(x);
+       
+       int y = m_clipsViewPort->verticalScrollBar()->value() + 
m_shuttleYfactor;
+       set_vscrollbar_value(y);
+       
+       if (m_shuttleXfactor != 0 || m_shuttleYfactor != 0) {
+               ie().jog();
+       }
+}
+
+
+Command* SheetView::goto_begin()
+{
+       stop_follow_play_head();
+       m_sheet->set_work_at(TimeRef());
+       center();
+       return (Command*) 0;
+}
+
+
+Command* SheetView::goto_end()
+{
+       stop_follow_play_head();
+       TimeRef lastlocation = m_sheet->get_last_location();
+       m_sheet->set_work_at(lastlocation);
+       center();
+       return (Command*) 0;
+}
+
+
+TrackPanelViewPort* SheetView::get_trackpanel_view_port( ) const
+{
+       return m_tpvp;
+}
+
+ClipsViewPort * SheetView::get_clips_viewport() const
+{
+       return m_clipsViewPort;
+}
+
+
+Command * SheetView::touch( )
+{
+       QPointF point = 
m_clipsViewPort->mapToScene(QPoint(cpointer().on_first_input_event_x(), 
cpointer().on_first_input_event_y()));
+       m_sheet->set_work_at(TimeRef(point.x() * timeref_scalefactor));
+
+       return 0;
+}
+
+Command * SheetView::touch_play_cursor( )
+{
+       QPointF point = 
m_clipsViewPort->mapToScene(QPoint(cpointer().on_first_input_event_x(), 
cpointer().on_first_input_event_y()));
+       m_playCursor->setPos(point.x(), 0);
+       m_sheet->set_transport_pos(TimeRef(point.x() * timeref_scalefactor));
+
+       return 0;
+}
+
+Command * SheetView::play_to_begin( )
+{
+       m_playCursor->setPos(0, 0);
+       m_sheet->set_transport_pos(TimeRef());
+
+       return 0;
+}
+
+Command * SheetView::play_cursor_move( )
+{
+       return new PlayHeadMove(m_playCursor, this);
+}
+
+Command * SheetView::work_cursor_move( )
+{
+       return new WorkCursorMove(m_playCursor, this);
+}
+
+void SheetView::set_snap_range(int start)
+{
+//     printf("SheetView::set_snap_range\n");
+       m_sheet->get_snap_list()->set_range(TimeRef(start * 
timeref_scalefactor),
+                                       TimeRef((start + 
m_clipsViewPort->viewport()->width()) * timeref_scalefactor),
+                                       timeref_scalefactor);
+}
+
+Command* SheetView::scroll_up( )
+{
+       PENTER3;
+       set_vscrollbar_value(m_clipsViewPort->verticalScrollBar()->value() - 
int(mean_track_height() * 0.75));
+       return (Command*) 0;
+}
+
+Command* SheetView::scroll_down( )
+{
+       PENTER3;
+       set_vscrollbar_value(m_clipsViewPort->verticalScrollBar()->value() + 
int(mean_track_height() * 0.75));
+       return (Command*) 0;
+}
+
+Command* SheetView::scroll_right()
+{
+       PENTER3;
+       stop_follow_play_head();
+       set_hscrollbar_value(m_clipsViewPort->horizontalScrollBar()->value() + 
50);
+       return (Command*) 0;
+}
+
+
+Command* SheetView::scroll_left()
+{
+       PENTER3;
+       stop_follow_play_head();
+       set_hscrollbar_value(m_clipsViewPort->horizontalScrollBar()->value() - 
50);
+       return (Command*) 0;
+}
+
+Command* SheetView::scroll_up_hold( )
+{
+       PENTER3;
+       return new Scroll(0, -20, this);
+}
+
+Command* SheetView::scroll_down_hold( )
+{
+       PENTER3;
+       return new Scroll(0, 20, this);
+}
+
+Command* SheetView::scroll_right_hold()
+{
+       PENTER3;
+       return new Scroll(20, 0, this);
+}
+
+
+Command* SheetView::scroll_left_hold()
+{
+       PENTER3;
+       return new Scroll(-20, 0, this);
+}
+
+int SheetView::hscrollbar_value() const
+{
+       return m_clipsViewPort->horizontalScrollBar()->value();
+}
+
+void SheetView::hscrollbar_action(int action)
+{
+       if (action == QAbstractSlider::SliderPageStepAdd || action == 
QAbstractSlider::SliderPageStepSub) {
+               stop_follow_play_head();
+       }
+}
+
+int SheetView::vscrollbar_value() const
+{
+       return m_clipsViewPort->verticalScrollBar()->value();
+}
+
+void SheetView::load_theme_data()
+{
+       m_trackSeperatingHeight = 
themer()->get_property("Sheet:track:seperatingheight", 0).toInt();
+       m_trackMinimumHeight = 
themer()->get_property("Sheet:track:minimumheight", 16).toInt();
+       m_trackMaximumHeight = 
themer()->get_property("Sheet:track:maximumheight", 300).toInt();
+       m_trackTopIndent = themer()->get_property("Sheet:track:topindent", 
6).toInt();
+       
+       
m_clipsViewPort->setBackgroundBrush(themer()->get_color("Sheet:background"));
+       
m_tpvp->setBackgroundBrush(themer()->get_color("TrackPanel:background"));
+
+       layout_tracks();
+}
+
+Command * SheetView::add_marker()
+{
+       return m_tlvp->get_timeline_view()->add_marker();
+}
+
+Command * SheetView::add_marker_at_playhead()
+{
+       return m_tlvp->get_timeline_view()->add_marker_at_playhead();
+}
+
+Command * SheetView::playhead_to_workcursor( )
+{
+       TimeRef worklocation = m_sheet->get_work_location();
+
+       m_sheet->set_transport_pos(worklocation);
+       m_playCursor->setPos(worklocation / timeref_scalefactor, 0);
+       
+       if (!m_sheet->is_transport_rolling()) {
+               center();
+       }
+
+       return (Command*) 0;
+}
+
+Command * SheetView::center_playhead( )
+{
+       TimeRef centerX = m_sheet->get_transport_location();
+       set_hscrollbar_value(int(centerX / timeref_scalefactor - 
m_clipsViewPort->width() / 2));
+       
+       follow_play_head();
+
+       return (Command*) 0;
+}
+
+void SheetView::set_hscrollbar_value(int value)
+{
+       m_clipsViewPort->horizontalScrollBar()->setValue(value);
+       m_hScrollBar->setValue(value);
+       m_sheet->set_scrollbar_xy(m_hScrollBar->value(), m_vScrollBar->value());
+}
+
+void SheetView::set_vscrollbar_value(int value)
+{
+       if (value > m_vScrollBar->maximum()) {
+               value = m_vScrollBar->maximum();
+       }
+       m_clipsViewPort->verticalScrollBar()->setValue(value);
+       m_vScrollBar->setValue(value);
+       m_sheet->set_scrollbar_xy(m_hScrollBar->value(), m_vScrollBar->value());
+}
+

Index: SheetView.h
===================================================================
RCS file: SheetView.h
diff -N SheetView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ SheetView.h 21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,170 @@
+/*
+    Copyright (C) 2005-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef SONG_VIEW_H
+#define SONG_VIEW_H
+
+#include "ViewItem.h"
+#include <QTimer>
+
+class Sheet;
+class TrackView;
+class ClipsViewPort;
+class TrackPanelViewPort;
+class TimeLineViewPort;
+class Track;
+class SheetWidget;
+class TrackView;
+class PlayHead;
+class WorkCursor;
+class Curve;
+
+class SheetView : public ViewItem
+{
+        Q_OBJECT
+       Q_CLASSINFO("touch", tr("Set"))
+       Q_CLASSINFO("touch_play_cursor", tr("Set"))
+       Q_CLASSINFO("center", tr("Center View"))
+       Q_CLASSINFO("scroll_right", tr("Right"))
+       Q_CLASSINFO("scroll_left", tr("Left"))
+       Q_CLASSINFO("scroll_up", tr("Up"))
+       Q_CLASSINFO("scroll_down", tr("Down"))
+       Q_CLASSINFO("scroll_right_hold", tr("Right"))
+       Q_CLASSINFO("scroll_left_hold", tr("Left"))
+       Q_CLASSINFO("scroll_up_hold", tr("Up"))
+       Q_CLASSINFO("scroll_down_hold", tr("Down"))
+       Q_CLASSINFO("shuttle", tr("Shuttle"))
+       Q_CLASSINFO("goto_begin", tr("To start"))
+       Q_CLASSINFO("goto_end", tr("To end"))
+       Q_CLASSINFO("play_to_begin", tr("To Start"))
+       Q_CLASSINFO("play_cursor_move", tr("Move"))
+       Q_CLASSINFO("work_cursor_move", tr("Move"))
+       Q_CLASSINFO("add_marker", tr("Add Marker"))
+       Q_CLASSINFO("add_marker_at_playhead", tr("Add Marker at Playhead"))
+       Q_CLASSINFO("playhead_to_workcursor", tr("To workcursor"))
+       Q_CLASSINFO("center_playhead", tr("Center"))
+
+public :
+
+        SheetView(SheetWidget* sheetwidget,
+                       ClipsViewPort* viewPort,
+                       TrackPanelViewPort* tpvp, 
+                               TimeLineViewPort* tlvp, 
+                       Sheet* sheet);
+        ~SheetView();
+       
+       void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) {};
+       QRectF boundingRect() const {return QRectF();}
+       
+       Sheet* get_sheet() const {return m_sheet;}
+       TrackPanelViewPort* get_trackpanel_view_port() const;
+       ClipsViewPort* get_clips_viewport() const;
+       
+       TrackView* get_trackview_under(QPointF point);
+       
+       void load_theme_data();
+       void start_shuttle(bool start, bool drag=false);
+       void update_shuttle_factor();
+       void set_shuttle_factor_values(int x, int y);
+       void vzoom(qreal scale);
+       void hzoom(qreal scale);
+       int hscrollbar_value() const;
+       int vscrollbar_value() const;
+       int get_peak_cache_zoom_factor() const {return m_peakCacheZoomFactor;}
+
+       qint64          timeref_scalefactor;
+
+private:
+        Sheet*                         m_sheet;
+       Curve*                  m_shuttleCurve;
+       Curve*                  m_dragShuttleCurve;
+       PlayHead*               m_playCursor;
+       ClipsViewPort*          m_clipsViewPort;
+       TrackPanelViewPort*     m_tpvp;
+       TimeLineViewPort*       m_tlvp;
+       QList<TrackView*>       m_trackViews;
+       WorkCursor*             m_workCursor;
+       int                     m_shuttleXfactor;
+       int                     m_shuttleYfactor;
+       int                     m_sceneHeight;
+       int                     m_peakCacheZoomFactor;
+       bool                    m_dragShuttle;
+       QTimer                  m_shuttletimer;
+       QScrollBar*             m_vScrollBar;
+       QScrollBar*             m_hScrollBar;
+       bool                    m_actOnPlayHead;
+       
+       // Themeing data
+       int     m_trackSeperatingHeight;
+       int     m_trackMinimumHeight;
+       int     m_trackMaximumHeight;
+       int     m_trackTopIndent;
+       
+       void layout_tracks();
+       void set_hscrollbar_value(int value);
+       void set_vscrollbar_value(int value);
+       
+       int mean_track_height();
+       
+       friend class PlayHead;
+
+
+public slots:
+       void set_snap_range(int);
+       void update_scrollbars();
+       void stop_follow_play_head();
+       void follow_play_head();
+       void set_follow_state(bool state);
+
+       Command* touch();
+       Command* touch_play_cursor();
+        Command* center();
+        Command* scroll_right();
+        Command* scroll_left();
+        Command* scroll_up();
+        Command* scroll_down();
+        Command* scroll_right_hold();
+        Command* scroll_left_hold();
+        Command* scroll_up_hold();
+        Command* scroll_down_hold();
+        Command* shuttle();
+        Command* goto_begin();
+        Command* goto_end();
+       Command* play_to_begin();
+       Command* play_cursor_move();
+       Command* work_cursor_move();
+       Command* add_marker();
+       Command* add_marker_at_playhead();
+       Command* playhead_to_workcursor();
+       Command* center_playhead();
+       
+private slots:
+       void scale_factor_changed();
+       void add_new_trackview(Track*);
+       void remove_trackview(Track*);
+       void update_shuttle();
+       void sheet_mode_changed();
+       void hscrollbar_value_changed(int);
+       void hscrollbar_action(int);
+};
+
+
+#endif

Index: SheetWidget.cpp
===================================================================
RCS file: SheetWidget.cpp
diff -N SheetWidget.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ SheetWidget.cpp     21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,309 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+               
+#include "SheetWidget.h"
+#include "TrackPanelViewPort.h"
+#include "ClipsViewPort.h"
+#include "TimeLineViewPort.h"
+#include "SheetView.h"
+#include "Themer.h"
+#include "Config.h"
+
+#include <Sheet.h>
+#include "Utils.h"
+#include "ContextPointer.h"
+#include "Mixer.h"
+
+#if defined (QT_OPENGL_SUPPORT)
+#include <QtOpenGL>
+#endif
+
+#include <QGridLayout>
+#include <QScrollBar>
+
+#include <Debugger.h>
+
+
+SheetPanelGain::SheetPanelGain(ViewItem* parent, Sheet* sheet)
+       : ViewItem(parent, sheet)
+       , m_sheet(sheet)
+{
+       m_boundingRect = QRectF(0, 0, 180, 9);
+       connect(sheet, SIGNAL(masterGainChanged()), this, SLOT(update_gain()));
+       setAcceptsHoverEvents(true);
+}
+
+void SheetPanelGain::paint( QPainter * painter, const QStyleOptionGraphicsItem 
* option, QWidget * widget )
+{
+       Q_UNUSED(widget);
+       const int height = 9;
+
+       int sliderWidth = (int)m_boundingRect.width() - 75;
+       float gain = m_sheet->get_gain();
+       QString sgain = coefficient_to_dbstring(gain);
+       float db = coefficient_to_dB(gain);
+
+       if (db < -60) {
+               db = -60;
+       }
+       int sliderdbx =  (int) (sliderWidth - (sliderWidth*0.3)) - (int) ( ( 
(-1 * db) / 60 ) * sliderWidth);
+       if (sliderdbx < 0) {
+               sliderdbx = 0;
+       }
+       if (db > 0) {
+               sliderdbx =  (int)(sliderWidth*0.7) + (int) ( ( db / 6 ) * 
(sliderWidth*0.3));
+       }
+
+       int cr = (gain >= 1 ? 30 + (int)(100 * gain) : (int)(50 * gain));
+       int cb = ( gain < 1 ? 150 + (int)(50 * gain) : abs((int)(10 * gain)) );
+       
+       painter->setPen(themer()->get_color("TrackPanel:text"));
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:gain"));
+       painter->drawText(0, height + 1, "GAIN");
+       painter->drawRect(30, 1, sliderWidth, height);
+       
+       bool mousehover = (option->state & QStyle::State_MouseOver);
+       QColor color(cr,0,cb);
+       if (mousehover) {
+               color = color.light(140);
+       }
+       painter->fillRect(31, 2, sliderdbx, height-1, color);
+       painter->drawText(sliderWidth + 35, height, sgain);
+}
+
+Command* SheetPanelGain::gain_increment()
+{
+       m_sheet->set_gain(m_sheet->get_gain() + 0.05);
+       return 0;
+}
+
+Command* SheetPanelGain::gain_decrement()
+{
+       m_sheet->set_gain(m_sheet->get_gain() - 0.05);
+       return 0;
+}
+
+
+SheetPanelView::SheetPanelView(QGraphicsScene* scene, Sheet* sheet)
+       : ViewItem(0, 0)
+       , m_sheet(sheet)
+{
+       scene->addItem(this);
+       m_gainview = new SheetPanelGain(this, m_sheet);
+       m_gainview->setPos(10, 16);
+#if QT_VERSION < 0x040300
+       scene->addItem(m_gainview);
+#endif
+       m_boundingRect = QRectF(0, 0, 200, TIMELINE_HEIGHT);
+}
+
+void SheetPanelView::paint(QPainter * painter, const QStyleOptionGraphicsItem 
* option, QWidget * widget)
+{
+       int xstart = (int)option->exposedRect.x();
+       int pixelcount = (int)option->exposedRect.width();
+       
+       painter->setPen(themer()->get_color("TrackPanel:text"));
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:led"));
+       painter->drawText(10, 11, "Sheet: " + m_sheet->get_title());
+       
+       QColor color = 
QColor(Qt::darkGray);//themer()->get_color("Track:cliptopoffset");
+       painter->setPen(color);
+       painter->fillRect(xstart, TIMELINE_HEIGHT - 2, pixelcount, 2, color);
+       painter->fillRect(199, 0, 1, TIMELINE_HEIGHT, color);
+}
+
+class SheetPanelViewPort : public ViewPort
+{
+public:
+       SheetPanelViewPort(QGraphicsScene* scene, SheetWidget* sw);
+       ~SheetPanelViewPort() {};
+
+       void get_pointed_context_items(QList<ContextItem* > &list)
+       {
+               QList<QGraphicsItem *> itemlist = 
items(cpointer().on_first_input_event_x(), cpointer().on_first_input_event_y());
+               foreach(QGraphicsItem* item, itemlist) {
+                       if (ViewItem::is_viewitem(item)) {
+                               list.append((ViewItem*)item);
+                       }
+               }
+               list.removeAll(m_spv);
+               list.append(m_sv);
+       }
+       
+       void set_sheet_view(SheetView* sv)
+       {
+               m_sv = sv;
+               m_spv = new SheetPanelView(scene(), m_sheet);
+               m_spv->setPos(-200, -TIMELINE_HEIGHT);
+       }
+
+private:
+       Sheet*  m_sheet;
+       SheetView* m_sv;
+       SheetPanelView* m_spv;
+};
+
+
+SheetPanelViewPort::SheetPanelViewPort(QGraphicsScene * scene, SheetWidget * 
sw)
+       : ViewPort(scene, sw)
+{
+       setSceneRect(-200, -TIMELINE_HEIGHT, 200, 0);
+       m_sheet = sw->get_sheet();
+       
+       setMaximumHeight(TIMELINE_HEIGHT);
+       setMinimumHeight(TIMELINE_HEIGHT);
+       setMinimumWidth(200);
+       setMaximumWidth(200);
+       setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       setBackgroundBrush(themer()->get_color("SheetPanel:background"));
+}
+
+
+SheetWidget::SheetWidget(Sheet* sheet, QWidget* parent)
+       : QFrame(parent)
+       , m_sheet(sheet)
+{
+       if (!m_sheet) {
+               return;
+       }
+       m_scene = new QGraphicsScene();
+       m_vScrollBar = new QScrollBar(this);
+       m_hScrollBar = new QScrollBar(this);
+       m_hScrollBar->setOrientation(Qt::Horizontal);
+
+       m_trackPanel = new TrackPanelViewPort(m_scene, this);
+       m_clipsViewPort = new ClipsViewPort(m_scene, this);
+       m_timeLine = new TimeLineViewPort(m_scene, this);
+       m_sheetPanelVP = new SheetPanelViewPort(m_scene, this);
+       
+       m_mainLayout = new QGridLayout(this);
+       m_mainLayout->addWidget(m_sheetPanelVP, 0, 0);
+       m_mainLayout->addWidget(m_timeLine, 0, 1);
+       m_mainLayout->addWidget(m_trackPanel, 1, 0);
+       m_mainLayout->addWidget(m_clipsViewPort, 1, 1);
+       m_mainLayout->addWidget(m_hScrollBar, 2, 1);
+       m_mainLayout->addWidget(m_vScrollBar, 1, 2);
+       
+       m_mainLayout->setMargin(0);
+       m_mainLayout->setSpacing(0);
+
+       setLayout(m_mainLayout);
+       
+       m_sv = new SheetView(this, m_clipsViewPort, m_trackPanel, m_timeLine, 
sheet);
+       m_timeLine->set_sheetview(m_sv);
+       m_sheetPanelVP->set_sheet_view(m_sv);
+       
+       connect(m_clipsViewPort->horizontalScrollBar(), 
+               SIGNAL(valueChanged(int)),
+               m_timeLine->horizontalScrollBar(), 
+               SLOT(setValue(int)));
+       
+       connect(m_timeLine->horizontalScrollBar(), 
+               SIGNAL(valueChanged(int)),
+               m_clipsViewPort->horizontalScrollBar(), 
+               SLOT(setValue(int)));
+       
+       connect(m_clipsViewPort->verticalScrollBar(), 
+               SIGNAL(valueChanged(int)),
+               m_trackPanel->verticalScrollBar(), 
+               SLOT(setValue(int)));
+       
+       connect(m_trackPanel->verticalScrollBar(), 
+               SIGNAL(valueChanged(int)),
+               m_clipsViewPort->verticalScrollBar(), 
+               SLOT(setValue(int)));
+       
+       connect(themer(), SIGNAL(themeLoaded()), this, SLOT(load_theme_data()), 
Qt::QueuedConnection);
+       
+       m_usingOpenGL  = false;
+       set_use_opengl(config().get_property("Interface", "OpenGL", 
false).toBool());
+
+       setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+
+       cpointer().set_current_viewport(m_clipsViewPort);
+       m_clipsViewPort->setFocus();
+}
+
+
+SheetWidget::~ SheetWidget()
+{
+       if (!m_sheet) {
+               return;
+       }
+       delete m_trackPanel;
+       delete m_clipsViewPort;
+       delete m_timeLine;
+       delete m_sheetPanelVP;
+       delete m_scene;
+}
+
+
+QSize SheetWidget::minimumSizeHint() const
+{
+       return QSize(400, 200);
+}
+
+QSize SheetWidget::sizeHint() const
+{
+       return QSize(700, 600);
+}
+
+void SheetWidget::set_use_opengl( bool useOpenGL )
+{
+       if (!m_sheet) {
+               return;
+       }
+       
+       if (useOpenGL != m_usingOpenGL) {
+#if defined (QT_OPENGL_SUPPORT)
+               m_clipsViewPort->setViewport(useOpenGL ? new 
QGLWidget(QGLFormat(QGL::SampleBuffers)) : new QWidget);
+               m_trackPanel->setViewport(useOpenGL ? new 
QGLWidget(QGLFormat(QGL::SampleBuffers)) : new QWidget);
+#endif
+       }
+       m_usingOpenGL = useOpenGL;
+}
+
+
+void SheetWidget::load_theme_data()
+{
+       QList<QGraphicsItem*> list = m_scene->items();
+       
+       for (int i = 0; i < list.size(); ++i) {
+               ViewItem* item = qgraphicsitem_cast<ViewItem*>(list.at(i));
+               if (item) {
+                       item->load_theme_data();
+               }
+       }
+       
+}
+
+Sheet * SheetWidget::get_sheet() const
+{
+       return m_sheet;
+}
+
+SheetView * SheetWidget::get_sheetview() const
+{
+       return m_sv;
+}
+

Index: SheetWidget.h
===================================================================
RCS file: SheetWidget.h
diff -N SheetWidget.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ SheetWidget.h       21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,114 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: SheetWidget.h,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#ifndef SONG_WIDGET_H
+#define SONG_WIDGET_H
+
+#include <QFrame>
+#include "ViewItem.h"
+
+class QGridLayout;
+class QGraphicsScene;
+class QScrollBar;
+               
+class TrackPanelViewPort;
+class TimeLineViewPort;
+class ClipsViewPort;
+class SheetPanelViewPort;
+
+class Project;
+class Sheet;
+class Command;
+class SheetView;
+
+class SheetPanelGain : public ViewItem
+{
+       Q_OBJECT
+public:
+       SheetPanelGain(ViewItem* parent, Sheet* sheet);
+       SheetPanelGain(){}
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+
+public slots:
+       Command* gain_increment();
+       Command* gain_decrement();
+
+private slots:
+       void update_gain() {update();}
+
+private:
+       Sheet* m_sheet;
+};
+
+class SheetPanelView : public ViewItem
+{
+       Q_OBJECT
+public:
+       SheetPanelView(QGraphicsScene* scene, Sheet* sheet);
+       ~SheetPanelView() {}
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+
+private:
+       SheetPanelGain* m_gainview;
+       Sheet* m_sheet;
+};
+
+class SheetWidget : public QFrame
+{
+       Q_OBJECT
+public:
+       SheetWidget(Sheet* sheet, QWidget* parent=0);
+       ~SheetWidget();
+       
+       void set_use_opengl(bool useOpenGL);
+       Sheet* get_sheet() const;
+       SheetView* get_sheetview() const;
+       
+protected:
+       QSize minimumSizeHint () const;
+       QSize sizeHint () const;
+
+private:
+       SheetView*              m_sv;
+       Sheet*                  m_sheet;
+       QGridLayout*            m_mainLayout;
+       TrackPanelViewPort*     m_trackPanel;
+       TimeLineViewPort*       m_timeLine;
+       ClipsViewPort*          m_clipsViewPort;
+       SheetPanelViewPort*     m_sheetPanelVP;
+       QGraphicsScene*         m_scene;
+       QScrollBar*             m_vScrollBar;
+       QScrollBar*             m_hScrollBar;
+       bool                    m_usingOpenGL;
+       
+       friend class SheetView;
+
+private slots:
+       void load_theme_data();
+};
+
+
+#endif
+
+//eof

Index: songcanvas.pri
===================================================================
RCS file: songcanvas.pri
diff -N songcanvas.pri
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ songcanvas.pri      21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,43 @@
+PRECOMPILED_HEADER = songcanvas/precompile.h
+
+
+SOURCES += \
+       songcanvas/AudioClipView.cpp \
+       songcanvas/SongWidget.cpp \
+       songcanvas/ClipsViewPort.cpp \
+       songcanvas/CurveView.cpp \
+       songcanvas/CurveNodeView.cpp \
+       songcanvas/TimeLineViewPort.cpp \
+       songcanvas/TrackPanelViewPort.cpp \
+       songcanvas/TrackView.cpp \
+#      songcanvas/ViewItem.cpp \
+       songcanvas/ViewPort.cpp \
+       songcanvas/SongView.cpp \
+       songcanvas/TimeLineView.cpp \
+       songcanvas/TrackPanelView.cpp \
+       songcanvas/Cursors.cpp \
+       songcanvas/FadeView.cpp \
+        songcanvas/FadeContextDialogView.cpp \
+       songcanvas/PluginView.cpp \
+       songcanvas/PluginChainView.cpp \
+
+HEADERS += \
+       songcanvas/AudioClipView.h \
+       songcanvas/SongWidget.h \
+       songcanvas/ClipsViewPort.h \
+       songcanvas/CurveView.h \
+       songcanvas/CurveNodeView.h \
+       songcanvas/TimeLineViewPort.h \
+       songcanvas/TrackPanelViewPort.h \
+       songcanvas/TrackView.h \
+       songcanvas/ViewItem.h \
+       songcanvas/ViewPort.h \
+       songcanvas/SongView.h \
+       songcanvas/TimeLineview.h \
+       songcanvas/TrackPanelView.h \
+       songcanvas/Cursors.h \
+       songcanvas/FadeView.h \
+        songcanvas/FadeContextDialogView.h \
+       songcanvas/PluginView.h \
+       songcanvas/PluginChainView.h \
+ 

Index: songcanvas.pro
===================================================================
RCS file: songcanvas.pro
diff -N songcanvas.pro
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ songcanvas.pro      21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,79 @@
+include(../../libbase.pri)
+
+TARGET = traversosongcanvas
+DESTDIR = ../../../lib
+TEMPLATE = lib
+
+PRECOMPILED_HEADER = precompile.h 
+
+INCLUDEPATH +=         ../../core \
+               ../../common \
+               ../../traverso \
+               ../../traverso/dialogs \
+               ../../engine \
+               ../../commands \
+               ../../commands/build \
+               ../../plugins \
+               ../../plugins/native \
+               ./
+
+SOURCES += AudioClipView.cpp \
+ClipsViewPort.cpp \
+Cursors.cpp \
+CurveNodeView.cpp \
+CurveView.cpp \
+FadeContextDialogView.cpp \
+FadeView.cpp \
+MarkerView.cpp \
+PluginChainView.cpp \
+PluginView.cpp \
+SongView.cpp \
+SongWidget.cpp \
+TimeLineView.cpp \
+TimeLineViewPort.cpp \
+TrackPanelView.cpp \
+TrackPanelViewPort.cpp \
+TrackView.cpp \
+ViewItem.cpp \
+dialogs/AudioClipEditDialog.cpp
+
+HEADERS += AudioClipView.h \
+ClipsViewPort.h \
+Cursors.h \
+CurveNodeView.h \
+CurveView.h \
+FadeContextDialogView.h \
+FadeView.h \
+libtraversosongcanvas.h \
+MarkerView.h \
+PluginChainView.h \
+PluginView.h \
+precompile.h \
+SongView.h \
+SongWidget.h \
+TimeLineView.h \
+TimeLineViewPort.h \
+TrackPanelView.h \
+TrackPanelViewPort.h \
+TrackView.h \
+ViewItem.h \
+LineView.h \
+dialogs/AudioClipEditDialog.h
+
+FORMS += \
+ui/AudioClipEditDialog.ui \
+
+
+contains(DEFINES, LV2_SUPPORT){
+    INCLUDEPATH +=     \
+       ../../plugins/LV2 \
+       ../../3rdparty/slv2 
+}
+
+contains(DEFINES, QT_OPENGL_SUPPORT){
+QT += opengl
+}
+
+win32{
+    INCLUDEPATH += ../../../3thparty/include
+}

Index: TimeLineView.cpp
===================================================================
RCS file: TimeLineView.cpp
diff -N TimeLineView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TimeLineView.cpp    21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,493 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include "TimeLineView.h"
+
+#include <QPainter>
+
+#include "Themer.h"
+#include "SheetView.h"
+#include "MarkerView.h"
+#include "TimeLineViewPort.h"
+#include "SnapList.h"
+
+#include <ProjectManager.h>
+#include <Project.h>
+#include <Sheet.h>
+#include <TimeLine.h>
+#include <Marker.h>
+#include <ContextPointer.h>
+#include <Utils.h>
+#include <defines.h>
+#include <AddRemove.h>
+#include <CommandGroup.h>
+#include "Information.h"
+#include "InputEngine.h"
+
+#include <QFont>
+#include <QDebug>
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+
+#define MARKER_SOFT_SELECTION_DISTANCE 50
+
+
+DragMarker::DragMarker(MarkerView* mview, qint64 scalefactor, const QString& 
des)
+       : Command(mview->get_marker(), des)
+{
+       d = new Data;
+       d->view = mview;
+       m_marker= d->view->get_marker();
+       d->scalefactor = scalefactor;
+       d->bypassjog = false;
+}
+
+int DragMarker::prepare_actions()
+{
+       return 1;
+}
+
+int DragMarker::begin_hold()
+{
+       m_origWhen = m_newWhen = m_marker->get_when();
+       m_marker->set_snappable(false);
+       d->view->get_sheetview()->start_shuttle(true, true);
+       d->view->set_dragging(true);    
+       return 1;
+}
+
+int DragMarker::finish_hold()
+{
+       m_marker->set_snappable(true);
+       d->view->get_sheetview()->start_shuttle(false);
+       d->view->set_dragging(false);
+       delete d;
+       
+       return 1;
+}
+
+int DragMarker::do_action()
+{
+       m_marker->set_when(m_newWhen);
+       return 1;
+}
+
+int DragMarker::undo_action()
+{
+       m_marker->set_when(m_origWhen);
+       return 1;
+}
+
+void DragMarker::cancel_action()
+{
+       finish_hold();
+       undo_action();
+}
+
+void DragMarker::move_left(bool )
+{
+       d->bypassjog = true;
+       // Move 1 pixel to the left
+       TimeRef newpos = TimeRef(m_newWhen - d->scalefactor);
+       if (newpos < TimeRef()) {
+               newpos = TimeRef();
+       }
+       m_newWhen = newpos;
+       do_action();
+}
+
+void DragMarker::move_right(bool )
+{
+       d->bypassjog = true;
+       // Move 1 pixel to the right
+       m_newWhen = m_newWhen + d->scalefactor;
+       do_action();
+}
+
+int DragMarker::jog()
+{
+       if (d->bypassjog) {
+               int diff = d->jogBypassPos - cpointer().x();
+               if (abs(diff) > 15) {
+                       d->bypassjog = false;
+               } else {
+                       return 0;
+               }
+       }
+       
+       d->jogBypassPos = cpointer().x();
+       TimeRef newpos = TimeRef(cpointer().scene_x() * d->scalefactor);
+
+       if (m_marker->get_timeline()->get_sheet()->is_snap_on()) {
+               SnapList* slist = 
m_marker->get_timeline()->get_sheet()->get_snap_list();
+               newpos = slist->get_snap_value(newpos);
+       }
+
+       if (newpos < TimeRef()) {
+               newpos = TimeRef();
+       }
+       
+       m_newWhen = newpos;
+       d->view->set_position(int(m_newWhen / d->scalefactor));
+       
+       d->view->get_sheetview()->update_shuttle_factor();
+       
+       return 1;
+}
+
+
+// End DragMarker
+
+
+
+TimeLineView::TimeLineView(SheetView* view)
+       : ViewItem(0, 0)
+       , m_blinkingMarker(0)
+{
+       PENTERCONS2;
+
+       m_sv = view;
+       m_boundingRect = QRectF(0, 0, MAX_CANVAS_WIDTH, TIMELINE_HEIGHT);
+       m_timeline = m_sv->get_sheet()->get_timeline();
+       
+#if QT_VERSION < 0x040300
+       view->scene()->addItem(this);
+#endif
+       load_theme_data();
+       
+       // Create MarkerViews for existing markers
+       foreach(Marker* marker, m_timeline->get_markers()) {
+               add_new_marker_view(marker);
+       }
+       
+       // Make connections to the 'core'
+       connect(m_timeline, SIGNAL(markerAdded(Marker*)), this, 
SLOT(add_new_marker_view(Marker*)));
+       connect(m_timeline, SIGNAL(markerRemoved(Marker*)), this, 
SLOT(remove_marker_view(Marker*)));
+
+       setAcceptsHoverEvents(true);
+
+       m_zooms[524288 * 640] = "20:00.000";
+       m_zooms[262144 * 640] = "10:00.000";
+       m_zooms[131072 * 640] = "5:00.000";
+       m_zooms[ 65536 * 640] = "2:30.000";
+       m_zooms[ 32768 * 640] = "1:00.000";
+       m_zooms[ 16384 * 640] = "0:30.000";
+       m_zooms[  8192 * 640] = "0:20.000";
+       m_zooms[  4096 * 640] = "0:10.000";
+       m_zooms[  2048 * 640] = "0:05.000";
+       m_zooms[  1024 * 640] = "0:02.000";
+       m_zooms[   512 * 640] = "0:01.000";
+       m_zooms[   256 * 640] = "0:00.800";
+       m_zooms[   128 * 640] = "0:00.400";
+       m_zooms[    64 * 640] = "0:00.200";
+       m_zooms[    32 * 640] = "0:00.100";
+       m_zooms[    16 * 640] = "0:00.050";
+       m_zooms[     8 * 640] = "0:00.020";
+       m_zooms[     4 * 640] = "0:00.010";
+       m_zooms[     2 * 640] = "0:00.005";
+       m_zooms[     1 * 640] = "0:00.002";
+}
+
+
+TimeLineView::~TimeLineView()
+{
+       PENTERDES;
+}
+
+
+void TimeLineView::hzoom_changed( )
+{
+       update();
+}
+
+void TimeLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem* 
option, QWidget* widget)
+{
+       PENTER3;
+       Q_UNUSED(widget);
+       
+       painter->save();
+       
+       // When the scrollarea moves by a small value, the text
+       // can be screwed up, so give it some room, 100 pixels should do!
+       int xstart = (int) option->exposedRect.x() - 100;
+       int pixelcount = (int) option->exposedRect.width() + 100;
+       int expheight = (int) option->exposedRect.height();
+       int top = (int) option->exposedRect.top();
+       bool paintText = top > 28 &&  expheight < 2 ? false : true;
+       
+       if (xstart < 0) {
+               xstart = 0;
+       }
+       
+       painter->setClipRect(m_boundingRect);
+       
+       int height = TIMELINE_HEIGHT;
+       
+       painter->fillRect(xstart, 0,  pixelcount, height, 
themer()->get_color("Timeline:background") );
+       
+       painter->setPen(themer()->get_color("Timeline:text"));
+       painter->setFont( themer()->get_font("Timeline:fontscale:label") );
+       
+       TimeRef major;
+       
+       if (m_zooms.contains(m_sv->timeref_scalefactor)) {
+               major = msms_to_timeref(m_zooms[m_sv->timeref_scalefactor]);
+       } else {
+               major = 120 * m_sv->timeref_scalefactor;
+       }
+
+       // minor is double so they line up right with the majors,
+       // despite not always being an even number of frames
+       // @Ben : is still still the same when using TimeRef based calculations?
+       double minor = double(major/double(10));
+
+       TimeRef firstLocation = TimeRef(xstart * m_sv->timeref_scalefactor);
+       TimeRef lastLocation = TimeRef(xstart * m_sv->timeref_scalefactor + 
pixelcount * m_sv->timeref_scalefactor);
+       int xstartoffset = m_sv->hscrollbar_value();
+       
+       painter->setMatrixEnabled(false);
+
+       TimeRef factor = (firstLocation/major)*major;
+       // Draw minor ticks
+       TimeRef range((lastLocation-firstLocation+major) / minor);
+       for (qint64 i = 0; i < range.universal_frame(); i++ ) {
+               int x = (int)((factor + i * minor) / m_sv->timeref_scalefactor) 
- xstartoffset;
+               painter->drawLine(x, height - 5, x, height - 1);
+       }
+       
+       // Draw major ticks
+       for (TimeRef location = factor; location < lastLocation; location += 
major) {
+               int x = int(location/m_sv->timeref_scalefactor - xstartoffset);
+               painter->drawLine(x, height - 13, x, height - 1);
+               if (paintText) {
+                       painter->drawText(x + 4, height - 8, 
timeref_to_text(location, m_sv->timeref_scalefactor));
+               }
+       }
+       
+       painter->restore();
+}
+
+void TimeLineView::calculate_bounding_rect()
+{
+       update();
+       ViewItem::calculate_bounding_rect();
+}
+
+
+void TimeLineView::add_new_marker_view(Marker * marker)
+{
+       MarkerView* view = new MarkerView(marker, m_sv, this);
+       view->set_active(false);
+       m_markerViews.append(view);
+#if QT_VERSION < 0x040300
+       m_sv->scene()->addItem(view);
+#endif
+       view->update();
+}
+
+void TimeLineView::remove_marker_view(Marker * marker)
+{
+       foreach(MarkerView* view, m_markerViews) {
+               if (view->get_marker() == marker) {
+                       m_markerViews.removeAll(view);
+                       scene()->removeItem(view);
+                       m_blinkingMarker = 0;
+                       delete view;
+                       return;
+               }
+       }
+}
+
+Command* TimeLineView::add_marker()
+{
+       QPointF point = mapFromScene(cpointer().scene_pos());
+       
+       TimeRef when(point.x() * m_sv->timeref_scalefactor);
+       
+       return add_marker_at(when);
+}
+
+Command* TimeLineView::add_marker_at_playhead()
+{
+       return add_marker_at(m_sv->get_sheet()->get_transport_location());
+}
+
+Command* TimeLineView::add_marker_at(const TimeRef when)
+{
+       CommandGroup* group = new CommandGroup(m_timeline, "");
+
+       // check if it is the first marker added to the timeline
+       if (!m_timeline->get_markers().size()) {
+               if (when > TimeRef()) {  // add one at the beginning of the 
sheet
+                       Marker* m = new Marker(m_timeline, TimeRef(), 
Marker::CDTRACK);
+                       m->set_description("");
+                       group->add_command(m_timeline->add_marker(m));
+               }
+
+               TimeRef lastlocation = m_sv->get_sheet()->get_last_location();
+               if (when < lastlocation) {  // add one at the end of the sheet
+                       Marker* me = new Marker(m_timeline, lastlocation, 
Marker::ENDMARKER);
+                       me->set_description(tr("End"));
+                       group->add_command(m_timeline->add_marker(me));
+               }
+       }
+
+       Marker* marker = new Marker(m_timeline, when, Marker::CDTRACK);
+       marker->set_description("");
+       
+       group->setText(tr("Add Marker"));
+       group->add_command(m_timeline->add_marker(marker));
+       
+       return group;
+}
+
+Command* TimeLineView::playhead_to_marker()
+{
+       
update_softselected_marker(QPoint(cpointer().on_first_input_event_scene_x(), 
cpointer().on_first_input_event_scene_y()));
+
+       if (m_blinkingMarker) {
+               
m_sv->get_sheet()->set_transport_pos(m_blinkingMarker->get_marker()->get_when());
+               return 0;
+       }
+
+       return ie().did_not_implement();
+}
+
+Command* TimeLineView::remove_marker()
+{
+       if (m_blinkingMarker) {
+               Marker* marker = m_blinkingMarker->get_marker();
+               if (marker->get_type() == Marker::ENDMARKER && 
m_markerViews.size() > 1) {
+                       info().information(tr("You have to remove all other 
markers first."));
+                       return ie().failure();
+               }
+               return m_timeline->remove_marker(marker);
+       }
+
+       return 0;
+}
+
+void TimeLineView::update_softselected_marker(QPoint pos)
+{
+       MarkerView* prevMarker = m_blinkingMarker;
+       if (m_markerViews.size()) {
+               m_blinkingMarker = m_markerViews.first();
+       }
+       
+       if (! m_blinkingMarker) {
+               return;
+       }
+       
+       int x = pos.x();
+       int blinkMarkerDist = abs(x - m_blinkingMarker->position());
+       
+       foreach(MarkerView* markerView, m_markerViews) {
+               int markerDist = abs(x - markerView->position());
+
+               fflush(stdout);
+               if (markerDist < blinkMarkerDist) {
+                       m_blinkingMarker = markerView;
+                       blinkMarkerDist = abs(x - m_blinkingMarker->position());
+               }
+       }
+       
+       if (blinkMarkerDist > MARKER_SOFT_SELECTION_DISTANCE) {
+               m_blinkingMarker = 0;
+       }
+       
+       if (prevMarker && (prevMarker != m_blinkingMarker) ) {
+               prevMarker->set_active(false);
+               if (m_blinkingMarker) {
+                       m_blinkingMarker->set_active(true);
+               }
+       }
+       
+       if (!prevMarker && m_blinkingMarker) {
+               m_blinkingMarker->set_active(true);
+       }
+}
+
+void TimeLineView::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
+{
+       Q_UNUSED(event);
+
+       if (m_blinkingMarker) {
+               m_blinkingMarker->set_active(true);
+       }
+}
+
+void TimeLineView::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
+{
+       Q_UNUSED(event);
+       
+       if (ie().is_holding()) {
+               event->ignore();
+               return;
+       }
+       
+       if (m_blinkingMarker) {
+               // TODO add these functions, or something else to 
+               // let the user know which marker is to be moved!
+               m_blinkingMarker->set_active(false);
+               m_blinkingMarker = 0;
+       }
+}
+               
+               
+void TimeLineView::hoverMoveEvent ( QGraphicsSceneHoverEvent * event )
+{
+       QPoint pos((int)event->pos().x(), (int)event->pos().y());
+
+       update_softselected_marker(pos);
+}
+
+
+Command * TimeLineView::drag_marker()
+{
+       
update_softselected_marker(QPoint(cpointer().on_first_input_event_scene_x(), 
cpointer().on_first_input_event_scene_y()));
+
+       if (m_blinkingMarker) {
+               return new DragMarker(m_blinkingMarker, 
m_sv->timeref_scalefactor, tr("Drag Marker"));
+       }
+       
+       return ie().did_not_implement();
+}
+
+Command * TimeLineView::clear_markers()
+{
+       CommandGroup* group = new CommandGroup(m_timeline, tr("Clear Markers"));
+
+       foreach(Marker *m, m_timeline->get_markers()) {
+               group->add_command(m_timeline->remove_marker(m));
+       }
+
+       return group;
+}
+
+void TimeLineView::load_theme_data()
+{
+       // TODO Load pixmap, fonts, colors from themer() !!
+       calculate_bounding_rect();
+}
+

Index: TimeLineView.h
===================================================================
RCS file: TimeLineView.h
diff -N TimeLineView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TimeLineView.h      21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,122 @@
+/*
+    Copyright (C) 2005-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#ifndef TIME_LINE_VIEW_H
+#define TIME_LINE_VIEW_H
+
+#include "ViewItem.h"
+#include <Command.h>
+
+#include <QTimer>
+
+class SheetView;
+class TimeLine;
+class MarkerView;
+class Marker;
+
+class DragMarker : public Command
+{
+       Q_OBJECT
+       Q_CLASSINFO("move_left", tr("Move Left"))
+       Q_CLASSINFO("move_right", tr("Move right"))
+
+public:
+       DragMarker(MarkerView* mview, qint64 scalefactor, const QString& des);
+
+       int prepare_actions();
+       int do_action();
+       int undo_action();
+       int finish_hold();
+       int begin_hold();
+       void cancel_action();
+       int jog();
+
+private :
+       Marker*         m_marker;
+       TimeRef         m_origWhen;
+       TimeRef         m_newWhen;
+       struct Data {
+               MarkerView*     view;
+               qint64          scalefactor;
+               bool            bypassjog;
+               int             jogBypassPos;
+       };
+       Data* d;
+
+public slots:
+       void move_left(bool autorepeat);
+       void move_right(bool autorepeat);
+};
+
+class TimeLineView : public ViewItem
+{
+        Q_OBJECT
+       Q_CLASSINFO("add_marker", tr("Add Marker"))
+       Q_CLASSINFO("add_marker_at_playhead", tr("Add Marker at Playhead"))
+       Q_CLASSINFO("remove_marker", tr("Remove Marker"))
+       Q_CLASSINFO("drag_marker", tr("Drag Marker"))
+       Q_CLASSINFO("clear_markers", tr("Clear all Markers"))
+       Q_CLASSINFO("playhead_to_marker", tr("Playhead to Marker"))
+
+public:
+        TimeLineView(SheetView* view);
+        ~TimeLineView();
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+       void load_theme_data();
+
+protected:
+       void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
+       void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
+       void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
+
+private:
+       QList<MarkerView* > m_markerViews;
+       TimeLine*       m_timeline;
+       MarkerView*     m_blinkingMarker;
+       QColor          m_blinkColor;
+
+       QHash<nframes_t, QString>       m_zooms;        
+
+       Command* add_marker_at(const TimeRef when);
+       void update_softselected_marker(QPoint pos);
+       
+       
+public slots:
+        void hzoom_changed();
+       
+public slots:
+       Command* add_marker();
+       Command* add_marker_at_playhead();
+       Command* remove_marker();
+       Command* drag_marker();
+       Command* clear_markers();
+       Command* playhead_to_marker();
+
+private slots:
+       void add_new_marker_view(Marker* marker);
+       void remove_marker_view(Marker* marker);
+};
+
+#endif
+
+//eof

Index: TimeLineViewPort.cpp
===================================================================
RCS file: TimeLineViewPort.cpp
diff -N TimeLineViewPort.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TimeLineViewPort.cpp        21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,81 @@
+/*
+    Copyright (C) 2006-2007 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+*/
+
+#include "TimeLineViewPort.h"
+#include "SheetView.h"
+#include "SheetWidget.h"
+#include "TimeLineView.h"
+#include <QScrollBar>
+#include <QWheelEvent>
+#include <ContextPointer.h>
+               
+#include <Debugger.h>
+
+TimeLineViewPort::TimeLineViewPort(QGraphicsScene* scene, SheetWidget* sw)
+       : ViewPort(scene, sw)
+{
+       setMaximumHeight(TIMELINE_HEIGHT);
+       setMinimumHeight(TIMELINE_HEIGHT);
+       setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       
+       m_timeLineView = 0;
+}
+
+
+void TimeLineViewPort::wheelEvent ( QWheelEvent * e )
+{
+       if (e->delta() > 0) {
+               m_sv->scroll_left();
+       } else {
+               m_sv->scroll_right();
+       }
+}
+
+void TimeLineViewPort::set_sheetview( SheetView * view )
+{
+       m_timeLineView = new TimeLineView(view);
+       scene()->addItem(m_timeLineView);
+       m_timeLineView->setPos(0, -TIMELINE_HEIGHT);
+       m_sv = view;
+}
+
+void TimeLineViewPort::get_pointed_context_items(QList<ContextItem* > &list)
+{
+       QList<QGraphicsItem *> itemlist = 
items(cpointer().on_first_input_event_x(), cpointer().on_first_input_event_y());
+       foreach(QGraphicsItem* item, itemlist) {
+               if (ViewItem::is_viewitem(item)) {
+                       list.append((ViewItem*)item);
+               }
+       }
+       list.append(m_sv);
+}
+
+void TimeLineViewPort::scale_factor_changed()
+{
+       if (m_timeLineView) {
+               m_timeLineView->calculate_bounding_rect();
+       }
+}
+
+
+//eof
+

Index: TimeLineViewPort.h
===================================================================
RCS file: TimeLineViewPort.h
diff -N TimeLineViewPort.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TimeLineViewPort.h  21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,56 @@
+/*
+    Copyright (C) 2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: TimeLineViewPort.h,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#ifndef TIME_LINE_VIEW_PORT_H
+#define TIME_LINE_VIEW_PORT_H
+
+#include "ViewPort.h"
+
+class SheetWidget;
+class SheetView;
+class TimeLineView;
+
+#define TIMELINE_HEIGHT 32
+               
+class TimeLineViewPort : public ViewPort
+{
+public:
+       TimeLineViewPort(QGraphicsScene* scene, SheetWidget* sw);
+       ~TimeLineViewPort() {};
+       
+       void set_sheetview(SheetView* view);
+       void scale_factor_changed();
+       TimeLineView* get_timeline_view() const {return m_timeLineView;}
+       
+       void get_pointed_context_items(QList<ContextItem* > &list);
+
+protected:
+       void wheelEvent ( QWheelEvent * e );
+
+private:
+       SheetView*      m_sv;
+       TimeLineView*   m_timeLineView;
+};
+
+#endif
+
+//eof

Index: TrackPanelView.cpp
===================================================================
RCS file: TrackPanelView.cpp
diff -N TrackPanelView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackPanelView.cpp  21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,497 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: TrackPanelView.cpp,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#include <QGraphicsScene>
+#include <QFont>
+#include "TrackPanelView.h"
+#include "TrackView.h"
+#include "SheetView.h"
+#include <Themer.h>
+#include "TrackPanelViewPort.h"
+#include <Track.h>
+#include "TrackPanelView.h"
+#include <Utils.h>
+#include <Mixer.h>
+#include <Gain.h>
+#include <TrackPan.h>
+               
+#include <Debugger.h>
+
+#define MICRO_HEIGHT 35
+#define SMALL_HEIGHT 65
+
+TrackPanelView::TrackPanelView(TrackView* trackView)
+       : ViewItem(0, trackView)
+       , m_tv(trackView)
+{
+       PENTERCONS;
+       
+       m_viewPort = m_tv->get_sheetview()->get_trackpanel_view_port();
+       m_track = m_tv->get_track();
+       
+       m_gainView = new TrackPanelGain(this, m_track);
+       m_gainView->set_width(m_viewPort->width() - 20);
+       
+       m_panView = new TrackPanelPan(this, m_track);
+       m_panView->set_width(m_viewPort->width() - 20);
+       
+       recLed = new TrackPanelLed(this, "rec", "toggle_arm");
+       soloLed = new TrackPanelLed(this, "solo", "solo");
+       muteLed = new TrackPanelLed(this, "mute", "mute");
+       
+       if (m_track->armed()) {
+               recLed->ison_changed(true);
+       }
+       if (m_track->is_solo()) {
+               soloLed->ison_changed(true);
+       }
+       if (m_track->is_muted()) {
+               muteLed->ison_changed(true);
+       }
+       
+       inBus = new TrackPanelBus(this, m_track, TrackPanelBus::BUSIN);
+       outBus = new TrackPanelBus(this, m_track, TrackPanelBus::BUSOUT);
+       
+       m_viewPort->scene()->addItem(this);
+
+       
+       m_boundingRect = QRectF(0, 0, 200, m_track->get_height());
+       
+       layout_panel_items();
+       
+       connect(m_track, SIGNAL(armedChanged(bool)), recLed, 
SLOT(ison_changed(bool)));
+       connect(m_track, SIGNAL(soloChanged(bool)), soloLed, 
SLOT(ison_changed(bool)));
+       connect(m_track, SIGNAL(muteChanged(bool)), muteLed, 
SLOT(ison_changed(bool)));
+       
+       connect(m_track, SIGNAL(gainChanged()), this, SLOT(update_gain()));
+       connect(m_track, SIGNAL(panChanged()), this, SLOT(update_pan()));
+       
+       connect(m_track, SIGNAL(inBusChanged()), inBus, SLOT(bus_changed()));
+       connect(m_track, SIGNAL(outBusChanged()), outBus, SLOT(bus_changed()));
+       
+       connect(m_track, SIGNAL(stateChanged()), this, 
SLOT(update_track_name()));
+       
+       
+//     setFlags(ItemIsSelectable | ItemIsMovable);
+//     setAcceptsHoverEvents(true);
+       setCursor(themer()->get_cursor("Track"));
+}
+
+TrackPanelView::~TrackPanelView( )
+{
+       PENTERDES;
+}
+
+
+void TrackPanelView::paint(QPainter* painter, const QStyleOptionGraphicsItem* 
option, QWidget* widget)
+{
+       Q_UNUSED(widget);
+       Q_UNUSED(option);
+       
+       int xstart = (int)option->exposedRect.x();
+       int pixelcount = (int)option->exposedRect.width();
+       
+       if (m_tv->m_topborderwidth > 0) {
+               QColor color = themer()->get_color("Track:cliptopoffset");
+               painter->fillRect(xstart, 0, pixelcount, 
m_tv->m_topborderwidth, color);
+       }
+       
+       if (m_tv->m_paintBackground) {
+               QColor color = themer()->get_color("Track:background");
+               painter->fillRect(xstart, m_tv->m_topborderwidth, pixelcount, 
m_track->get_height() - m_tv->m_bottomborderwidth, color);
+       }
+       
+       if (m_tv->m_bottomborderwidth > 0) {
+               QColor color = themer()->get_color("Track:clipbottomoffset");
+               painter->fillRect(xstart, m_track->get_height() - 
m_tv->m_bottomborderwidth, pixelcount, m_tv->m_bottomborderwidth, color);
+       }
+
+       // Track / track panel seperator is painted in TrackPanelViewPort... 
not the best place perhaps ?
+       painter->fillRect(m_viewPort->width() - 3, 0, 3, m_track->get_height() 
- 1, themer()->get_color("TrackPanel:trackseparation"));
+       
+       if (xstart < 180) {
+               draw_panel_track_name(painter);
+       }
+}
+
+void TrackPanelView::update_track_name()
+{
+       update();
+}
+
+void TrackPanelView::update_gain()
+{
+       m_gainView->update();
+}
+
+
+void TrackPanelView::update_pan()
+{
+       m_panView->update();
+}
+
+
+void TrackPanelView::draw_panel_track_name(QPainter* painter)
+{
+       QString title = QString::number(m_track->get_sort_index() + 1) + "  " + 
m_track->get_name();
+       
+       if (m_track->get_height() < SMALL_HEIGHT) {
+               QFontMetrics 
fm(themer()->get_font("TrackPanel:fontscale:name"));
+               title = fm.elidedText(title, Qt::ElideMiddle, 90);
+       }
+       
+       painter->setPen(themer()->get_color("TrackPanel:text"));
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:name"));
+       painter->drawText(4, 12, title);
+}
+
+
+void TrackPanelView::calculate_bounding_rect()
+{
+       prepareGeometryChange();
+       m_boundingRect = QRectF(0, 0, 200, m_track->get_height());
+       layout_panel_items();
+}
+
+void TrackPanelView::layout_panel_items()
+{
+       int height =  m_track->get_height();
+       
+       m_gainView->setPos(10, 39);
+       m_panView->setPos(10, 54);
+       
+       inBus->setPos(10, 73);
+       outBus->setPos(100, 73);
+       
+       if (height < SMALL_HEIGHT) {
+               m_gainView->setPos(10, 20);
+               m_panView->setPos(10, 36);
+       } else {
+               muteLed->setPos(70, 19);
+               soloLed->setPos(118, 19);
+               recLed->setPos(162, 19);
+               muteLed->set_bounding_rect(QRectF(0, 0, 41, 14)); 
+               soloLed->set_bounding_rect(QRectF(0, 0, 38, 14)); 
+               recLed->set_bounding_rect(QRectF(0, 0, 30, 14)); 
+               
+               m_gainView->setPos(10, 39);
+               m_panView->setPos(10, 54);
+       }
+       
+       if (height < SMALL_HEIGHT) {
+               muteLed->setPos(90, 1.5);
+               soloLed->setPos(132, 1.5);
+               recLed->setPos(166, 1.5);
+               muteLed->set_bounding_rect(QRectF(0, 0, 39, 12)); 
+               soloLed->set_bounding_rect(QRectF(0, 0, 31, 12)); 
+               recLed->set_bounding_rect(QRectF(0, 0, 27, 12)); 
+       }
+       
+       if ((inBus->pos().y() + inBus->boundingRect().height()) >= height) {
+               inBus->hide();
+               outBus->hide();
+       } else {
+               inBus->show();
+               outBus->show();
+       }
+       
+       if ( (m_panView->pos().y() + m_panView->boundingRect().height()) >= 
height) {
+               m_panView->hide();
+       } else {
+               m_panView->show();
+       }
+       
+       if ( (m_gainView->pos().y() + m_panView->boundingRect().height()) >= 
height) {
+               m_gainView->hide();
+       } else {
+               m_gainView->show();
+       }
+}
+
+
+TrackPanelGain::TrackPanelGain(TrackPanelView* parent, Track * track)
+       : ViewItem(parent, track)
+       , m_track(track)
+{
+       setAcceptsHoverEvents(true);
+
+}
+
+void TrackPanelGain::paint( QPainter * painter, const QStyleOptionGraphicsItem 
* option, QWidget * widget )
+{
+       Q_UNUSED(widget);
+       const int height = 9;
+
+       int sliderWidth = (int)m_boundingRect.width() - 75;
+       float gain = m_track->get_gain();
+       QString sgain = coefficient_to_dbstring(gain);
+       float db = coefficient_to_dB(gain);
+
+       if (db < -60) {
+               db = -60;
+       }
+       int sliderdbx =  (int) (sliderWidth - (sliderWidth*0.3)) - (int) ( ( 
(-1 * db) / 60 ) * sliderWidth);
+       if (sliderdbx < 0) {
+               sliderdbx = 0;
+       }
+       if (db > 0) {
+               sliderdbx =  (int)(sliderWidth*0.7) + (int) ( ( db / 6 ) * 
(sliderWidth*0.3));
+       }
+
+       int cr = (gain >= 1 ? 30 + (int)(100 * gain) : (int)(50 * gain));
+       int cb = ( gain < 1 ? 150 + (int)(50 * gain) : abs((int)(10 * gain)) );
+       
+       painter->setPen(themer()->get_color("TrackPanel:text"));
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:gain"));
+       painter->drawText(0, height + 1, "GAIN");
+       painter->drawRect(30, 0, sliderWidth, height);
+       
+       bool mousehover = (option->state & QStyle::State_MouseOver);
+       QColor color(cr,0,cb);
+       if (mousehover) {
+               color = color.light(140);
+       }
+       painter->fillRect(31, 1, sliderdbx, height-1, color);
+       painter->drawText(sliderWidth + 35, height, sgain);
+}
+
+void TrackPanelGain::set_width(int width)
+{
+       m_boundingRect = QRectF(0, 0, width, 9);
+}
+
+Command* TrackPanelGain::gain_increment()
+{
+       m_track->set_gain(m_track->get_gain() + 0.05);
+       return 0;
+}
+
+Command* TrackPanelGain::gain_decrement()
+{
+       m_track->set_gain(m_track->get_gain() - 0.05);
+       return 0;
+}
+
+TrackPanelPan::TrackPanelPan(TrackPanelView* parent, Track * track)
+       : ViewItem(parent, track)
+       , m_track(track)
+{
+       setAcceptsHoverEvents(true);
+}
+
+void TrackPanelPan::paint( QPainter * painter, const QStyleOptionGraphicsItem 
* option, QWidget * widget )
+{
+       Q_UNUSED(widget);
+
+       bool mousehover = (option->state & QStyle::State_MouseOver);
+       
+       QColor color = themer()->get_color("TrackPanel:slider:background");
+       if (mousehover) {
+               color = color.light(110);
+       }
+       
+       const int PAN_H = 9;
+
+       int sliderWidth = (int)m_boundingRect.width() - 75;
+       float v;
+       //      int y;
+       QString s, span;
+       painter->setPen(themer()->get_color("TrackPanel:text"));
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:pan"));
+
+       painter->drawText(0, PAN_H + 1, "PAN");
+
+       v = m_track->get_pan();
+       span = QByteArray::number(v,'f',1);
+       s = ( v > 0 ? QString("+") + span :  span );
+       painter->fillRect(30, 0, sliderWidth, PAN_H, color);
+       painter->drawRect(30, 0, sliderWidth, PAN_H);
+       int pm= 31 + sliderWidth/2;
+       int z = abs((int)(v*(sliderWidth/2)));
+       int c = abs((int)(255*v));
+       if (v>=0) {
+               painter->fillRect(pm, 1, z, PAN_H-1, QColor(c,0,0));
+       } else {
+               painter->fillRect(pm-z, 1, z, PAN_H-1, QColor(c,0,0));
+       }
+       painter->drawText(30 + sliderWidth + 10, PAN_H + 1, s);
+}
+
+void TrackPanelPan::set_width(int width)
+{
+       m_boundingRect = QRectF(0, 0, width, 9);
+}
+
+Command* TrackPanelPan::pan_left()
+{
+       m_track->set_pan(m_track->get_pan() - 0.05);
+       return 0;
+}
+
+Command* TrackPanelPan::pan_right()
+{
+       m_track->set_pan(m_track->get_pan() + 0.05);
+       return 0;
+}
+
+
+
+TrackPanelLed::TrackPanelLed(TrackPanelView* parent, const QString& name, 
const QString& toggleslot)
+       : ViewItem(parent, 0)
+       , m_name(name)
+       , m_toggleslot(toggleslot)
+       , m_isOn(false)
+{
+       m_track = parent->get_track();
+       setAcceptsHoverEvents(true);
+}
+
+void TrackPanelLed::paint(QPainter* painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget )
+{
+       Q_UNUSED(widget);
+       
+       bool mousehover = (option->state & QStyle::State_MouseOver);
+       int roundfactor = 20;
+       
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       if (m_isOn) {
+               QColor color = themer()->get_color("TrackPanel:" + m_name + 
"led");
+               if (mousehover) {
+                       color = color.light(110);
+               }
+               
+               
painter->setPen(themer()->get_color("TrackPanel:led:margin:active"));
+               painter->setBrush(color);
+               painter->drawRoundRect(m_boundingRect, roundfactor, 
roundfactor);
+               
+               
painter->setFont(themer()->get_font("TrackPanel:fontscale:led"));
+               
painter->setPen(themer()->get_color("TrackPanel:led:font:active"));
+               
+               painter->drawText(m_boundingRect, Qt::AlignCenter, m_name);
+       } else {
+               QColor color = themer()->get_color("TrackPanel:led:inactive");
+               if (mousehover) {
+                       color = color.light(110);
+               }
+               
+               
painter->setPen(themer()->get_color("TrackPanel:led:margin:inactive"));
+               painter->setBrush(color);
+               painter->drawRoundRect(m_boundingRect, roundfactor, 
roundfactor);
+               
+               
painter->setFont(themer()->get_font("TrackPanel:fontscale:led"));
+               
painter->setPen(themer()->get_color("TrackPanel:led:font:inactive"));
+               
+               painter->drawText(m_boundingRect, Qt::AlignCenter, m_name);
+       }
+       
+}
+
+void TrackPanelLed::set_bounding_rect(QRectF rect)
+{
+       prepareGeometryChange();
+       m_boundingRect = rect;
+}
+
+
+void TrackPanelLed::ison_changed(bool isOn)
+{
+        m_isOn = isOn;
+       update();
+}
+
+Command * TrackPanelLed::toggle()
+{
+       Command* com;
+       QMetaObject::invokeMethod(m_track, QS_C(m_toggleslot), 
Qt::DirectConnection, Q_RETURN_ARG(Command*, com));
+       return 0;
+}
+
+
+
+TrackPanelBus::TrackPanelBus(TrackPanelView* parent, Track* track, int type)
+       : ViewItem(parent, 0)
+       , m_track(track)
+       , m_type(type)
+{
+       bus_changed();
+       setAcceptsHoverEvents(true);
+}
+
+void TrackPanelBus::paint(QPainter* painter, const QStyleOptionGraphicsItem * 
option, QWidget * widget )
+{
+       Q_UNUSED(option);
+       Q_UNUSED(widget);
+       
+       QColor color = themer()->get_color("TrackPanel:bus:background");
+       int roundfactor = 15;
+       
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       if (option->state & QStyle::State_MouseOver) {
+               color = color.light(110);
+       }
+        
+       painter->setPen(themer()->get_color("TrackPanel:bus:margin"));
+       painter->setBrush(color);
+       painter->drawRoundRect(m_boundingRect, roundfactor, roundfactor);
+       
+       painter->setFont(themer()->get_font("TrackPanel:fontscale:led"));
+       painter->setPen(themer()->get_color("TrackPanel:bus:font"));
+       
+       QString leftright = "";
+       
+       if ((m_type == BUSIN) && ! (m_track->capture_left_channel() && 
m_track->capture_right_channel()) ) {
+               if (m_track->capture_left_channel()) {
+                       leftright = " L";
+               } else {
+                       leftright = " R";
+               }
+       }
+       
+       painter->drawText(m_boundingRect.adjusted(15, 0, 0, 0), 
Qt::AlignCenter, m_busName + leftright);
+                       
+       painter->drawPixmap(3, 3, m_pix);
+}
+
+void TrackPanelBus::bus_changed()
+{
+       QFontMetrics fm(themer()->get_font("TrackPanel:bus"));
+       prepareGeometryChange();
+       
+       if (m_type == BUSIN) {
+               m_busName =  m_track->get_bus_in();
+               m_pix = find_pixmap(":/bus_in");
+               m_boundingRect = m_pix.rect();
+               m_boundingRect.setWidth(m_pix.rect().width() + 
fm.width(m_busName) + 10);
+       } else {
+               m_busName = m_track->get_bus_out();
+               m_pix = find_pixmap(":/bus_out");
+               m_boundingRect = m_pix.rect();
+               m_boundingRect.setWidth(m_pix.rect().width() + 
fm.width(m_busName) + 10);
+       }
+       
+       m_boundingRect.setHeight(m_boundingRect.height() + 6);
+       
+       update();
+}
+

Index: TrackPanelView.h
===================================================================
RCS file: TrackPanelView.h
diff -N TrackPanelView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackPanelView.h    21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,158 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: TrackPanelView.h,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#ifndef TRACK_PANEL_VIEW_H
+#define TRACK_PANEL_VIEW_H
+
+#include "ViewItem.h"
+
+class Track;
+class TrackView;
+class TrackPanelViewPort;
+class PanelLed;
+class TrackPanelView;
+
+class TrackPanelGain : public ViewItem
+{
+       Q_OBJECT
+
+public:
+       TrackPanelGain(TrackPanelView* parent, Track* track);
+       TrackPanelGain(){}
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void set_width(int width);
+
+public slots:
+       Command* gain_increment();
+       Command* gain_decrement();
+       
+private:
+       Track* m_track;
+};
+
+class TrackPanelPan : public ViewItem
+{
+       Q_OBJECT
+       
+public:
+       TrackPanelPan(TrackPanelView* parent, Track* track);
+       TrackPanelPan(){}
+       
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void set_width(int width);
+
+public slots:
+       Command* pan_left();
+       Command* pan_right();
+
+private:
+       Track* m_track;
+};
+
+
+
+class TrackPanelLed : public ViewItem
+{
+       Q_OBJECT
+public:
+       TrackPanelLed(TrackPanelView* view, const QString& name, const QString& 
toggleslot);
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void set_bounding_rect(QRectF rect);
+
+private:
+       Track* m_track;
+        QString m_name;
+       QString m_toggleslot;
+       bool m_isOn;
+
+public slots:
+        void ison_changed(bool isOn);
+       
+       Command* toggle();
+};
+
+class TrackPanelBus : public ViewItem
+{
+       Q_OBJECT
+public:
+       TrackPanelBus(TrackPanelView* view, Track* track, int busType);
+       TrackPanelBus(){}
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       
+       enum { BUSIN, BUSOUT };
+
+private:
+       Track*  m_track;
+        int    m_type;
+       QString m_busName;
+       QPixmap m_pix;
+
+public slots:
+        void bus_changed();
+};
+
+
+class TrackPanelView : public ViewItem
+{
+       Q_OBJECT
+
+public:
+       TrackPanelView(TrackView* trackView);
+       ~TrackPanelView();
+
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       void calculate_bounding_rect();
+       
+       Track* get_track() const {return m_track;}
+       
+private:
+       Track*                  m_track;
+       TrackView*              m_tv;
+       TrackPanelViewPort*     m_viewPort;
+       TrackPanelGain*         m_gainView;
+       TrackPanelPan*          m_panView;
+       
+       TrackPanelLed* muteLed;
+       TrackPanelLed* soloLed;
+       TrackPanelLed* recLed;
+       
+       TrackPanelBus*  inBus;
+       TrackPanelBus*  outBus;
+
+       void draw_panel_track_name(QPainter* painter);
+       void layout_panel_items();
+
+private slots:
+       void update_gain();
+       void update_pan();
+       void update_track_name();
+};
+
+
+#endif
+
+//eof
+ 

Index: TrackPanelViewPort.cpp
===================================================================
RCS file: TrackPanelViewPort.cpp
diff -N TrackPanelViewPort.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackPanelViewPort.cpp      21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,56 @@
+/*
+    Copyright (C) 2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: TrackPanelViewPort.cpp,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#include "TrackPanelViewPort.h"
+               
+#include "SheetWidget.h"
+#include "SheetView.h"
+#include "TrackPanelView.h"
+#include <ContextPointer.h>
+
+#include <Debugger.h>
+
+
+TrackPanelViewPort::TrackPanelViewPort(QGraphicsScene* scene, SheetWidget* sw)
+       : ViewPort(scene, sw)
+{
+       setMinimumWidth(200);
+       setMaximumWidth(200);
+
+       m_sw = sw;
+       
+       setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+void TrackPanelViewPort::get_pointed_context_items(QList<ContextItem* > &list)
+{
+       QList<QGraphicsItem *> itemlist = 
items(cpointer().on_first_input_event_x(), cpointer().on_first_input_event_y());
+       foreach(QGraphicsItem* item, itemlist) {
+               if (ViewItem::is_viewitem(item)) {
+                       list.append((ViewItem*)item);
+               }
+       }
+       list.append(m_sw->get_sheetview());
+}
+
+
+//eof

Index: TrackPanelViewPort.h
===================================================================
RCS file: TrackPanelViewPort.h
diff -N TrackPanelViewPort.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackPanelViewPort.h        21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,49 @@
+/*
+    Copyright (C) 2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: TrackPanelViewPort.h,v 1.1 2008/01/21 16:17:30 r_sijrier Exp $
+*/
+
+#ifndef TRACK_PANEL_VIEW_PORT_H
+#define TRACK_PANEL_VIEW_PORT_H
+
+#include "ViewPort.h"
+               
+class SheetWidget;
+               
+class TrackPanelViewPort : public ViewPort
+{
+public:
+       TrackPanelViewPort(QGraphicsScene* scene, SheetWidget* sw);
+       ~TrackPanelViewPort() {};
+       
+        void get_pointed_context_items(QList<ContextItem* > &list);
+
+private:
+       SheetWidget*    m_sw;
+};
+
+#endif
+
+//eof
+
+ 
+ 
+ 
+ 

Index: TrackView.cpp
===================================================================
RCS file: TrackView.cpp
diff -N TrackView.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackView.cpp       21 Jan 2008 16:17:30 -0000      1.1
@@ -0,0 +1,217 @@
+/*
+Copyright (C) 2005-2007 Remon Sijrier
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#include <QLineEdit>
+#include <QInputDialog>
+#include <QGraphicsScene>
+
+#include "TrackView.h"
+#include "AudioClipView.h"
+#include "PluginChainView.h"
+#include "Themer.h"
+#include "TrackPanelViewPort.h"
+#include "SheetView.h"
+#include "TrackPanelView.h"
+#include <Interface.h>
+
+#include <Sheet.h>
+#include <Track.h>
+#include <AudioClip.h>
+#include <Utils.h>
+
+#include <PluginSelectorDialog.h>
+
+#include <Debugger.h>
+
+TrackView::TrackView(SheetView* sv, Track * track)
+       : ViewItem(0, track)
+{
+       PENTERCONS;
+       
+       setZValue(sv->zValue() + 1);
+       
+       m_sv = sv;
+       sv->scene()->addItem(this);
+       
+       load_theme_data();
+
+       m_track = track;
+       setFlags(ItemIsSelectable | ItemIsMovable);
+       setCursor(themer()->get_cursor("Track"));
+
+       m_panel = new TrackPanelView(this);
+       calculate_bounding_rect();
+       
+       m_pluginChainView = new PluginChainView(m_sv, this, 
m_track->get_plugin_chain());
+
+       connect(m_track, SIGNAL(audioClipAdded(AudioClip*)), this, 
SLOT(add_new_audioclipview(AudioClip*)));
+       connect(m_track, SIGNAL(audioClipRemoved(AudioClip*)), this, 
SLOT(remove_audioclipview(AudioClip*)));
+       
+       
+       foreach(AudioClip* clip, m_track->get_cliplist()) {
+               add_new_audioclipview(clip);
+       }
+}
+
+TrackView:: ~ TrackView( )
+{
+}
+
+void TrackView::paint(QPainter* painter, const QStyleOptionGraphicsItem* 
option, QWidget* widget)
+{
+       Q_UNUSED(widget);
+       
+//     printf("TrackView:: PAINT :: exposed rect is: x=%f, y=%f, w=%f, 
h=%f\n", option->exposedRect.x(), option->exposedRect.y(), 
option->exposedRect.width(), option->exposedRect.height());
+       
+       int xstart = (int)option->exposedRect.x();
+       int pixelcount = (int)option->exposedRect.width();
+       
+       if (m_topborderwidth > 0) {
+               QColor color = themer()->get_color("Track:cliptopoffset");
+               painter->fillRect(xstart, 0, pixelcount+1, m_topborderwidth, 
color);
+       }
+       
+       if (m_paintBackground) {
+               QColor color = themer()->get_color("Track:background");
+               painter->fillRect(xstart, m_topborderwidth, pixelcount+1, 
m_track->get_height() - m_bottomborderwidth, color);
+       }
+       
+       if (m_bottomborderwidth > 0) {
+               QColor color = themer()->get_color("Track:clipbottomoffset");
+               painter->fillRect(xstart, m_track->get_height() - 
m_bottomborderwidth, pixelcount+1, m_bottomborderwidth, color);
+       }
+}
+
+void TrackView::add_new_audioclipview( AudioClip * clip )
+{
+       PENTER;
+       AudioClipView* clipView = new AudioClipView(m_sv, this, clip);
+       m_clipViews.append(clipView);
+}
+
+void TrackView::remove_audioclipview( AudioClip * clip )
+{
+       PENTER;
+       foreach(AudioClipView* view, m_clipViews) {
+               if (view->get_clip() == clip) {
+                       m_clipViews.removeAll(view);
+                       scene()->removeItem(view);
+                       delete view;
+                       return;
+               }
+       }
+}
+
+Track* TrackView::get_track( ) const
+{
+       return m_track;
+}
+
+TrackPanelView * TrackView::get_trackpanel_view() const
+{
+       return m_panel;
+}
+
+int TrackView::get_childview_y_offset() const
+{
+       return m_topborderwidth + m_cliptopmargin;
+}
+
+void TrackView::move_to( int x, int y )
+{
+       Q_UNUSED(x);
+       setPos(0, y);
+       m_panel->setPos(-200, y);
+}
+
+int TrackView::get_height( )
+{
+       return m_track->get_height() - (m_topborderwidth + m_bottomborderwidth 
+ m_clipbottommargin + m_cliptopmargin);
+}
+
+Command* TrackView::edit_properties( )
+{
+       bool ok;
+       QString text = 
QInputDialog::getText(m_sv->get_trackpanel_view_port()->viewport(), tr("Set 
Track name"),
+                                       tr("Enter new Track name"),
+                                       QLineEdit::Normal, m_track->get_name(), 
&ok);
+       if (ok && !text.isEmpty()) {
+               m_track->set_name(text);
+       }
+
+       return (Command*) 0;
+}
+
+Command* TrackView::add_new_plugin( )
+{
+       PluginSelectorDialog::instance()->set_description(tr("Track %1:  %2")
+                       
.arg(m_track->get_sort_index()+1).arg(m_track->get_name()));
+       
+       if (PluginSelectorDialog::instance()->exec() == QDialog::Accepted) {
+               Plugin* plugin = 
PluginSelectorDialog::instance()->get_selected_plugin();
+               if (plugin) {
+                       // Force showing into effects mode, just in case the 
user adds
+                       // a plugin in edit mode, which means it won't show up!
+                       m_sv->get_sheet()->set_effects_mode();
+                       return m_track->add_plugin(plugin);
+               }
+       }
+
+       return 0;
+}
+
+void TrackView::set_height( int height )
+{
+       m_height = height;
+}
+
+void TrackView::calculate_bounding_rect()
+{
+       prepareGeometryChange();
+       m_boundingRect = QRectF(0, 0, MAX_CANVAS_WIDTH, m_track->get_height());
+       m_panel->calculate_bounding_rect();
+       ViewItem::calculate_bounding_rect();
+}
+
+void TrackView::load_theme_data()
+{
+       m_paintBackground = 
themer()->get_property("Track:paintbackground").toInt();
+       m_topborderwidth = 
themer()->get_property("Track:topborderwidth").toInt();
+       m_bottomborderwidth = 
themer()->get_property("Track:bottomborderwidth").toInt();
+       
+       m_cliptopmargin = themer()->get_property("Track:cliptopmargin").toInt();
+       m_clipbottommargin = 
themer()->get_property("Track:clipbottommargin").toInt();
+}
+
+
+Command* TrackView::select_bus()
+{
+       Interface::instance()->show_busselector(m_track);
+       return 0; 
+}
+
+Command* TrackView::insert_silence()
+{
+       Interface::instance()->show_insertsilence_dialog();
+       Interface::instance()->set_insertsilence_track(m_track);
+       return 0; 
+}
+

Index: TrackView.h
===================================================================
RCS file: TrackView.h
diff -N TrackView.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ TrackView.h 21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,89 @@
+/*
+Copyright (C) 2005-2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef TRACK_VIEW_H
+#define TRACK_VIEW_H
+
+#include "ViewItem.h"
+
+class Track;
+class AudioClip;
+class AudioClipView;
+class TrackPanelView;
+class PluginChainView;
+
+class TrackView : public ViewItem
+{
+       Q_OBJECT
+       Q_CLASSINFO("edit_properties", tr("Edit properties"))
+       Q_CLASSINFO("add_new_plugin", tr("Add new Plugin")) 
+       Q_CLASSINFO("select_bus", tr("Select Bus")) 
+       Q_CLASSINFO("insert_silence", tr("Insert Silence")) 
+
+public:
+       TrackView(SheetView* sv, Track* track);
+       ~TrackView();
+       
+       enum {Type = UserType + 2};
+       
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 
QWidget *widget);
+       
+       Track* get_track() const;
+       QList<AudioClipView* >* get_clipviews() {return &m_clipViews;}
+       TrackPanelView* get_trackpanel_view() const;
+       
+       int get_childview_y_offset() const;
+       void move_to(int x, int y);
+       int get_height();
+       void set_height(int height);
+       
+       void calculate_bounding_rect();
+       void load_theme_data();
+       
+private:
+       Track*                  m_track;
+       QList<AudioClipView* >  m_clipViews;
+       TrackPanelView*         m_panel;
+       PluginChainView*        m_pluginChainView;
+       int                     m_height;
+       int                     m_paintBackground;
+       int                     m_cliptopmargin;
+       int                     m_clipbottommargin;
+       int                     m_topborderwidth;
+       int                     m_bottomborderwidth;
+       
+       friend class TrackPanelView;
+
+public slots:
+       Command* edit_properties();
+       Command* add_new_plugin();      
+       Command* select_bus();
+       Command* insert_silence();
+
+private slots:
+       void add_new_audioclipview(AudioClip* clip);
+       void remove_audioclipview(AudioClip* clip);
+};
+
+
+#endif
+
+//eof

Index: ViewItem.cpp
===================================================================
RCS file: ViewItem.cpp
diff -N ViewItem.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ ViewItem.cpp        21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,32 @@
+/*
+Copyright (C) 2005-2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+
+#include "ViewItem.h"
+
+ViewItem::ViewItem(ViewItem* parentViewItem, ContextItem* parentContext)
+       : ContextItem(parentViewItem)
+       , QGraphicsItem(parentViewItem)
+{
+       set_context_item(parentContext);
+       m_parentViewItem = parentViewItem;
+       setCursor(themer()->get_cursor("Default"));
+}

Index: ViewItem.h
===================================================================
RCS file: ViewItem.h
diff -N ViewItem.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ ViewItem.h  21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,99 @@
+/*
+Copyright (C) 2005-2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef VIEW_ITEM_H
+#define VIEW_ITEM_H
+
+#include <ContextItem.h>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <QGraphicsItem>
+#include <QGraphicsSceneMouseEvent>
+#include <QStyleOptionGraphicsItem>
+#include <QCursor>
+#include <Utils.h>
+#include <Themer.h>
+
+class SheetView;
+               
+// Canvas width should be 2^31, but it doesn't work ok
+// 2^30 works ok, so let's use that, still gives a lot 
+// of headroom for real large recordings
+#if ! defined (Q_WS_WIN)
+#define MAX_CANVAS_WIDTH 1073741824
+#define MAX_CANVAS_HEIGHT 1073741824
+#else          
+#define MAX_CANVAS_WIDTH 107374182
+#define MAX_CANVAS_HEIGHT 107374182
+#endif
+
+
+class ViewItem : public ContextItem, public QGraphicsItem
+{
+       Q_OBJECT
+       
+public:
+
+       ViewItem(ViewItem* parentViewItem=0, ContextItem* parentContext=0);
+       ~ViewItem() {};
+       
+       enum {Type = UserType + 1};
+       
+       QRectF boundingRect() const;
+       virtual void calculate_bounding_rect() {
+               for (int i=0; i< QGraphicsItem::children().size(); ++i) {
+                       QGraphicsItem* item = QGraphicsItem::children().at(i);
+                       if (is_viewitem(item)) {
+                               ((ViewItem*)item)->calculate_bounding_rect();
+                       }
+               }
+       }
+       void prepare_geometry_change() {prepareGeometryChange();}
+       virtual int get_childview_y_offset() const {return 0;}
+       virtual int type() const;
+       virtual int get_height() const {return (int)m_boundingRect.height();}
+       
+       /**
+        *      Reimplement and call update() in the reimplementation
+        *      to make the theme change visible.
+        */
+       virtual void load_theme_data() {};
+       
+       SheetView* get_sheetview() const {return m_sv;}
+       
+       static bool is_viewitem(QGraphicsItem* item) {
+               return item->type() == Type;
+       }
+               
+
+protected:
+
+       SheetView*      m_sv;
+       ViewItem*       m_parentViewItem;
+       QRectF          m_boundingRect;
+};
+
+inline QRectF ViewItem::boundingRect() const {return m_boundingRect;}
+inline int ViewItem::type() const {return Type;}
+
+#endif
+
+//eof

Index: dialogs/AudioClipEditDialog.cpp
===================================================================
RCS file: dialogs/AudioClipEditDialog.cpp
diff -N dialogs/AudioClipEditDialog.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dialogs/AudioClipEditDialog.cpp     21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,402 @@
+/*
+Copyright (C) 2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+
+#include "AudioClipEditDialog.h"
+
+#include "AudioClip.h"
+#include "FadeCurve.h"
+#include "ProjectManager.h"
+#include "Project.h"
+#include "Utils.h"
+#include "Mixer.h"
+#include "Command.h"
+#include "AudioClipExternalProcessing.h"
+#include "InputEngine.h"
+#include "AudioDevice.h"
+
+#define TIME_FORMAT "hh:mm:ss.zzz"
+
+AudioClipEditDialog::AudioClipEditDialog(AudioClip* clip, QWidget* parent) 
+       : QDialog(parent), m_clip(clip)
+{
+       setupUi(this);
+
+       locked = false;
+       
+       // Used for cancelling the changes on Cancel button activated
+       QDomDocument tempDoc;
+       m_origState = clip->get_state(tempDoc);
+       
+       clipStartEdit->setDisplayFormat(TIME_FORMAT);
+       clipLengthEdit->setDisplayFormat(TIME_FORMAT);
+       fadeInEdit->setDisplayFormat(TIME_FORMAT);
+       fadeOutEdit->setDisplayFormat(TIME_FORMAT);
+
+       fadeInModeBox->insertItem(1, "Bended");
+       fadeInModeBox->insertItem(2, "S-Shape");
+       fadeInModeBox->insertItem(3, "Long");
+
+       fadeOutModeBox->insertItem(1, "Bended");
+       fadeOutModeBox->insertItem(2, "S-Shape");
+       fadeOutModeBox->insertItem(3, "Long");
+
+       // Used to set gain and name
+       clip_state_changed();
+       
+       // used for length, track start position
+       clip_position_changed();
+       
+       // detect and set fade params
+       fade_curve_added();
+       
+       connect(clip, SIGNAL(stateChanged()), this, SLOT(clip_state_changed()));
+       connect(clip, SIGNAL(positionChanged(Snappable*)), this, 
SLOT(clip_position_changed()));
+       connect(clip, SIGNAL(fadeAdded(FadeCurve*)), this, 
SLOT(fade_curve_added()));
+       
+       connect(clipGainSpinBox, SIGNAL(valueChanged(double)), this, 
SLOT(gain_spinbox_value_changed(double)));
+       
+       connect(clipStartEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(clip_start_edit_changed(const QTime&)));
+       connect(clipLengthEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(clip_length_edit_changed(const QTime&)));
+       
+       connect(fadeInEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(fadein_edit_changed(const QTime&)));
+       connect(fadeInModeBox, SIGNAL(currentIndexChanged(int)), this, 
SLOT(fadein_mode_edit_changed(int)));
+       connect(fadeInBendingBox, SIGNAL(valueChanged(double)), this, 
SLOT(fadein_bending_edit_changed(double)));
+       connect(fadeInStrengthBox, SIGNAL(valueChanged(double)), this, 
SLOT(fadein_strength_edit_changed(double)));
+       connect(fadeInLinearButton, SIGNAL(clicked()), this, 
SLOT(fadein_linear()));
+       connect(fadeInDefaultButton, SIGNAL(clicked()), this, 
SLOT(fadein_default()));
+
+       connect(fadeOutEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(fadeout_edit_changed(const QTime&)));
+       connect(fadeOutModeBox, SIGNAL(currentIndexChanged(int)), this, 
SLOT(fadeout_mode_edit_changed(int)));
+       connect(fadeOutBendingBox, SIGNAL(valueChanged(double)), this, 
SLOT(fadeout_bending_edit_changed(double)));
+       connect(fadeOutStrengthBox, SIGNAL(valueChanged(double)), this, 
SLOT(fadeout_strength_edit_changed(double)));
+       connect(fadeOutLinearButton, SIGNAL(clicked()), this, 
SLOT(fadeout_linear()));
+       connect(fadeOutDefaultButton, SIGNAL(clicked()), this, 
SLOT(fadeout_default()));
+       
+       connect(externalProcessingButton, SIGNAL(clicked()), this, 
SLOT(external_processing()));
+       connect(buttonBox, SIGNAL(accepted()), this, SLOT(save_changes()));
+       connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancel_changes()));
+}
+
+
+void AudioClipEditDialog::external_processing()
+{
+       Command::process_command(new AudioClipExternalProcessing(m_clip));
+}
+
+void AudioClipEditDialog::clip_state_changed()
+{
+       if (m_clip->get_name() != clipNameLineEdit->text()) {
+               setWindowTitle(m_clip->get_name());
+               clipNameLineEdit->setText(m_clip->get_name());
+       }
+       
+       clipGainSpinBox->setValue(coefficient_to_dB(m_clip->get_gain()));
+}
+
+void AudioClipEditDialog::save_changes()
+{
+       hide();
+       QString name = clipNameLineEdit->text();
+       if (!name.isEmpty()) {
+               m_clip->set_name(name);
+       } else {
+               clipNameLineEdit->setText(m_clip->get_name());
+       }               
+}
+
+void AudioClipEditDialog::cancel_changes()
+{
+       hide();
+       m_clip->set_state(m_origState);
+}
+
+void AudioClipEditDialog::gain_spinbox_value_changed(double value)
+{
+       float gain = dB_to_scale_factor(value);
+       m_clip->set_gain(gain);
+}
+
+void AudioClipEditDialog::clip_position_changed()
+{
+       if (locked) return;
+
+       QTime clipLengthTime = timeref_to_qtime(m_clip->get_length());
+       clipLengthEdit->setTime(clipLengthTime);
+       
+       QTime clipStartTime = 
timeref_to_qtime(m_clip->get_track_start_location());
+       clipStartEdit->setTime(clipStartTime);
+
+       update_clip_end();
+}
+
+void AudioClipEditDialog::fadein_length_changed()
+{
+       if (ie().is_holding()) return;
+       if (locked) return;
+       
+       TimeRef ref(qint64(m_clip->get_fade_in()->get_range()));
+       QTime fadeTime = timeref_to_qtime(ref);
+       fadeInEdit->setTime(fadeTime);
+}
+
+void AudioClipEditDialog::fadeout_length_changed()
+{
+       if (locked) return;
+
+       TimeRef ref(qint64(m_clip->get_fade_out()->get_range()));
+       QTime fadeTime = timeref_to_qtime(ref);
+       fadeOutEdit->setTime(fadeTime);
+}
+
+void AudioClipEditDialog::fadein_edit_changed(const QTime& time)
+{
+       // Hmm, we can't distinguish between hand editing the time edit
+       // or moving the clip with the mouse! In the latter case this function
+       // causes trouble when moving the right edge with the mouse! 
+       // This 'fixes' it .....
+       if (ie().is_holding()) return;
+
+       locked = true;
+       double range = double(qtime_to_timeref(time).universal_frame());
+       if (range == 0) {
+               m_clip->set_fade_in(1);
+       } else {
+               m_clip->set_fade_in(range);
+       }
+       locked = false;
+}
+
+void AudioClipEditDialog::fadeout_edit_changed(const QTime& time)
+{
+       if (ie().is_holding()) return;
+
+       locked = true;
+       double range = double(qtime_to_timeref(time).universal_frame());
+       if (range == 0) {
+               m_clip->set_fade_out(1);
+       } else {
+               m_clip->set_fade_out(range);
+       }
+       locked = false;
+}
+
+void AudioClipEditDialog::clip_length_edit_changed(const QTime& time)
+{
+       if (ie().is_holding()) return;
+
+       locked = true;
+       
+       TimeRef ref = qtime_to_timeref(time);
+
+       if (ref >= m_clip->get_source_length()) {
+               ref = m_clip->get_source_length();
+               QTime clipLengthTime = timeref_to_qtime(ref);
+               clipLengthEdit->setTime(clipLengthTime);
+       }
+
+       m_clip->set_right_edge(ref + m_clip->get_track_start_location());
+       update_clip_end();
+       locked = false;
+}
+
+void AudioClipEditDialog::clip_start_edit_changed(const QTime& time)
+{
+       if (ie().is_holding()) return;
+
+       locked = true;
+       m_clip->set_track_start_location(qtime_to_timeref(time));
+       update_clip_end();
+       locked = false;
+}
+
+void AudioClipEditDialog::fadein_mode_changed()
+{
+       if (locked) return;
+
+       int m = m_clip->get_fade_in()->get_mode();
+       fadeInModeBox->setCurrentIndex(m);
+}
+
+void AudioClipEditDialog::fadeout_mode_changed()
+{
+       if (locked) return;
+
+       int m = m_clip->get_fade_out()->get_mode();
+       fadeOutModeBox->setCurrentIndex(m);
+}
+
+void AudioClipEditDialog::fadein_bending_changed()
+{
+       if (locked) return;
+       fadeInBendingBox->setValue(m_clip->get_fade_in()->get_bend_factor());
+}
+
+void AudioClipEditDialog::fadeout_bending_changed()
+{
+       if (locked) return;
+       fadeOutBendingBox->setValue(m_clip->get_fade_out()->get_bend_factor());
+}
+
+void AudioClipEditDialog::fadein_strength_changed()
+{
+       if (locked) return;
+       
fadeInStrengthBox->setValue(m_clip->get_fade_in()->get_strength_factor());
+}
+
+void AudioClipEditDialog::fadeout_strength_changed()
+{
+       if (locked) return;
+       
fadeOutStrengthBox->setValue(m_clip->get_fade_out()->get_strength_factor());
+}
+
+void AudioClipEditDialog::fadein_mode_edit_changed(int index)
+{
+       if (!m_clip->get_fade_in()) return;
+       locked = true;
+       m_clip->get_fade_in()->set_mode(index);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadeout_mode_edit_changed(int index)
+{
+       if (!m_clip->get_fade_out()) return;
+       locked = true;
+       m_clip->get_fade_out()->set_mode(index);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadein_bending_edit_changed(double value)
+{
+       if (!m_clip->get_fade_in()) return;
+       locked = true;
+       m_clip->get_fade_in()->set_bend_factor(value);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadeout_bending_edit_changed(double value)
+{
+       if (!m_clip->get_fade_out()) return;
+       locked = true;
+       m_clip->get_fade_out()->set_bend_factor(value);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadein_strength_edit_changed(double value)
+{
+       if (!m_clip->get_fade_in()) return;
+       locked = true;
+       m_clip->get_fade_in()->set_strength_factor(value);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadeout_strength_edit_changed(double value)
+{
+       if (!m_clip->get_fade_out()) return;
+       locked = true;
+       m_clip->get_fade_out()->set_strength_factor(value);
+       locked = false;
+}
+
+void AudioClipEditDialog::fadein_linear()
+{
+       if (!m_clip->get_fade_in()) return;
+       fadeInBendingBox->setValue(0.5);
+       fadeInStrengthBox->setValue(0.5);
+}
+
+void AudioClipEditDialog::fadein_default()
+{
+       if (!m_clip->get_fade_in()) return;
+       fadeInBendingBox->setValue(0.0);
+       fadeInStrengthBox->setValue(0.5);
+}
+
+void AudioClipEditDialog::fadeout_linear()
+{
+       if (!m_clip->get_fade_out()) return;
+       fadeOutBendingBox->setValue(0.5);
+       fadeOutStrengthBox->setValue(0.5);
+}
+
+void AudioClipEditDialog::fadeout_default()
+{
+       if (!m_clip->get_fade_out()) return;
+       fadeOutBendingBox->setValue(0.0);
+       fadeOutStrengthBox->setValue(0.5);
+}
+
+TimeRef AudioClipEditDialog::qtime_to_timeref(const QTime & time)
+{
+       TimeRef ref(time.hour() * ONE_HOUR_UNIVERSAL_SAMPLE_RATE + 
time.minute() * ONE_MINUTE_UNIVERSAL_SAMPLE_RATE + time.second() * 
UNIVERSAL_SAMPLE_RATE + (time.msec() * UNIVERSAL_SAMPLE_RATE) / 1000);
+       return ref;
+}
+
+QTime AudioClipEditDialog::timeref_to_qtime(TimeRef& ref)
+{
+       qint64 remainder;
+       int hours, mins, secs, msec;
+
+       qint64 universalframe = ref.universal_frame();
+       
+       hours = universalframe / (ONE_HOUR_UNIVERSAL_SAMPLE_RATE);
+       remainder = universalframe - (hours * ONE_HOUR_UNIVERSAL_SAMPLE_RATE);
+       mins = remainder / ( ONE_MINUTE_UNIVERSAL_SAMPLE_RATE );
+       remainder = remainder - (mins * ONE_MINUTE_UNIVERSAL_SAMPLE_RATE );
+       secs = remainder / UNIVERSAL_SAMPLE_RATE;
+       remainder -= secs * UNIVERSAL_SAMPLE_RATE;
+       msec = remainder * 1000 / UNIVERSAL_SAMPLE_RATE;
+
+       QTime time(hours, mins, secs, msec);
+       return time;
+}
+
+void AudioClipEditDialog::fade_curve_added()
+{
+       if (m_clip->get_fade_in()) {
+               fadein_length_changed();
+               fadein_mode_changed();
+               fadein_bending_changed();
+               fadein_strength_changed();
+               connect(m_clip->get_fade_in(), SIGNAL(rangeChanged()), this, 
SLOT(fadein_length_changed()));
+               connect(m_clip->get_fade_in(), SIGNAL(modeChanged()), this, 
SLOT(fadein_mode_changed()));
+               connect(m_clip->get_fade_in(), SIGNAL(bendValueChanged()), 
this, SLOT(fadein_bending_changed()));
+               connect(m_clip->get_fade_in(), SIGNAL(strengthValueChanged()), 
this, SLOT(fadein_strength_changed()));
+       }
+       if (m_clip->get_fade_out()) {
+               fadeout_length_changed();
+               fadeout_mode_changed();
+               fadeout_bending_changed();
+               fadeout_strength_changed();
+               connect(m_clip->get_fade_out(), SIGNAL(rangeChanged()), this, 
SLOT(fadeout_length_changed()));
+               connect(m_clip->get_fade_out(), SIGNAL(modeChanged()), this, 
SLOT(fadeout_mode_changed()));
+               connect(m_clip->get_fade_out(), SIGNAL(bendValueChanged()), 
this, SLOT(fadeout_bending_changed()));
+               connect(m_clip->get_fade_out(), SIGNAL(strengthValueChanged()), 
this, SLOT(fadeout_strength_changed()));
+       }
+}
+
+void AudioClipEditDialog::update_clip_end()
+{
+       TimeRef clipEndLocation = m_clip->get_track_start_location() + 
m_clip->get_length();
+       QTime clipEndTime = timeref_to_qtime(clipEndLocation);
+       clipEndLineEdit->setText(clipEndTime.toString(TIME_FORMAT));
+}
+

Index: dialogs/AudioClipEditDialog.h
===================================================================
RCS file: dialogs/AudioClipEditDialog.h
diff -N dialogs/AudioClipEditDialog.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dialogs/AudioClipEditDialog.h       21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,88 @@
+/*
+Copyright (C) 2007 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+*/
+
+#ifndef AUDIOCLIP_EDIT_DIALOG_H
+#define AUDIOCLIP_EDIT_DIALOG_H
+
+#include "ui_AudioClipEditDialog.h"
+
+#include <QDomDocument>
+#include <QDomElement>
+#include <QDialog>
+
+#include "defines.h"
+
+class AudioClip;
+
+class AudioClipEditDialog : public QDialog, protected Ui::AudioClipEditDialog
+{
+       Q_OBJECT
+
+public:
+       AudioClipEditDialog(AudioClip* clip, QWidget* parent);
+       ~AudioClipEditDialog() {}
+
+private:
+       AudioClip* m_clip;
+       QDomNode m_origState;
+
+       TimeRef qtime_to_timeref(const QTime& time);
+       QTime timeref_to_qtime(TimeRef& ref);
+       bool locked;
+
+private slots:
+       void external_processing();
+       void clip_state_changed();
+       void save_changes();
+       void cancel_changes();
+       void clip_position_changed();
+       void gain_spinbox_value_changed(double value);
+
+       void fadein_length_changed();
+       void fadein_edit_changed(const QTime& time);
+       void fadein_mode_changed();
+       void fadein_mode_edit_changed(int index);
+       void fadein_bending_changed();
+       void fadein_bending_edit_changed(double value);
+       void fadein_strength_changed();
+       void fadein_strength_edit_changed(double value);
+       void fadein_linear();
+       void fadein_default();
+
+       void fadeout_edit_changed(const QTime& time);
+       void fadeout_length_changed();
+       void fadeout_mode_changed();
+       void fadeout_mode_edit_changed(int index);
+       void fadeout_bending_changed();
+       void fadeout_bending_edit_changed(double value);
+       void fadeout_strength_changed();
+       void fadeout_strength_edit_changed(double value);
+       void fadeout_linear();
+       void fadeout_default();
+
+       void clip_start_edit_changed(const QTime& time);
+       void clip_length_edit_changed(const QTime& time);
+       void update_clip_end();
+
+       void fade_curve_added();
+};
+
+#endif

Index: ui/AudioClipEditDialog.ui
===================================================================
RCS file: ui/AudioClipEditDialog.ui
diff -N ui/AudioClipEditDialog.ui
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ ui/AudioClipEditDialog.ui   21 Jan 2008 16:17:31 -0000      1.1
@@ -0,0 +1,341 @@
+<ui version="4.0" >
+ <class>AudioClipEditDialog</class>
+ <widget class="QDialog" name="AudioClipEditDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>500</width>
+    <height>285</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QTabWidget" name="tabWidget" >
+     <property name="currentIndex" >
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="tab" >
+      <attribute name="title" >
+       <string>Clip Parameters</string>
+      </attribute>
+      <layout class="QGridLayout" >
+       <property name="margin" >
+        <number>9</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item row="5" column="0" colspan="2" >
+        <spacer>
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" >
+          <size>
+           <width>261</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item row="5" column="2" >
+        <widget class="QPushButton" name="externalProcessingButton" >
+         <property name="text" >
+          <string>External Processing</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1" colspan="2" >
+        <widget class="QLineEdit" name="clipNameLineEdit" />
+       </item>
+       <item row="1" column="1" colspan="2" >
+        <widget class="QDoubleSpinBox" name="clipGainSpinBox" >
+         <property name="maximum" >
+          <double>30.000000000000000</double>
+         </property>
+         <property name="minimum" >
+          <double>-120.000000000000000</double>
+         </property>
+         <property name="singleStep" >
+          <double>0.200000000000000</double>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1" colspan="2" >
+        <widget class="QTimeEdit" name="clipStartEdit" >
+         <property name="toolTip" >
+          <string>hh:mm:ss.sss</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1" colspan="2" >
+        <widget class="QTimeEdit" name="clipLengthEdit" >
+         <property name="toolTip" >
+          <string>hh:mm:ss.sss</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1" colspan="2" >
+        <widget class="QLabel" name="clipEndLineEdit" >
+         <property name="frameShape" >
+          <enum>QFrame::StyledPanel</enum>
+         </property>
+         <property name="frameShadow" >
+          <enum>QFrame::Sunken</enum>
+         </property>
+         <property name="text" >
+          <string>TextLabel</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="0" >
+        <widget class="QLabel" name="label_6" >
+         <property name="text" >
+          <string>End</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0" >
+        <widget class="QLabel" name="label_2" >
+         <property name="text" >
+          <string>Length</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" >
+        <widget class="QLabel" name="label_3" >
+         <property name="text" >
+          <string>Track start</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" >
+        <widget class="QLabel" name="label_4" >
+         <property name="text" >
+          <string>Gain</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="0" >
+        <widget class="QLabel" name="label" >
+         <property name="text" >
+          <string>Name</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="tab_2" >
+      <attribute name="title" >
+       <string>Fades</string>
+      </attribute>
+      <layout class="QHBoxLayout" >
+       <property name="margin" >
+        <number>9</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <item>
+        <widget class="QGroupBox" name="groupBox" >
+         <property name="title" >
+          <string>Fade In</string>
+         </property>
+         <layout class="QGridLayout" >
+          <property name="margin" >
+           <number>9</number>
+          </property>
+          <property name="spacing" >
+           <number>6</number>
+          </property>
+          <item row="0" column="1" >
+           <widget class="QTimeEdit" name="fadeInEdit" >
+            <property name="maximumTime" >
+             <time>
+              <hour>22</hour>
+              <minute>0</minute>
+              <second>0</second>
+             </time>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="1" >
+           <widget class="QDoubleSpinBox" name="fadeInStrengthBox" >
+            <property name="maximum" >
+             <double>1.000000000000000</double>
+            </property>
+            <property name="singleStep" >
+             <double>0.050000000000000</double>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1" >
+           <widget class="QDoubleSpinBox" name="fadeInBendingBox" >
+            <property name="maximum" >
+             <double>1.000000000000000</double>
+            </property>
+            <property name="singleStep" >
+             <double>0.050000000000000</double>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="0" >
+           <widget class="QLabel" name="label_7" >
+            <property name="text" >
+             <string>Mode</string>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="0" >
+           <widget class="QLabel" name="label_10" >
+            <property name="text" >
+             <string>Bending</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" >
+           <widget class="QLabel" name="label_5" >
+            <property name="text" >
+             <string>Length</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1" >
+           <widget class="QComboBox" name="fadeInModeBox" />
+          </item>
+          <item row="3" column="0" >
+           <widget class="QLabel" name="label_11" >
+            <property name="text" >
+             <string>Strength</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0" >
+           <widget class="QPushButton" name="fadeInLinearButton" >
+            <property name="text" >
+             <string>&amp;Linear</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="1" >
+           <widget class="QPushButton" name="fadeInDefaultButton" >
+            <property name="text" >
+             <string>&amp;Default</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="groupBox_2" >
+         <property name="title" >
+          <string>Fade Out</string>
+         </property>
+         <layout class="QGridLayout" >
+          <property name="margin" >
+           <number>9</number>
+          </property>
+          <property name="spacing" >
+           <number>6</number>
+          </property>
+          <item row="3" column="1" >
+           <widget class="QDoubleSpinBox" name="fadeOutStrengthBox" >
+            <property name="maximum" >
+             <double>1.000000000000000</double>
+            </property>
+            <property name="singleStep" >
+             <double>0.050000000000000</double>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="0" >
+           <widget class="QLabel" name="label_12" >
+            <property name="text" >
+             <string>Bending</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="0" >
+           <widget class="QLabel" name="label_8" >
+            <property name="text" >
+             <string>Mode</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1" >
+           <widget class="QComboBox" name="fadeOutModeBox" />
+          </item>
+          <item row="0" column="0" >
+           <widget class="QLabel" name="label_9" >
+            <property name="text" >
+             <string>Length</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1" >
+           <widget class="QTimeEdit" name="fadeOutEdit" />
+          </item>
+          <item row="3" column="0" >
+           <widget class="QLabel" name="label_13" >
+            <property name="text" >
+             <string>Strength</string>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1" >
+           <widget class="QDoubleSpinBox" name="fadeOutBendingBox" >
+            <property name="maximum" >
+             <double>1.000000000000000</double>
+            </property>
+            <property name="singleStep" >
+             <double>0.050000000000000</double>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0" >
+           <widget class="QPushButton" name="fadeOutLinearButton" >
+            <property name="text" >
+             <string>&amp;Linear</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="1" >
+           <widget class="QPushButton" name="fadeOutDefaultButton" >
+            <property name="text" >
+             <string>&amp;Default</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]