OSDN Git Service

Initial commit of 3D gallery source code to project.
[android-x86/packages-apps-Gallery2.git] / src / com / cooliris / media / Layer.java
1 package com.cooliris.media;
2
3 import javax.microedition.khronos.opengles.GL11;
4
5 import android.view.MotionEvent;
6
7 public abstract class Layer {
8     float mX = 0f;
9     float mY = 0f;
10     float mWidth = 0;
11     float mHeight = 0;
12     boolean mHidden = false;
13
14     public final float getX() {
15         return mX;
16     }
17
18     public final float getY() {
19         return mY;
20     }
21
22     public final void setPosition(float x, float y) {
23         mX = x;
24         mY = y;
25     }
26
27     public final float getWidth() {
28         return mWidth;
29     }
30
31     public final float getHeight() {
32         return mHeight;
33     }
34
35     public final void setSize(float width, float height) {
36         if (mWidth != width || mHeight != height) {
37             mWidth = width;
38             mHeight = height;
39             onSizeChanged();
40         }
41     }
42
43     public boolean isHidden() {
44         return mHidden;
45     }
46
47     public void setHidden(boolean hidden) {
48         if (mHidden != hidden) {
49             mHidden = hidden;
50             onHiddenChanged();
51         }
52     }
53
54     public abstract void generate(RenderView view, RenderView.Lists lists);
55
56     // Returns true if something is animating.
57     public boolean update(RenderView view, float frameInterval) {
58         return false;
59     }
60
61     public void renderOpaque(RenderView view, GL11 gl) {
62     }
63
64     public void renderBlended(RenderView view, GL11 gl) {
65     }
66
67     public boolean onTouchEvent(MotionEvent event) {
68         return false;
69     }
70
71     // Allows subclasses to further constrain the hit test defined by layer bounds.
72     public boolean containsPoint(float x, float y) {
73         return true;
74     }
75
76     protected void onSurfaceCreated(RenderView view, GL11 gl) {
77     }
78
79     protected void onSizeChanged() {
80     }
81
82     protected void onHiddenChanged() {
83     }
84 }