~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-yakkety-1895

« back to all changes in this revision

Viewing changes to plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml

  • Committer: Bileto Bot
  • Date: 2016-06-20 14:01:03 UTC
  • mfrom: (103.6.69 fingerprint)
  • Revision ID: ci-train-bot@canonical.com-20160620140103-q57lulbze89e6yyd
jonas-drange
* Add components for Fingerprint management.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by  Florian Boucault <florian.boucault@canonical.com>
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
 
 
21
Item {
 
22
    id: segImg
 
23
    property alias textureSource: segmentRenderer.source
 
24
    property alias boxesSource: segmentBoundingBoxes.source
 
25
 
 
26
    implicitWidth: segmentRenderer.implicitWidth
 
27
    implicitHeight: segmentRenderer.implicitHeight
 
28
 
 
29
    // Ready to enroll.
 
30
    signal ready()
 
31
 
 
32
    function enrollMasks(masks) {
 
33
        if (masks && masks.length) {
 
34
            var segments = [];
 
35
            masks.forEach(function (mask, i) {
 
36
                var hitBox = [mask.x, mask.y, mask.width, mask.height];
 
37
                segments = segments.concat(segmentBoundingBoxes.computeIntersections(hitBox));
 
38
            });
 
39
            segmentRenderer.animate(segments);
 
40
        }
 
41
    }
 
42
 
 
43
    SegmentRenderer {
 
44
        id: segmentRenderer
 
45
        segmentsCount: segmentBoundingBoxes.count
 
46
    }
 
47
 
 
48
    SegmentBoundingBoxes {
 
49
        id: segmentBoundingBoxes
 
50
        onReady: segImg.ready()
 
51
    }
 
52
}