-
Notifications
You must be signed in to change notification settings - Fork 1
/
Canvas.qml
85 lines (79 loc) · 2.83 KB
/
Canvas.qml
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
import QtQuick 2.0
Item {
property var tilesByIndex: handler.tileMap
property var highlightTheseTiles: []
//property list<Tile> tiles
id: root
Connections{
target: handler
function onTilesToHighlightChanged(theseTiles){
highlightTheseTiles = theseTiles;
}
}
Component.onCompleted: {
// dimensionsWidth = handler.getDimensionsWidth()
// dimensionsHeight = handler.getDimensionsHeight()
console.log("Item completed")
}
// Connections {
// target: handler
// function onSendTilesToBeHighlightedToQml(list) {
// console.log(list)
// highlightTheseTiles = list
// }
// }
//This is the Connection to the grid InitFunction
//The GridView is initialized in the correct way
//If i need this code again:
//let component = Qt.createComponent("Tile.qml")
// //"qmltiles/Image_Index_" + newTileIndex + ".qml")
// let newTile = component.createObject(root, {
// "index": newTileIndex,
// "height": root.height / dimensions,
// "width": root.width / dimensions
// })
anchors.fill: parent
//Click anywhere to start Algorithm
Rectangle {
id: gridBackground
anchors.fill: parent
color: background
GridView {
id: tileGrid
anchors.fill: parent
cellWidth: tileWidthHeightInPixel//root.width / dimensionsWidth
cellHeight: tileWidthHeightInPixel//root.height / dimensionsHeight
clip: true
model: tilesByIndex.length
delegate: Tile {
width: tileWidthHeightInPixel//root.width / dimensionsWidth
height: tileWidthHeightInPixel//root.height / dimensionsHeight
m_index: tilesByIndex[index]
m_highlighted: highlightTheseTiles.indexOf(index) !== -1
}
}
MouseArea {
anchors.fill: parent
onClicked: {
this.visible = false
switchColor.visible = true
highlightTheseTiles = handler.getTilesToHighlight()
handler.startCollapsing()
}
}
MouseArea {
id: switchColor
visible: false
anchors.fill: parent
onClicked: {
if (background === "black") {
background = "white"
lineColor = "black"
} else {
background = "black"
lineColor = "#BADEAFFE"
}
}
}
}
}