blob: 908948ea2aa4c2178f9668bc96f678004bf4b78b [file] [log] [blame]
Jeff Brown2352b972011-04-12 22:39:53 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROID_VIEW_POINTER_ICON_H
18#define _ANDROID_VIEW_POINTER_ICON_H
19
20#include "jni.h"
21
Jun Mukai808196f2015-10-28 16:46:44 -070022#include <vector>
23
Derek Sollenberger9ca5bbe2019-08-14 15:50:59 -040024#include <android/graphics/bitmap.h>
Jeff Brown2352b972011-04-12 22:39:53 -070025#include <utils/Errors.h>
Jeff Brown2352b972011-04-12 22:39:53 -070026
27namespace android {
28
29/* Pointer icon styles.
30 * Must match the definition in android.view.PointerIcon.
31 */
32enum {
33 POINTER_ICON_STYLE_CUSTOM = -1,
34 POINTER_ICON_STYLE_NULL = 0,
35 POINTER_ICON_STYLE_ARROW = 1000,
Jun Mukai1db53972015-09-11 18:08:31 -070036 POINTER_ICON_STYLE_CONTEXT_MENU = 1001,
37 POINTER_ICON_STYLE_HAND = 1002,
38 POINTER_ICON_STYLE_HELP = 1003,
39 POINTER_ICON_STYLE_WAIT = 1004,
40 POINTER_ICON_STYLE_CELL = 1006,
41 POINTER_ICON_STYLE_CROSSHAIR = 1007,
42 POINTER_ICON_STYLE_TEXT = 1008,
43 POINTER_ICON_STYLE_VERTICAL_TEXT = 1009,
44 POINTER_ICON_STYLE_ALIAS = 1010,
45 POINTER_ICON_STYLE_COPY = 1011,
46 POINTER_ICON_STYLE_NO_DROP = 1012,
47 POINTER_ICON_STYLE_ALL_SCROLL = 1013,
48 POINTER_ICON_STYLE_HORIZONTAL_DOUBLE_ARROW = 1014,
49 POINTER_ICON_STYLE_VERTICAL_DOUBLE_ARROW = 1015,
50 POINTER_ICON_STYLE_TOP_RIGHT_DOUBLE_ARROW = 1016,
51 POINTER_ICON_STYLE_TOP_LEFT_DOUBLE_ARROW = 1017,
52 POINTER_ICON_STYLE_ZOOM_IN = 1018,
53 POINTER_ICON_STYLE_ZOOM_OUT = 1019,
54 POINTER_ICON_STYLE_GRAB = 1020,
55 POINTER_ICON_STYLE_GRABBING = 1021,
56
Jeff Brown2352b972011-04-12 22:39:53 -070057 POINTER_ICON_STYLE_SPOT_HOVER = 2000,
58 POINTER_ICON_STYLE_SPOT_TOUCH = 2001,
59 POINTER_ICON_STYLE_SPOT_ANCHOR = 2002,
60};
61
62/*
63 * Describes a pointer icon.
64 */
65struct PointerIcon {
66 inline PointerIcon() {
67 reset();
68 }
69
70 int32_t style;
Derek Sollenberger9ca5bbe2019-08-14 15:50:59 -040071 graphics::Bitmap bitmap;
Jeff Brown2352b972011-04-12 22:39:53 -070072 float hotSpotX;
73 float hotSpotY;
Derek Sollenberger9ca5bbe2019-08-14 15:50:59 -040074 std::vector<graphics::Bitmap> bitmapFrames;
Jun Mukai808196f2015-10-28 16:46:44 -070075 int32_t durationPerFrame;
Jeff Brown2352b972011-04-12 22:39:53 -070076
77 inline bool isNullIcon() {
78 return style == POINTER_ICON_STYLE_NULL;
79 }
80
81 inline void reset() {
82 style = POINTER_ICON_STYLE_NULL;
83 bitmap.reset();
84 hotSpotX = 0;
85 hotSpotY = 0;
Jun Mukai808196f2015-10-28 16:46:44 -070086 bitmapFrames.clear();
87 durationPerFrame = 0;
Jeff Brown2352b972011-04-12 22:39:53 -070088 }
89};
90
91/* Gets a system pointer icon with the specified style. */
92extern jobject android_view_PointerIcon_getSystemIcon(JNIEnv* env,
93 jobject contextObj, int32_t style);
94
95/* Loads the bitmap associated with a pointer icon.
96 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */
97extern status_t android_view_PointerIcon_load(JNIEnv* env,
98 jobject pointerIconObj, jobject contextObj, PointerIcon* outPointerIcon);
99
Jun Mukaid4eaef72015-10-30 15:54:33 -0700100/* Obtain the data of pointerIconObj and put to outPointerIcon. */
101extern status_t android_view_PointerIcon_getLoadedIcon(JNIEnv* env, jobject pointerIconObj,
102 PointerIcon* outPointerIcon);
103
104
Jeff Brown2352b972011-04-12 22:39:53 -0700105/* Loads the bitmap associated with a pointer icon by style.
106 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */
107extern status_t android_view_PointerIcon_loadSystemIcon(JNIEnv* env,
108 jobject contextObj, int32_t style, PointerIcon* outPointerIcon);
109
110} // namespace android
111
112#endif // _ANDROID_OS_POINTER_ICON_H