Title: [110730] trunk/Source/WebCore
Revision
110730
Author
pierre.ro...@gmail.com
Date
2012-03-14 12:45:31 -0700 (Wed, 14 Mar 2012)

Log Message

[Qt] Add support for vertical sliders in mobile theme
https://bugs.webkit.org/show_bug.cgi?id=80179

This makes sliders using the "slider-vertical" appearance more sensible.

Reviewed by Simon Hausmann.

No new tests, since the mobile theme still isn't used in layout tests.

* platform/qt/RenderThemeQtMobile.cpp:
(WebCore):
(WebCore::StylePainterMobile::drawProgress):
(WebCore::RenderThemeQtMobile::paintSliderTrack):
* platform/qt/RenderThemeQtMobile.h:
(StylePainterMobile):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110729 => 110730)


--- trunk/Source/WebCore/ChangeLog	2012-03-14 19:30:54 UTC (rev 110729)
+++ trunk/Source/WebCore/ChangeLog	2012-03-14 19:45:31 UTC (rev 110730)
@@ -1,3 +1,21 @@
+2012-03-14  Pierre Rossi  <pierre.ro...@gmail.com>
+
+        [Qt] Add support for vertical sliders in mobile theme
+        https://bugs.webkit.org/show_bug.cgi?id=80179
+
+        This makes sliders using the "slider-vertical" appearance more sensible.
+
+        Reviewed by Simon Hausmann.
+
+        No new tests, since the mobile theme still isn't used in layout tests.
+
+        * platform/qt/RenderThemeQtMobile.cpp:
+        (WebCore):
+        (WebCore::StylePainterMobile::drawProgress):
+        (WebCore::RenderThemeQtMobile::paintSliderTrack):
+        * platform/qt/RenderThemeQtMobile.h:
+        (StylePainterMobile):
+
 2012-03-14  Jer Noble  <jer.no...@apple.com>
 
         WebProcess spins beneath [QTMovie movieFileTypes:]

Modified: trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp (110729 => 110730)


--- trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp	2012-03-14 19:30:54 UTC (rev 110729)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp	2012-03-14 19:45:31 UTC (rev 110730)
@@ -56,7 +56,7 @@
 static const int frameWidth = 2;
 static const int checkBoxWidth = 21;
 static const int radioWidth = 21;
-static const int sliderSize = 19;
+static const int sliderSize = 20;
 static const int buttonHeightRatio = 1.5;
 
 static const float multipleComboDotsOffsetFactor = 1.8;
@@ -465,13 +465,16 @@
     painter->drawPixmap(targetRect.toRect(), pic);
 }
 
-void StylePainterMobile::drawProgress(const QRect& rect, double progress, bool leftToRight, bool animated) const
+void StylePainterMobile::drawProgress(const QRect& rect, double progress, bool leftToRight, bool animated, bool vertical) const
 {
-    const int border = rect.height() / 4;
-    const QRect targetRect = rect.adjusted(0, border, 0, -border);
+    const int horizontalBorder = (vertical ? rect.width() / 4 : 0);
+    const int verticalBorder = (vertical ? 0 : rect.height() / 4);
+    const QRect targetRect = rect.adjusted(horizontalBorder, verticalBorder, -horizontalBorder, -verticalBorder);
 
     QPixmap result;
-    const QSize imageSize = sizeForPainterScale(targetRect);
+    QSize imageSize = sizeForPainterScale(targetRect);
+    if (vertical)
+        qSwap(imageSize.rheight(), imageSize.rwidth());
     KeyIdentifier id;
     id.type = KeyIdentifier::Progress;
     id.width = imageSize.width();
@@ -516,7 +519,9 @@
         }
         insertIntoCache(id, result);
     }
-    painter->drawPixmap(targetRect, result);
+    QTransform transform;
+    transform.rotate(-90);
+    painter->drawPixmap(targetRect, vertical ? result.transformed(transform) : result);
 }
 
 void StylePainterMobile::drawSliderThumb(const QRect & rect, bool pressed) const
@@ -801,10 +806,14 @@
     const double max = slider->maximum();
     const double progress = (max - min > 0) ? (slider->valueAsNumber() - min) / (max - min) : 0;
 
-    // Render the spin buttons for LTR or RTL accordingly.
-    const int groovePadding = r.height() * sliderGrooveBorderRatio;
-    const QRect rect(r);
-    p.drawProgress(rect.adjusted(0, groovePadding, 0, -groovePadding), progress, o->style()->isLeftToRightDirection());
+    QRect rect(r);
+    const bool vertical = (o->style()->appearance() == SliderVerticalPart);
+    const int groovePadding = vertical ? r.width() * sliderGrooveBorderRatio : r.height() * sliderGrooveBorderRatio;
+    if (vertical)
+        rect.adjust(groovePadding, 0, -groovePadding, 0);
+    else
+        rect.adjust(0, groovePadding, 0, -groovePadding);
+    p.drawProgress(rect, progress, o->style()->isLeftToRightDirection(), /*animated = */ false, vertical);
 
     return false;
 }

Modified: trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h (110729 => 110730)


--- trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h	2012-03-14 19:30:54 UTC (rev 110729)
+++ trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.h	2012-03-14 19:45:31 UTC (rev 110730)
@@ -135,7 +135,7 @@
     void drawRadioButton(const QRect&, bool checked, bool enabled = true);
     void drawPushButton(const QRect&, bool sunken, bool enabled = true);
     void drawComboBox(const QRect&, bool multiple, bool enabled = true);
-    void drawProgress(const QRect&, double progress, bool leftToRight = true, bool animated = false) const;
+    void drawProgress(const QRect&, double progress, bool leftToRight = true, bool animated = false, bool vertical = false) const;
     void drawSliderThumb(const QRect&, bool pressed) const;
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to