summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/GLZoomIndicator.java
blob: c6612bfe040bae8dcad4986a40513134a697e05d (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
package com.android.camera.ui;

import android.graphics.Color;
import android.graphics.Rect;

import javax.microedition.khronos.opengles.GL11;

public class GLZoomIndicator extends GLView {

    private final StringTexture mTitle;

    public GLZoomIndicator(String title) {
        mTitle = StringTexture.newInstance(title, 24, 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);
        }
    }
}