MCPcopy Create free account
hub / github.com/LMMS/lmms / paintEvent

Method paintEvent

src/gui/AutomationPatternView.cpp:233–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232
233void AutomationPatternView::paintEvent( QPaintEvent * )
234{
235 QPainter painter( this );
236
237 if( !needsUpdate() )
238 {
239 painter.drawPixmap( 0, 0, m_paintPixmap );
240 return;
241 }
242
243 setNeedsUpdate( false );
244
245 m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size()
246 ? QPixmap( size() ) : m_paintPixmap;
247
248 QPainter p( &m_paintPixmap );
249
250 QLinearGradient lingrad( 0, 0, 0, height() );
251 QColor c;
252 bool muted = m_pat->getTrack()->isMuted() || m_pat->isMuted();
253 bool current = gui->automationEditor()->currentPattern() == m_pat;
254
255 // state: selected, muted, normal
256 c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor()
257 : painter.background().color() );
258
259 lingrad.setColorAt( 1, c.darker( 300 ) );
260 lingrad.setColorAt( 0, c );
261
262 // paint a black rectangle under the pattern to prevent glitches with transparent backgrounds
263 p.fillRect( rect(), QColor( 0, 0, 0 ) );
264
265 if( gradient() )
266 {
267 p.fillRect( rect(), lingrad );
268 }
269 else
270 {
271 p.fillRect( rect(), c );
272 }
273
274 const float ppt = fixedTCOs() ?
275 ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
276 / (float) m_pat->timeMapLength().getTact() :
277 pixelsPerTact();
278
279 const int x_base = TCO_BORDER_WIDTH;
280
281 const float min = m_pat->firstObject()->minValue<float>();
282 const float max = m_pat->firstObject()->maxValue<float>();
283
284 const float y_scale = max - min;
285 const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale;
286 const float ppTick = ppt / MidiTime::ticksPerTact();
287
288 p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH );
289 p.scale( 1.0f, -h );
290

Callers

nothing calls this directly

Calls 15

sizeFunction · 0.85
fixedTCOsFunction · 0.85
ticksPerTactFunction · 0.85
getIconPixmapFunction · 0.85
isNullMethod · 0.80
getTactMethod · 0.80
timeMapLengthMethod · 0.80
firstObjectMethod · 0.80
keyMethod · 0.80
valuesAfterMethod · 0.80
drawLineMethod · 0.80
rightMethod · 0.80

Tested by

no test coverage detected