~mpredotka/mini-maker/MiniMakerFA

« back to all changes in this revision

Viewing changes to MiniMakerFF/MenuPanel.qml

  • Committer: Michal Predotka
  • Date: 2016-06-22 21:54:31 UTC
  • Revision ID: mpredotka@gmail.com-20160622215431-tqyb17nda9nkkhu3
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.4
 
2
import "Storage.js" as Storage
 
3
 
 
4
Rectangle {
 
5
    id: root
 
6
 
 
7
    width: menuPanelVisible ? main_row.width : 0
 
8
    color: "#efefef"
 
9
 
 
10
    SequentialAnimation {
 
11
        id: flash_anim
 
12
 
 
13
        PropertyAction { target: flash; properties: "width"; value: main_window.width }
 
14
 
 
15
        PropertyAction { target: flash; property: "height"; value: main_window.height }
 
16
 
 
17
        PauseAnimation { duration: 200 }
 
18
 
 
19
        PropertyAction { target: flash; properties: "width"; value: 0 }
 
20
 
 
21
        PropertyAction { target: flash; property: "height"; value: 0 }
 
22
    }
 
23
 
 
24
    Row {
 
25
        id: main_row
 
26
 
 
27
        spacing: units.gu(.5)
 
28
        anchors {
 
29
            left: parent.left
 
30
            verticalCenter: parent.verticalCenter
 
31
        }
 
32
 
 
33
        PressButton {
 
34
            id: home_btn
 
35
 
 
36
            width: height
 
37
            height: panelHeight
 
38
            img_source: "ui/home-btn.svg"
 
39
            img_press_source: "ui/home-btn-press.svg"
 
40
            img_width: parent.width
 
41
            onClicked: {
 
42
                menuPanelVisible = false
 
43
                isPlayScreen = false
 
44
            }
 
45
        }
 
46
 
 
47
        PressButton {
 
48
            id: photo_btn
 
49
 
 
50
            visible: menuPanelVisible && play_field.children.length > 0
 
51
            width: height
 
52
            height: panelHeight
 
53
            img_source: "ui/camera-btn.svg"
 
54
            img_press_source: "ui/camera-btn-press.svg"
 
55
            img_width: parent.width
 
56
            ma.onPressed: {
 
57
                var stamp = Date.now().toString()
 
58
                var backurl = backgroundImg
 
59
 
 
60
                flash_anim.start()
 
61
                Storage.saveBacks(stamp, backurl)
 
62
 
 
63
                for (var i = 0; i < play_field.children.length; i++ ) {
 
64
                    var iurl = play_field.children[i].elemImg
 
65
                    var ix = play_field.children[i].x
 
66
                    var iy = play_field.children[i].y
 
67
                    var is = play_field.children[i].scale
 
68
                    var iMirror = play_field.children[i].isMirror
 
69
                    var iwidth = play_field.children[i].width / units.gu(1)
 
70
                    Storage.saveSnaps(stamp, iurl, ix, iy, is, iMirror, iwidth)
 
71
                }
 
72
 
 
73
                play_field.grabToImage(function(result) {
 
74
                    createSnapImage(result.url)
 
75
                })
 
76
                hasSnaps = true
 
77
 
 
78
            }
 
79
        }
 
80
 
 
81
        PressButton {
 
82
            id: reset_btn
 
83
 
 
84
            visible: menuPanelVisible && play_field.children.length > 0
 
85
            width: height
 
86
            height: panelHeight
 
87
            img_source: "ui/bin-btn.svg"
 
88
            img_press_source: "ui/bin-btn-press.svg"
 
89
            img_width: parent.width
 
90
            ma.onPressed: {
 
91
                for (var i = 0; i < play_field.children.length; i++ ) {
 
92
                    play_field.children[i].remove_anim.start()
 
93
                    play_field.children[i].destroy(150)
 
94
                }
 
95
            }
 
96
        }
 
97
    }
 
98
 
 
99
}
 
100