~oif-packaging/frame/debian

« back to all changes in this revision

Viewing changes to src/touch.cpp

  • Committer: Daniel d'Andrada
  • Date: 2012-11-08 16:04:20 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: daniel.dandrada@canonical.com-20121108160420-ql9g1jm5t9xifyxs
Tags: upstream-2.4.3
ImportĀ upstreamĀ versionĀ 2.4.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include "frame.h"
26
26
 
 
27
#include <oif/frame_backend.h>
 
28
 
 
29
oif::frame::UFTouch* UFBackendTouch_::GetModifiableTouch() {
 
30
  if (shared_ptr.unique()) {
 
31
    return static_cast<oif::frame::UFTouch*>(shared_ptr.get());
 
32
  } else {
 
33
    /* Make a hard-copy. We don't want other holders of that UFTouch (like frames
 
34
       from previous but still existing events) to get the changes about to be
 
35
       made through this UFBackendTouch. */
 
36
    oif::frame::UFTouch *old_touch =
 
37
      static_cast<oif::frame::UFTouch*>(shared_ptr.get());
 
38
    oif::frame::UFTouch *new_touch = new oif::frame::UFTouch(*old_touch);
 
39
    shared_ptr.reset(new_touch);
 
40
    return new_touch;
 
41
  }
 
42
}
 
43
 
27
44
namespace oif {
28
45
namespace frame {
29
46
 
 
47
UFTouch::UFTouch()
 
48
  : state_(UFTouchStateBegin) {
 
49
  const Value* value;
 
50
 
 
51
  value = new Value(state_);
 
52
  InsertProperty(UFTouchPropertyState, value);
 
53
}
 
54
 
30
55
UFTouch::UFTouch(UFTouchState state, UFTouchId id, float x, float y,
31
56
                 uint64_t time)
32
57
    : id_(id),
205
230
  return start_time;
206
231
}
207
232
 
 
233
UFBackendTouch frame_backend_touch_new()
 
234
{
 
235
  return new UFBackendTouch_(new oif::frame::UFTouch);
 
236
}
 
237
 
 
238
UFTouch frame_backend_touch_get_touch(UFBackendTouch touch)
 
239
{
 
240
  return touch->shared_ptr.get();
 
241
}
 
242
 
 
243
void frame_backend_touch_set_id(UFBackendTouch touch_backend, UFTouchId id)
 
244
{
 
245
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
246
 
 
247
  touch->InsertProperty(UFTouchPropertyId, new oif::frame::Value(id));
 
248
  touch->SetId(id);
 
249
}
 
250
 
 
251
void frame_backend_touch_set_ended(UFBackendTouch touch_backend)
 
252
{
 
253
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
254
 
 
255
  touch->InsertProperty(UFTouchPropertyState, new oif::frame::Value(UFTouchStateEnd));
 
256
  touch->SetState(UFTouchStateEnd);
 
257
}
 
258
 
 
259
void frame_backend_touch_set_window_pos(UFBackendTouch touch_backend, float x, float y)
 
260
{
 
261
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
262
 
 
263
  touch->InsertProperty(UFTouchPropertyWindowX, new oif::frame::Value(x));
 
264
  touch->InsertProperty(UFTouchPropertyWindowY, new oif::frame::Value(y));
 
265
}
 
266
 
 
267
void frame_backend_touch_set_time(UFBackendTouch touch_backend, uint64_t time)
 
268
{
 
269
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
270
 
 
271
  touch->InsertProperty(UFTouchPropertyTime, new oif::frame::Value(time));
 
272
}
 
273
 
 
274
void frame_backend_touch_set_start_time(UFBackendTouch touch_backend,
 
275
                                        uint64_t start_time)
 
276
{
 
277
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
278
 
 
279
  touch->InsertProperty(UFTouchPropertyStartTime, new oif::frame::Value(start_time));
 
280
}
 
281
 
 
282
void frame_backend_touch_set_owned(UFBackendTouch touch_backend, int owned)
 
283
{
 
284
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
285
 
 
286
  touch->InsertProperty(UFTouchPropertyOwned, new oif::frame::Value(owned));
 
287
}
 
288
 
 
289
void frame_backend_touch_set_pending_end(UFBackendTouch touch_backend, int pending_end)
 
290
{
 
291
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
292
 
 
293
  touch->InsertProperty(UFTouchPropertyPendingEnd, new oif::frame::Value(pending_end));
 
294
}
 
295
 
 
296
void frame_backend_touch_set_value(UFBackendTouch touch_backend,
 
297
                                   UFAxisType type, float value)
 
298
{
 
299
  oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch();
 
300
 
 
301
  touch->SetValue(type, value);
 
302
}
 
303
 
208
304
} // extern "C"