/* Some defaults */
#define ELM_MOUSE_DEVICE 0
-#define ELM_GESTURE_ZOOM_FACTOR 1.0
-#define ELM_GESTURE_ZOOM_WHEEL_FACTOR 0.05
-#define ELM_GESTURE_ROTATION_TOLERANCE 0.034906585 /* Represents 2 DEG */
/* ELM_GESTURE_NEGATIVE_ANGLE - magic number says we didn't compute this yet */
#define ELM_GESTURE_NEGATIVE_ANGLE (-1.0) /* Magic number */
#define ELM_GESTURE_MOMENTUM_TIMEOUT 50
-#define ELM_GESTURE_LINE_ANGLE_TOLERANCE 0.34906585 /* Represents 20 DEG */
-#define FLICK_MAX_MS 60
#define DBL_CLICK_TIME 400
/* Some Trigo values */
Pointer_Event zoom_mv1;
Evas_Event_Mouse_Wheel *zoom_wheel;
Evas_Coord zoom_base; /* Holds gap between fingers on zoom-start */
- Evas_Coord zoom_tolerance;
+ Evas_Coord zoom_distance_tolerance;
double next_step;
};
typedef struct _Zoom_Type Zoom_Type;
Pointer_Event rotate_mv;
Pointer_Event rotate_st1;
Pointer_Event rotate_mv1;
- double rotate_tolerance;
+ double rotate_angular_tolerance;
double next_step;
};
typedef struct _Rotate_Type Rotate_Type;
Event_History *event_history_list;
int line_min_length;
- Evas_Coord zoom_tolerance;
- Evas_Coord line_tolerance;
- float zoom_wheel_factor; /* mouse wheel zoom steps */
- float factor; /* used for zoom factor */
- double rotate_tolerance;
+ Evas_Coord zoom_distance_tolerance;
+ Evas_Coord line_distance_tolerance;
+ double line_angular_tolerance;
+ double zoom_wheel_factor; /* mouse wheel zoom steps */
+ double zoom_finger_factor; /* used for zoom factor */
+ double rotate_angular_tolerance;
+ unsigned int flick_time_limit_ms;
double zoom_step;
double rotate_step;
Widget_Data *wd = elm_widget_data_get(gesture->obj);
Zoom_Type *st = gesture->data;
Pointer_Event pe, pe1;
+ Evas_Modifier_Mask mask = evas_key_modifier_mask_get(
+ evas_object_evas_get(wd->target), "Control");
+ evas_object_key_ungrab(wd->target, "Control_L", mask, 0);
+ evas_object_key_ungrab(wd->target, "Control_R", mask, 0);
pe.timestamp = pe1.timestamp = 0;
if (pe1.timestamp && (!pe.timestamp))
memcpy(&st->zoom_st1, &pe1, sizeof(Pointer_Event));
- st->zoom_tolerance = wd->zoom_tolerance;
+ st->zoom_distance_tolerance = wd->zoom_distance_tolerance;
st->info.zoom = 1.0;
}
st->info.base_angle = ELM_GESTURE_NEGATIVE_ANGLE;
- st->rotate_tolerance = wd->rotate_tolerance;
+ st->rotate_angular_tolerance = wd->rotate_angular_tolerance;
}
#if defined(DEBUG_GESTURE_LAYER)
printf("%s a=<%f> d=<%f>\n", __func__, (a * 57.295779513), d);
#endif
- if ((d > wd->line_tolerance) || (a > ELM_GESTURE_LINE_ANGLE_TOLERANCE))
-// if (a > ELM_GESTURE_LINE_ANGLE_TOLERANCE)
+ if ((d > wd->line_distance_tolerance) || (a > wd->line_angular_tolerance))
{ /* Broke tolerance: abort line and start a new one */
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
&st->info, EINA_FALSE);
if (t_line->line_angle >= 0)
{ /* Compare angle only with lines with direction defined */
if (fabs(base_angle - t_line->line_angle) >
- ELM_GESTURE_LINE_ANGLE_TOLERANCE)
+ wd->line_angular_tolerance)
lines_parallel = EINA_FALSE;
}
}
return;
}
- if ((g_type == ELM_GESTURE_N_FLICKS) && ((tm_end - tm_start) > FLICK_MAX_MS))
+ if ((g_type == ELM_GESTURE_N_FLICKS) && ((tm_end - tm_start) > wd->flick_time_limit_ms))
{ /* We consider FLICK as a fast line.ABORT if take too long to finish */
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT, &st->info,
EINA_FALSE);
if (st->info.base_angle < 0)
return EINA_FALSE; /* Angle has to be computed first */
- if (st->rotate_tolerance < 0)
+ if (st->rotate_angular_tolerance < 0)
return EINA_TRUE;
- double low = st->info.base_angle - st->rotate_tolerance;
- double high = st->info.base_angle + st->rotate_tolerance;
+ double low = st->info.base_angle - st->rotate_angular_tolerance;
+ double high = st->info.base_angle + st->rotate_angular_tolerance;
double t = st->info.angle;
if (low < 0)
#endif
if ((t < low) || (t > high))
{ /* This marks that roation action has started */
- st->rotate_tolerance = ELM_GESTURE_NEGATIVE_ANGLE;
+ st->rotate_angular_tolerance = ELM_GESTURE_NEGATIVE_ANGLE;
st->info.base_angle = st->info.angle; /* Avoid jump in angle value */
return EINA_TRUE;
}
* @ingroup Elm_Gesture_Layer
*/
/* FIXME change float to double */
-static float
+static double
compute_zoom(Zoom_Type *st, Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
- Evas_Coord x2, Evas_Coord y2, unsigned int tm2, float factor)
+ Evas_Coord x2, Evas_Coord y2, unsigned int tm2, double zoom_finger_factor)
{
- float rt = 1.0;
+ double rt = 1.0;
Evas_Coord diam = get_finger_gap_length(x1, y1, x2, y2,
&st->info.x, &st->info.y);
return st->info.zoom;
}
- if (st->zoom_tolerance)
+ if (st->zoom_distance_tolerance)
{ /* zoom tolerance <> ZERO, means zoom action NOT started yet */
- if (diam < (st->zoom_base - st->zoom_tolerance))
+ if (diam < (st->zoom_base - st->zoom_distance_tolerance))
{ /* avoid jump with zoom value when break tolerance */
- st->zoom_base -= st->zoom_tolerance;
- st->zoom_tolerance = 0;
+ st->zoom_base -= st->zoom_distance_tolerance;
+ st->zoom_distance_tolerance = 0;
}
- if (diam > (st->zoom_base + st->zoom_tolerance))
+ if (diam > (st->zoom_base + st->zoom_distance_tolerance))
{ /* avoid jump with zoom value when break tolerance */
- st->zoom_base += st->zoom_tolerance;
- st->zoom_tolerance = 0;
+ st->zoom_base += st->zoom_distance_tolerance;
+ st->zoom_distance_tolerance = 0;
}
return rt;
/* We use factor only on the difference between gap-base */
/* if gap=120, base=100, we get ((120-100)/100)=0.2*factor */
rt = ((1.0) + ((((float) diam - (float) st->zoom_base) /
- (float) st->zoom_base) * factor));
+ (float) st->zoom_base) * zoom_finger_factor));
#if 0
/* Momentum: zoom per second: (NOT YET SUPPORTED) */
}
/* Using mouse wheel with CTRL for zoom */
- if (st->zoom_wheel || (st->zoom_tolerance == 0))
- { /* when (zoom_wheel == NULL) and (zoom_tolerance == 0)
+ if (st->zoom_wheel || (st->zoom_distance_tolerance == 0))
+ { /* when (zoom_wheel == NULL) and (zoom_distance_tolerance == 0)
we continue a zoom gesture */
force = EINA_TRUE;
s = ELM_GESTURE_STATE_MOVE;
}
else
{ /* On first wheel event, report START */
+ Evas_Modifier_Mask mask = evas_key_modifier_mask_get(
+ evas_object_evas_get(wd->target), "Control");
force = EINA_FALSE;
s = ELM_GESTURE_STATE_START;
+ if (!evas_object_key_grab(wd->target, "Control_L", mask, 0, EINA_FALSE))
+ ERR("Failed to Grabbed CTRL_L");
+ if (!evas_object_key_grab(wd->target, "Control_R", mask, 0, EINA_FALSE))
+ ERR("Failed to Grabbed CTRL_R");
}
- st->zoom_tolerance = 0; /* Cancel tolerance */
+ st->zoom_distance_tolerance = 0; /* Cancel tolerance */
st->zoom_wheel = (Evas_Event_Mouse_Wheel *) event_info;
st->info.x = st->zoom_wheel->canvas.x;
st->info.y = st->zoom_wheel->canvas.y;
if (st->zoom_wheel->z > 0) /* zoom in */
- st->info.zoom += (wd->factor * wd->zoom_wheel_factor);
+ st->info.zoom += (wd->zoom_finger_factor * wd->zoom_wheel_factor);
if (st->zoom_wheel->z < 0) /* zoom out */
- st->info.zoom -= (wd->factor * wd->zoom_wheel_factor);
+ st->info.zoom -= (wd->zoom_finger_factor * wd->zoom_wheel_factor);
if (st->info.zoom < 0.0)
st->info.zoom = 0.0;
st->info.zoom = compute_zoom(st,
st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
- wd->factor);
+ wd->zoom_finger_factor);
break;
}
st->info.zoom = compute_zoom(st,
st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
st->zoom_st1.x, st->zoom_st1.y, st->zoom_st1.timestamp,
- wd->factor);
+ wd->zoom_finger_factor);
break;
}
st->info.zoom = compute_zoom(st,
st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
- wd->factor);
+ wd->zoom_finger_factor);
break;
}
st->info.zoom = compute_zoom(st,
st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
st->zoom_st.x, st->zoom_st.y, st->zoom_st.timestamp,
- wd->factor);
+ wd->zoom_finger_factor);
break;
}
by _zoom_test_reset() to retain finger-down data */
consume_event(wd, event_info, event_type, ev_flag);
if (((st->zoom_wheel) || (st->zoom_base)) &&
- (st->zoom_tolerance == 0))
+ (st->zoom_distance_tolerance == 0))
{
ev_flag = _set_state(gesture_zoom, ELM_GESTURE_STATE_END,
&st->info, EINA_FALSE);
}
- if (!st->zoom_tolerance)
+ if (!st->zoom_distance_tolerance)
if ((event_type == EVAS_CALLBACK_MOUSE_MOVE) ||
(event_type == EVAS_CALLBACK_MULTI_MOVE))
{
consume_event(wd, event_info, event_type, ev_flag);
/* Reset timestamp of finger-up.This is used later
by rotate_test_reset() to retain finger-down data */
- if (st->rotate_tolerance < 0)
+ if (st->rotate_angular_tolerance < 0)
{
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_END,
&st->info, EINA_FALSE);
elm_widget_disable_hook_set(obj, _disable_hook);
wd->target = NULL;
- wd->line_min_length = wd->zoom_tolerance = elm_finger_size_get();
- wd->line_tolerance = elm_finger_size_get() * 3;
- wd->factor = ELM_GESTURE_ZOOM_FACTOR;
- wd->zoom_wheel_factor = ELM_GESTURE_ZOOM_WHEEL_FACTOR ; /* mouse wheel zoom steps */
- wd->rotate_tolerance = ELM_GESTURE_ROTATION_TOLERANCE;
+ wd->line_min_length =_elm_config->glayer_line_min_length * elm_finger_size_get();
+ wd->zoom_distance_tolerance = _elm_config->glayer_zoom_distance_tolerance * elm_finger_size_get();
+ wd->line_distance_tolerance = _elm_config->glayer_line_distance_tolerance * elm_finger_size_get();
+ wd->zoom_finger_factor = _elm_config->glayer_zoom_finger_factor;
+ wd->zoom_wheel_factor = _elm_config->glayer_zoom_wheel_factor; /* mouse wheel zoom steps */
+ wd->rotate_angular_tolerance = _elm_config->glayer_rotate_angular_tolerance;
+ wd->line_angular_tolerance = _elm_config->glayer_line_angular_tolerance;
+ wd->flick_time_limit_ms = _elm_config->glayer_flick_time_limit_ms;
wd->repeat_events = EINA_TRUE;
#if defined(DEBUG_GESTURE_LAYER)
printf("size of Gestures = <%d>\n", sizeof(wd->gesture));
+ printf("initial values:\n\tzoom_finger_factor=<%f>\n\tzoom_distance_tolerance=<%d>\n\tline_min_length=<%d>\n\tline_distance_tolerance=<%d>\n\tzoom_wheel_factor=<%f>\n\trotate_angular_tolerance=<%f>\n\twd->line_angular_tolerance=<%f>\n\twd->flick_time_limit_ms=<%d>\n", wd->zoom_finger_factor, wd->zoom_distance_tolerance, wd->line_min_length, wd->line_distance_tolerance, wd->zoom_wheel_factor, wd->rotate_angular_tolerance, wd->line_angular_tolerance, wd->flick_time_limit_ms);
#endif
memset(wd->gesture, 0, sizeof(wd->gesture));