CarouselView.java revision fb179e7afd8f02be63061b478b0283e3085fc25f
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.content.res.Resources;
245ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.graphics.Bitmap;
25a3cb716626b477c98ba912698c765eab20f27286Jim Millerimport android.graphics.PixelFormat;
265ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.graphics.Bitmap.Config;
275ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.FileA3D;
28b0f070636c29ad178f4e21306f301fe3d20c183bJim Millerimport android.renderscript.Float4;
295ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.Mesh;
305ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.RSSurfaceView;
315ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.renderscript.RenderScriptGL;
325ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.util.AttributeSet;
335ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.util.Log;
345ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.view.MotionEvent;
355ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerimport android.view.SurfaceHolder;
365ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
377cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller/**
387cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * <p>
397cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * This class represents the basic building block for using a 3D Carousel. The Carousel is
407cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * basically a scene of cards and slots.  The spacing between cards is dictated by the number
417cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * of slots and the radius. The number of visible cards dictates how far the Carousel can be moved.
427cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * If the number of cards exceeds the number of slots, then the Carousel will continue to go
437cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller * around until the last card can be seen.
447cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller */
455ce730797a8a7278dfe19dac8a9460b25675fed0Jim Millerpublic abstract class CarouselView extends RSSurfaceView {
465ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private static final boolean USE_DEPTH_BUFFER = true;
475ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private static final String TAG = "CarouselView";
487cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    private static final boolean DBG = false;
495ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private CarouselRS mRenderScript;
505ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private RenderScriptGL mRS;
515ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private Context mContext;
525ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private boolean mTracking;
539afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller
547cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    CarouselController mController;
555ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
564a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney    // Note: remember to update carousel.rs when changing the values below
574a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney    public static class DetailAlignment {
584a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Detail is centered vertically with respect to the card **/
594a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int CENTER_VERTICAL = 1;
604a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Detail is aligned with the top edge of the carousel view **/
614a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int VIEW_TOP = 1 << 1;
624a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Detail is aligned with the bottom edge of the carousel view (not yet implemented) **/
634a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int VIEW_BOTTOM = 1 << 2;
644a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Detail is positioned above the card (not yet implemented) **/
654a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int ABOVE = 1 << 3;
664a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Detail is positioned below the card **/
674a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int BELOW = 1 << 4;
684a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Mask that selects those bits that control vertical alignment **/
694a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int VERTICAL_ALIGNMENT_MASK = 0xff;
704a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney
714a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /**
724a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * Detail is centered horizontally with respect to either the top or bottom
734a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * extent of the card, depending on whether the detail is above or below the card.
744a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         */
754a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int CENTER_HORIZONTAL = 1 << 8;
764a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /**
774a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * Detail is aligned with the left edge of either the top or the bottom of
784a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * the card, depending on whether the detail is above or below the card.
794a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         */
804a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int LEFT = 1 << 9;
814a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /**
824a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * Detail is aligned with the right edge of either the top or the bottom of
834a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * the card, depending on whether the detail is above or below the card.
844a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         * (not yet implemented)
854a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney         */
864a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int RIGHT = 1 << 10;
874a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        /** Mask that selects those bits that control horizontal alignment **/
884a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney        public static final int HORIZONTAL_ALIGNMENT_MASK = 0xff00;
894a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney    }
904a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney
915ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public static class Info {
929afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller        public Info(int _resId) { resId = _resId; }
935ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        public int resId; // resource for renderscript resource (e.g. R.raw.carousel)
945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
955ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
965ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public abstract Info getRenderScriptInfo();
975ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
985ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public CarouselView(Context context) {
997cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        this(context, new CarouselController());
1007cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    }
1017cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma
1027cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    public CarouselView(Context context, CarouselController controller) {
1037cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        this(context, null, controller);
1045ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1055ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1065ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    /**
1075ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * Constructor used when this widget is created from a layout file.
1085ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     */
1095ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public CarouselView(Context context, AttributeSet attrs) {
1107cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        this(context, attrs, new CarouselController());
1117cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    }
1127cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma
1137cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    public CarouselView(Context context, AttributeSet attrs, CarouselController controller) {
1145ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        super(context, attrs);
1155ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        mContext = context;
1167cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController = controller;
1175ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        boolean useDepthBuffer = true;
118e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney        ensureRenderScript();
1195ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        // TODO: add parameters to layout
120594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma
1217cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        setOnLongClickListener(new View.OnLongClickListener() {
122594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma            public boolean onLongClick(View v) {
123594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma                if (interpretLongPressEvents()) {
1247cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                    mController.onLongPress();
125594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma                    return true;
126594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma                } else {
127594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma                    return false;
128594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma                }
129594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma            }
130594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma        });
1315ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1325ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1335ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    private void ensureRenderScript() {
134e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney        if (mRS == null) {
135fc1960b04f7746f8bdb13cc5bf3297fe0928c851Jason Sams            RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
1367cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma            if (USE_DEPTH_BUFFER) {
1377cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                sc.setDepth(16, 24);
1387cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma            }
139fc1960b04f7746f8bdb13cc5bf3297fe0928c851Jason Sams            mRS = createRenderScript(sc);
140e386bbba584685f6261e6dc846c9d05c79b53535Bryan Mawhinney        }
141a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller        if (mRenderScript == null) {
1427cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma            mRenderScript = new CarouselRS(mRS, mContext.getResources(),
1437cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                    getRenderScriptInfo().resId);
144a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller            mRenderScript.resumeRendering();
145a044fbbb1e5498a0112f20a1b0de11a4089ef612Jim Miller        }
1467cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setRS(mRS, mRenderScript);
1475ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1485ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1495ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    @Override
1505ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
1515ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        super.surfaceChanged(holder, format, w, h);
152fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller        // setZOrderOnTop(true);
1537cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.onSurfaceChanged();
1547cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    }
1557cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma
1567cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    public CarouselController getController() {
1577cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        return mController;
1587cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    }
1597cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma
1607cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    public void setController(CarouselController controller) {
1617cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController = controller;
1627cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setRS(mRS, mRenderScript);
1635ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1645ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1655ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    /**
166594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     * Do I want to interpret the long-press gesture? If so, long-presses will cancel the
167594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     * current selection and call the appropriate callbacks. Otherwise, a long press will
168594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     * not be handled any way other than as a continued drag.
169594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     *
170594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     * @return True if we interpret long-presses
171594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma     */
172594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma    public boolean interpretLongPressEvents() {
173594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma        return false;
174594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma    }
175594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma
176594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma    /**
1775ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * Loads geometry from a resource id.
1785ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     *
1795ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * @param resId
1805ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * @return the loaded mesh or null if it cannot be loaded
1815ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     */
1825ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public Mesh loadGeometry(int resId) {
1837cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        return mController.loadGeometry(mContext.getResources(), resId);
1845ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1855ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1865ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    /**
1875ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * Load A3D file from resource.  If resId == 0, will clear geometry for this item.
1885ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * @param n
1895ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     * @param resId
1905ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller     */
1915ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setGeometryForItem(int n, Mesh mesh) {
1927cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setGeometryForItem(n, mesh);
1935ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
1945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
1957cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
1967cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Set the number of slots around the Carousel. Basically equivalent to the poles horses
1977cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * might attach to on a real Carousel.
1987cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
1997cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param n the number of slots
2007cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
2015ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setSlotCount(int n) {
2027cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setSlotCount(n);
2035ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
2045ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
2057cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
2067cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Sets the number of visible slots around the Carousel.  This is primarily used as a cheap
2077cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * form of clipping. The Carousel will never show more than this many cards.
2087cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param n the number of visible slots
2097cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
2105ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setVisibleSlots(int n) {
2117cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setVisibleSlots(n);
2127c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma    }
2137c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma
2147c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma    /**
2154fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * Set the number of cards to pre-load that are outside of the visible region, as determined by
2164fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * setVisibleSlots(). This number gets added to the number of visible slots and used to
2174fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * determine when resources for cards should be loaded. This number should be small (n <= 4)
2184fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * for systems with limited texture memory or views that show more than half dozen cards in the
2194fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * view.
2204fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     *
2214fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     * @param n the number of cards; should be even, so the count is the same on each side
2224fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma     */
2234fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma    public void setPrefetchCardCount(int n) {
2247cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setPrefetchCardCount(n);
2254fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma    }
2264fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma
2274fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma    /**
2287cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     * Set the number of detail textures that can be visible at one time.
2297c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     *
2307cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     * @param n the number of slots
2317cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     */
2327cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    public void setVisibleDetails(int n) {
2337cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setVisibleDetails(n);
2347cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    }
2357cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma
2367cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    /**
2377cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     * Sets how detail textures are aligned with respect to the card.
238fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     *
2394a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney     * @param alignment a bitmask of DetailAlignment flags.
2407c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     */
2414a8736e22d7b40ab9dfa3fbd8a10de92144912b3Bryan Mawhinney    public void setDetailTextureAlignment(int alignment) {
2427cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDetailTextureAlignment(alignment);
2434fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma    }
2444fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma
2457cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma    /**
246fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * Set whether depth is enabled while blending. Generally, this is discouraged because
247fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * it causes bad artifacts. Careful attention to geometry and alpha transparency of
248fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * textures can mitigate much of this. For example, geometry for an item must be drawn
249fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * back-to-front if any edges overlap.
2507cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     *
251fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * @param enabled True to enable depth while blending, and false to disable it.
2527cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma     */
253fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller    public void setForceBlendCardsWithZ(boolean enabled) {
254fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller        mController.setForceBlendCardsWithZ(enabled);
255bfc5ce2da9e0d8d0ec2535c465624574d98418d7Jim Shuma    }
256bfc5ce2da9e0d8d0ec2535c465624574d98418d7Jim Shuma
2574fe6ea729d1fc44c8126de7a92a710c3885fb2ecJim Shuma    /**
2587c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     * Set whether to draw a ruler from the card to the detail texture
2597c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     *
2607c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     * @param drawRuler True to draw a ruler, false to draw nothing where the ruler would go.
2617c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma     */
2627c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma    public void setDrawRuler(boolean drawRuler) {
2637cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDrawRuler(drawRuler);
2647c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma    }
2657c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma
2667c09ccce478100d75e4427d87866ff19d758ae7aJim Shuma    /**
2677cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This dictates how many cards are in the deck.  If the number of cards is greater than the
2687cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * number of slots, then the Carousel goes around n / slot_count times.
2697cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
2707cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Can be called again to increase or decrease the number of cards.
2717cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
2727cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param n the number of cards to create.
2737cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
2745ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void createCards(int n) {
2757cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.createCards(n);
2765ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
2775ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
278a3cb716626b477c98ba912698c765eab20f27286Jim Miller    public int getCardCount() {
2797cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        return mController.getCardCount();
280a3cb716626b477c98ba912698c765eab20f27286Jim Miller    }
281a3cb716626b477c98ba912698c765eab20f27286Jim Miller
2827cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
2837cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This sets the texture on card n.  It should only be called in response to
2847cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * {@link CarouselCallback#onRequestTexture(int)}.  Since there's no guarantee
2857cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * that a given texture is still on the screen, replacing this texture should be done
2867cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * by first setting it to null and then waiting for the next
2877cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * {@link CarouselCallback#onRequestTexture(int)} to swap it with the new one.
2887cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
2897cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param n the card given by {@link CarouselCallback#onRequestTexture(int)}
2907cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap the bitmap image to show
2917cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
2925ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setTextureForItem(int n, Bitmap bitmap) {
2937cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setTextureForItem(n, bitmap);
2945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
2955ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
2967cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
2977cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This sets the detail texture that floats above card n. It should only be called in response
2987cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * to {@link CarouselCallback#onRequestDetailTexture(int)}.  Since there's no guarantee
2997cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * that a given texture is still on the screen, replacing this texture should be done
3007cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * by first setting it to null and then waiting for the next
3017cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * {@link CarouselCallback#onRequestDetailTexture(int)} to swap it with the new one.
3027cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
303b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller     * @param n the card to set detail texture for
304b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller     * @param offx an optional offset to apply to the texture (in pixels) from top of detail line
305b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller     * @param offy an optional offset to apply to the texture (in pixels) from top of detail line
306b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller     * @param loffx an optional offset to apply to the line (in pixels) from left edge of card
307b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller     * @param loffy an optional offset to apply to the line (in pixels) from top of screen
3087cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap the bitmap to show as the detail
3097cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
310b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller    public void setDetailTextureForItem(int n, float offx, float offy, float loffx, float loffy,
311b378af500b36226635b6343b1d5009ee9af44fc1Jim Miller            Bitmap bitmap) {
3127cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDetailTextureForItem(n, offx, offy, loffx, loffy, bitmap);
3137cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    }
3147cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller
3157cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
3167cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Sets the bitmap to show on a card when the card draws the very first time.
3177cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Generally, this bitmap will only be seen during the first few frames of startup
3187cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * or when the number of cards are changed.  It can be ignored in most cases,
3197cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * as the cards will generally only be in the loading or loaded state.
3207cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
3217cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap
3227cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
3235ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setDefaultBitmap(Bitmap bitmap) {
3247cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDefaultBitmap(bitmap);
3255ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
3265ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
3277cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
3287cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Sets the bitmap to show on the card while the texture is loading. It is set to this
3297cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * value just before {@link CarouselCallback#onRequestTexture(int)} is called and changed
3307cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * when {@link CarouselView#setTextureForItem(int, Bitmap)} is called. It is shared by all
3317cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * cards.
3327cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
3337cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap
3347cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
3355ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setLoadingBitmap(Bitmap bitmap) {
3367cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setLoadingBitmap(bitmap);
3375ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
3385ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
3397cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
340b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * Sets background to specified color.  If a background texture is specified with
341b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * {@link CarouselView#setBackgroundBitmap(Bitmap)}, then this call has no effect.
342b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     *
343b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * @param red the amount of red
344b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * @param green the amount of green
345b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * @param blue the amount of blue
346b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * @param alpha the amount of alpha
347b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     */
348b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller    public void setBackgroundColor(float red, float green, float blue, float alpha) {
3497cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setBackgroundColor(red, green, blue, alpha);
350b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller    }
351420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller
352b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller    /**
353b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * Can be used to optionally set the background to a bitmap. When set to something other than
354b0f070636c29ad178f4e21306f301fe3d20c183bJim Miller     * null, this overrides {@link CarouselView#setBackgroundColor(Float4)}.
3557cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
3567cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap
3577cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
3589afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller    public void setBackgroundBitmap(Bitmap bitmap) {
3597cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setBackgroundBitmap(bitmap);
3609afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller    }
3619afba8c61f6aff94c68acbfaae1cc58bd28c13eaJim Miller
3627cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
363420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * Can be used to optionally set a "loading" detail bitmap. Typically, this is just a black
364420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * texture with alpha = 0 to allow details to slowly fade in.
365420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     *
366420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * @param bitmap
367420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     */
368420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    public void setDetailLoadingBitmap(Bitmap bitmap) {
3697cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDetailLoadingBitmap(bitmap);
370420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    }
371420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller
372420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    /**
3737cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This texture is used to draw a line from the card alongside the texture detail. The line
3747cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * will be as wide as the texture. It can be used to give the line glow effects as well as
3757cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * allowing other blending effects. It is typically one dimensional, e.g. 3x1.
3767cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
3777cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param bitmap
3787cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
3797cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    public void setDetailLineBitmap(Bitmap bitmap) {
3807cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDetailLineBitmap(bitmap);
3817cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    }
3827cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller
3837cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
3847cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This geometry will be shown when no geometry has been loaded for a given slot. If not set,
385fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * a quad will be drawn in its place. It is shared for all cards. If something other than
386fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * simple planar geometry is used, consider enabling depth test with
387fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * {@link CarouselView#setForceBlendCardsWithZ(boolean)}
3887cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
3897cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param mesh
3907cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
3915ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setDefaultGeometry(Mesh mesh) {
3927cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDefaultGeometry(mesh);
3935ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
3945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
3957cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
3967cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * This is an intermediate version of the object to show while geometry is loading. If not set,
397fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * a quad will be drawn in its place.  It is shared for all cards. If something other than
398fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * simple planar geometry is used, consider enabling depth test with
399fb179e7afd8f02be63061b478b0283e3085fc25fJim Miller     * {@link CarouselView#setForceBlendCardsWithZ(boolean)}
4007cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
4017cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param mesh
4027cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
4035ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setLoadingGeometry(Mesh mesh) {
4047cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setLoadingGeometry(mesh);
4055ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
4065ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
4077cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
4087cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Sets the callback for receiving events from RenderScript.
4097cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
4107cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param callback
4117cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
4125ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setCallback(CarouselCallback callback)
4135ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    {
4147cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setCallback(callback);
4155ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
4165ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
4177cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller    /**
4187cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Sets the startAngle for the Carousel. The start angle is the first position of the first
4197cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * slot draw.  Cards will be drawn from this angle in a counter-clockwise manner around the
4207cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * Carousel.
4217cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     *
4227cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     * @param angle the angle, in radians.
4237cb0068e59dde61ef0e649735199e5ba31c9c6afJim Miller     */
4245ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public void setStartAngle(float angle)
4255ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    {
4267cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setStartAngle(angle);
427a84feeb7e4dc1a75ec6d0b1f2494893987fc3ca3Jack Palevich    }
428a84feeb7e4dc1a75ec6d0b1f2494893987fc3ca3Jack Palevich
429c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setRadius(float radius) {
4307cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setRadius(radius);
431c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
432c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma
433c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setCardRotation(float cardRotation) {
4347cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setCardRotation(cardRotation);
435c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
436c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma
43783d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney    public void setCardsFaceTangent(boolean faceTangent) {
4387cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setCardsFaceTangent(faceTangent);
43983d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney    }
44083d7a5f03e6511372f73e3e4e03a6d403b20125dBryan Mawhinney
441c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setSwaySensitivity(float swaySensitivity) {
4427cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setSwaySensitivity(swaySensitivity);
443c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
444c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma
445c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setFrictionCoefficient(float frictionCoefficient) {
4467cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setFrictionCoefficient(frictionCoefficient);
447c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
448c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma
449c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setDragFactor(float dragFactor) {
4507cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setDragFactor(dragFactor);
451c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
452c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma
453c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    public void setLookAt(float[] eye, float[] at, float[] up) {
4547cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setLookAt(eye, at, up);
455c0bb8af58ae15674178f2db240283719918c6f28Jim Shuma    }
4565ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
457420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    /**
458420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * This sets the number of cards in the distance that will be shown "rezzing in".
459420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * These alpha values will be faded in from the background to the foreground over
460420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * 'n' cards.  A floating point value is used to allow subtly changing the rezzing in
461420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * position.
462420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     *
463420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * @param n the number of cards to rez in.
464420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     */
465420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    public void setRezInCardCount(float n) {
4667cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setRezInCardCount(n);
467420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    }
468420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller
469420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    /**
470420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * This sets the duration (in ms) that a card takes to fade in when loaded via a call
471420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * to {@link CarouselView#setTextureForItem(int, Bitmap)}. The timer starts the
472420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * moment {@link CarouselView#setTextureForItem(int, Bitmap)} is called and continues
473420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * until all of the cards have faded in.  Note: using large values will extend the
474420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * animation until all cards have faded in.
475420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     *
476420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     * @param t
477420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller     */
478420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    public void setFadeInDuration(long t) {
4797cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setFadeInDuration(t);
480420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller    }
481420b44b8b11ec1c309ea130e69a6876325dbfef9Jim Miller
4825ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    @Override
4835ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    protected void onDetachedFromWindow() {
4845ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        super.onDetachedFromWindow();
485c3e94dc22d3c03b514bf3aff41082bfab7aca845Jack Palevich        mRenderScript = null;
486c3e94dc22d3c03b514bf3aff41082bfab7aca845Jack Palevich        if (mRS != null) {
4875ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            mRS = null;
4885ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            destroyRenderScript();
4895ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        }
4907cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma        mController.setRS(mRS, mRenderScript);
4915ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
4925ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
4935ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    @Override
4945ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    protected void onAttachedToWindow() {
4955ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        super.onAttachedToWindow();
4965ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        ensureRenderScript();
4975ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
4985ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
4995ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    @Override
5005ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    public boolean onTouchEvent(MotionEvent event) {
501594ff62c170509c0d69b30f4c2a5e71d4799a9c8Jim Shuma        super.onTouchEvent(event);
5025ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        final int action = event.getAction();
5035ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        final float x = event.getX();
5045ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        final float y = event.getY();
5055ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
5065ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        if (mRenderScript == null) {
5075ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            return true;
5085ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        }
5095ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
5105ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        switch (action) {
5115ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            case MotionEvent.ACTION_DOWN:
5125ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                mTracking = true;
5137cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                mController.onTouchStarted(x, y);
5145ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                break;
5155ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
5165ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            case MotionEvent.ACTION_MOVE:
5175ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                if (mTracking) {
5187cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                    mController.onTouchMoved(x, y);
5195ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                }
5205ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                break;
5215ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
5225ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller            case MotionEvent.ACTION_UP:
5237cc5787b49708f63aeb818bdd06efed3d4229925Jim Shuma                mController.onTouchStopped(x, y);
5245ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                mTracking = false;
5255ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller                break;
5265ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        }
5275ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller
5285ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller        return true;
5295ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller    }
5305ce730797a8a7278dfe19dac8a9460b25675fed0Jim Miller}
531