88 int selected,
const QColor & lineColor,
const QColor & handleColor,
const QColor & selectedColor)
90 if (envelope.empty()) {
94 for (
int i = 0; i < static_cast<int>(envelope.size()) -1; i++){
95 painter.setPen( QPen(lineColor, 1 , Qt::SolidLine) );
96 painter.drawLine( envelope[i].frame, envelope[i].value, envelope[i + 1].frame, envelope[i +1].value );
97 if ( i == selected ) {
98 painter.setBrush( selectedColor );
100 painter.setBrush( handleColor );
102 painter.drawEllipse ( envelope[i].frame - 6/2, envelope[i].value - 6/2, 6, 6 );
106 if ( 0 == selected ) {
107 painter.setBrush( selectedColor );
109 painter.setBrush( handleColor );
111 painter.drawRect ( envelope[0].frame - 12/2, envelope[0].value - 6/2, 12, 6 );
113 if ( envelope.size() - 1 == selected ) {
114 painter.setBrush( selectedColor );
116 painter.setBrush( handleColor );
118 painter.drawRect ( envelope[envelope.size() -1].frame - 12/2, envelope[envelope.size() -1].value - 6/2, 12, 6 );
123 QPainter painter(
this );
127 painter.setRenderHint( QPainter::Antialiasing );
128 painter.drawPixmap( ev->rect(),
m_Background, ev->rect() );
129 painter.setPen( QColor( 252, 142, 73 ));
131 int VCenter = height() / 2;
132 int LCenter = VCenter -4;
133 int RCenter = VCenter +4;
135 for (
int x = 0; x < width() - 1; x++ ) {
139 painter.setPen( QColor( 116, 186, 255 ));
140 for (
int x = 0; x < width() - 1; x++ ) {
145 font.setWeight( QFont::Bold );
146 painter.setFont( font );
148 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
149 painter.setPen( QPen( QColor( 255, 255, 255 ), 1, Qt::SolidLine ) );
152 QColor volumeLineColor = QColor( 255, 255, 255, 200);
153 QColor volumeHandleColor = QColor( 99, 160, 233);
154 QColor panLineColor = QColor( 249, 235, 116, 200 );
155 QColor panHandleColor = QColor( 77, 189, 55 );
156 QColor selectedtHandleColor = QColor( 255, 100, 90 );
160 volumeLineColor, volumeHandleColor, selectedtHandleColor);
163 panLineColor, panHandleColor, selectedtHandleColor);
165 painter.setPen( QPen( QColor( 255, 255, 255 ), 1, Qt::DotLine ) );
166 painter.drawLine( 0, LCenter,
UI_WIDTH, LCenter );
167 painter.setPen( QPen( QColor( 255, 255, 255 ), 1, Qt::DotLine ) );
168 painter.drawLine( 0, RCenter,
UI_WIDTH, RCenter );
172 painter.drawText(
m_nX +5,
m_nY, 60, 20, Qt::AlignLeft, QString(
m_sInfo ) );
176 painter.drawText(
m_nX - 65,
m_nY, 60, 20, Qt::AlignRight, QString(
m_sInfo ) );
182 painter.drawText(
m_nX +5,
m_nY -20, 60, 20, Qt::AlignLeft, QString(
m_sInfo ) );
186 painter.drawText(
m_nX - 65,
m_nY -20, 60, 20, Qt::AlignRight, QString(
m_sInfo ) );
213 if ( pLayer && pLayer->get_sample() ) {
215 int nSampleLength = pLayer->get_sample()->get_frames();
216 float nScaleFactor = nSampleLength / width();
218 float fGain = (height() - 8) / 2.0 * pLayer->get_gain();
220 auto pSampleDatal = pLayer->get_sample()->get_data_l();
221 auto pSampleDatar = pLayer->get_sample()->get_data_r();
225 for (
int i = 0; i < width(); ++i ){
228 for (
int j = 0; j < nScaleFactor; ++j ) {
229 if ( j < nSampleLength ) {
230 if ( pSampleDatal[ nSamplePos ] < 0 ){
231 int newVal =
static_cast<int>( pSampleDatal[ nSamplePos ] * -fGain );
235 int newVal =
static_cast<int>( pSampleDatal[ nSamplePos ] * fGain );
238 if ( pSampleDatar[ nSamplePos ] > 0 ){
239 int newVal =
static_cast<int>( pSampleDatar[ nSamplePos ] * -fGain );
243 int newVal =
static_cast<int>( pSampleDatar[ nSamplePos ] * fGain );
static void paintEnvelope(Sample::VelocityEnvelope &envelope, QPainter &painter, int selected, const QColor &lineColor, const QColor &handleColor, const QColor &selectedColor)