OSDN Git Service

be98ae0de745131047708223ed9e2de6200043dd
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / ui / StripDrawer.java
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.android.gallery3d.ui;
18
19 import com.android.gallery3d.R;
20 import com.android.gallery3d.data.Path;
21
22 import android.content.Context;
23 import android.graphics.Rect;
24
25 public class StripDrawer extends SelectionDrawer {
26     private NinePatchTexture mFocusBox;
27     private Rect mFocusBoxPadding;
28
29     public StripDrawer(Context context) {
30         mFocusBox = new NinePatchTexture(context, R.drawable.focus_box);
31         mFocusBoxPadding = mFocusBox.getPaddings();
32     }
33
34     @Override
35     public void prepareDrawing() {
36     }
37
38     @Override
39     public void draw(GLCanvas canvas, Texture content, int width, int height,
40             int rotation, Path path, int topIndex, int dataSourceType,
41             int mediaType, int darkStripHeight, boolean wantCache,
42             boolean isCaching) {
43
44         int x = -width / 2;
45         int y = -height / 2;
46
47         drawWithRotation(canvas, content, x, y, width, height, rotation);
48     }
49
50     @Override
51     public void drawFocus(GLCanvas canvas, int width, int height) {
52         int x = -width / 2;
53         int y = -height / 2;
54         Rect p = mFocusBoxPadding;
55         mFocusBox.draw(canvas, x - p.left, y - p.top,
56                 width + p.left + p.right, height + p.top + p.bottom);
57     }
58 }