blob: 36c06a3c9001457371f23c47acbb8bded1593024 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.android.camera.ui;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import javax.microedition.khronos.opengles.GL11;
public class ZoomIndicator extends GLView {
private static final int FONT_SIZE = 16;
private final StringTexture mTitle;
public ZoomIndicator(Context context, String title) {
float fontSize = GLRootView.dpToPixel(context, FONT_SIZE);
mTitle = StringTexture.newInstance(title, fontSize, Color.WHITE);
}
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
new MeasureHelper(this)
.setPreferedContentSize(mTitle.getWidth(), mTitle.getHeight())
.measure(widthSpec, heightSpec);
}
@Override
protected void render(GLRootView root, GL11 gl) {
if (mTitle.bind(root, gl)) {
Rect p = mPaddings;
int width = getWidth() - p.left - p.right;
int height = getHeight() - p.top - p.bottom;
mTitle.draw(root,
p.left + (width - mTitle.getWidth()) / 2,
p.top + (height - mTitle.getHeight()) / 2);
}
}
}
|