1pragma ComponentBehavior: Bound
6import QGroundControl.Controls
8// The video sources that play beside the main picture, in a row of tiles: the USB camera or the stream it took the main
9// picture from, then the other streams of the vehicle's cameras. The tiles share the width the row is given, which the
10// row tells the manager the room of: the manager plays no more sources in tiles than fit at a tile's least size.
14 /// The manager whose sources in tiles are shown.
15 property VideoManager videoManager: QGroundControl.videoManager
16 /// The width the row may take.
17 property real maximumWidth: 0
18 /// Whether the tiles are on display: not in a view without room for them, whose sources then play nowhere.
19 property bool shown: true
21 /// The least width of a tile: a smaller picture shows nothing.
22 readonly property real minimumTileWidth: ScreenTools.defaultFontPixelHeight * 4 * root._tileAspectRatio
24 readonly property int _tileCount: root.videoManager.tileCount
25 // Wide-screen tiles, small enough to leave the main picture in view, and smaller where the row has less room.
26 readonly property real _tileAspectRatio: 16 / 9
27 readonly property int _room: Math.max(0, Math.floor((root.maximumWidth + root.spacing)
28 / (root.minimumTileWidth + root.spacing)))
29 readonly property real _tileWidth: root._tileCount === 0 ? 0
30 : Math.max(0, Math.min(ScreenTools.defaultFontPixelHeight * 8 * root._tileAspectRatio,
31 (root.maximumWidth - (root.spacing * (root._tileCount - 1))) / root._tileCount))
33 spacing: ScreenTools.defaultFontPixelWidth
36 // A row that isn't shown, as the picture-in-picture's, leaves the manager with the room the row had: the tiles'
37 // sources stay as they are until the row is back.
39 target: root.videoManager
43 restoreMode: Binding.RestoreNone
47 model: root.videoManager.sources
52 required property VideoStreamController modelData
54 active: tileLoader.modelData.tile
55 // The loader of a source that has no tile would still take a place in the row.
56 visible: tileLoader.modelData.tile
58 sourceComponent: VideoTile {
59 source: tileLoader.modelData
60 videoManager: root.videoManager
62 width: root._tileWidth
63 height: width / root._tileAspectRatio