void Style::drawSliderHandle(const QRect &handle, const QStyleOption *option, QPainter *painter, int step) const { OPT_SUNKEN OPT_ENABLED OPT_FOCUS bool fullHover = config.scroll.fullHover && !config.btn.backLightHover; // shadow QPoint xy = handle.topLeft(); if (step && config.btn.backLightHover) fillWithMask(painter, xy, Colors::mid(FCOLOR(Window), CCOLOR(scroll._, Fg), 6-step, step), lights.slider); if (sunken) xy += QPoint(F(1), 0); painter->drawPixmap(xy, shadows.slider[isEnabled][sunken]); // gradient xy += QPoint(sunken ? F(1) : F(2), F(1)); QColor bc = hasFocus ? FCOLOR(Highlight) : CCOLOR(scroll._, Bg); if (fullHover) bc = Colors::mid(bc, CCOLOR(scroll._, Fg), 6-step, step); const QPixmap &fill = Gradients::pix(bc, masks.slider.height(), Qt::Vertical, isEnabled ? GRAD(scroll) : Gradients::None); fillWithMask(painter, xy, fill, masks.slider); if (!fullHover && isEnabled) { const QColor fc = Colors::mid(bc, hasFocus ? FCOLOR(HighlightedText) : CCOLOR(scroll._, Fg), 6-step, step+3); const QSize d = (masks.slider.size() - masks.notch.size())/2; xy += QPoint(d.width(), d.height()); fillWithMask(painter, xy, fc, masks.notch); } }
void Style::drawHeaderSection(const QStyleOption *option, QPainter *painter, const QWidget*) const { OPT_SUNKEN OPT_HOVER const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option); const bool sorting = header && (header->sortIndicator != QStyleOptionHeader::None); Qt::Orientation o = Qt::Vertical; int s = RECT.height(); if (header && header->orientation == Qt::Vertical) { o = Qt::Horizontal; s = RECT.width(); } QColor c = sorting ? COLOR(config.view.sortingHeader_role[Bg]) : COLOR(config.view.header_role[Bg]); if (Colors::value(c) < 50) { int h,s,v,a; c.getHsv(&h, &s, &v, &a); c.setHsv(h, s, 50, a); } if (appType == GTK) sunken = option->state & State_HasFocus; if (sunken) { const QPixmap &sunk = Gradients::pix(c, s, o, Gradients::Sunken); painter->drawTiledPixmap(RECT, sunk); return; } const Gradients::Type gt = sorting ? config.view.sortingHeaderGradient : config.view.headerGradient; if (hover) c = Colors::mid(c, sorting ? CCOLOR(view.sortingHeader, Fg) : CCOLOR(view.header, Fg),8,1); if (gt == Gradients::None) painter->fillRect(RECT, c); else painter->drawTiledPixmap(RECT, Gradients::pix(c, s, o, gt)); if (o == Qt::Vertical) { if (!header || header->section < QStyleOptionHeader::End) { QRect r = RECT; r.setLeft(r.right() - F(1)); painter->drawTiledPixmap(r, Gradients::pix(CCOLOR(view.header, Bg), s, o, Gradients::Sunken)); } if (Colors::value(CCOLOR(view.header, Bg)) > 90) // not on dark elements - looks just stupid... { SAVE_PEN painter->setPen(Colors::mid(FCOLOR(Base), Qt::black, 6, 1)); painter->drawLine(RECT.bottomLeft(), RECT.bottomRight()); RESTORE_PEN } }
void Style::drawSlider(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { ASSURE_OPTION(slider, Slider); OPT_SUNKEN OPT_ENABLED OPT_HOVER if (isEnabled && slider->subControls & SC_SliderTickmarks) { int ticks = slider->tickPosition; if (ticks != QSlider::NoTicks) { int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval < 1) interval = slider->pageStep; if (interval) { // const int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); const int len = pixelMetric(PM_SliderLength, slider, widget); const int fudge = len / 2; int pos, v = slider->minimum, nextInterval; // Since there is no subrect for tickmarks do a translation here. painter->save(); painter->translate(RECT.x(), RECT.y()); #define DRAW_TICKS(_X1_, _Y1_, _X2_, _Y2_) \ while (v <= slider->maximum) { \ pos = sliderPositionFromValue(slider->minimum, slider->maximum, v, available) + fudge;\ painter->drawLine(_X1_, _Y1_, _X2_, _Y2_);\ nextInterval = v + interval;\ if (nextInterval < v) break;\ v = nextInterval; \ } // skip semicolon painter->setPen(Colors::mid(BGCOLOR, FGCOLOR, 3,1)); if (slider->orientation == Qt::Horizontal) { const int y = RECT.height()/2; if (ticks == QSlider::TicksAbove) { DRAW_TICKS(pos, 0, pos, y); } else if (ticks == QSlider::TicksBelow) { DRAW_TICKS(pos, y, pos, RECT.height()); } else { DRAW_TICKS(pos, RECT.y(), pos, RECT.height()); } } else { const int x = RECT.width()/2; if (ticks == QSlider::TicksAbove) { DRAW_TICKS(0, pos, x, pos); } else if (ticks == QSlider::TicksBelow) { DRAW_TICKS(x, pos, RECT.width(), pos); } else { DRAW_TICKS(0, pos, RECT.width(), pos); } } painter->restore(); } } } QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget); QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget); isEnabled = isEnabled && (slider->maximum > slider->minimum); hover = isEnabled && (appType == GTK || (hover && (slider->activeSubControls & SC_SliderHandle))); sunken = sunken && (slider->activeSubControls & SC_SliderHandle); // const int ground = 0; // groove if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { QStyleOption grooveOpt = *option; grooveOpt.rect = groove; const Groove::Mode gType = config.scroll.groove; if (gType) config.scroll.groove = Groove::Groove; drawScrollBarGroove(&grooveOpt, painter, widget); config.scroll.groove = gType; #if 1 // thermometer, #2 if (slider->minimum > -1 && (slider->maximum - slider->minimum) > 20 && slider->sliderPosition != slider->minimum) { SAVE_PEN; bool hadAntiAlias = painter->testRenderHint(QPainter::Antialiasing); painter->setRenderHint( QPainter::Antialiasing, gType ); painter->setPen(QPen(CCOLOR(scroll._, Fg), gType ? F(3) : F(1), Qt::SolidLine, Qt::RoundCap)); if ( slider->orientation == Qt::Horizontal ) { const int y = groove.center().y() + (gType ? 1 : 0); bool ltr = slider->direction == Qt::LeftToRight; if (slider->upsideDown) ltr = !ltr; const int x2 = ltr ? groove.left() + F(5) : groove.right() - F(5); painter->drawLine(handle.center().x(), y, x2, y); } else { const int x = groove.center().x(); const int y2 = slider->upsideDown ? groove.bottom() - F(5) : groove.top() + F(5); painter->drawLine(x, handle.center().y(), x, y2); } painter->setRenderHint( QPainter::Antialiasing, hadAntiAlias ); RESTORE_PEN; } #endif } // int direction = 0; // if (slider->orientation == Qt::Vertical) // ++direction; // handle ====================================== if (slider->subControls & SC_SliderHandle) { int step = 0; if (sunken) step = 6; else if (isEnabled) { const Animator::ComplexInfo *info = Animator::HoverComplex::info(widget, slider->activeSubControls & SC_SliderHandle); if (info && ( info->fades[Animator::In] & SC_SliderHandle || info->fades[Animator::Out] & SC_SliderHandle )) step = info->step(SC_SliderHandle); if (hover && !step) step = 6; } drawSliderHandle(handle, option, painter, step); } }