예제 #1
0
void CAlphaSetup::paint()
{
    int c_rad_mid = RADIUS_MID;
    frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, c_rad_mid, CORNER_TOP);
    g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
    frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, c_rad_mid, CORNER_BOTTOM);

    paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2RED, true );
    paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2     , false);
}
예제 #2
0
/*!\reimp
*/
void QSlider::paintEvent( QPaintEvent * )
{

    QPainter p( this );
    const QRect & sliderR = sliderRect();
    const QColorGroup & g = colorGroup();
    int mid = thickness()/2;
    if ( ticks & Above )
	mid += style().sliderLength() / 8;
    if ( ticks & Below )
	mid -= style().sliderLength() / 8;
    if ( orient == Horizontal ) {
	style().drawSliderGroove(&p, 0, tickOffset, width(), thickness(),
				     g, mid, Horizontal );
// 	    p.fillRect( 0, 0, width(), tickOffset, g.background() );
// 	    p.fillRect( 0, tickOffset + thickness(),
// 			width(), height()/*###*/, g.background() );
	erase( 0, 0, width(), tickOffset );
	erase( 0, tickOffset + thickness(), width(), height() );
    }
    else {
	style().drawSliderGroove( &p, tickOffset, 0, thickness(), height(),
				      g, mid, Vertical );
// 	    p.fillRect( 0, 0,  tickOffset, height(), g.background() );
// 	    p.fillRect( tickOffset + thickness(), 0,
// 			width()/*###*/, height(), g.background() );
	erase( 0, 0,  tickOffset, height() );
	erase( tickOffset + thickness(), 0, width()/*###*/, height() );
    }

    int interval = tickInt;
    if ( interval <= 0 ) {
	interval = lineStep();
	if ( positionFromValue( interval ) - positionFromValue( 0 ) < 3 )
	    interval = pageStep();
    }
    if ( ticks & Above )
	drawTicks( &p, g, 0, tickOffset - 2, interval );

    if ( ticks & Below ) {
	int avail = (orient == Horizontal) ? height() : width();
	avail -= tickOffset + thickness();
	drawTicks( &p, g, tickOffset + thickness() + 1, avail - 2, interval );
    }
    if ( hasFocus() ) {
	QRect r;
	if ( orient == Horizontal )
	    r.setRect( 0, tickOffset-1, width(), thickness()+2 );
	else
	    r.setRect( tickOffset-1, 0, thickness()+2, height() );
	r = r.intersect( rect() );
	if (style() == MotifStyle)
	    style().drawFocusRect(&p, QRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2), g);
	else
	    style().drawFocusRect(&p, r, g);
    }
    paintSlider( &p, g, sliderR );

}
예제 #3
0
void
QvisOpacitySlider::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    int mid = thickness()/2 + sliderLength() / 8;

    // Draw the gradient pixmap.
    if(gradientImage == 0)
        createGradientImage();
    p.drawImage(0, tickOffset, *gradientImage);

    // Draw the groove on which the slider slides.    
    drawSliderGroove(&p, 0, tickOffset, imageWidth(), thickness(), mid);

    // Figure out the interval between the tick marks.
    int interval = tickInt;
    if(interval <= 0)
    {
        interval = singleStep();
        if(positionFromValue(interval) - positionFromValue(0) < 3)
            interval = pageStep();
    }

    // Draw the tick marks.
    p.fillRect(0, 0, imageWidth(), tickOffset,
               palette().brush(QPalette::Background));
    p.fillRect(0, tickOffset + thickness(), imageWidth(), height(),
               palette().brush(QPalette::Background));
    drawTicks(&p, palette(), 0, tickOffset - 2, interval);

    // Draw the slider
    paintSlider(&p, palette(), sliderRect());

    // Draw the value text.
    paintValueText(&p, palette(), imageWidth(), height());

    // If this widget has focus, draw the focus rectangle.
    if(hasFocus())
    {
        QStyleOptionFocusRect so;
        so.initFrom(this);
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, 
                               &so,
                               &p);
    }
}
예제 #4
0
int CAlphaSetup::exec(CMenuTarget* parent, const std::string &)
{
    neutrino_msg_t      msg;
    neutrino_msg_data_t data;

    int res = menu_return::RETURN_REPAINT;
    if (parent)
    {
        parent->hide();
    }
    unsigned char alpha1_alt= *alpha1;
    unsigned char alpha2_alt= *alpha2;

    paint();

    int selected = 0;
    int max = 1;

    unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);

    bool loop=true;
    while (loop)
    {
        g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);

        if ( msg <= CRCInput::RC_MaxRC )
        {
            timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
        }

        switch (msg & ~CRCInput::RC_Repeat)
        {
        case CRCInput::RC_down:
        {
            if(selected<max)
            {
                paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2     , false);
                paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2     , false);

                selected++;

                switch (selected)
                {
                case 0:
                    paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2RED, true );
                    break;
                case 1:
                    paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2GREEN, true );
                    break;
                }
            }
            break;
        }
        case CRCInput::RC_up:
        {
            if (selected > 0)
            {
                paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2     , false);
                paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2     , false);

                selected--;

                switch (selected)
                {
                case 0:
                    paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2RED, true );
                    break;
                case 1:
                    paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2GREEN, true );
                    break;
                }
            }
            break;
        }
        case CRCInput::RC_right:
        {
            switch (selected)
            {
            case 0:
                if (*alpha1<8)
                {
                    *alpha1+=1;
                    paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2RED, true );
                    frameBuffer->setBlendLevel(*alpha1, *alpha2);
                }
                break;
            case 1:
                if (*alpha2<8)
                {
                    *alpha2+=1;
                    paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2GREEN, true );
                    frameBuffer->setBlendLevel(*alpha1, *alpha2);
                }
                break;
            }
            break;
        }
        case CRCInput::RC_left:
        {
            switch (selected)
            {
            case 0:
                if (*alpha1>=1)
                {
                    *alpha1-=1;
                    paintSlider(x + 10, y + hheight          , alpha1, LOCALE_GTXALPHA_ALPHA1, NEUTRINO_ICON_VOLUMESLIDER2RED, true );
                    frameBuffer->setBlendLevel(*alpha1, *alpha2);
                }
                break;
            case 1:
                if (*alpha2>=1)
                {
                    *alpha2-=1;
                    paintSlider(x + 10, y + hheight + mheight, alpha2, LOCALE_GTXALPHA_ALPHA2, NEUTRINO_ICON_VOLUMESLIDER2GREEN, true );
                    frameBuffer->setBlendLevel(*alpha1, *alpha2);
                }
                break;
            }
            break;
        }
        case CRCInput::RC_home:
            if ((*alpha1 != alpha1_alt) || (*alpha2 != alpha2_alt))
            {
                if (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)
                {
                    break;
                }
            }

            // sonst abbruch...
            *alpha1 = alpha1_alt;
            *alpha2 = alpha2_alt;
            frameBuffer->setBlendLevel(*alpha1, *alpha2);
            loop = false;
            break;
        case CRCInput::RC_ok:
            if (msg != CRCInput::RC_ok) // ignore repeat
                break;
        /* else fallthrough */
        case CRCInput::RC_timeout:
            loop = false;
            break;

        default:
            if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
            {
                loop = false;
                res = menu_return::RETURN_EXIT_ALL;
            }
        }
    }

    hide();

    return res;
}