int TransitionMngr::Private::transitionMosaic(bool aInit) { int dim = 10; // Size of a cell (dim x dim) int margin = dim + (int)(dim / 4); if (aInit) { eff_i = 30; // giri totaly eff_pixelMatrix = new bool*[eff_outSize.width()]; for (int x = 0 ; x < eff_outSize.width() ; ++x) { eff_pixelMatrix[x] = new bool[eff_outSize.height()]; for (int y = 0 ; y < eff_outSize.height() ; ++y) { eff_pixelMatrix[x][y] = false; } } } if (eff_i <= 0) { eff_curFrame = eff_outImage; return -1; } int w = eff_outSize.width(); int h = eff_outSize.height(); QPainter bufferPainter(&eff_curFrame); for (int x = 0 ; x < w ; x += (qrand() % margin) + dim) { for (int y = 0 ; y < h ; y += (qrand() % margin) + dim) { if (eff_pixelMatrix[x][y] == true) { if (y != 0) y--; continue; } bufferPainter.fillRect(x, y, dim, dim, QBrush(eff_outImage)); for (int i = 0 ; i < dim && (x + i) < w ; ++i) { for (int j = 0 ; j < dim && (y + j) < h ; ++j) { eff_pixelMatrix[x+i][y+j] = true; } } } } bufferPainter.end(); eff_i--; return 20; }
/** * Draw custom background colours & round corners */ void OSUpdaterPopup::paintEvent( QPaintEvent *e ) { QPainter bufferPainter(this); bufferPainter.setPen(QPen(QColorGroup::Background,2,SolidLine)); bufferPainter.setBrush( colorGroup().brush( QColorGroup::Background ) ); bufferPainter.setPen(QPen(QColorGroup::Background,3,SolidLine)); //draw the line under the title bufferPainter.drawLine(0,_title->y() + _title->height() + 3,this->width(),_title->y() + _title->height() + 3); bufferPainter.setPen(QPen(QColorGroup::Background,3,SolidLine)); //draw black border bufferPainter.drawRoundRect(0,0,width(),height(),1600/width(),1600/height()); bufferPainter.setPen(QColor(55,97,155)); bufferPainter.setBrush(QColor(55,97,155)); bufferPainter.setBackgroundColor(QColor(55,97,155)); //set title colour to blue _title->setPaletteBackgroundColor(QColor(55,97,155)); _title->setPaletteForegroundColor(QColor(255,255,255)); _closeButton->setPalette(QPalette(QColor(55,97,155),QColor(55,97,155))); //draw blue background behind title bufferPainter.drawRect(0,0,width(),_title->y() + _title->height()+3); //do rounded corners //create mask the size of the popup _mask.resize(width(), height()); _mask.fill(Qt::black); QPainter maskPainter(&_mask); maskPainter.setBrush(Qt::white); maskPainter.setPen(Qt::white); //draw the rounded corners on the mask maskPainter.drawRoundRect(_mask.rect(), 1600 / _mask.rect().width(), 1600 / _mask.rect().height()); //apply the mask to this popup. setMask(_mask); }
int TransitionMngr::Private::transitionFade(bool aInit) { if (aInit) { eff_fd = 1.0; } QPainter bufferPainter(&eff_curFrame); bufferPainter.drawImage(0, 0, eff_outImage); bufferPainter.setOpacity(eff_fd); bufferPainter.drawImage(0, 0, eff_inImage); bufferPainter.setOpacity(1.0); bufferPainter.end(); eff_fd = eff_fd - 0.1; if (eff_fd > 0.0) { return 15; } eff_curFrame = eff_outImage; return -1; }
int TransitionMngr::Private::transitionMeltdown(bool aInit) { int i; if (aInit) { delete [] eff_intArray; eff_w = eff_outSize.width(); eff_h = eff_outSize.height(); eff_dx = 4; eff_dy = 16; eff_ix = eff_w / eff_dx; eff_intArray = new int[eff_ix]; for (i = eff_ix - 1 ; i >= 0 ; --i) eff_intArray[i] = 0; } eff_pdone = true; int y, x; QPainter bufferPainter(&eff_curFrame); for (i = 0, x = 0 ; i < eff_ix ; ++i, x += eff_dx) { y = eff_intArray[i]; if (y >= eff_h) continue; eff_pdone = false; if ((qrand() & 15) < 6) continue; //bufferPainter.drawImage(x, y + eff_dy, eff_curFrame, x, y, eff_dx, eff_h - y - eff_dy); bufferPainter.drawImage(x, y, eff_outImage, x, y, eff_dx, eff_dy); eff_intArray[i] += eff_dy; } bufferPainter.end(); if (eff_pdone) { delete [] eff_intArray; eff_intArray = nullptr; eff_curFrame = eff_outImage; return -1; } return 15; }
void OSDWidget::renderOSDText( const QString &text) { static QBitmap mask; // Set a sensible maximum size, don't cover the whole desktop or cross the screen //Actually unused but it definitly should //QSize max = QApplication::desktop() ->screen( m_screen ) ->size() - QSize( MARGIN*2 + 20, 100 ); if(this->m_srt!=0){ delete m_srt; } this->m_srt=new QSimpleRichText(text,this->font(),this->m_context); // The title cannnot be taller than one line // AlignAuto = align Arabic to the right, etc. int w=this->m_srt->widthUsed(); int h=this->m_srt->height(); osdBuffer.resize(w,h); mask.resize(w,h); // Start painting! QPainter bufferPainter( &osdBuffer ); QPainter maskPainter( &mask ); // Draw backing rectangle //bufferPainter.save(); bufferPainter.setPen( Qt::black ); bufferPainter.setBrush( backgroundColor() ); bufferPainter.drawRoundRect( 0,0,w,h, 1500 /w, 1500/h); //bufferPainter.restore(); this->m_srt->draw(&bufferPainter,0,0,QRect(),this->colorGroup()); // Masking for transparency mask.fill( Qt::black ); maskPainter.setBrush( Qt::white ); maskPainter.drawRoundRect(0,0,w,h, 1500/w,1500/h); setMask( mask ); //do last to reduce noticeable change when showing multiple OSDs in succession reposition(QSize(w,h)); m_currentText = text; m_dirty = false; if(this->m_linking&&this==this->mouseGrabber()){ this->releaseMouse(); this->m_linking=false; } update(); }
int TransitionMngr::Private::transitionBlurOut(bool aInit) { if (aInit) { eff_fd = 1.0; } QPainter bufferPainter(&eff_curFrame); bufferPainter.drawImage(0, 0, fastBlur(eff_inImage, eff_fd)); bufferPainter.end(); eff_fd = eff_fd + 1.0; if (eff_fd <= 25.0) { return 15; } eff_curFrame = eff_outImage; return -1; }
int TransitionMngr::Private::transitionCubism(bool aInit) { if (aInit) { eff_alpha = M_PI * 2; eff_w = eff_outSize.width(); eff_h = eff_outSize.height(); eff_i = 150; } if (eff_i <= 0) { eff_curFrame = eff_outImage; return -1; } QPainterPath painterPath; QPainter bufferPainter(&eff_curFrame); eff_x = qrand() % eff_w; eff_y = qrand() % eff_h; int r = (qrand() % 100) + 100; eff_px = eff_x - r; eff_py = eff_y - r; eff_psx = r; eff_psy = r; QMatrix matrix; matrix.rotate((qrand() % 20) - 10); QRect rect(eff_px, eff_py, eff_psx, eff_psy); bufferPainter.setMatrix(matrix); bufferPainter.fillRect(rect, QBrush(eff_outImage)); bufferPainter.end(); eff_i--; return 10; }
int TransitionMngr::Private::transitionBlobs(bool aInit) { int r; if (aInit) { eff_alpha = M_PI * 2; eff_w = eff_outSize.width(); eff_h = eff_outSize.height(); eff_i = 150; } if (eff_i <= 0) { eff_curFrame = eff_outImage; return -1; } eff_x = qrand() % eff_w; eff_y = qrand() % eff_h; r = (qrand() % 200) + 50; eff_px = eff_x - r; eff_py = eff_y - r; eff_psx = r; eff_psy = r; QPainterPath painterPath; painterPath.addEllipse(eff_px, eff_py, eff_psx, eff_psy); QPainter bufferPainter(&eff_curFrame); bufferPainter.fillPath(painterPath, QBrush(eff_outImage)); bufferPainter.end(); eff_i--; return 10; }
void OSDWidget::renderOSDText( const QString &txt ) { // Escaped text QString text = Konversation::removeIrcMarkup(txt); static QBitmap mask; //This is various spacings and margins, based on the font to look "just right" const uint METRIC = fontMetrics().width( 'x' ); // Set a sensible maximum size, don't cover the whole desktop or cross the screen QSize max = QApplication::desktop()->screen( m_screen )->size() - QSize( MARGIN*2 + METRIC*2, 100 ); QFont titleFont( "Arial", 12, QFont::Bold ); QFontMetrics titleFm( titleFont ); // The title cannnot be taller than one line // AlignAuto = align Arabic to the right, etc. QRect titleRect = titleFm.boundingRect( 0, 0, max.width() - METRIC, titleFm.height(), AlignAuto, m_appName ); // The osd cannot be larger than the screen QRect textRect = fontMetrics().boundingRect( 0, 0, max.width(), max.height(), AlignAuto | WordBreak, text ); if ( textRect.width() < titleRect.width() ) textRect.setWidth( titleRect.width() ); //this should still be within the screen bounds textRect.addCoords( 0, 0, METRIC*2, titleRect.height() + METRIC ); osdBuffer.resize( textRect.size() ); mask.resize( textRect.size() ); // Start painting! QPainter bufferPainter( &osdBuffer ); QPainter maskPainter( &mask ); // Draw backing rectangle const uint xround = (METRIC * 200) / textRect.width(); const uint yround = (METRIC * 200) / textRect.height(); bufferPainter.setPen( Qt::black ); bufferPainter.setBrush( backgroundColor() ); bufferPainter.drawRoundRect( textRect, xround, yround ); bufferPainter.setFont( font() ); const uint w = textRect.width() - 1; const uint h = textRect.height() - 1; // Draw the text shadow if ( m_shadow ) { bufferPainter.setPen( backgroundColor().dark( 175 ) ); bufferPainter.drawText( METRIC + 3, (METRIC/2) + titleFm.height() + 1, w, h, AlignLeft | WordBreak, text ); } // Draw the text bufferPainter.setPen( foregroundColor() ); bufferPainter.drawText( METRIC, (METRIC/2) + titleFm.height() - 1, w, h, AlignLeft | WordBreak, text ); // Draw the title text bufferPainter.setFont( titleFont ); bufferPainter.drawText( METRIC * 2, (METRIC/2), w, h, AlignLeft, m_appName ); // Masking for transparency mask.fill( Qt::black ); maskPainter.setBrush( Qt::white ); maskPainter.drawRoundRect( textRect, xround, yround ); setMask( mask ); //do last to reduce noticeable change when showing multiple OSDs in succession reposition( textRect.size() ); m_currentText = text; m_dirty = false; update(); }
void KalziumTip::displayInternal() { if (!m_richText) return; // determine text rectangel sizes QRect textRect(0,0,0,0); textRect.setWidth(m_richText->widthUsed()); textRect.setHeight(m_richText->height()); //moves the rect textRect.moveBy(-textRect.left(), -textRect.top()); // add the new coordinates textRect.addCoords(0,0,2,2); int margin = KDialog::marginHint(); int height = QMAX(m_icon.height(), textRect.height()) + 2 * margin; int textX = 2 + m_icon.width() + 2 * margin; int width = textX + textRect.width() + margin; int textY = (height - textRect.height()) / 2; //resize pixmap, mask and widget m_mask.resize(width, height); m_pixmap.resize(width, height); resize(width, height); // create and set transparency mask switch(m_maskEffect) { case Plain: plainMask(); break; case Dissolve: dissolveMask(); break; } // draw background QPainter bufferPainter(&m_pixmap); bufferPainter.setPen(Qt::black); bufferPainter.setBrush(backgroundColor()); bufferPainter.drawRoundRect(0, 0, width, height, 1600 / width, 1600 / height); // draw icon if present if (!m_icon.isNull()) { bufferPainter.drawPixmap(margin, margin, m_icon, 0, 0, m_icon.width(), m_icon.height()); } // draw text shadow QColorGroup cg = colorGroup(); cg.setColor(QColorGroup::Text, cg.background().dark(115)); int shadowOffset = QApplication::reverseLayout() ? -1 : 1; m_richText->draw(&bufferPainter, 5 + textX + shadowOffset, textY + 1, QRect(), cg); // draw text cg = colorGroup(); m_richText->draw(&bufferPainter, 5 + textX, textY, rect(), cg); }
void KickerTip::displayInternal() { // we need to check for m_tippingFor here as well as m_richText // since if one is really persistant and moves the mouse around very fast // you can trigger a situation where m_tippingFor gets reset to 0 but // before display() is called! if (!m_tippingFor || !m_richText) { return; } // determine text rectangle QRect textRect(0, 0, 0, 0); if (KickerSettings::mouseOversShowText()) { textRect.setWidth(m_richText->widthUsed()); textRect.setHeight(m_richText->height()); } int margin = KDialog::marginHint(); int height = QMAX(m_icon.height(), textRect.height()) + 2 * margin; int textX = m_icon.isNull() ? margin : 2 + m_icon.width() + 2 * margin; int width = textX + textRect.width() + margin; int textY = (height - textRect.height()) / 2; // resize pixmap, mask and widget bool firstTime = m_dissolveSize == 24; if (firstTime) { m_mask.resize(width, height); m_pixmap.resize(width, height); resize(width, height); if (isVisible()) { // we've already been shown before, but we may grow larger. // in the case of Up or Right displaying tips, this growth can // result in the tip occluding the panel and causing it to redraw // once we return back to display() causing horrid flicker move(KickerLib::popupPosition(m_direction, this, m_tippingFor)); } } // create and set transparency mask switch(m_maskEffect) { case Plain: plainMask(); break; case Dissolve: dissolveMask(); break; } // draw background QPainter bufferPainter(&m_pixmap); bufferPainter.setPen(Qt::black); bufferPainter.setBrush(colorGroup().background()); bufferPainter.drawRoundRect(0, 0, width, height, 1600 / width, 1600 / height); // draw icon if present if (!m_icon.isNull()) { bufferPainter.drawPixmap(margin, margin, m_icon, 0, 0, m_icon.width(), m_icon.height()); } if (KickerSettings::mouseOversShowText()) { // draw text shadow QColorGroup cg = colorGroup(); cg.setColor(QColorGroup::Text, cg.background().dark(115)); int shadowOffset = QApplication::reverseLayout() ? -1 : 1; m_richText->draw(&bufferPainter, 5 + textX + shadowOffset, textY + 1, QRect(), cg); // draw text cg = colorGroup(); m_richText->draw(&bufferPainter, 5 + textX, textY, rect(), cg); } }