--- qsampler/trunk/src/qsamplerChannelStrip.cpp 2007/11/23 09:32:06 1513 +++ qsampler/trunk/src/qsamplerChannelStrip.cpp 2008/02/05 15:42:33 1668 @@ -2,7 +2,7 @@ // /**************************************************************************** Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. - Copyright (C) 2007, Christian Schoenebeck + Copyright (C) 2007, 2008 Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,6 +25,9 @@ #include "qsamplerMainForm.h" +#include "qsamplerChannelFxForm.h" + +#include #include #include @@ -34,8 +37,6 @@ // Needed for lroundf() #include -namespace QSampler { - #ifndef CONFIG_ROUND static inline long lroundf ( float x ) { @@ -46,6 +47,16 @@ } #endif + +namespace QSampler { + +//------------------------------------------------------------------------- +// QSampler::ChannelStrip -- Channel strip form implementation. +// + +// Channel strip activation/selection. +ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; + ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) : QWidget(pParent, wflags) { @@ -77,11 +88,18 @@ QObject::connect(m_ui.ChannelEditPushButton, SIGNAL(clicked()), SLOT(channelEdit())); + QObject::connect(m_ui.FxPushButton, + SIGNAL(clicked()), + SLOT(channelFxEdit())); + + setSelected(false); } ChannelStrip::~ChannelStrip (void) { + setSelected(false); + // Destroy existing channel descriptor. if (m_pChannel) delete m_pChannel; @@ -104,7 +122,7 @@ while (iter.hasNext()) { const QString& sFilename = iter.next().toLocalFile(); if (!sFilename.isEmpty()) { - bAccept = qsamplerChannel::isInstrumentFile(sFilename); + bAccept = Channel::isInstrumentFile(sFilename); break; } } @@ -145,7 +163,7 @@ // Channel strip setup formal initializer. -void ChannelStrip::setup ( qsamplerChannel *pChannel ) +void ChannelStrip::setup ( Channel *pChannel ) { // Destroy any previous channel descriptor; // (remember that once setup we own it!) @@ -165,7 +183,7 @@ // Channel secriptor accessor. -qsamplerChannel *ChannelStrip::channel (void) const +Channel *ChannelStrip::channel (void) const { return m_pChannel; } @@ -201,6 +219,7 @@ pal.setColor(QPalette::Background, Qt::black); } m_ui.ChannelInfoFrame->setPalette(pal); + m_ui.InstrumentNameTextLabel->setPalette(pal); m_ui.StreamVoiceCountTextLabel->setPalette(pal); } @@ -272,6 +291,33 @@ m_pChannel->editChannel(); } +bool ChannelStrip::channelFxEdit (void) +{ + MainForm *pMainForm = MainForm::getInstance(); + if (!pMainForm || !channel()) + return false; + + pMainForm->appendMessages(QObject::tr("channel fx sends...")); + + bool bResult = false; + +#if CONFIG_FXSEND + ChannelFxForm *pChannelFxForm = + new ChannelFxForm(channel(), parentWidget()); + if (pChannelFxForm) { + //pChannelForm->setup(this); + bResult = pChannelFxForm->exec(); + delete pChannelFxForm; + } +#else // CONFIG_FXSEND + QMessageBox::critical(this, + QSAMPLER_TITLE ": " + tr("Unavailable"), + tr("Sorry, QSampler was built without FX send support!\n\n" + "(Make sure you have a recent liblscp when recompiling QSampler)")); +#endif // CONFIG_FXSEND + + return bResult; +} // Channel reset slot. bool ChannelStrip::channelReset (void) @@ -303,10 +349,10 @@ if (m_pChannel->instrumentName().isEmpty()) { if (m_pChannel->instrumentStatus() >= 0) { m_ui.InstrumentNameTextLabel->setText( - ' ' + qsamplerChannel::loadingInstrument()); + ' ' + Channel::loadingInstrument()); } else { m_ui.InstrumentNameTextLabel->setText( - ' ' + qsamplerChannel::noInstrumentName()); + ' ' + Channel::noInstrumentName()); } } else { m_ui.InstrumentNameTextLabel->setText( @@ -365,7 +411,7 @@ // Engine name... if (m_pChannel->engineName().isEmpty()) { m_ui.EngineNameTextLabel->setText( - ' ' + qsamplerChannel::noEngineName()); + ' ' + Channel::noEngineName()); } else { m_ui.EngineNameTextLabel->setText( ' ' + m_pChannel->engineName()); @@ -503,6 +549,37 @@ m_iErrorCount = 0; } + +// Channel strip activation/selection. +void ChannelStrip::setSelected ( bool bSelected ) +{ + if (bSelected) { + if (g_pSelectedStrip == this) + return; + if (g_pSelectedStrip) + g_pSelectedStrip->setSelected(false); + g_pSelectedStrip = this; + } else { + if (g_pSelectedStrip == this) + g_pSelectedStrip = NULL; + } + + QPalette pal; + if (bSelected) { + const QColor& color = pal.midlight().color(); + pal.setColor(QPalette::Background, color.dark(150)); + pal.setColor(QPalette::Foreground, color.light(150)); + } + QWidget::setPalette(pal); +} + + +bool ChannelStrip::isSelected (void) const +{ + return (this == g_pSelectedStrip); +} + + } // namespace QSampler