diff options
| author | Henrik Rydberg <rydberg@bitmath.org> | 2010-08-03 15:01:50 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-05 22:48:38 +0200 |
| commit | d07c43f9f19dc0ee38aaf44947cfc396f437490e (patch) | |
| tree | 2f9af561594a1de5553ba85b69b50bee421d5507 /include/grail-bits.h | |
| parent | 342a43e7b2ceec1dd200bffa24b052fec33f5bdc (diff) | |
Introduce zoom, rotate and combo gestures
Introduce grail_mask bit functions, and add new gestures as separate
functions, referring to the same move model.
Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'include/grail-bits.h')
| -rw-r--r-- | include/grail-bits.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/include/grail-bits.h b/include/grail-bits.h new file mode 100644 index 0000000..ca04c3f --- /dev/null +++ b/include/grail-bits.h | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * grail - Gesture Recognition And Instantiation Library | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010 Canonical Ltd. | ||
| 6 | * | ||
| 7 | * This program is free software: you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation, either version 3 of the License, or (at your | ||
| 10 | * option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | * Authors: | ||
| 21 | * Henrik Rydberg <rydberg@bitmath.org> | ||
| 22 | * | ||
| 23 | ****************************************************************************/ | ||
| 24 | |||
| 25 | #ifndef _GRAIL_BITS_H | ||
| 26 | #define _GRAIL_BITS_H | ||
| 27 | |||
| 28 | typedef unsigned char grail_mask_t; | ||
| 29 | |||
| 30 | static inline void grail_mask_set(grail_mask_t *mask, int i) | ||
| 31 | { | ||
| 32 | mask[i >> 3] |= (1 << (i & 7)); | ||
| 33 | } | ||
| 34 | |||
| 35 | static inline void grail_mask_clear(grail_mask_t *mask, int i) | ||
| 36 | { | ||
| 37 | mask[i >> 3] &= ~(1 << (i & 7)); | ||
| 38 | } | ||
| 39 | |||
| 40 | static inline void grail_mask_modify(grail_mask_t *mask, int i, int v) | ||
| 41 | { | ||
| 42 | if (v) | ||
| 43 | grail_mask_set(mask, i); | ||
| 44 | else | ||
| 45 | grail_mask_clear(mask, i); | ||
| 46 | } | ||
| 47 | |||
| 48 | static inline int grail_mask_get(const grail_mask_t *mask, int i) | ||
| 49 | { | ||
| 50 | return (mask[i >> 3] >> (i & 7)) & 1; | ||
| 51 | } | ||
| 52 | |||
| 53 | void grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); | ||
| 54 | void grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b, int bytes); | ||
| 55 | |||
| 56 | int grail_mask_count(const grail_mask_t *mask, int bytes); | ||
| 57 | int grail_mask_get_first(const grail_mask_t *mask, int bytes); | ||
| 58 | int grail_mask_get_next(int i, const grail_mask_t *mask, int bytes); | ||
| 59 | |||
| 60 | #define grail_mask_foreach(i, mask, bytes) \ | ||
| 61 | for (i = grail_mask_get_first(mask, bytes); \ | ||
| 62 | i >= 0; \ | ||
| 63 | i = grail_mask_get_next(i, mask, bytes)) | ||
| 64 | |||
| 65 | #endif | ||
