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

📄 editview.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* -*- 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 "EditView.h"#include <qlayout.h>#include "base/BaseProperties.h"#include <klocale.h>#include <kconfig.h>#include "misc/Debug.h"#include "misc/Strings.h"#include "ActiveItem.h"#include "base/AnalysisTypes.h"#include "base/Composition.h"#include "base/CompositionTimeSliceAdapter.h"#include "base/Controllable.h"#include "base/ControlParameter.h"#include "base/Device.h"#include "base/Event.h"#include "base/Exception.h"#include "base/Instrument.h"#include "base/MidiDevice.h"#include "base/MidiProgram.h"#include "base/MidiTypes.h"#include "base/NotationTypes.h"#include "base/Profiler.h"#include "base/Property.h"#include "base/PropertyName.h"#include "base/RulerScale.h"#include "base/Segment.h"#include "base/Selection.h"#include "base/SoftSynthDevice.h"#include "base/Staff.h"#include "base/Studio.h"#include "base/ViewElement.h"#include "commands/edit/InvertCommand.h"#include "commands/edit/MoveCommand.h"#include "commands/edit/RescaleCommand.h"#include "commands/edit/RetrogradeCommand.h"#include "commands/edit/RetrogradeInvertCommand.h"#include "commands/edit/TransposeCommand.h"#include "commands/segment/AddTempoChangeCommand.h"#include "commands/segment/AddTimeSignatureAndNormalizeCommand.h"#include "commands/segment/AddTimeSignatureCommand.h"#include "document/MultiViewCommandHistory.h"#include "document/RosegardenGUIDoc.h"#include "document/ConfigGroups.h"#include "EditViewBase.h"#include "gui/dialogs/RescaleDialog.h"#include "gui/dialogs/TempoDialog.h"#include "gui/dialogs/IntervalDialog.h"#include "gui/dialogs/TimeSignatureDialog.h"#include "gui/rulers/StandardRuler.h"#include "gui/kdeext/KTmpStatusMsg.h"#include "gui/kdeext/QCanvasGroupableItem.h"#include "gui/rulers/ControllerEventsRuler.h"#include "gui/rulers/ControlRuler.h"#include "gui/rulers/PropertyControlRuler.h"#include "RosegardenCanvasView.h"#include <kaction.h>#include <kcommand.h>#include <kdockwidget.h>#include <kglobal.h>#include <kiconloader.h>#include <ktabwidget.h>#include <kxmlguiclient.h>#include <qaccel.h>#include <qbutton.h>#include <qdialog.h>#include <qframe.h>#include <qinputdialog.h>#include <qobjectlist.h>#include <qpopupmenu.h>#include <qsize.h>#include <qstring.h>#include <qtabwidget.h>#include <qvbox.h>#include <qwidget.h>#include <qwmatrix.h>namespace Rosegarden{const unsigned int EditView::CONTROLS_ROW         = 0;const unsigned int EditView::RULERS_ROW           = CONTROLS_ROW + 1;const unsigned int EditView::TOPBARBUTTONS_ROW    = RULERS_ROW + 1;const unsigned int EditView::CANVASVIEW_ROW       = TOPBARBUTTONS_ROW + 1;const unsigned int EditView::CONTROLRULER_ROW     = CANVASVIEW_ROW + 1;// Just some simple features we might want to show - make them bit maskable//static int FeatureShowVelocity = 0x00001; // show the velocity rulerEditView::EditView(RosegardenGUIDoc *doc,                   std::vector<Segment *> segments,                   unsigned int cols,                   QWidget *parent, const char *name) :        EditViewBase(doc, segments, cols, parent, name),        m_currentEventSelection(0),        m_activeItem(0),        m_canvasView(0),        m_rulerBox(new QVBoxLayout),  // top ruler box - added to grid later on        m_controlBox(new QVBoxLayout),  // top control ruler box - added to grid later on        m_bottomBox(new QVBox(this, "bottomframe")),  // bottom box - added to bottom of canvas view by setCanvasView()        m_topStandardRuler(0),        m_bottomStandardRuler(0),        m_controlRuler(0),        m_controlRulers(new KTabWidget(getBottomWidget(), "controlrulers")){    m_controlRulers->setHoverCloseButton(true);    m_controlRulers->setHoverCloseButtonDelayed(false);    connect(m_controlRulers, SIGNAL(closeRequest(QWidget*)),            this, SLOT(slotRemoveControlRuler(QWidget*)));    (dynamic_cast<QBoxLayout*>(m_bottomBox->layout()))->setDirection(QBoxLayout::BottomToTop);    m_grid->addLayout(m_rulerBox, RULERS_ROW, m_mainCol);    m_grid->addMultiCellLayout(m_controlBox, CONTROLS_ROW, CONTROLS_ROW, 0, 1);    m_controlBox->setAlignment(AlignRight);    //     m_grid->addWidget(m_controlRulers, CONTROLRULER_ROW, 2);    m_controlRulers->hide();    m_controlRulers->setTabPosition(QTabWidget::Bottom);}EditView::~EditView(){    delete m_currentEventSelection;    m_currentEventSelection = 0;}void EditView::updateBottomWidgetGeometry(){    getBottomWidget()->layout()->invalidate();    getBottomWidget()->updateGeometry();    getCanvasView()->updateBottomWidgetGeometry();}void EditView::paintEvent(QPaintEvent* e){    RG_DEBUG << "EditView::paintEvent()\n";    EditViewBase::paintEvent(e);    if (m_needUpdate) {        RG_DEBUG << "EditView::paintEvent() - calling updateView\n";        updateView();        getCanvasView()->slotUpdate();        // update rulers        QLayoutIterator it = m_rulerBox->iterator();        QLayoutItem *child;        while ( (child = it.current()) != 0 ) {            if (child->widget())                child->widget()->update();            ++it;        }        updateControlRulers();    } else {        getCanvasView()->slotUpdate();        updateControlRulers();    }    m_needUpdate = false;}void EditView::updateControlRulers(bool updateHPos){    for (int i = 0; i < m_controlRulers->count(); ++i) {        ControlRuler* ruler = dynamic_cast<ControlRuler*>(m_controlRulers->page(i));        if (ruler) {            if (updateHPos)                ruler->slotUpdateElementsHPos();            else                ruler->slotUpdate();        }    }}void EditView::setControlRulersZoom(QWMatrix zoomMatrix){    m_currentRulerZoomMatrix = zoomMatrix;    for (int i = 0; i < m_controlRulers->count(); ++i) {        ControlRuler* ruler = dynamic_cast<ControlRuler*>(m_controlRulers->page(i));        if (ruler)            ruler->setWorldMatrix(zoomMatrix);    }}void EditView::setControlRulersCurrentSegment(){    RG_DEBUG << "EditView::setControlRulersCurrentSegment: visible is " << m_controlRulers->isVisible() << endl;    bool visible = m_controlRulers->isVisible();    delete m_controlRulers;    m_controlRulers = new KTabWidget(getBottomWidget(), "controlrulers");    bool haveTabs = setupControllerTabs();    setupAddControlRulerMenu();    if (haveTabs)        m_controlRulers->show();    else        m_controlRulers->hide();    updateBottomWidgetGeometry();    /*        for (int i = 0; i < m_controlRulers->count(); ++i) {                 PropertyControlRuler *pcr = dynamic_cast<PropertyControlRuler *>    	    (m_controlRulers->page(i));                 if (pcr) pcr->setStaff(getCurrentStaff());    	else {         	    ControllerEventsRuler *cer = dynamic_cast<ControllerEventsRuler *>    		(m_controlRulers->page(i));         	    if (cer) cer->setSegment(getCurrentSegment());    	}        }    */}void EditView::setTopStandardRuler(StandardRuler* w){    delete m_topStandardRuler;    m_topStandardRuler = w;    m_grid->addWidget(w, TOPBARBUTTONS_ROW, m_mainCol);    if (m_canvasView) {        connect(m_canvasView->horizontalScrollBar(), SIGNAL(valueChanged(int)),                m_topStandardRuler, SLOT(slotScrollHoriz(int)));        connect(m_canvasView->horizontalScrollBar(), SIGNAL(sliderMoved(int)),                m_topStandardRuler, SLOT(slotScrollHoriz(int)));    }}void EditView::setBottomStandardRuler(StandardRuler* w){    delete m_bottomStandardRuler;    m_bottomStandardRuler = w;    //     m_bottomBox->insertWidget(0, w);    if (m_canvasView) {        connect(m_canvasView->horizontalScrollBar(), SIGNAL(valueChanged(int)),                m_bottomStandardRuler, SLOT(slotScrollHoriz(int)));        connect(m_canvasView->horizontalScrollBar(), SIGNAL(sliderMoved(int)),                m_bottomStandardRuler, SLOT(slotScrollHoriz(int)));    }}void EditView::setRewFFwdToAutoRepeat(){    QWidget* transportToolbar = factory()->container("Transport Toolbar", this);    if (transportToolbar) {        QObjectList *l = transportToolbar->queryList();        QObjectListIt it(*l); // iterate over the buttons        QObject *obj;        while ( (obj = it.current()) != 0 ) {            // for each found object...            ++it;            //             RG_DEBUG << "EditView::setRewFFwdToAutoRepeat() : obj name : " << obj->name() << endl;            QString objName = obj->name();            if (objName.endsWith("playback_pointer_back_bar") || objName.endsWith("playback_pointer_forward_bar")) {                QButton* btn = dynamic_cast<QButton*>(obj);                if (!btn) {                    RG_DEBUG << "Very strange - found widgets in Transport Toolbar which aren't buttons\n";                    continue;                }                btn->setAutoRepeat(true);            }        }        delete l;    } else {        RG_DEBUG << "transportToolbar == 0\n";    }}void EditView::addRuler(QWidget* w){    m_rulerBox->addWidget(w);    if (m_canvasView) {        connect(m_canvasView->horizontalScrollBar(), SIGNAL(valueChanged(int)),                w, SLOT(slotScrollHoriz(int)));        connect(m_canvasView->horizontalScrollBar(), SIGNAL(sliderMoved(int)),                w, SLOT(slotScrollHoriz(int)));    }}void EditView::addPropertyBox(QWidget *w){    m_controlBox->addWidget(w);}void EditView::addControlRuler(ControlRuler* ruler){    ruler->setWorldMatrix(m_currentRulerZoomMatrix);    m_controlRulers->addTab(ruler, KGlobal::iconLoader()->loadIconSet("fileclose", KIcon::Small),                            ruler->getName());    m_controlRulers->showPage(ruler);    if (m_canvasView) {        connect(m_canvasView->horizontalScrollBar(), SIGNAL(valueChanged(int)),                ruler->horizontalScrollBar(), SIGNAL(valueChanged(int)));        connect(m_canvasView->horizontalScrollBar(), SIGNAL(sliderMoved(int)),                ruler->horizontalScrollBar(), SIGNAL(sliderMoved(int)));    }    connect(ruler, SIGNAL(stateChange(const QString&, bool)),            this, SLOT(slotStateChanged(const QString&, bool)));    stateChanged("have_control_ruler", KXMLGUIClient::StateReverse);}void EditView::readjustViewSize(QSize requestedSize, bool exact){    Profiler profiler("EditView::readjustViewSize", true);    if (exact) {        RG_DEBUG << "EditView::readjustViewSize: exact size requested ("        << requestedSize.width() << ", " << requestedSize.height()        << ")\n";        setViewSize(requestedSize);        getCanvasView()->slotUpdate();        return ;    }    int requestedWidth = requestedSize.width(),        requestedHeight = requestedSize.height(),        windowWidth = width(),        windowHeight = height();    QSize newSize;    newSize.setWidth(((requestedWidth / windowWidth) + 1) * windowWidth);    newSize.setHeight(((requestedHeight / windowHeight) + 1) * windowHeight);    RG_DEBUG << "EditView::readjustViewSize: requested ("    << requestedSize.width() << ", " << requestedSize.height()    << "), getting (" << newSize.width() << ", "    << newSize.height() << ")" << endl;    setViewSize(newSize);    getCanvasView()->slotUpdate();}void EditView::setCanvasView(RosegardenCanvasView *canvasView){    delete m_canvasView;    m_canvasView = canvasView;    m_grid->addWidget(m_canvasView, CANVASVIEW_ROW, m_mainCol);    m_canvasView->setBottomFixedWidget(m_bottomBox);    // TODO : connect canvas view's horiz. scrollbar to top/bottom bars and rulers    //     m_horizontalScrollBar->setRange(m_canvasView->horizontalScrollBar()->minValue(),    //                                     m_canvasView->horizontalScrollBar()->maxValue());    //     m_horizontalScrollBar->setSteps(m_canvasView->horizontalScrollBar()->lineStep(),    //                                     m_canvasView->horizontalScrollBar()->pageStep());    //     connect(m_horizontalScrollBar, SIGNAL(valueChanged(int)),    //             m_canvasView->horizontalScrollBar(), SIGNAL(valueChanged(int)));    //     connect(m_horizontalScrollBar, SIGNAL(sliderMoved(int)),    //             m_canvasView->horizontalScrollBar(), SIGNAL(sliderMoved(int)));}Device *EditView::getCurrentDevice(){    Segment *segment = getCurrentSegment();    if (!segment)        return 0;    Studio &studio = getDocument()->getStudio();    Instrument *instrument =        studio.getInstrumentById        (segment->getComposition()->getTrackById(segment->getTrack())->

⌨️ 快捷键说明

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