on xenial help sign in
first take on adding screens to the spread
commita884ed986c3cb1d0d556e992ab19c7a8d10b0c11 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 16 Jan 2017, 12:23 (10 years ago) parent6be9288
6 files changed+96−7
qml/Stage/Spread/ScreensAndWorkspaces.qml+75 qml/Stage/Spread/Spread.qml+5−5 qml/Stage/Stage.qml+8−2 qml/Stage/SurfaceContainer.qml+2 tests/mocks/Unity/Application/MirSurfaceItem.cpp+5 tests/mocks/Unity/Screens/screens.cpp+1
qml/Stage/Spread/ScreensAndWorkspaces.qmlnew file+75
@@ -0,0 +1,75 @@
1+import QtQuick 2.4
2+import Ubuntu.Components 1.3
3+import Unity.Screens 0.1
4+import Unity.Application 0.1
5+import ".."
6+
7+Item {
8+ id: root
9+
10+
11+ Rectangle { anchors.fill: parent; color: "blue"; opacity: .3 }
12+
13+ Row {
14+ anchors.centerIn: parent
15+ spacing: units.gu(1)
16+
17+ Repeater {
18+ model: Screens
19+
20+ delegate: Rectangle {
21+ id: previewSpace
22+ height: root.height * .5
23+ width: height * 1.4
24+ color: "red"
25+
26+ property int screenWidth: model.geometry.width
27+ property int screenHeight: model.geometry.height
28+
29+ Label {
30+ text: model.name + "," + model.geometry.width
31+ }
32+
33+ Rectangle {
34+ anchors.fill: parent
35+ anchors.topMargin: units.gu(4)
36+
37+ Repeater {
38+ id: topLevelSurfaceRepeater
39+ model: topLevelSurfaceList
40+ delegate: Rectangle {
41+ width: surfaceItem.width
42+ height: surfaceItem.height
43+ x: model.window.position.x * surfaceItem.previewScale
44+ y: model.window.position.y * surfaceItem.previewScale
45+ color: "blue"
46+ z: topLevelSurfaceRepeater.count - index
47+
48+
49+ MirSurfaceItem {
50+ id: surfaceItem
51+
52+ property real previewScale: previewSpace.width / previewSpace.screenWidth
53+
54+ width: implicitWidth * previewScale
55+ height: implicitHeight * previewScale
56+// fillMode: MirSurfaceItem.Stretch
57+ surfaceWidth: -1
58+ surfaceHeight: -1
59+ onImplicitHeightChanged: print("item", surfaceItem, "height changed", implicitHeight)
60+ // surfaceWidth: 100
61+ // surfaceHeight: 100
62+ // requestedHeight: 100// -1// !counterRotate ? root.requestedHeight - d.requestedDecorationHeight : root.requestedWidth
63+ // requestedWidth: 100// -1// !counterRotate ? root.requestedWidth : root.requestedHeight - d.requestedDecorationHeight
64+
65+ // application: model.application
66+ surface: model.window.surface
67+ }
68+ }
69+ }
70+ }
71+
72+ }
73+ }
74+ }
75+}
qml/Stage/Spread/Spread.qml+5−5
@@ -28,10 +28,10 @@ Item {
2828 property var spreadFlickable
2929
3030 // some config options
31− property real contentMargin: 0.16 * root.height
32− property real contentTopMargin: contentMargin
33− property real contentBottomMargin: 0.35 * contentMargin
34− property real windowTitleTopMargin: 3/4 * (contentTopMargin - windowTitle.height)
31+ property real contentMargin: 0.1 * root.height
32+ property real contentTopMargin: contentMargin + root.y + windowTitle.height
33+ property real contentBottomMargin: contentMargin
34+ property real windowTitleTopMargin: contentMargin - windowTitle.height
3535 property int stackItemCount: 3
3636 property real leftRotationAngle: 22
3737 property real rightRotationAngle: 32
@@ -51,7 +51,7 @@ Item {
5151
5252 readonly property real spreadWidth: rightStackXPos - leftStackXPos
5353 readonly property real spreadHeight: root.height
54− readonly property real spreadItemHeight: spreadHeight - contentTopMargin - contentBottomMargin
54+ readonly property real spreadItemHeight: spreadHeight - contentMargin * 2
5555 readonly property real spreadItemWidth: stackHeight
5656
5757 readonly property real dynamicLeftRotationAngle: leftRotationAngle * rotationAngleFactor
qml/Stage/Stage.qml+8−2
@@ -469,7 +469,7 @@ FocusScope {
469469 },
470470 State {
471471 name: "staged"; when: root.mode === "staged"
472− PropertyChanges { target: wallpaper; visible: false }
472+ PropertyChanges { target: wallpaper; visible: priv.focusedAppDelegate && priv.focusedAppDelegate.x === 0 }
473473 },
474474 State {
475475 name: "stagedWithSideStage"; when: root.mode === "stagedWithSideStage"
@@ -546,10 +546,16 @@ FocusScope {
546546 visible: false
547547 }
548548
549+ ScreensAndWorkspaces {
550+ id: screensAndWorkspaces
551+ anchors { left: parent.left; top: parent.top; right: parent.right }
552+ height: parent.height / 3
553+ }
554+
549555 Spread {
550556 id: spreadItem
551557 objectName: "spreadItem"
552− anchors.fill: appContainer
558+ anchors { left: parent.left; bottom: parent.bottom; right: parent.right; top: screensAndWorkspaces.bottom }
553559 leftMargin: root.leftMargin
554560 model: root.topLevelSurfaceList
555561 spreadFlickable: floatingFlickable
qml/Stage/SurfaceContainer.qml+2
@@ -66,6 +66,8 @@ FocusScope {
6666 fillMode: MirSurfaceItem.PadOrCrop
6767 consumesInput: true
6868
69+ onSurfaceChanged: print("surface changed", surface, implicitWidth, implicitHeight)
70+
6971 surfaceWidth: root.requestedWidth
7072 surfaceHeight: root.requestedHeight
7173
tests/mocks/Unity/Application/MirSurfaceItem.cpp+5
@@ -293,6 +293,10 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
293293 connect(m_qmlSurface, &MirSurface::screenshotUrlChanged, this, &MirSurfaceItem::updateScreenshot);
294294 connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
295295 connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
296+ connect(m_qmlSurface, &MirSurface::sizeChanged, this, [this] () {
297+ m_qmlItem->setSize(m_qmlSurface->size());
298+ setImplicitSize(m_qmlSurface->width(), m_qmlSurface->height());
299+ });
296300
297301 QUrl qmlComponentFilePath;
298302 if (!m_qmlSurface->qmlFilePath().isEmpty()) {
@@ -387,6 +391,7 @@ void MirSurfaceItem::updateSurfaceSize()
387391 m_qmlItem->setWidth(m_surfaceWidth);
388392 m_qmlItem->setHeight(m_surfaceHeight);
389393 }
394+ qDebug() << this << "setting implicitsize" << m_surfaceWidth << m_surfaceHeight;
390395 setImplicitSize(m_surfaceWidth, m_surfaceHeight);
391396 }
392397}
tests/mocks/Unity/Screens/screens.cpp+1
@@ -70,6 +70,7 @@ QVariant Screens::data(const QModelIndex &index, int role) const
7070
7171 switch(role) {
7272 case ScreenRole:
73+ qDebug() << "returning" << m_screenList.at(index.row())->qScreen;
7374 return QVariant::fromValue(m_screenList.at(index.row())->qScreen);
7475 case OutputTypeRole:
7576 return m_screenList.at(index.row())->outputTypes;