Table.qml 2.72 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
    Copyright 2013 Denis Kuplyakov <dener.kup@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

18
import QtQuick 1.1
19
20
21
import "globals.js" as Globals

Item {
22
    id: tableContainer
23
    anchors.fill: parent
24
25
26
27

    property bool isBoardShowingLabels: false
    property string chipsImagePrefix: "chip_bw"
    property int chipsAnimationTime: 25 * 12
28
29

    signal cellClicked(int row, int column)
30
31
32

    function setLegal(row, column, value) {
        board.setLegal(row, column, value);
33
34
    }

35
36
37
    function setChipState(row, column, value) {
        board.setChipState(row, column, value);
    }
38

39
40
41
42
43
44
45
46
    function setHint(row, col, show) {
        board.setHint(row, col, show);
    }

    function setLastMove(row, column, value) {
        board.setLastMove(row, column, value)
    }

Denis Kuplyakov's avatar
Denis Kuplyakov committed
47
    function showPopup(text) {
48
        popup.show(text, "SHOWING");
Denis Kuplyakov's avatar
Denis Kuplyakov committed
49
    }
50

51
    CanvasItem {
52
53
54
55
56
57
58
59
60
61
62
63
        id: table_background
        anchors.fill: parent
        spriteKey: "background"
    }

    Board {
        id: board
        width: Math.min(parent.width, parent.height)
        height: Math.min(parent.width, parent.height)
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter

64
65
66
67
        isShowingLabels: parent.isBoardShowingLabels
        chipsImagePrefix: parent.chipsImagePrefix
        chipsAnimationTime: parent.chipsAnimationTime

68
        onCellClicked: tableContainer.cellClicked(row, column)
69
    }
Denis Kuplyakov's avatar
Denis Kuplyakov committed
70
71
72

    Popup {
        id: popup
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

        anchors.bottom: undefined
        anchors.top: parent.bottom
        anchors.left: parent.left
        anchors.leftMargin: 5
        anchors.bottomMargin: 5

        states: [
            State {
                name: "SHOWING"

                AnchorChanges {
                    target: popup
                    anchors.bottom: popup.parent.bottom
                    anchors.top: undefined
                }
            }
        ]

        transitions: [
            Transition {
                from: ""
                to: "SHOWING"
96
                reversible: true
97
98
99
100
101
102
103

                AnchorAnimation {

                    duration: 300
                }
           }
        ]
Denis Kuplyakov's avatar
Denis Kuplyakov committed
104
    }
105
}