From 150bf97172421048de08289d676addc5587c6e2e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 21 Aug 2008 20:15:32 +0000 Subject: [PATCH] mouseover and mousepressed effects by choosing different svg elements svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=850598 --- private/style.cpp | 55 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/private/style.cpp b/private/style.cpp index 7c6e503a2..c8e5e6dc3 100644 --- a/private/style.cpp +++ b/private/style.cpp @@ -70,39 +70,68 @@ void Style::drawComplexControl(ComplexControl control, painter->save(); painter->setRenderHint(QPainter::Antialiasing); + const bool sunken =option->state & State_Sunken; const QStyleOptionSlider *scrollOption = qstyleoption_cast(option); + QString prefix; + + if (option->state & State_MouseOver) { + prefix= "mouseover-"; + } QRect subLine; QRect addLine; if (scrollOption && scrollOption->orientation == Qt::Horizontal) { - subLine = d->scrollbar->elementRect("arrow-left").toRect(); - addLine = d->scrollbar->elementRect("arrow-right").toRect(); + subLine = d->scrollbar->elementRect(prefix + "arrow-left").toRect(); + addLine = d->scrollbar->elementRect(prefix + "arrow-right").toRect(); } else { - subLine = d->scrollbar->elementRect("arrow-up").toRect(); - addLine = d->scrollbar->elementRect("arrow-down").toRect(); + subLine = d->scrollbar->elementRect(prefix + "arrow-up").toRect(); + addLine = d->scrollbar->elementRect(prefix + "arrow-down").toRect(); } - + subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center()); addLine.moveCenter(subControlRect(control, option, SC_ScrollBarAddLine, widget).center()); - + const QRect slider = subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0); d->scrollbar->setElementPrefix("background"); d->scrollbar->resizePanel(option->rect.size()); d->scrollbar->paintPanel(painter); - - d->scrollbar->setElementPrefix("slider"); + + if (sunken && scrollOption->activeSubControls & SC_ScrollBarSlider) { + d->scrollbar->setElementPrefix("sunken-slider"); + } else { + d->scrollbar->setElementPrefix(prefix + "slider"); + } + d->scrollbar->resizePanel(slider.size()); d->scrollbar->paintPanel(painter, slider.topLeft()); if (scrollOption && scrollOption->orientation == Qt::Horizontal) { - d->scrollbar->paint(painter, addLine.topLeft(), "arrow-left"); - d->scrollbar->paint(painter, subLine.topLeft(), "arrow-right"); + if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) { + d->scrollbar->paint(painter, addLine.topLeft(), "sunken-arrow-right"); + } else { + d->scrollbar->paint(painter, addLine.topLeft(), prefix + "arrow-right"); + } + + if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) { + d->scrollbar->paint(painter, subLine.topLeft(), "sunken-arrow-left"); + } else { + d->scrollbar->paint(painter, subLine.topLeft(), prefix + "arrow-left"); + } } else { - d->scrollbar->paint(painter, addLine.topLeft(), "arrow-down"); - d->scrollbar->paint(painter, subLine.topLeft(), "arrow-up"); + if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) { + d->scrollbar->paint(painter, addLine.topLeft(), "sunken-arrow-down"); + } else { + d->scrollbar->paint(painter, addLine.topLeft(), prefix + "arrow-down"); + } + + if (sunken && scrollOption->activeSubControls & SC_ScrollBarSubLine) { + d->scrollbar->paint(painter, subLine.topLeft(), "sunken-arrow-up"); + } else { + d->scrollbar->paint(painter, subLine.topLeft(), prefix + "arrow-up"); + } } - + painter->restore(); }