Debian Codegraph @

utils/fgqcanvas/qml/CanvasFrame.qml

raw
1 import QtQuick 2.0
2 import FlightGear 1.0 as FG
3
4 Item {
5 id: root
6 property bool showDecorations: true
7 property alias canvas: paintedDisplay.canvas
8 property bool showUi: true
9 property bool showMenu: false
10
11
12 Component.onCompleted: {
13 if (canvas) {
14 width = canvas.size.width
15 height = canvas.size.height
16 x = canvas.origin.x
17 y = canvas.origin.y
18 }
19 }
20
21 function saveGeometry()
22 {
23 canvas.origin = Qt.point(x, y )
24 canvas.size = Qt.size(root.width, root.height);
25 }
26
27 Item {
28 id: clipShell
29 anchors.fill: parent
30 clip: true
31
32 // FG.CanvasDisplay {
33 // id: canvasDisplay
34 // anchors.fill: parent
35
36 // onCanvasChanged: {
37 // if (canvas) {
38 // root.width = canvas.size.width
39 // root.height = canvas.size.height
40 // root.x = canvas.origin.x
41 // root.y = canvas.origin.y
42 // }
43 // }
44 // }
45
46 FG.PaintedCanvasDisplay {
47 id: paintedDisplay
48 anchors.fill: parent
49 // canvas: canvasDisplay.canvas
50
51 onCanvasChanged: {
52 if (canvas) {
53 root.width = canvas.size.width
54 root.height = canvas.size.height
55 root.x = canvas.origin.x
56 root.y = canvas.origin.y
57 }
58 }
59 }
60 }
61
62 Rectangle {
63 border.width: 1
64 border.color: "orange"
65 color: "transparent"
66 anchors.centerIn: parent
67 width: parent.width
68 height: parent.height
69 visible: showUi
70
71 MouseArea {
72 anchors.fill: parent
73
74 drag.target: root
75
76 onReleased: {
77 root.saveGeometry();
78 }
79
80 onPressAndHold: {
81 root.showMenu = true;
82 }
83 }
84
85 Rectangle {
86 width: 32
87 height: 32
88 color: "orange"
89 opacity: 0.5
90 anchors.right: parent.right
91 anchors.bottom: parent.bottom
92
93 MouseArea {
94 anchors.fill: parent
95
96 // resizing
97
98 onPositionChanged: {
99 var rootPos = mapToItem(root, mouse.x, mouse.y);
100 // var rootDiff = Qt.point(rootPos.x - root.x,
101 // rootPos.y - root.y);
102
103 root.width = rootPos.x;
104 root.height = rootPos.y;
105 }
106
107 onReleased: {
108 saveGeometry();
109 }
110 }
111 }
112
113 Text {
114 color: "orange"
115 anchors.centerIn: parent
116 text: "Canvas"
117 visible: !root.showMenu
118 }
119
120 Text {
121 anchors.fill: parent
122 verticalAlignment: Text.AlignBottom
123
124 function statusAsString(status)
125 {
126 switch (status) {
127 case FG.CanvasConnection.NotConnected: return "Not connected";
128 case FG.CanvasConnection.Connecting: return "Connecting";
129 case FG.CanvasConnection.Connected: return "Connected";
130 case FG.CanvasConnection.Closed: return "Closed";
131 case FG.CanvasConnection.Reconnecting: return "Re-connecting";
132 case FG.CanvasConnection.Error: return "Error";
133 case FG.CanvasConnection.Snapshot: return "Snapshot";
134 }
135 }
136
137 text: "WS: " + canvas.webSocketUrl + "\n"
138 + "Root:" + canvas.rootPath + "\n"
139 + "Status:" + statusAsString(canvas.status);
140 color: "white"
141
142 }
143
144 CanvasMenu {
145 anchors.fill:parent
146 visible: root.showMenu
147 onMenuBack: root.showMenu = false
148 onCloseCanvas: _application.closeCanvas(canvas);
149 onReconnectCanvas: canvas.reconnect();
150 }
151
152 }
153 }