~mpredotka/mini-maker/MiniMakerFA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import QtQuick 2.4
import "Storage.js" as Storage

Rectangle {
    id: root

    width: menuPanelVisible ? main_row.width : 0
    color: "#efefef"

    SequentialAnimation {
        id: flash_anim

        PropertyAction { target: flash; properties: "width"; value: main_window.width }

        PropertyAction { target: flash; property: "height"; value: main_window.height }

        PauseAnimation { duration: 200 }

        PropertyAction { target: flash; properties: "width"; value: 0 }

        PropertyAction { target: flash; property: "height"; value: 0 }
    }

    Row {
        id: main_row

        spacing: units.gu(.5)
        anchors {
            left: parent.left
            verticalCenter: parent.verticalCenter
        }

        PressButton {
            id: home_btn

            width: height
            height: panelHeight
            img_source: "ui/home-btn.svg"
            img_press_source: "ui/home-btn-press.svg"
            img_width: parent.width
            onClicked: {
                menuPanelVisible = false
                isPlayScreen = false
            }
        }

        PressButton {
            id: photo_btn

            visible: menuPanelVisible && play_field.children.length > 0
            width: height
            height: panelHeight
            img_source: "ui/camera-btn.svg"
            img_press_source: "ui/camera-btn-press.svg"
            img_width: parent.width
            ma.onPressed: {
                var stamp = Date.now().toString()
                var backurl = backgroundImg

                flash_anim.start()
                Storage.saveBacks(stamp, backurl)

                for (var i = 0; i < play_field.children.length; i++ ) {
                    var iurl = play_field.children[i].elemImg
                    var ix = play_field.children[i].x
                    var iy = play_field.children[i].y
                    var is = play_field.children[i].scale
                    var iMirror = play_field.children[i].isMirror
                    var iwidth = play_field.children[i].width / units.gu(1)
                    Storage.saveSnaps(stamp, iurl, ix, iy, is, iMirror, iwidth)
                }

                play_field.grabToImage(function(result) {
                    createSnapImage(result.url)
                })
                hasSnaps = true

            }
        }

        PressButton {
            id: reset_btn

            visible: menuPanelVisible && play_field.children.length > 0
            width: height
            height: panelHeight
            img_source: "ui/bin-btn.svg"
            img_press_source: "ui/bin-btn-press.svg"
            img_width: parent.width
            ma.onPressed: {
                for (var i = 0; i < play_field.children.length; i++ ) {
                    play_field.children[i].remove_anim.start()
                    play_field.children[i].destroy(150)
                }
            }
        }
    }

}