⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rosegardenguiview.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//*    Rosegarden    A MIDI and audio sequencer and musical notation editor.     This program is Copyright 2000-2007        Guillaume Laurent   <glaurent@telegraph-road.org>,        Chris Cannam        <cannam@all-day-breakfast.com>,        Richard Bown        <richard.bown@ferventsoftware.com>     The moral rights of Guillaume Laurent, Chris Cannam, and Richard    Bown to claim authorship of this work have been asserted.     Other copyrights also apply to some parts of this work.  Please    see the AUTHORS file and individual file headers for details.     This program 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.  See the file    COPYING included with this distribution for more information.*/#include "RosegardenGUIView.h"#include <kapplication.h>#include "sound/Midi.h"#include "gui/editors/segment/TrackButtons.h"#include <klocale.h>#include "misc/Debug.h"#include "misc/Strings.h"#include "document/ConfigGroups.h"#include "gui/application/RosegardenDCOP.h"#include "base/AudioLevel.h"#include "base/Composition.h"#include "base/Instrument.h"#include "base/MidiDevice.h"#include "base/MidiProgram.h"#include "base/NotationTypes.h"#include "base/RealTime.h"#include "base/RulerScale.h"#include "base/Segment.h"#include "base/Selection.h"#include "base/Studio.h"#include "base/Track.h"#include "commands/segment/AudioSegmentAutoSplitCommand.h"#include "commands/segment/AudioSegmentInsertCommand.h"#include "commands/segment/SegmentSingleRepeatToCopyCommand.h"#include "document/MultiViewCommandHistory.h"#include "document/RosegardenGUIDoc.h"#include "RosegardenApplication.h"#include "gui/configuration/GeneralConfigurationPage.h"#include "gui/configuration/AudioConfigurationPage.h"#include "gui/dialogs/AudioSplitDialog.h"#include "gui/dialogs/AudioManagerDialog.h"#include "gui/dialogs/DocumentConfigureDialog.h"#include "gui/dialogs/TempoDialog.h"#include "gui/editors/eventlist/EventView.h"#include "gui/editors/matrix/MatrixView.h"#include "gui/editors/notation/NotationView.h"#include "gui/editors/parameters/InstrumentParameterBox.h"#include "gui/editors/parameters/SegmentParameterBox.h"#include "gui/editors/parameters/TrackParameterBox.h"#include "gui/editors/segment/segmentcanvas/CompositionView.h"#include "gui/editors/segment/segmentcanvas/SegmentSelector.h"#include "gui/editors/segment/TrackEditor.h"#include "gui/seqmanager/SequenceManager.h"#include "gui/seqmanager/SequencerMapper.h"#include "gui/rulers/ChordNameRuler.h"#include "gui/rulers/LoopRuler.h"#include "gui/rulers/TempoRuler.h"#include "gui/rulers/StandardRuler.h"#include "gui/widgets/ProgressDialog.h"#include "gui/widgets/CurrentProgressDialog.h"#include "RosegardenGUIApp.h"#include "SetWaitCursor.h"#include "sound/AudioFile.h"#include "sound/AudioFileManager.h"#include "sound/MappedEvent.h"#include <kcommand.h>#include <kconfig.h>#include <kmessagebox.h>#include <kprocess.h>#include <qapplication.h>#include <qcursor.h>#include <qdialog.h>#include <qfileinfo.h>#include <qobject.h>#include <qstring.h>#include <qvbox.h>#include <qwidget.h>namespace Rosegarden{// Use this to define the basic unit of the main QCanvas size.//// This apparently arbitrary figure is what we think is an// appropriate width in pixels for a 4/4 bar.  Beware of making it// too narrow, as shorter bars will be proportionally smaller --// the visual difference between 2/4 and 4/4 is perhaps greater// than it sounds.//static double barWidth44 = 100.0;const QWidget *RosegardenGUIView::m_lastActiveMainWindow = 0;// This is the maximum number of matrix, event view or percussion// matrix editors to open in a single operation (not the maximum that// can be open at a time -- there isn't one)//static int maxEditorsToOpen = 8;RosegardenGUIView::RosegardenGUIView(bool showTrackLabels,                                     SegmentParameterBox* segmentParameterBox,                                     InstrumentParameterBox* instrumentParameterBox,                                     TrackParameterBox* trackParameterBox,                                     QWidget *parent,                                     const char* /*name*/)        : QVBox(parent),        m_rulerScale(0),        m_trackEditor(0),        m_segmentParameterBox(segmentParameterBox),        m_instrumentParameterBox(instrumentParameterBox),        m_trackParameterBox(trackParameterBox){    RosegardenGUIDoc* doc = getDocument();    Composition *comp = &doc->getComposition();    double unitsPerPixel =        TimeSignature(4, 4).getBarDuration() / barWidth44;    m_rulerScale = new SimpleRulerScale(comp, 0, unitsPerPixel);    // Construct the trackEditor first so we can then    // query it for placement information    //    m_trackEditor = new TrackEditor(doc, this,                                    m_rulerScale, showTrackLabels, unitsPerPixel, this /*hbox*/);    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editSegment(Segment*)),            SLOT(slotEditSegment(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editSegmentNotation(Segment*)),            SLOT(slotEditSegmentNotation(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editSegmentMatrix(Segment*)),            SLOT(slotEditSegmentMatrix(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editSegmentAudio(Segment*)),            SLOT(slotEditSegmentAudio(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(audioSegmentAutoSplit(Segment*)),            SLOT(slotSegmentAutoSplit(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editSegmentEventList(Segment*)),            SLOT(slotEditSegmentEventList(Segment*)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(editRepeat(Segment*, timeT)),            SLOT(slotEditRepeat(Segment*, timeT)));    connect(m_trackEditor->getSegmentCanvas(),            SIGNAL(setPointerPosition(timeT)),            doc, SLOT(slotSetPointerPosition(timeT)));    connect(m_trackEditor,            SIGNAL(droppedDocument(QString)),            parent,            SLOT(slotOpenDroppedURL(QString)));    connect(m_trackEditor,            SIGNAL(droppedAudio(QString)),            this,            SLOT(slotDroppedAudio(QString)));    connect(m_trackEditor,            SIGNAL(droppedNewAudio(QString)),            this,            SLOT(slotDroppedNewAudio(QString)));    connect(m_instrumentParameterBox,            SIGNAL(changeInstrumentLabel(InstrumentId, QString)),            this,            SLOT(slotChangeInstrumentLabel(InstrumentId, QString)));    connect(m_instrumentParameterBox,            SIGNAL(changeInstrumentLabel(InstrumentId, QString)),            m_trackParameterBox,            SLOT(slotInstrumentLabelChanged(InstrumentId, QString)));    connect(m_trackEditor->getTrackButtons(),            SIGNAL(nameChanged()),            m_trackParameterBox,            SLOT(slotSelectedTrackNameChanged()));    connect(m_trackEditor->getTrackButtons(),            SIGNAL(instrumentSelected(int)),            m_trackParameterBox,            SLOT(slotUpdateControls(int)));    connect(m_trackParameterBox,            SIGNAL(instrumentSelected(TrackId, int)),            m_trackEditor->getTrackButtons(),            SLOT(slotTrackInstrumentSelection(TrackId, int)));    connect(this, SIGNAL(controllerDeviceEventReceived(MappedEvent *, const void *)),            this, SLOT(slotControllerDeviceEventReceived(MappedEvent *, const void *)));    if (doc) {        /* signal no longer exists        	connect(doc, SIGNAL(recordingSegmentUpdated(Segment *,        						    timeT)),        		this, SLOT(slotUpdateRecordingSegment(Segment *,        						      timeT)));        */        QObject::connect        (getCommandHistory(), SIGNAL(commandExecuted()),         m_trackEditor->getSegmentCanvas(), SLOT(slotUpdateSegmentsDrawBuffer()));    }}RosegardenGUIView::~RosegardenGUIView(){    RG_DEBUG << "~RosegardenGUIView()" << endl;    delete m_rulerScale;}RosegardenGUIDoc*RosegardenGUIView::getDocument() const{    return RosegardenGUIApp::self()->getDocument();}void RosegardenGUIView::print(Composition* p, bool previewOnly){    SetWaitCursor waitCursor;    std::vector<Segment *> segmentsToEdit;    for (Composition::iterator i = p->begin(); i != p->end(); ++i) {        if ((*i)->getType() != Segment::Audio) {            segmentsToEdit.push_back(*i);        }    }    if (segmentsToEdit.empty()) {        KMessageBox::sorry(this, i18n("No non-audio segments in composition"));        return ;    }    NotationView *notationView = new NotationView(getDocument(),                                 segmentsToEdit,                                 this,                                 (NotationView *)0);    if (!notationView->isOK()) {        RG_DEBUG << "RosegardenGUIView::print : operation cancelled" << endl;        delete notationView;        return ;    }    notationView->print(previewOnly);    delete notationView;}void RosegardenGUIView::selectTool(const QString toolName){    m_trackEditor->getSegmentCanvas()->slotSetTool(toolName);}boolRosegardenGUIView::haveSelection(){    return m_trackEditor->getSegmentCanvas()->haveSelection();}SegmentSelectionRosegardenGUIView::getSelection(){    return m_trackEditor->getSegmentCanvas()->getSelectedSegments();}void RosegardenGUIView::updateSelectionContents(){    m_trackEditor->getSegmentCanvas()->updateSelectionContents();}/* hjj: WHAT DO DO WITH THIS ?voidRosegardenGUIView::slotEditMetadata(QString name){    const QWidget *ww = dynamic_cast<const QWidget *>(sender());    QWidget *w = const_cast<QWidget *>(ww);    DocumentConfigureDialog *configDlg =        new DocumentConfigureDialog(getDocument(), w ? w : this);    configDlg->selectMetadata(name);    configDlg->show();}*/void RosegardenGUIView::slotEditSegment(Segment* segment){    Segment::SegmentType type = Segment::Internal;    if (segment) {        type = segment->getType();    } else {        if (haveSelection()) {            bool haveType = false;            SegmentSelection selection = getSelection();            for (SegmentSelection::iterator i = selection.begin();                    i != selection.end(); ++i) {                Segment::SegmentType myType = (*i)->getType();                if (haveType) {                    if (myType != type) {                        KMessageBox::sorry(this, i18n("Selection must contain only audio or non-audio segments"));                        return ;                    }                } else {                    type = myType;                    haveType = true;                    segment = *i;                }            }        } else            return ;    }    if (type == Segment::Audio) {        slotEditSegmentAudio(segment);    } else {        KConfig* config = kapp->config();        config->setGroup(GeneralOptionsConfigGroup);        GeneralConfigurationPage::DoubleClickClient        client =            (GeneralConfigurationPage::DoubleClickClient)            (config->readUnsignedNumEntry("doubleclickclient",                                          (unsigned int)GeneralConfigurationPage::NotationView));        if (client == GeneralConfigurationPage::MatrixView) {            bool isPercussion = false;            Track *track = getDocument()->getComposition().getTrackById                (segment->getTrack());            if (track) {                InstrumentId iid = track->getInstrument();                Instrument *instrument =                    getDocument()->getStudio().getInstrumentById(iid);                if (instrument && instrument->isPercussion()) isPercussion = true;            }            if (isPercussion) {                slotEditSegmentPercussionMatrix(segment);            } else {                slotEditSegmentMatrix(segment);            }        } else if (client == GeneralConfigurationPage::EventView) {            slotEditSegmentEventList(segment);        } else {            slotEditSegmentNotation(segment);        }    }}void RosegardenGUIView::slotEditRepeat(Segment *segment,                                       timeT time){    SegmentSingleRepeatToCopyCommand *command =        new SegmentSingleRepeatToCopyCommand(segment, time);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -