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

📄 segmentparameterbox.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* -*- 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 "SegmentParameterBox.h"#include <qlayout.h>#include <kapplication.h>#include <klocale.h>#include "misc/Debug.h"#include "misc/Strings.h"#include "document/ConfigGroups.h"#include "base/Colour.h"#include "base/ColourMap.h"#include "base/Composition.h"#include "base/MidiProgram.h"#include "base/NotationTypes.h"#include "base/BasicQuantizer.h"#include "base/RealTime.h"#include "base/Segment.h"#include "base/Selection.h"#include "commands/segment/SegmentChangeQuantizationCommand.h"#include "commands/segment/SegmentColourCommand.h"#include "commands/segment/SegmentColourMapCommand.h"#include "commands/segment/SegmentCommandRepeat.h"#include "commands/segment/SegmentLabelCommand.h"#include "document/MultiViewCommandHistory.h"#include "document/RosegardenGUIDoc.h"#include "gui/dialogs/PitchPickerDialog.h"#include "gui/editors/notation/NotationStrings.h"#include "gui/editors/notation/NotePixmapFactory.h"#include "gui/general/GUIPalette.h"#include "gui/widgets/ColourTable.h"#include "gui/widgets/TristateCheckBox.h"#include "RosegardenParameterArea.h"#include "RosegardenParameterBox.h"#include <kcolordialog.h>#include <kcombobox.h>#include <kcommand.h>#include <kconfig.h>#include <klineeditdlg.h>#include <ktabwidget.h>#include <qbutton.h>#include <qcheckbox.h>#include <qcolor.h>#include <qdialog.h>#include <qfont.h>#include <qfontmetrics.h>#include <qframe.h>#include <qlabel.h>#include <qpixmap.h>#include <qpushbutton.h>#include <qscrollview.h>#include <qspinbox.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>#include <qwidgetstack.h>namespace Rosegarden{SegmentParameterBox::SegmentParameterBox(RosegardenGUIDoc* doc,        QWidget *parent)        : RosegardenParameterBox(i18n("Segment"),                                 i18n("Segment Parameters"),                                 parent),        m_highestPlayable(127),        m_lowestPlayable(0),        m_standardQuantizations(BasicQuantizer::getStandardQuantizations()),        m_doc(doc),        m_transposeRange(48){    initBox();    m_doc->getComposition().addObserver(this);    connect(getCommandHistory(), SIGNAL(commandExecuted()),            this, SLOT(update()));}SegmentParameterBox::~SegmentParameterBox(){    if (!isCompositionDeleted()) {        m_doc->getComposition().removeObserver(this);    }}voidSegmentParameterBox::initBox(){    QFont font(m_font);    QFontMetrics fontMetrics(font);    // magic numbers: 13 is the height of the menu pixmaps, 10 is just 10    //int comboHeight = std::max(fontMetrics.height(), 13) + 10;    int width = fontMetrics.width("12345678901234567890");    //    QFrame *frame = new QFrame(this);    QGridLayout *gridLayout = new QGridLayout(this, 8, 6, 4, 2);    QLabel *label	= new QLabel(i18n("Label"), this);    QLabel *repeatLabel = new QLabel(i18n("Repeat"), this);    QLabel *quantizeLabel = new QLabel(i18n("Quantize"), this);    QLabel *transposeLabel = new QLabel(i18n("Transpose"), this);    QLabel *delayLabel = new QLabel(i18n("Delay"), this);    QLabel *colourLabel = new QLabel(i18n("Color"), this);//    m_autoFadeLabel = new QLabel(i18n("Audio auto-fade"), this);//    m_fadeInLabel = new QLabel(i18n("Fade in"), this);//    m_fadeOutLabel = new QLabel(i18n("Fade out"), this);//    m_rangeLabel = new QLabel(i18n("Range"), this);    // Label ..    m_label = new QLabel(this);    m_label->setFont(font);    m_label->setFixedWidth(width);    //m_label->setFixedHeight(comboHeight);    m_label->setFrameStyle(QFrame::Panel | QFrame::Sunken);    // .. and edit button    m_labelButton = new QPushButton(i18n("Edit"), this);    m_labelButton->setFont(font);    //    m_labelButton->setFixedWidth(50);    connect(m_labelButton, SIGNAL(released()),            SLOT(slotEditSegmentLabel()));    m_repeatValue = new TristateCheckBox(this);    m_repeatValue->setFont(font);    //m_repeatValue->setFixedHeight(comboHeight);    // handle state changes    connect(m_repeatValue, SIGNAL(pressed()), SLOT(slotRepeatPressed()));    // non-reversing motif style read-only combo    m_quantizeValue = new KComboBox(this);    m_quantizeValue->setFont(font);    //m_quantizeValue->setFixedHeight(comboHeight);    // handle quantize changes from drop down    connect(m_quantizeValue, SIGNAL(activated(int)),            SLOT(slotQuantizeSelected(int)));    // reversing motif style read-write combo    m_transposeValue = new KComboBox(this);    m_transposeValue->setFont(font);    //m_transposeValue->setFixedHeight(comboHeight);    // handle transpose combo changes    connect(m_transposeValue, SIGNAL(activated(int)),            SLOT(slotTransposeSelected(int)));    // and text changes    connect(m_transposeValue, SIGNAL(textChanged(const QString&)),            SLOT(slotTransposeTextChanged(const QString&)));    // reversing motif style read-write combo    m_delayValue = new KComboBox(this);    m_delayValue->setFont(font);    //m_delayValue->setFixedHeight(comboHeight);    // handle delay combo changes    connect(m_delayValue, SIGNAL(activated(int)),            SLOT(slotDelaySelected(int)));    // Detect when the document colours are updated    connect(m_doc, SIGNAL(docColoursChanged()),            this, SLOT(slotDocColoursChanged()));    // handle text changes for delay    connect(m_delayValue, SIGNAL(textChanged(const QString&)),            SLOT(slotDelayTextChanged(const QString &)));    // set up combo box for colours    m_colourValue = new KComboBox(false, this);    m_colourValue->setFont(font);    //m_colourValue->setFixedHeight(comboHeight);    //    m_colourValue->setMaximumWidth(width);    m_colourValue->setSizeLimit(20);    // handle colour combo changes    connect(m_colourValue, SIGNAL(activated(int)),            SLOT(slotColourSelected(int)));    // pre-set width of buttons so they don't grow later//    width = fontMetrics.width(i18n("used internally for spacing", "High: ----"));    // highest playable note    ////    m_highButton = new QPushButton(i18n("High: ---"), this);//    QToolTip::add//        (m_highButton, i18n("Choose the highest suggested playable note, using a staff"));//    m_highButton->setFont(font);//    m_highButton->setMinimumWidth(width);//    connect(m_highButton, SIGNAL(released()),//            SLOT(slotHighestPressed()));    // lowest playable note    ////    m_lowButton = new QPushButton(i18n("Low: ----"), this);//    QToolTip::add//        (m_lowButton, i18n("Choose the lowest suggested playable note, using a staff"));//    m_lowButton->setFont(font);//    m_lowButton->setMinimumWidth(width);//    connect(m_lowButton, SIGNAL(released()),//            SLOT(slotLowestPressed()));    // Audio autofade enabled    ////    m_autoFadeBox = new QCheckBox(this);//    connect(m_autoFadeBox, SIGNAL(stateChanged(int)),//            this, SLOT(slotAudioFadeChanged(int)));    // Fade in and out times    ////    m_fadeInSpin = new QSpinBox(this);//    m_fadeInSpin->setMinValue(0);//    m_fadeInSpin->setMaxValue(5000);//    m_fadeInSpin->setSuffix(i18n(" ms"));//    connect(m_fadeInSpin, SIGNAL(valueChanged(int)),//            this, SLOT(slotFadeInChanged(int)));//    m_fadeOutSpin = new QSpinBox(this);//    m_fadeOutSpin->setMinValue(0);//    m_fadeOutSpin->setMaxValue(5000);//    m_fadeOutSpin->setSuffix(i18n(" ms"));//    connect(m_fadeOutSpin, SIGNAL(valueChanged(int)),//            this, SLOT(slotFadeOutChanged(int)));    label->setFont(font);    repeatLabel->setFont(font);    quantizeLabel->setFont(font);    transposeLabel->setFont(font);    delayLabel->setFont(font);    colourLabel->setFont(font);//    m_autoFadeLabel->setFont(font);//    m_fadeInLabel->setFont(font);//    m_fadeOutLabel->setFont(font);//    m_rangeLabel->setFont(font);    int row = 0;//    gridLayout->addRowSpacing(0, 12); // why??    gridLayout->addWidget(label, row, 0); //, AlignRight);    gridLayout->addMultiCellWidget(m_label, row, row, 1, 4); //, AlignLeft);    gridLayout->addWidget(m_labelButton, row, 5); //, AlignLeft);    ++row;    gridLayout->addWidget(repeatLabel, row, 0); //, AlignRight);    gridLayout->addWidget(m_repeatValue, row, 1); //, AlignLeft);    gridLayout->addMultiCellWidget(transposeLabel, row, row, 2, 3, AlignRight);    gridLayout->addMultiCellWidget(m_transposeValue, row, row, 4, 5);    ++row;    gridLayout->addWidget(quantizeLabel, row, 0); //, AlignRight);    gridLayout->addMultiCellWidget(m_quantizeValue, row, row, 1, 2); //, AlignLeft);    gridLayout->addWidget(delayLabel, row, 3, AlignRight);    gridLayout->addMultiCellWidget(m_delayValue, row, row, 4, 5);    ++row;    gridLayout->addWidget(colourLabel, row, 0); //, AlignRight);    gridLayout->addMultiCellWidget(m_colourValue, row, row, 1, 5);    ++row;//    gridLayout->addWidget(m_rangeLabel, row, 0); //, AlignRight);//    gridLayout->addMultiCellWidget(m_lowButton, row, row, 1, 2);//    gridLayout->addMultiCellWidget(m_highButton, row, row, 3, 4);//    ++row;//    m_autoFadeLabel->hide();//    m_autoFadeBox->hide();    /*        gridLayout->addWidget(m_fadeInLabel,   5, 0, AlignRight);        gridLayout->addWidget(m_fadeInSpin,  5, 1);             gridLayout->addWidget(m_fadeOutLabel,  5, 2, AlignRight);        gridLayout->addWidget(m_fadeOutSpin, 5, 3);    */     // Configure the empty final row to accomodate any extra vertical space.    gridLayout->setRowStretch(gridLayout->numRows() - 1, 1);    // Configure the empty final column to accomodate any extra horizontal    // space.//    gridLayout->setColStretch(gridLayout->numCols() - 1, 1);    // populate the quantize combo    //    QPixmap noMap = NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap("menu-no-note"));    for (unsigned int i = 0; i < m_standardQuantizations.size(); ++i) {        timeT time = m_standardQuantizations[i];        timeT error = 0;        QString label = NotationStrings::makeNoteMenuLabel(time, true, error);        QPixmap pmap = NotePixmapFactory::toQPixmap(NotePixmapFactory::makeNoteMenuPixmap(time, error));        m_quantizeValue->insertItem(error ? noMap : pmap, label);    }    m_quantizeValue->insertItem(noMap, i18n("Off"));    // default to last item    m_quantizeValue->setCurrentItem(m_quantizeValue->count() - 1);    // populate the transpose combo    //    for (int i = -m_transposeRange; i < m_transposeRange + 1; i++) {        m_transposeValue->insertItem(noMap, QString("%1").arg(i));        if (i == 0)            m_transposeValue->setCurrentItem(m_transposeValue->count() - 1);    }    m_delays.clear();    for (int i = 0; i < 6; i++) {        timeT time = 0;        if (i > 0 && i < 6) {            time = Note(Note::Hemidemisemiquaver).getDuration() << (i - 1);        } else if (i > 5) {            time = Note(Note::Crotchet).getDuration() * (i - 4);        }        m_delays.push_back(time);        // check if it's a valid note duration (it will be for the        // time defn above, but if we were basing it on the sequencer        // resolution it might not be) & include a note pixmap if so        //        timeT error = 0;        QString label = NotationStrings::makeNoteMenuLabel(time, true, error);        QPixmap pmap = NotePixmapFactory::toQPixmap(NotePixmapFactory::makeNoteMenuPixmap(time, error));        m_delayValue->insertItem((error ? noMap : pmap), label);    }    for (int i = 0; i < 10; i++) {        int rtd = (i < 5 ? ((i + 1) * 10) : ((i - 3) * 50));        m_realTimeDelays.push_back(rtd);        m_delayValue->insertItem(i18n("%1 ms").arg(rtd));    }    // set delay blank initially    m_delayValue->setCurrentItem( -1);    // populate m_colourValue    slotDocColoursChanged();    //!!! disabled until after 1.3//    m_highButton->hide();//    m_lowButton->hide();//    m_rangeLabel->hide();    //////////////////////////////}voidSegmentParameterBox::setDocument(RosegardenGUIDoc* doc){    if (m_doc != 0)        disconnect(m_doc, SIGNAL(docColoursChanged()),                   this, SLOT(slotDocColoursChanged()));    m_doc = doc;    // Detect when the document colours are updated    connect (m_doc, SIGNAL(docColoursChanged()),             this, SLOT(slotDocColoursChanged()));    slotDocColoursChanged(); // repopulate combo}voidSegmentParameterBox::useSegment(Segment *segment){    m_segments.clear();    m_segments.push_back(segment);    populateBoxFromSegments();}

⌨️ 快捷键说明

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