void HudItemButton::onDraw(Renderer2D &out) const { HudButton::onDraw(out); FRect rect = this->rect(); if(!m_entry.item.isDummy()) { FRect uv_rect; auto texture = m_entry.item.guiImage(true, uv_rect); float2 size(texture->width() * uv_rect.width(), texture->height() * uv_rect.height()); float2 pos = (float2)(int2)(rect.center() - size / 2); out.addFilledRect(FRect(pos, pos + size), texture); if(m_entry.count > 1) m_font->draw(out, rect, {textColor(), textShadowColor(), HAlign::right}, format("%", m_entry.count)); if(isDropping()) m_font->draw(out, rect, {textColor(true), textShadowColor(), HAlign::left, VAlign::bottom}, format("-%", dropCount())); } }
void BBTCOView::paintEvent( QPaintEvent * ) { QPainter painter( this ); if( !needsUpdate() ) { painter.drawPixmap( 0, 0, m_paintPixmap ); return; } setNeedsUpdate( false ); m_paintPixmap = m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ? QPixmap( size() ) : m_paintPixmap; QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; bool muted = m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted(); // state: selected, muted, default, user selected c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor() : ( m_bbTCO->m_useStyleColor ? painter.background().color() : m_bbTCO->colorObj() ) ); lingrad.setColorAt( 0, c.light( 130 ) ); lingrad.setColorAt( 1, c.light( 70 ) ); if( gradient() ) { p.fillRect( rect(), lingrad ); } else { p.fillRect( rect(), c ); } // bar lines const int lineSize = 3; p.setPen( c.darker( 200 ) ); tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() ); if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 ) { for( int x = static_cast<int>( t * pixelsPerTact() ); x < width() - 2; x += static_cast<int>( t * pixelsPerTact() ) ) { p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize ); p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ), x, rect().bottom() - TCO_BORDER_WIDTH ); } } // pattern name p.setRenderHint( QPainter::TextAntialiasing ); if( m_staticTextName.text() != m_bbTCO->name() ) { m_staticTextName.setText( m_bbTCO->name() ); } QFont font; font.setHintingPreference( QFont::PreferFullHinting ); font.setPointSize( 8 ); p.setFont( font ); const int textTop = TCO_BORDER_WIDTH + 1; const int textLeft = TCO_BORDER_WIDTH + 1; p.setPen( textShadowColor() ); p.drawStaticText( textLeft + 1, textTop + 1, m_staticTextName ); p.setPen( textColor() ); p.drawStaticText( textLeft, textTop, m_staticTextName ); // inner border p.setPen( c.lighter( 130 ) ); p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH, rect().bottom() - TCO_BORDER_WIDTH ); // outer border p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); // draw the 'muted' pixmap only if the pattern was manualy muted if( m_bbTCO->isMuted() ) { const int spacing = TCO_BORDER_WIDTH; const int size = 14; p.drawPixmap( spacing, height() - ( size + spacing ), embed::getIconPixmap( "muted", size, size ) ); } p.end(); painter.drawPixmap( 0, 0, m_paintPixmap ); }