summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/AbstractIndicator.java
blob: 531640d2af8f09a8aea908224045be2bf96f8c7d (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
39
40
41
42
43

package com.android.camera.ui;

import android.graphics.Rect;

import javax.microedition.khronos.opengles.GL11;

public abstract class AbstractIndicator extends GLView {
    private static final int DEFAULT_PADDING = 5;

    abstract protected ResourceTexture getIcon();

    public AbstractIndicator() {
        setPaddings(DEFAULT_PADDING, 0, DEFAULT_PADDING, 0);
    }

    @Override
    protected void onMeasure(int widthSpec, int heightSpec) {
        ResourceTexture icon = getIcon();
        new MeasureHelper(this)
               .setPreferedContentSize(icon.getWidth(), icon.getHeight())
               .measure(widthSpec, heightSpec);
    }

    @Override
    protected void render(GLRootView root, GL11 gl) {
        ResourceTexture icon = getIcon();

        Rect p = mPaddings;
        int width = getWidth() - p.left - p.right;
        int height = getHeight() - p.top - p.bottom;

        if (icon != null && icon.bind(root, gl)) {
            icon.draw(root,
                    p.left + (width - icon.getWidth()) / 2,
                    p.top + (height - icon.getHeight()) / 2);
        }
    }

    abstract public GLView getPopupContent();

    abstract public void overrideSettings(String key, String settings);
}