1/* 2 * Copyright (C) 2009 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 17package com.cooliris.media; 18 19import javax.microedition.khronos.opengles.GL11; 20 21import android.view.MotionEvent; 22 23public abstract class Layer { 24 float mX = 0f; 25 float mY = 0f; 26 float mWidth = 0; 27 float mHeight = 0; 28 boolean mHidden = false; 29 30 public final float getX() { 31 return mX; 32 } 33 34 public final float getY() { 35 return mY; 36 } 37 38 public final void setPosition(float x, float y) { 39 mX = x; 40 mY = y; 41 } 42 43 public final float getWidth() { 44 return mWidth; 45 } 46 47 public final float getHeight() { 48 return mHeight; 49 } 50 51 public final void setSize(float width, float height) { 52 if (mWidth != width || mHeight != height) { 53 mWidth = width; 54 mHeight = height; 55 onSizeChanged(); 56 } 57 } 58 59 public boolean isHidden() { 60 return mHidden; 61 } 62 63 public void setHidden(boolean hidden) { 64 if (mHidden != hidden) { 65 mHidden = hidden; 66 onHiddenChanged(); 67 } 68 } 69 70 public abstract void generate(RenderView view, RenderView.Lists lists); 71 72 // Returns true if something is animating. 73 public boolean update(RenderView view, float frameInterval) { 74 return false; 75 } 76 77 public void renderOpaque(RenderView view, GL11 gl) { 78 } 79 80 public void renderBlended(RenderView view, GL11 gl) { 81 } 82 83 public boolean onTouchEvent(MotionEvent event) { 84 return false; 85 } 86 87 // Allows subclasses to further constrain the hit test defined by layer 88 // bounds. 89 public boolean containsPoint(float x, float y) { 90 return true; 91 } 92 93 protected void onSurfaceCreated(RenderView view, GL11 gl) { 94 } 95 96 protected void onSizeChanged() { 97 } 98 99 protected void onHiddenChanged() { 100 } 101} 102