15ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller/* 25ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * Copyright (C) 2010 The Android Open Source Project 35ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * 45ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * Licensed under the Apache License, Version 2.0 (the "License"); 55ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * you may not use this file except in compliance with the License. 65ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * You may obtain a copy of the License at 75ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * 85ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * http://www.apache.org/licenses/LICENSE-2.0 95ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * 105ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * Unless required by applicable law or agreed to in writing, software 115ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * distributed under the License is distributed on an "AS IS" BASIS, 125ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * See the License for the specific language governing permissions and 145ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * limitations under the License. 155ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller */ 165ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 175ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerpackage com.android.ex.carousel; 185ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 19594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shumaimport android.view.View; 205ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport com.android.ex.carousel.CarouselRS.CarouselCallback; 215ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 225ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.content.Context; 235ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.graphics.Bitmap; 24b0f070636c29ad178f4e21306f301fe3d20c183bJim Millerimport android.renderscript.Float4; 255ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.Mesh; 265ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.RSSurfaceView; 275ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.RenderScriptGL; 285ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.util.AttributeSet; 295ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.view.MotionEvent; 305ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.view.SurfaceHolder; 315ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 327cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller/** 337cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * <p> 347cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This class represents the basic building block for using a 3D Carousel. The Carousel is 357cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * basically a scene of cards and slots. The spacing between cards is dictated by the number 367cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * of slots and the radius. The number of visible cards dictates how far the Carousel can be moved. 377cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * If the number of cards exceeds the number of slots, then the Carousel will continue to go 387cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * around until the last card can be seen. 397cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 405ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerpublic abstract class CarouselView extends RSSurfaceView { 415ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private static final boolean USE_DEPTH_BUFFER = true; 425ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private static final String TAG = "CarouselView"; 435ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private CarouselRS mRenderScript; 445ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private RenderScriptGL mRS; 455ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private Context mContext; 465ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private boolean mTracking; 479afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller 487cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma CarouselController mController; 495ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 50be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller // Drag relative to x coordinate of motion on screen 51be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller public static final int DRAG_MODEL_SCREEN_DELTA = CarouselRS.DRAG_MODEL_SCREEN_DELTA; 52be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller // Drag relative to projected point on plane of carousel 53be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller public static final int DRAG_MODEL_PLANE = CarouselRS.DRAG_MODEL_PLANE; 54be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller // Drag relative to projected point on inside (far point) of cylinder centered around carousel 55be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller public static final int DRAG_MODEL_CYLINDER_INSIDE = CarouselRS.DRAG_MODEL_CYLINDER_INSIDE; 56be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller // Drag relative to projected point on outside (near point) of cylinder centered around carousel 57be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller public static final int DRAG_MODEL_CYLINDER_OUTSIDE = CarouselRS.DRAG_MODEL_CYLINDER_OUTSIDE; 58be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller 5914d2c1ec52bb04b5120c2bfdd1a8811a238573ceJim Shuma // Draw cards counterclockwise around the carousel 6014d2c1ec52bb04b5120c2bfdd1a8811a238573ceJim Shuma public static final int FILL_DIRECTION_CCW = CarouselRS.FILL_DIRECTION_CCW; 6114d2c1ec52bb04b5120c2bfdd1a8811a238573ceJim Shuma // Draw cards clockwise around the carousel 6214d2c1ec52bb04b5120c2bfdd1a8811a238573ceJim Shuma public static final int FILL_DIRECTION_CW = CarouselRS.FILL_DIRECTION_CW; 63be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller 644a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney // Note: remember to update carousel.rs when changing the values below 658debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry public static class InterpolationMode { 668debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry /** y= x **/ 678debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry public static final int LINEAR = 0; 688debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry /** The quadratic curve y= 1 - (1 - x)^2 moves quickly towards the target 698debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry * while decelerating constantly. **/ 708debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry public static final int DECELERATE_QUADRATIC = 1; 718debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry /** The cubic curve y= (3-2x)*x^2 gradually accelerates at the origin, 728debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry * and decelerates near the target. **/ 738debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry public static final int ACCELERATE_DECELERATE_CUBIC = 2; 748debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry } 758debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry 768debeb8a0a785f0ad66bc75200cdb47c137602bcArnaud Berry // Note: remember to update carousel.rs when changing the values below 774a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static class DetailAlignment { 784a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Detail is centered vertically with respect to the card **/ 794a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int CENTER_VERTICAL = 1; 804a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Detail is aligned with the top edge of the carousel view **/ 814a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int VIEW_TOP = 1 << 1; 824a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Detail is aligned with the bottom edge of the carousel view (not yet implemented) **/ 834a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int VIEW_BOTTOM = 1 << 2; 844a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Detail is positioned above the card (not yet implemented) **/ 854a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int ABOVE = 1 << 3; 864a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Detail is positioned below the card **/ 874a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int BELOW = 1 << 4; 884a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Mask that selects those bits that control vertical alignment **/ 894a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int VERTICAL_ALIGNMENT_MASK = 0xff; 904a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney 914a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** 924a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * Detail is centered horizontally with respect to either the top or bottom 934a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * extent of the card, depending on whether the detail is above or below the card. 944a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney */ 954a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int CENTER_HORIZONTAL = 1 << 8; 964a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** 974a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * Detail is aligned with the left edge of either the top or the bottom of 984a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * the card, depending on whether the detail is above or below the card. 994a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney */ 1004a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int LEFT = 1 << 9; 1014a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** 1024a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * Detail is aligned with the right edge of either the top or the bottom of 1034a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * the card, depending on whether the detail is above or below the card. 1044a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * (not yet implemented) 1054a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney */ 1064a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int RIGHT = 1 << 10; 1074a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney /** Mask that selects those bits that control horizontal alignment **/ 1084a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public static final int HORIZONTAL_ALIGNMENT_MASK = 0xff00; 1094a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney } 1104a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney 1115ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public static class Info { 1129afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller public Info(int _resId) { resId = _resId; } 1135ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public int resId; // resource for renderscript resource (e.g. R.raw.carousel) 1145ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 1155ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1165ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public abstract Info getRenderScriptInfo(); 1175ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1185ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public CarouselView(Context context) { 1197cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma this(context, new CarouselController()); 1207cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 1217cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma 1227cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma public CarouselView(Context context, CarouselController controller) { 1237cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma this(context, null, controller); 1245ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 1255ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1265ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller /** 1275ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * Constructor used when this widget is created from a layout file. 1285ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller */ 1295ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public CarouselView(Context context, AttributeSet attrs) { 1307cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma this(context, attrs, new CarouselController()); 1317cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 1327cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma 1337cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma public CarouselView(Context context, AttributeSet attrs, CarouselController controller) { 1345ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller super(context, attrs); 1355ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller mContext = context; 1367cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController = controller; 1375ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller boolean useDepthBuffer = true; 138e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney ensureRenderScript(); 1395ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller // TODO: add parameters to layout 140594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma 1417cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma setOnLongClickListener(new View.OnLongClickListener() { 142594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma public boolean onLongClick(View v) { 143594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma if (interpretLongPressEvents()) { 1447cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.onLongPress(); 145594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma return true; 146594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma } else { 147594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma return false; 148594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma } 149594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma } 150594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma }); 1515ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 1525ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1535ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller private void ensureRenderScript() { 154e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney if (mRS == null) { 155fc1960b04f7746f8bdb13cc5bf3297fe0928c851Jason Sams RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); 1567cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma if (USE_DEPTH_BUFFER) { 1577cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma sc.setDepth(16, 24); 1587cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 15927b81f375cfa65f4f689c64bd2c48e3a56c1e11bJason Sams mRS = createRenderScriptGL(sc); 160e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney } 161a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller if (mRenderScript == null) { 1627cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mRenderScript = new CarouselRS(mRS, mContext.getResources(), 1637cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma getRenderScriptInfo().resId); 164a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller mRenderScript.resumeRendering(); 165a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller } 1667cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setRS(mRS, mRenderScript); 1675ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 1685ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1695ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller @Override 1705ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 1715ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller super.surfaceChanged(holder, format, w, h); 172fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller // setZOrderOnTop(true); 1737cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.onSurfaceChanged(); 1747cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 1757cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma 1767cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma public CarouselController getController() { 1777cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma return mController; 1787cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 1797cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma 1807cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma public void setController(CarouselController controller) { 1817cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController = controller; 1827cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setRS(mRS, mRenderScript); 1835ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 1845ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 1855ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller /** 186594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma * Do I want to interpret the long-press gesture? If so, long-presses will cancel the 187594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma * current selection and call the appropriate callbacks. Otherwise, a long press will 188594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma * not be handled any way other than as a continued drag. 189594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma * 190594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma * @return True if we interpret long-presses 191594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma */ 192594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma public boolean interpretLongPressEvents() { 193594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma return false; 194594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma } 195594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma 196594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma /** 1975ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * Loads geometry from a resource id. 1985ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * 1995ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * @param resId 2005ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * @return the loaded mesh or null if it cannot be loaded 2015ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller */ 2025ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public Mesh loadGeometry(int resId) { 203358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney return mController.loadGeometry(resId); 2045ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 2055ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 2065ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller /** 207358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney * Set the geometry for a given item. 2085ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller * @param n 209358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney * @param mesh 2105ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller */ 2115ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setGeometryForItem(int n, Mesh mesh) { 2127cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setGeometryForItem(n, mesh); 2135ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 214c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma 215c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma /** 216c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma * Set the matrix for a given item. 217c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma * @param n 218c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma * @param matrix the requested matrix; null to just use the default 219c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma */ 220c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma public void setMatrixForItem(int n, float[] matrix) { 221c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma mController.setMatrixForItem(n, matrix); 222c2baf88a763ae0e3694c8a10c13f203db9aec363Jim Shuma } 2235ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 2247cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 2257cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Set the number of slots around the Carousel. Basically equivalent to the poles horses 2267cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * might attach to on a real Carousel. 2277cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 2287cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param n the number of slots 2297cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 2305ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setSlotCount(int n) { 2317cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setSlotCount(n); 2325ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 2335ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 2347cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 2357cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Sets the number of visible slots around the Carousel. This is primarily used as a cheap 2367cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * form of clipping. The Carousel will never show more than this many cards. 2377cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param n the number of visible slots 2387cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 2395ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setVisibleSlots(int n) { 2407cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setVisibleSlots(n); 2417c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma } 2427c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma 2437c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma /** 2444fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * Set the number of cards to pre-load that are outside of the visible region, as determined by 2454fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * setVisibleSlots(). This number gets added to the number of visible slots and used to 2464fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * determine when resources for cards should be loaded. This number should be small (n <= 4) 2474fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * for systems with limited texture memory or views that show more than half dozen cards in the 2484fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * view. 2494fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * 2504fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma * @param n the number of cards; should be even, so the count is the same on each side 2514fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma */ 2524fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma public void setPrefetchCardCount(int n) { 2537cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setPrefetchCardCount(n); 2544fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma } 2554fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma 2564fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma /** 2570cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney * Sets the number of rows of cards to show in each slot. 2580cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney */ 2590cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney public void setRowCount(int n) { 2600cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney mController.setRowCount(n); 2610cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney } 2620cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney 2630cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney /** 2640cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney * Sets the spacing between each row of cards when rowCount > 1. 2650cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney */ 2660cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney public void setRowSpacing(float s) { 2670cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney mController.setRowSpacing(s); 2680cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney } 2690cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney 2700cec8afdb4f9d78adf88c9b9b41e993aef617beaBryan Mawhinney /** 2711a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson * Sets the position of the first card when rowCount > 1. 2721a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson */ 2731a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson public void setFirstCardTop(boolean f) { 2741a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson mController.setFirstCardTop(f); 2751a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson } 2761a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson 2771a5b4d109397ea175b5cbaa7490ca18e78eb040fSimon Wilson /** 2789afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney * Sets the amount of allowed overscroll (in slots) 2799afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney */ 2809afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney public void setOverscrollSlots(float slots) { 2819afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney mController.setOverscrollSlots(slots); 2829afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney } 2839afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney 2849afded4d212243e554c2695c4a2f90c13628e24bBryan Mawhinney /** 2857cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma * Set the number of detail textures that can be visible at one time. 2867c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma * 2877cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma * @param n the number of slots 2887cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma */ 2897cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma public void setVisibleDetails(int n) { 2907cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setVisibleDetails(n); 2917cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma } 2927cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma 2937cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma /** 2947cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma * Sets how detail textures are aligned with respect to the card. 295fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * 2964a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney * @param alignment a bitmask of DetailAlignment flags. 2977c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma */ 2984a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney public void setDetailTextureAlignment(int alignment) { 2997cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDetailTextureAlignment(alignment); 3004fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma } 3014fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma 3027cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma /** 303fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * Set whether depth is enabled while blending. Generally, this is discouraged because 304fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * it causes bad artifacts. Careful attention to geometry and alpha transparency of 305fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * textures can mitigate much of this. For example, geometry for an item must be drawn 306fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * back-to-front if any edges overlap. 3077cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma * 308fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * @param enabled True to enable depth while blending, and false to disable it. 3097cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma */ 310fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller public void setForceBlendCardsWithZ(boolean enabled) { 311fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller mController.setForceBlendCardsWithZ(enabled); 312bfc5ce2da9e0d8d0ec2535c465624574d98418d7Jim Shuma } 313bfc5ce2da9e0d8d0ec2535c465624574d98418d7Jim Shuma 3144fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma /** 3157c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma * Set whether to draw a ruler from the card to the detail texture 3167c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma * 3177c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma * @param drawRuler True to draw a ruler, false to draw nothing where the ruler would go. 3187c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma */ 3197c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma public void setDrawRuler(boolean drawRuler) { 3207cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDrawRuler(drawRuler); 3217c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma } 3227c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma 3237c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma /** 3247cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This dictates how many cards are in the deck. If the number of cards is greater than the 3257cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * number of slots, then the Carousel goes around n / slot_count times. 3267cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 3277cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Can be called again to increase or decrease the number of cards. 3287cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 3297cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param n the number of cards to create. 3307cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 3315ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void createCards(int n) { 3327cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.createCards(n); 3335ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 3345ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 335a3cb716626b477c98ba912698c765eab20f27286Jim Miller public int getCardCount() { 3367cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma return mController.getCardCount(); 337a3cb716626b477c98ba912698c765eab20f27286Jim Miller } 338a3cb716626b477c98ba912698c765eab20f27286Jim Miller 3397cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 3407cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This sets the texture on card n. It should only be called in response to 3417cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * {@link CarouselCallback#onRequestTexture(int)}. Since there's no guarantee 3427cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * that a given texture is still on the screen, replacing this texture should be done 3437cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * by first setting it to null and then waiting for the next 3447cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * {@link CarouselCallback#onRequestTexture(int)} to swap it with the new one. 3457cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 3467cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param n the card given by {@link CarouselCallback#onRequestTexture(int)} 3477cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap the bitmap image to show 3487cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 3495ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setTextureForItem(int n, Bitmap bitmap) { 3507cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setTextureForItem(n, bitmap); 3515ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 3525ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 3537cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 3547cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This sets the detail texture that floats above card n. It should only be called in response 3557cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * to {@link CarouselCallback#onRequestDetailTexture(int)}. Since there's no guarantee 3567cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * that a given texture is still on the screen, replacing this texture should be done 3577cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * by first setting it to null and then waiting for the next 3587cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * {@link CarouselCallback#onRequestDetailTexture(int)} to swap it with the new one. 3597cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 360b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller * @param n the card to set detail texture for 361b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller * @param offx an optional offset to apply to the texture (in pixels) from top of detail line 362b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller * @param offy an optional offset to apply to the texture (in pixels) from top of detail line 363b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller * @param loffx an optional offset to apply to the line (in pixels) from left edge of card 364b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller * @param loffy an optional offset to apply to the line (in pixels) from top of screen 3657cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap the bitmap to show as the detail 3667cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 367b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller public void setDetailTextureForItem(int n, float offx, float offy, float loffx, float loffy, 368b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller Bitmap bitmap) { 3697cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDetailTextureForItem(n, offx, offy, loffx, loffy, bitmap); 3707cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller } 3717cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller 3727cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 3737cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Sets the bitmap to show on a card when the card draws the very first time. 3747cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Generally, this bitmap will only be seen during the first few frames of startup 3757cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * or when the number of cards are changed. It can be ignored in most cases, 3767cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * as the cards will generally only be in the loading or loaded state. 3777cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 3787cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap 3797cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 3805ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setDefaultBitmap(Bitmap bitmap) { 3817cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDefaultBitmap(bitmap); 3825ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 3835ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 3847cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 3857cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Sets the bitmap to show on the card while the texture is loading. It is set to this 3867cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * value just before {@link CarouselCallback#onRequestTexture(int)} is called and changed 3877cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * when {@link CarouselView#setTextureForItem(int, Bitmap)} is called. It is shared by all 3887cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * cards. 3897cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 3907cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap 3917cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 3925ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setLoadingBitmap(Bitmap bitmap) { 3937cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setLoadingBitmap(bitmap); 3945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 3955ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 3967cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 397b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * Sets background to specified color. If a background texture is specified with 398b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * {@link CarouselView#setBackgroundBitmap(Bitmap)}, then this call has no effect. 399b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * 400b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * @param red the amount of red 401b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * @param green the amount of green 402b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * @param blue the amount of blue 403b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * @param alpha the amount of alpha 404b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller */ 405b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller public void setBackgroundColor(float red, float green, float blue, float alpha) { 4067cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setBackgroundColor(red, green, blue, alpha); 407b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller } 408420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller 409b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller /** 410b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * Can be used to optionally set the background to a bitmap. When set to something other than 411b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller * null, this overrides {@link CarouselView#setBackgroundColor(Float4)}. 4127cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 4137cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap 4147cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 4159afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller public void setBackgroundBitmap(Bitmap bitmap) { 4167cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setBackgroundBitmap(bitmap); 4179afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller } 4189afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller 4197cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 420420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * Can be used to optionally set a "loading" detail bitmap. Typically, this is just a black 421420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * texture with alpha = 0 to allow details to slowly fade in. 422420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * 423420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * @param bitmap 424420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller */ 425420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller public void setDetailLoadingBitmap(Bitmap bitmap) { 4267cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDetailLoadingBitmap(bitmap); 427420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller } 428420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller 429420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller /** 4307cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This texture is used to draw a line from the card alongside the texture detail. The line 4317cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * will be as wide as the texture. It can be used to give the line glow effects as well as 4327cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * allowing other blending effects. It is typically one dimensional, e.g. 3x1. 4337cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 4347cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param bitmap 4357cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 4367cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller public void setDetailLineBitmap(Bitmap bitmap) { 4377cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDetailLineBitmap(bitmap); 4387cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller } 4397cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller 4407cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 4417cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This geometry will be shown when no geometry has been loaded for a given slot. If not set, 442fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * a quad will be drawn in its place. It is shared for all cards. If something other than 443fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * simple planar geometry is used, consider enabling depth test with 444fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * {@link CarouselView#setForceBlendCardsWithZ(boolean)} 4457cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 446358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney * @param resId 4477cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 448358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney public void setDefaultGeometry(int resId) { 449358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney mController.setDefaultGeometry(resId); 4505ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 4515ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 4527cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 45351dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * Sets the matrix used to transform card geometries. By default, this 45451dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * is the identity matrix, but you can specify a different matrix if you 45551dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * want to scale, translate and / or rotate the card before drawing. 45651dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * 45751dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * @param matrix array of 9 or 16 floats representing a 3x3 or 4x4 matrix, 45851dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney * or null as a shortcut for an identity matrix. 45951dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney */ 46051dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney public void setDefaultCardMatrix(float[] matrix) { 46151dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney mController.setDefaultCardMatrix(matrix); 46251dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney } 46351dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney 46451dd0196e4f3bd4086545f5bf30038ca9ad9ac27Bryan Mawhinney /** 4657cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This is an intermediate version of the object to show while geometry is loading. If not set, 466fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * a quad will be drawn in its place. It is shared for all cards. If something other than 467fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * simple planar geometry is used, consider enabling depth test with 468fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller * {@link CarouselView#setForceBlendCardsWithZ(boolean)} 4697cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 470358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney * @param resId 4717cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 472358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney public void setLoadingGeometry(int resId) { 473358868df5043b240c9a241c7bb75128ff94b1f34Bryan Mawhinney mController.setLoadingGeometry(resId); 4745ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 4755ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 4767cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 4777cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Sets the callback for receiving events from RenderScript. 4787cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 4797cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param callback 4807cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 4815ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setCallback(CarouselCallback callback) 4825ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller { 4837cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setCallback(callback); 4845ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 4855ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 4867cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller /** 4877cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Sets the startAngle for the Carousel. The start angle is the first position of the first 4887cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * slot draw. Cards will be drawn from this angle in a counter-clockwise manner around the 4897cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * Carousel. 4907cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * 4917cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * @param angle the angle, in radians. 4927cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */ 4935ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public void setStartAngle(float angle) 4945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller { 4957cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setStartAngle(angle); 496a84feeb7e4dc1a75ec6d0b1f2494893987fc3ca3Jack Palevich } 497a84feeb7e4dc1a75ec6d0b1f2494893987fc3ca3Jack Palevich 498c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setRadius(float radius) { 4997cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setRadius(radius); 500c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 501c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma 502c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setCardRotation(float cardRotation) { 5037cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setCardRotation(cardRotation); 504c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 505c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma 50683d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney public void setCardsFaceTangent(boolean faceTangent) { 5077cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setCardsFaceTangent(faceTangent); 50883d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney } 50983d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney 510c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setSwaySensitivity(float swaySensitivity) { 5117cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setSwaySensitivity(swaySensitivity); 512c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 513c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma 514c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setFrictionCoefficient(float frictionCoefficient) { 5157cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setFrictionCoefficient(frictionCoefficient); 516c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 517c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma 518c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setDragFactor(float dragFactor) { 5197cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setDragFactor(dragFactor); 520c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 521c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma 522be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller public void setDragModel(int model) { 523be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller mController.setDragModel(model); 524be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller } 525be5482f170e191aa98a3c2ecefdeaf936b7df412Jim Miller 526c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma public void setLookAt(float[] eye, float[] at, float[] up) { 5277cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setLookAt(eye, at, up); 528c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma } 5295ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 530420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller /** 531420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * This sets the number of cards in the distance that will be shown "rezzing in". 532420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * These alpha values will be faded in from the background to the foreground over 533420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * 'n' cards. A floating point value is used to allow subtly changing the rezzing in 534420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * position. 535420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * 536420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * @param n the number of cards to rez in. 537420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller */ 538420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller public void setRezInCardCount(float n) { 5397cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setRezInCardCount(n); 540420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller } 541420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller 542420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller /** 543420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * This sets the duration (in ms) that a card takes to fade in when loaded via a call 544420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * to {@link CarouselView#setTextureForItem(int, Bitmap)}. The timer starts the 545420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * moment {@link CarouselView#setTextureForItem(int, Bitmap)} is called and continues 546420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * until all of the cards have faded in. Note: using large values will extend the 547420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * animation until all cards have faded in. 548420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * 549420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller * @param t 550420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller */ 551420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller public void setFadeInDuration(long t) { 5527cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setFadeInDuration(t); 553420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller } 554420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller 5555ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller @Override 5565ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller protected void onDetachedFromWindow() { 5575ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller super.onDetachedFromWindow(); 558c3e94dc22d3c03b514bf3aff41082bfab7aca845Jack Palevich mRenderScript = null; 559c3e94dc22d3c03b514bf3aff41082bfab7aca845Jack Palevich if (mRS != null) { 5605ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller mRS = null; 56127b81f375cfa65f4f689c64bd2c48e3a56c1e11bJason Sams destroyRenderScriptGL(); 5625ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 5637cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma mController.setRS(mRS, mRenderScript); 5645ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 5655ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5665ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller @Override 5675ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller protected void onAttachedToWindow() { 5685ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller super.onAttachedToWindow(); 5695ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller ensureRenderScript(); 5705ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 5715ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5725ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller @Override 5735ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller public boolean onTouchEvent(MotionEvent event) { 574594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma super.onTouchEvent(event); 5755ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller final int action = event.getAction(); 5765ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5775ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller if (mRenderScript == null) { 5785ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller return true; 5795ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 5805ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5815ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller switch (action) { 5825ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller case MotionEvent.ACTION_DOWN: 5835ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller mTracking = true; 5841882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller mController.onTouchStarted(event.getX(), event.getY(), event.getEventTime()); 5855ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller break; 5865ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5875ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller case MotionEvent.ACTION_MOVE: 5885ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller if (mTracking) { 5891882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller for (int i = 0; i < event.getHistorySize(); i++) { 5901882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller mController.onTouchMoved(event.getHistoricalX(i), event.getHistoricalY(i), 5911882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller event.getHistoricalEventTime(i)); 5921882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller } 5931882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller mController.onTouchMoved(event.getX(), event.getY(), event.getEventTime()); 5945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 5955ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller break; 5965ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 5975ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller case MotionEvent.ACTION_UP: 5981882cebdc1b7b0551189ca33fb7cb77ef10c988bJim Miller mController.onTouchStopped(event.getX(), event.getY(), event.getEventTime()); 5995ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller mTracking = false; 6005ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller break; 6015ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 6025ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller 6035ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller return true; 6045ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller } 6055ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller} 606