~chasedouglas/grail/work-in-progress

« back to all changes in this revision

Viewing changes to src/v3/gesture.cpp

  • Committer: Daniel d'Andrada
  • Date: 2012-03-14 19:15:09 UTC
  • mfrom: (196.1.3 lp949916_v3)
  • Revision ID: daniel.dandrada@canonical.com-20120314191509-tcaxcjy9nxshghm5
Merge "Atomic rules: Don't send slices from premature gestures."

+ refactoring of v3/Recognizer
+ regression test

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
      not_owned_(false),
52
52
      recognized_(0),
53
53
      canceled_(false),
54
 
      ended_(false) {
 
54
      ended_(false),
 
55
      keep_slices_(false) {
55
56
}
56
57
 
57
58
/**
83
84
 
84
85
/**
85
86
 * @internal
 
87
 * Add a new set of touches to an existing gesture.
 
88
 */
 
89
void Gesture::AddTouches(TouchSet touch_set) {
 
90
  current_touches_.insert(touch_set.begin(), touch_set.end());
 
91
  unowned_touches_.insert(touch_set.begin(), touch_set.end());
 
92
}
 
93
 
 
94
/**
 
95
 * @internal
 
96
 * Returns whether that gesture contains the given touch.
 
97
 */
 
98
bool Gesture::ContainsTouch(UFTouchId touch_id) const {
 
99
  return current_touches_.find(touch_id) != current_touches_.end();
 
100
}
 
101
 
 
102
/**
 
103
 * @internal
86
104
 * Update a gesture with the passed in frame event and list of modified touches
87
105
 */
88
106
void Gesture::Update(UFEvent frame_event, TouchSet& modified_touches) {
298
316
 * @internal
299
317
 * Flush all pending gesture slices to the client as grail events */
300
318
void Gesture::FlushSlices() {
 
319
  if (keep_slices_)
 
320
    return;
 
321
 
301
322
  while (!slices_.empty()) {
302
323
    UGEvent* event = new UGEvent(slices_.front());
303
324
    slices_.front()->ReferenceGesture();
373
394
  unowned_touches_.clear();
374
395
}
375
396
 
 
397
/**
 
398
 * @internal
 
399
 * If true, FlushSlices() will have no effect. The Gesture will keep all its
 
400
 * slices until this property is disabled again, which will cause all pending
 
401
 * slices to be flushed.
 
402
 *
 
403
 * By default, this property is false. */
 
404
void Gesture::SetKeepSlices(bool keep_slices)
 
405
{
 
406
  if (keep_slices_ && !keep_slices) {
 
407
    keep_slices_ = keep_slices;
 
408
    FlushSlices();
 
409
  } else {
 
410
    keep_slices_ = keep_slices;
 
411
  }
 
412
}
 
413
 
376
414
} // namespace grail
377
415
} // namespace utouch