summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2011-03-16 15:34:02 -0400
committerLeon Scroggins <scroggo@google.com>2011-03-16 16:06:29 -0400
commit9d867bf3af621a847929fdc13e4c36ffcaa580f2 (patch)
tree2cb118b83e1889e19584476cc0baf12dfeeb64eb /WebKit/android
parent4754f7630fe9e26150d5ed2cfb4f231c57539c02 (diff)
downloadexternal_webkit-9d867bf3af621a847929fdc13e4c36ffcaa580f2.zip
external_webkit-9d867bf3af621a847929fdc13e4c36ffcaa580f2.tar.gz
external_webkit-9d867bf3af621a847929fdc13e4c36ffcaa580f2.tar.bz2
More improvements to video player controls.
Bug:4080127 Inset the track by half the width of the thumb so the thumb travels along the entire length of it. Make the track narrower vertically, and align it with the center of the thumb drawing. Draw the portion of the track that has already been covered with a different asset. Change-Id: I37acedc8e8b75bab59fcac7e075c59d70550795c
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/RenderSkinMediaButton.cpp34
-rw-r--r--WebKit/android/RenderSkinMediaButton.h5
2 files changed, 36 insertions, 3 deletions
diff --git a/WebKit/android/RenderSkinMediaButton.cpp b/WebKit/android/RenderSkinMediaButton.cpp
index c1451cb..6a11eda 100644
--- a/WebKit/android/RenderSkinMediaButton.cpp
+++ b/WebKit/android/RenderSkinMediaButton.cpp
@@ -30,7 +30,9 @@
#include "Document.h"
#include "IntRect.h"
#include "Node.h"
+#include "RenderObject.h"
#include "RenderSkinMediaButton.h"
+#include "RenderSlider.h"
#include "SkCanvas.h"
#include "SkNinePatch.h"
#include "SkRect.h"
@@ -45,7 +47,7 @@ struct PatchData {
static const PatchData gFiles[] =
{
- { "btn_media_player.9.png", 0, 0 }, // DEFAULT BGD BUTTON
+ { "scrubber_primary_holo.9.png", 0, 0 }, // SLIDER_TRACK, left of the SLIDER_THUMB
{ "ic_media_pause.png", 0, 0}, // PAUSE
{ "ic_media_play.png", 0, 0 }, // PLAY
{ "ic_media_pause.png", 0, 0 }, // MUTE
@@ -82,7 +84,8 @@ void RenderSkinMediaButton::Init(android::AssetManager* am, String drawableDirec
}
}
-void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, bool translucent)
+void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType,
+ bool translucent, RenderObject* o)
{
// If we failed to decode, do nothing. This way the browser still works,
// and webkit will still draw the label and layout space for us.
@@ -155,6 +158,33 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT
SkIRect margin;
margin.set(marginValue, marginValue, marginValue, marginValue);
+ if (buttonType == SLIDER_TRACK) {
+ // Cut the height in half (with some extra slop determined by trial
+ // and error to get the placement just right.
+ SkScalar quarterHeight = SkScalarHalf(SkScalarHalf(bounds.height()));
+ bounds.fTop += quarterHeight + SkScalarHalf(3);
+ bounds.fBottom += -quarterHeight + SK_ScalarHalf;
+ if (o && o->isSlider()) {
+ RenderSlider* slider = toRenderSlider(o);
+ IntRect thumb = slider->thumbRect();
+ // Inset the track by half the width of the thumb, so the track
+ // does not appear to go beyond the space where the thumb can
+ // be.
+ SkScalar thumbHalfWidth = SkIntToScalar(thumb.width()/2);
+ bounds.fLeft += thumbHalfWidth;
+ bounds.fRight -= thumbHalfWidth;
+ if (thumb.x() > 0) {
+ // The video is past the starting point. Show the area to
+ // left of the thumb as having been played.
+ SkScalar alreadyPlayed = SkIntToScalar(thumb.center().x() + r.x());
+ SkRect playedRect(bounds);
+ playedRect.fRight = alreadyPlayed;
+ SkNinePatch::DrawNine(canvas, playedRect, gButton[0], margin);
+ bounds.fLeft = alreadyPlayed;
+ }
+
+ }
+ }
SkNinePatch::DrawNine(canvas, bounds, gButton[ninePatchIndex], margin);
}
diff --git a/WebKit/android/RenderSkinMediaButton.h b/WebKit/android/RenderSkinMediaButton.h
index bde31eb..026f538 100644
--- a/WebKit/android/RenderSkinMediaButton.h
+++ b/WebKit/android/RenderSkinMediaButton.h
@@ -32,6 +32,8 @@ class SkCanvas;
namespace WebCore {
class IntRect;
+class RenderObject;
+
class RenderSkinMediaButton
{
public:
@@ -44,7 +46,8 @@ public:
* Draw the skin to the canvas, using the rectangle for its bounds and the
* State to determine which skin to use, i.e. focused or not focused.
*/
- static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false);
+ static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false,
+ RenderObject* o = 0);
/**
* Button types
*/