From 4860c1fcc203f261479efbf37a06d7cb0fe818c1 Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Mon, 10 Apr 2023 19:08:24 +0800 Subject: [PATCH 1/2] add exit split view Signed-off-by: chyyy0213 --- .../scene/session/HWSceneSession.ts | 2 +- .../scene/session/HWSceneSessionManager.ts | 24 ++++++- .../screen/session/HWScreenSession.ts | 31 ++++++++++ .../ets/default/constants/StyleConstants.ts | 4 +- .../src/main/ets/WindowScene/HWDivider.ets | 41 ++++++------ .../main/ets/WindowScene/HWGestureNavBar.ets | 8 ++- .../src/main/ets/WindowScene/HWScene.ets | 62 +++++++++++++++++-- .../main/ets/WindowScene/HWSceneContainer.ets | 40 +++++++++--- .../src/main/ets/WindowScene/HWScenePanel.ets | 2 +- 9 files changed, 175 insertions(+), 39 deletions(-) diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts b/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts index d1c20d82..53ef4619 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts +++ b/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts @@ -26,7 +26,7 @@ import { HWTransitionEffect } from '../../animation/HWTransitionEffect' export class HWSceneSession { readonly sceneInfo: HWSceneInfo readonly session: sceneSessionManager.SceneSession - isActive: boolean = false + isActive: boolean = true translateX: number = 0 translateY: number = 0 scaleX: number = 1 diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts b/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts index 097a365b..7c3c8973 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts +++ b/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts @@ -100,12 +100,13 @@ export class HWSceneSessionManager { Log.showError(TAG, 'Failed to request scene session!'); return; } - + Log.showInfo(TAG,"desktopState: " + screenSession.desktopState ) if (screenSession.desktopState === DesktopState.HOME) { let sceneContainerSession = screenSession.getSceneContainerSession(sceneSession); if (sceneContainerSession === null) { sceneContainerSession = new HWSceneContainerSession(sceneSession, screenSession.bounds); screenSession.addSceneContainerSession(sceneContainerSession); + Log.showInfo(TAG,"start scene add new container session: " + sceneContainerSession.containerId) } this.requestSceneContainerActivation(sceneContainerSession); screenSession.enterAppView(sceneContainerSession); @@ -113,9 +114,11 @@ export class HWSceneSessionManager { let sceneContainerSession = screenSession.getSceneContainerSession(sceneSession); if (sceneContainerSession !== null) { screenSession.removeSceneContainerSession(sceneContainerSession); + Log.showInfo(TAG,"start scene split remove new container session: " + sceneContainerSession.containerId) } let activeSceneContainerSession = screenSession.getActiveSceneContainerSession(); activeSceneContainerSession.addSceneSession(sceneSession); + Log.showInfo(TAG,"start scene split after add active sceneSession container: " + activeSceneContainerSession.containerId) this.requestSceneSessionActivation(sceneSession); screenSession.enterAppView(activeSceneContainerSession); } @@ -199,4 +202,23 @@ export class HWSceneSessionManager { this.requestSceneSessionDestruction(sceneContainerSession.secondarySession); } } + + /** + * Request the scene session exit split. + * @param sceneSession The session of the scene container which exit split. + */ + public requestSceneSessionExitSplit(sceneSession: HWSceneSession) { + if (sceneSession === null) { + Log.showError(TAG, 'The scene session is null!'); + return; + } + let screenSession = HWScreenSessionManager.getInstance().getScreenSession(sceneSession.sceneInfo.screenId); + if (screenSession === null) { + Log.showError(TAG, 'Failed to get main Screen Session!'); + return; + } + screenSession.exitSplitView(sceneSession) + this.requestSceneSessionBackground(sceneSession); + Log.showInfo(TAG, 'requestSceneSessionExitSplit end!'); + } } diff --git a/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts b/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts index b8f2a4a5..fae40883 100644 --- a/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts +++ b/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts @@ -199,4 +199,35 @@ export class HWScreenSession { this.desktopState = DesktopState.SPLIT; this.recentViewParam.init(); } + + public exitSplitView(sceneSession: HWSceneSession) { + const index = this.sceneContainerSessionList.findIndex((item) => { + return item.primarySession === sceneSession || item.secondarySession === sceneSession; + }); + if (index === -1) { + Log.showError(TAG, 'Failed to get scene containerSession with scene session id: ' + + sceneSession.session.persistentId); + return null; + } + let currContainerSession = this.sceneContainerSessionList[index] + if (currContainerSession === null) { + Log.showError(TAG, 'Failed to get scene containerSession with scene session id: ' + + sceneSession.session.persistentId); + return + } + this.desktopState = DesktopState.APP; + this.recentViewParam.init(); + currContainerSession.removeSceneSession(sceneSession) + currContainerSession.init(); + currContainerSession.isSplit = false + let newSceneContainerSession = new HWSceneContainerSession(sceneSession, this.bounds); + newSceneContainerSession.isActive = false; + Log.showInfo(TAG, 'exitSplitView before insert list length: ' + this.sceneContainerSessionList.length); + this.sceneContainerSessionList.splice(index, 0, newSceneContainerSession); + Log.showInfo(TAG, 'exitSplitView after insert list length: ' + this.sceneContainerSessionList.length); + this.sceneContainerSessionList.forEach((container)=>{ + Log.showInfo(TAG, 'after exit containerId: ' + container.containerId + ' active: ' + container.isActive + ' persistentId: ' + container.primarySession?.session.persistentId); + + }); + } } diff --git a/common/src/main/ets/default/constants/StyleConstants.ts b/common/src/main/ets/default/constants/StyleConstants.ts index d6fb0e04..d47f508c 100644 --- a/common/src/main/ets/default/constants/StyleConstants.ts +++ b/common/src/main/ets/default/constants/StyleConstants.ts @@ -67,7 +67,8 @@ export class StyleConstants { static readonly PERCENTAGE_75 = '75%'; static readonly PERCENTAGE_70 = '70%'; static readonly PERCENTAGE_15 = '15%'; - static readonly PERCENTAGE_DIVIDER_HEIGHT = '2%'; + static readonly DIVIDER_HEIGHT = 8; + static readonly DIVIDER_BUTTON_WIDTH = '46vp'; static readonly DEFAULT_APP_IMAGE = '/common/pics/img_app_default.png'; static readonly DEFAULT_DELETE_IMAGE = '/common/pics/ic_public_delete.svg'; static readonly DEFAULT_BACKGROUND_IMAGE_RECENT = '/common/pics/ic_wallpaper_recent.jpg'; @@ -126,6 +127,7 @@ export class StyleConstants { static readonly DEFAULT_SMART_DOCK_MISSION_MERGIN_BOTTOM = 6; static readonly DEFAULT_SMART_DOCK_MISSION_MERGIN_RIGHT = 2; static readonly DEFAULT_SMART_DOCK_MISSION_IMAGE_HEIGHT = 80; + static readonly DEFAULT_SPLIT_EXIT_RATIO = 0.1; //image resources static readonly DEFAULT_FORM_MGR_BACKGROUND_IMAGE = '/common/pics/ic_wallpaper_form_manager.jpg'; diff --git a/product/phone/src/main/ets/WindowScene/HWDivider.ets b/product/phone/src/main/ets/WindowScene/HWDivider.ets index 46e0a7b8..c09c1b82 100644 --- a/product/phone/src/main/ets/WindowScene/HWDivider.ets +++ b/product/phone/src/main/ets/WindowScene/HWDivider.ets @@ -15,6 +15,7 @@ import { HWDividerParam, StyleConstants } from '@ohos/common' import { Log } from '@ohos/common' +import { HWSceneSessionManager, HWSceneContainerSession } from '@ohos/common' import screenSessionManager from '@ohos.screenSessionManager' const TAG = 'HWDivider' @@ -22,26 +23,16 @@ const TAG = 'HWDivider' @Component export struct HWDivider { @Link dividerParam: HWDividerParam + @Link sceneContainerSession: HWSceneContainerSession; screenBounds: screenSessionManager.RRect buildLog1() { - Log.showInfo(TAG, "Action Update " + " priScaleY: " + this.dividerParam.primaryScaleY + " secScaleY: " + this.dividerParam.secondaryScaleY) - Log.showInfo(TAG, "event.offsetY: " + this.dividerParam.translateY) - return true - } - - buildLog2() { - Log.showInfo(TAG, "Action end primaryH: " + parseFloat(this.dividerParam.primaryH) + " secondaryH: " + parseFloat(this.getSecondaryH())) - return true - } - - buildLog3() { - Log.showInfo(TAG, "Action begin primaryH: " + parseFloat(this.dividerParam.primaryH) + " secondaryH: " + parseFloat(this.getSecondaryH())) + Log.showInfo(TAG, "Action begin primaryH: " + parseFloat(this.dividerParam.primaryH)) return true } getSecondaryH(): string { - let str = (100 - parseFloat(this.dividerParam.primaryH) - parseFloat(StyleConstants.PERCENTAGE_DIVIDER_HEIGHT)).toString(); + let str = (100 - parseFloat(this.dividerParam.primaryH) - StyleConstants.DIVIDER_HEIGHT / this.screenBounds.height * 100).toString(); str += "%"; return str; } @@ -50,9 +41,10 @@ export struct HWDivider { // Divider Stack({ alignContent: Alignment.Center }) { Button() - .backgroundColor(Color.White) - .width('25%') - .height('80%') + .responseRegion({ x: 0, y: '-500%', width: '100%', height: '1100%' }) + .backgroundColor('#CCFFFFFF') + .width(StyleConstants.DIVIDER_BUTTON_WIDTH) + .height('50%') .gesture(PanGesture({ distance: 1 }) .onActionStart((event: GestureEvent) => { this.dividerParam.blurRadius = 50 @@ -75,13 +67,26 @@ export struct HWDivider { this.dividerParam.primaryScaleY = 1 this.dividerParam.secondaryScaleY = 1 let beginPrimaryH = this.screenBounds.height * parseFloat(this.dividerParam.primaryH) * 0.01 - this.dividerParam.primaryH = ((beginPrimaryH + event.offsetY) / this.screenBounds.height) * 100 + '%' + let heightRatio = (beginPrimaryH + event.offsetY) / this.screenBounds.height; + this.dividerParam.primaryH = heightRatio * 100 + '%' this.dividerParam.blurRadius = 0 + if (this.buildLog1()){} + if (heightRatio < StyleConstants.DEFAULT_SPLIT_EXIT_RATIO) { + Log.showInfo(TAG, "exit primarySession with ratio: " + heightRatio) + this.dividerParam.init() + HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + this.sceneContainerSession.primarySession); + } else if (heightRatio > (1 - StyleConstants.DEFAULT_SPLIT_EXIT_RATIO)) { + this.dividerParam.init() + Log.showInfo(TAG, "exit secondarySession with ratio: " + heightRatio) + HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + this.sceneContainerSession.secondarySession); + } })) } .translate({ y: this.dividerParam.translateY }) .width('100%') - .height(StyleConstants.PERCENTAGE_DIVIDER_HEIGHT) + .height(StyleConstants.DIVIDER_HEIGHT.toString() + 'vp') .backgroundColor(Color.Black) } } diff --git a/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets b/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets index 145e5658..a351ccd3 100644 --- a/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets +++ b/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets @@ -72,9 +72,11 @@ export struct HWGestureNavBar { HWSceneSessionManager.getInstance().requestSceneContainerBackground(this.sceneContainerSession); this.screenSession.enterHomeView(); } else if (event.offsetY < -200) { - this.dividerParam.primaryH = ((100 - parseFloat(StyleConstants.PERCENTAGE_DIVIDER_HEIGHT)) / 2) + '%'; - this.sceneContainerSession.isSplit = true; - this.screenSession.enterSplitView(); + this.dividerParam.primaryH = ((100 - StyleConstants.DIVIDER_HEIGHT / this.sceneContainerSession.screenBounds.height * 100) / 2) + '%'; + if (!this.sceneContainerSession.isSplit) { + this.sceneContainerSession.isSplit = true; + this.screenSession.enterSplitView(); + } } else if (event.offsetY < -100) { let recentViewSceneSpace = 50; let scrollWidth = diff --git a/product/phone/src/main/ets/WindowScene/HWScene.ets b/product/phone/src/main/ets/WindowScene/HWScene.ets index c9ed3c23..ced254b6 100644 --- a/product/phone/src/main/ets/WindowScene/HWScene.ets +++ b/product/phone/src/main/ets/WindowScene/HWScene.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { HWSceneSession } from '@ohos/common' +import { HWSceneSession, HWSceneSessionManager, HWDividerParam } from '@ohos/common' import { StyleConstants } from '@ohos/common' import { Log } from '@ohos/common' @@ -21,24 +21,74 @@ const TAG = 'HWScene' @Component export struct HWScene { - sceneSession: HWSceneSession + @ObjectLink sceneSession: HWSceneSession + @Link dividerParam: HWDividerParam buildLog(sceneSession: HWSceneSession) { if (sceneSession) { Log.showInfo(TAG, 'HWSceneSession bundle name: ' + sceneSession.sceneInfo.bundleName + ' id: ' + sceneSession.session.persistentId); - return true; } else { Log.showError(TAG, 'HWSceneSession is null'); - return false; } + Log.showInfo(TAG, 'HWScene build: ' + this.sceneSession?.sceneInfo.bundleName + ' id: ' + this.sceneSession?.session.persistentId); + return true } + buildLog1() { + Log.showInfo(TAG, 'HWScene translateX: ' + this.sceneSession?.translateX + ' id: ' + this.sceneSession?.session.persistentId); + return true + } + + buildLog2() { + Log.showInfo(TAG, 'HWScene translateX begin: ' + this.sceneSession?.translateX + ' id: ' + this.sceneSession?.session.persistentId); + return true + } + + buildLog3() { + Log.showInfo(TAG, 'HWScene longPress end--------- '); + return true + } build() { Stack() { - if (this.buildLog(this.sceneSession)) { - HostWindowScene(this.sceneSession.session) + if (this.buildLog(this.sceneSession)) {} + if (this.sceneSession !== null) { + HostWindowScene(this.sceneSession?.session) .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) + Stack() { + } + .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) + .priorityGesture( + GestureGroup(GestureMode.Sequence, + LongPressGesture({ repeat: true }) + .onAction((event: GestureEvent) => { + if(this.buildLog3()) {} + }) + .onActionEnd(() => { + if(this.buildLog3()) {} + }), + PanGesture({ direction: PanDirection.Horizontal }) // when screen is vertical, use Vertical + .onActionStart((event: GestureEvent) => { + if (this.buildLog2()) {} + }) + .onActionUpdate((event: GestureEvent) => { + if (this.buildLog1()) { + } + this.sceneSession.translateX = event.offsetX; + }) + .onActionEnd((event: GestureEvent) => { + if (event.offsetX < -200 || event.offsetX > 200) { + this.dividerParam.init() + Log.showInfo(TAG, "exit split ") + HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + this.sceneSession); + } + this.sceneSession.translateX = 0 + }) + ) + ) } } + .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) + .translate({x: this.sceneSession?.translateX}) } } diff --git a/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets b/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets index 19413b0f..7d36776c 100644 --- a/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets +++ b/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets @@ -14,7 +14,7 @@ */ import curves from '@ohos.curves' -import { HWSceneContainerSession, HWDividerParam } from '@ohos/common' +import { HWSceneContainerSession, HWDividerParam, HWSceneSession } from '@ohos/common' import { HWRecentViewParam } from '@ohos/common'; import { HWScreenSession, DesktopState } from '@ohos/common'; import { HWSceneSessionManager } from '@ohos/common'; @@ -33,11 +33,34 @@ export struct HWSceneContainer { @ObjectLink dividerParam: HWDividerParam; @Link recentViewParam: HWRecentViewParam; + buildLog1() { + Log.showInfo(TAG, " pri Id: " + this.sceneContainerSession.primarySession?.session.persistentId + " sec id: " + this.sceneContainerSession.secondarySession?.session.persistentId + + " containerId: " + this.sceneContainerSession.containerId + ' priH: ' + this.dividerParam.primaryH) + return true + } + + buildLog2(sceneSession : HWSceneSession) { + console.log(TAG + " primary active: "+ JSON.stringify(sceneSession?.isActive) + " id: " + sceneSession.session.persistentId + + " containerId: " + this.sceneContainerSession.containerId + ' primary transX: ' + this.sceneContainerSession.primarySession?.translateX) + return true + } + + buildLog3(sceneSession : HWSceneSession) { + console.log(TAG + "secondary active: "+ JSON.stringify(sceneSession?.isActive) + " id: " + sceneSession.session.persistentId + + " containerId: " + this.sceneContainerSession.containerId) + return true + } + + buildLog4() { + Log.showInfo(TAG, 'container pan gesture') + return true + } build() { Stack() { Column() { - if (this.sceneContainerSession.primarySession) { - HWScene({ sceneSession: this.sceneContainerSession.primarySession }) + if (this.buildLog1()) {} + if (this.sceneContainerSession.primarySession && this.buildLog2(this.sceneContainerSession.primarySession)) { + HWScene({ sceneSession: this.sceneContainerSession.primarySession, dividerParam: $dividerParam }) .width('100%') .height(this.dividerParam.primaryH) .scale({ y: this.dividerParam.primaryScaleY, centerY: 0 }) @@ -46,12 +69,13 @@ export struct HWSceneContainer { // divider if (this.sceneContainerSession.isSplit) { - HWDivider({ dividerParam: $dividerParam, screenBounds: this.sceneContainerSession.screenBounds }) + HWDivider({ dividerParam: $dividerParam, sceneContainerSession: $sceneContainerSession, + screenBounds: this.sceneContainerSession.screenBounds }) } // When primary Exit - if (this.sceneContainerSession.secondarySession) { - HWScene({ sceneSession: this.sceneContainerSession.secondarySession }) + if (this.sceneContainerSession.secondarySession && this.buildLog3(this.sceneContainerSession.secondarySession)) { + HWScene({ sceneSession: this.sceneContainerSession.secondarySession, dividerParam: $dividerParam }) .scale({ y: this.dividerParam.secondaryScaleY, centerY: 0 }) .blur(this.dividerParam.blurRadius) .translate({ y: this.dividerParam.secTransY }) @@ -64,7 +88,7 @@ export struct HWSceneContainer { Stack() { } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) - .hitTestBehavior(HitTestMode.Default) + .hitTestBehavior(HitTestMode.Transparent) .onClick(() => { let activeSceneContainerSession = this.screenSession.getActiveSceneContainerSession(); if (activeSceneContainerSession && @@ -75,7 +99,7 @@ export struct HWSceneContainer { HWSceneSessionManager.getInstance().requestSceneContainerActivation(this.sceneContainerSession); this.screenSession.enterAppView(this.sceneContainerSession); }) - .gesture( + .parallelGesture( PanGesture({ direction: PanDirection.Vertical }) .onActionStart((event: GestureEvent) => { }) diff --git a/product/phone/src/main/ets/WindowScene/HWScenePanel.ets b/product/phone/src/main/ets/WindowScene/HWScenePanel.ets index 5d068b60..d00d3e6a 100644 --- a/product/phone/src/main/ets/WindowScene/HWScenePanel.ets +++ b/product/phone/src/main/ets/WindowScene/HWScenePanel.ets @@ -62,7 +62,7 @@ export struct HWScenePanel { } }, (item: HWSceneContainerSession) => item.containerId.toString()) } - .hitTestBehavior(HitTestMode.None) +// .hitTestBehavior(HitTestMode.None) .translate({ x: this.recentViewParam.translateX, y: this.recentViewParam.translateY }) .scale({ x: this.recentViewParam.scaleX, -- Gitee From e7d4b01f4930492ed49a2c85fb238c5b11113d2e Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Wed, 19 Apr 2023 12:02:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=8B=E5=8A=BF=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=B1=BB=E9=87=8D=E6=9E=84&=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E5=B1=8F=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chyyy0213 --- common/index.ets | 19 +- ...sitionEffect.ts => SCBTransitionEffect.ts} | 34 +- .../WindowScene/common/SCBGestureManager.ts | 113 +++++++ .../ets/WindowScene/common/SCBGestureModel.ts | 116 +++++++ .../scene/session/HWRecentViewParam.ts | 89 ------ .../{HWDividerParam.ts => SCBDividerParam.ts} | 14 +- ...SceneSession.ts => SCBRootSceneSession.ts} | 17 +- ...Session.ts => SCBSceneContainerSession.ts} | 22 +- .../{HWSceneInfo.ts => SCBSceneInfo.ts} | 6 +- .../{HWSceneSession.ts => SCBSceneSession.ts} | 24 +- ...onManager.ts => SCBSceneSessionManager.ts} | 74 ++--- ...HWScreenSession.ts => SCBScreenSession.ts} | 69 ++--- ...nManager.ts => SCBScreenSessionManager.ts} | 24 +- .../ets/default/constants/StyleConstants.ts | 1 + .../default/manager/LauncherAbilityManager.ts | 8 +- .../src/main/ets/MainAbility/MainAbility.ts | 8 +- .../{HWDesktop.ets => SCBDesktop.ets} | 290 +++++++++--------- .../{HWDivider.ets => SCBDivider.ets} | 16 +- ...GestureNavBar.ets => SCBGestureNavBar.ets} | 51 +-- .../WindowScene/{HWScene.ets => SCBScene.ets} | 33 +- ...eneContainer.ets => SCBSceneContainer.ets} | 52 ++-- .../{HWScenePanel.ets => SCBScenePanel.ets} | 85 ++--- .../{HWScreen.ets => SCBScreen.ets} | 24 +- .../{HWSystemUi.ets => SCBSystemUi.ets} | 4 +- .../{HWWallpaper.ets => SCBWallpaper.ets} | 48 +-- .../phone/src/main/ets/pages/EntryView.ets | 17 +- 26 files changed, 697 insertions(+), 561 deletions(-) rename common/src/main/ets/WindowScene/animation/{HWTransitionEffect.ts => SCBTransitionEffect.ts} (54%) create mode 100644 common/src/main/ets/WindowScene/common/SCBGestureManager.ts create mode 100644 common/src/main/ets/WindowScene/common/SCBGestureModel.ts delete mode 100644 common/src/main/ets/WindowScene/scene/session/HWRecentViewParam.ts rename common/src/main/ets/WindowScene/scene/session/{HWDividerParam.ts => SCBDividerParam.ts} (83%) rename common/src/main/ets/WindowScene/scene/session/{HWRootSceneSession.ts => SCBRootSceneSession.ts} (72%) rename common/src/main/ets/WindowScene/scene/session/{HWSceneContainerSession.ts => SCBSceneContainerSession.ts} (82%) rename common/src/main/ets/WindowScene/scene/session/{HWSceneInfo.ts => SCBSceneInfo.ts} (87%) rename common/src/main/ets/WindowScene/scene/session/{HWSceneSession.ts => SCBSceneSession.ts} (65%) rename common/src/main/ets/WindowScene/scene/session/{HWSceneSessionManager.ts => SCBSceneSessionManager.ts} (73%) rename common/src/main/ets/WindowScene/screen/session/{HWScreenSession.ts => SCBScreenSession.ts} (77%) rename common/src/main/ets/WindowScene/screen/session/{HWScreenSessionManager.ts => SCBScreenSessionManager.ts} (84%) rename product/phone/src/main/ets/WindowScene/{HWDesktop.ets => SCBDesktop.ets} (96%) rename product/phone/src/main/ets/WindowScene/{HWDivider.ets => SCBDivider.ets} (88%) rename product/phone/src/main/ets/WindowScene/{HWGestureNavBar.ets => SCBGestureNavBar.ets} (44%) rename product/phone/src/main/ets/WindowScene/{HWScene.ets => SCBScene.ets} (65%) rename product/phone/src/main/ets/WindowScene/{HWSceneContainer.ets => SCBSceneContainer.ets} (71%) rename product/phone/src/main/ets/WindowScene/{HWScenePanel.ets => SCBScenePanel.ets} (66%) rename product/phone/src/main/ets/WindowScene/{HWScreen.ets => SCBScreen.ets} (66%) rename product/phone/src/main/ets/WindowScene/{HWSystemUi.ets => SCBSystemUi.ets} (97%) rename product/phone/src/main/ets/WindowScene/{HWWallpaper.ets => SCBWallpaper.ets} (93%) diff --git a/common/index.ets b/common/index.ets index 80b6cda6..962fcb50 100644 --- a/common/index.ets +++ b/common/index.ets @@ -87,12 +87,13 @@ export { DragArea } from './src/main/ets/default/interface/DragArea' export { DragItemPosition } from './src/main/ets/default/interface/DragItemPosition' // Window scene -export { HWRootSceneSession } from './src/main/ets/WindowScene/scene/session/HWRootSceneSession' -export { HWSceneInfo } from './src/main/ets/WindowScene/scene/session/HWSceneInfo' -export { HWDividerParam } from './src/main/ets/WindowScene/scene/session/HWDividerParam' -export { HWRecentViewParam } from './src/main/ets/WindowScene/scene/session/HWRecentViewParam' -export { HWSceneSession } from './src/main/ets/WindowScene/scene/session/HWSceneSession' -export { HWSceneSessionManager } from './src/main/ets/WindowScene/scene/session/HWSceneSessionManager' -export { HWScreenSession, DesktopState, SceneContainerSessionArray } from './src/main/ets/WindowScene/screen/session/HWScreenSession' -export { HWScreenSessionManager } from './src/main/ets/WindowScene/screen/session/HWScreenSessionManager' -export { HWSceneContainerSession } from './src/main/ets/WindowScene/scene/session/HWSceneContainerSession' \ No newline at end of file +export { SCBRootSceneSession } from './src/main/ets/WindowScene/scene/session/SCBRootSceneSession' +export { SCBSceneInfo } from './src/main/ets/WindowScene/scene/session/SCBSceneInfo' +export { SCBDividerParam } from './src/main/ets/WindowScene/scene/session/SCBDividerParam' +export { SCBSceneSession } from './src/main/ets/WindowScene/scene/session/SCBSceneSession' +export { SCBSceneSessionManager } from './src/main/ets/WindowScene/scene/session/SCBSceneSessionManager' +export { SCBScreenSession, DesktopState, SceneContainerSessionArray } from './src/main/ets/WindowScene/screen/session/SCBScreenSession' +export { SCBScreenSessionManager } from './src/main/ets/WindowScene/screen/session/SCBScreenSessionManager' +export { SCBSceneContainerSession } from './src/main/ets/WindowScene/scene/session/SCBSceneContainerSession' +export { SCBGestureModel } from './src/main/ets/WindowScene/common/SCBGestureModel' +export { SCBGestureManager } from './src/main/ets/WindowScene/common/SCBGestureManager' diff --git a/common/src/main/ets/WindowScene/animation/HWTransitionEffect.ts b/common/src/main/ets/WindowScene/animation/SCBTransitionEffect.ts similarity index 54% rename from common/src/main/ets/WindowScene/animation/HWTransitionEffect.ts rename to common/src/main/ets/WindowScene/animation/SCBTransitionEffect.ts index a369f67a..70ff532e 100644 --- a/common/src/main/ets/WindowScene/animation/HWTransitionEffect.ts +++ b/common/src/main/ets/WindowScene/animation/SCBTransitionEffect.ts @@ -21,17 +21,17 @@ export class SharedTransitionParam { } // TODO Transition configuration -export class HWTransitionEffect { - static DEFAULT: HWTransitionEffect +export class SCBTransitionEffect { + static DEFAULT: SCBTransitionEffect - static APPEAR_FROM_ITEM: HWTransitionEffect - static APPEAR_FROM_ITEM_PC: HWTransitionEffect - static APPEAR_FROM_NONE: HWTransitionEffect - static APPEAR_FROM_SCENE: HWTransitionEffect + static APPEAR_FROM_ITEM: SCBTransitionEffect + static APPEAR_FROM_ITEM_PC: SCBTransitionEffect + static APPEAR_FROM_NONE: SCBTransitionEffect + static APPEAR_FROM_SCENE: SCBTransitionEffect - static DISAPPEAR_FROM_SCENE: HWTransitionEffect - static DISAPPEAR_TO_HOME: HWTransitionEffect - static DISAPPEAR_TO_HOME_PC: HWTransitionEffect + static DISAPPEAR_FROM_SCENE: SCBTransitionEffect + static DISAPPEAR_TO_HOME: SCBTransitionEffect + static DISAPPEAR_TO_HOME_PC: SCBTransitionEffect constructor() {} @@ -51,11 +51,11 @@ export class HWTransitionEffect { animationParam: AnimateParam } -HWTransitionEffect.DEFAULT = new HWTransitionEffect() -HWTransitionEffect.APPEAR_FROM_ITEM = new HWTransitionEffect() -HWTransitionEffect.APPEAR_FROM_NONE = new HWTransitionEffect() -HWTransitionEffect.APPEAR_FROM_SCENE = new HWTransitionEffect() -HWTransitionEffect.APPEAR_FROM_ITEM_PC = new HWTransitionEffect() -HWTransitionEffect.DISAPPEAR_FROM_SCENE = new HWTransitionEffect() -HWTransitionEffect.DISAPPEAR_TO_HOME = new HWTransitionEffect() -HWTransitionEffect.DISAPPEAR_TO_HOME_PC = new HWTransitionEffect() +SCBTransitionEffect.DEFAULT = new SCBTransitionEffect() +SCBTransitionEffect.APPEAR_FROM_ITEM = new SCBTransitionEffect() +SCBTransitionEffect.APPEAR_FROM_NONE = new SCBTransitionEffect() +SCBTransitionEffect.APPEAR_FROM_SCENE = new SCBTransitionEffect() +SCBTransitionEffect.APPEAR_FROM_ITEM_PC = new SCBTransitionEffect() +SCBTransitionEffect.DISAPPEAR_FROM_SCENE = new SCBTransitionEffect() +SCBTransitionEffect.DISAPPEAR_TO_HOME = new SCBTransitionEffect() +SCBTransitionEffect.DISAPPEAR_TO_HOME_PC = new SCBTransitionEffect() diff --git a/common/src/main/ets/WindowScene/common/SCBGestureManager.ts b/common/src/main/ets/WindowScene/common/SCBGestureManager.ts new file mode 100644 index 00000000..e87ebf60 --- /dev/null +++ b/common/src/main/ets/WindowScene/common/SCBGestureManager.ts @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import screenSessionManager from '@ohos.screenSessionManager' +import { Log } from '../../default/utils/Log' +import { SCBGestureModel, DesktopState } from './SCBGestureModel' + +const TAG = 'SCBGestureManager' + +/** + * Gesture manager. + */ +//@Observed +export class SCBGestureManager { + gestureModel : SCBGestureModel = new SCBGestureModel() + mainScreenBounds: screenSessionManager.RRect = { + left: 0, + top: 0, + width: 0, + height: 0, + radius: 0 + }; + rotation: number; + + private constructor() { + this.gestureModel.init() + this.gestureModel = AppStorage.SetAndLink("gestureModel", this.gestureModel).get() + } + + /** + * Get the singleton of the screen session manager. + */ + static getInstance(): SCBGestureManager { + if (!globalThis.SCBGestureManagerInstance) { + Log.showInfo(TAG, "SCBGestureManager Initialize is called!") + globalThis.SCBGestureManagerInstance = new SCBGestureManager() + } + + return globalThis.SCBGestureManagerInstance + } + + public updateMainScreenBounds(bounds: screenSessionManager.RRect, rotation: number) { + this.mainScreenBounds = bounds + this.rotation = rotation + // todo: change recent when screen bounds change + } + + public updateDesktopState(state: DesktopState) { + Log.showInfo(TAG, `UpdateDesktopState from ${this.gestureModel.desktopState} to ${state}`) + this.gestureModel.desktopState = state; + } + + public initRecentViewParam() { + this.gestureModel.init(); + } + + public setRecentViewParamOnActionStart(listLen: number) { + this.gestureModel.margin = 50; + let scrollWidth = listLen * this.mainScreenBounds.width + (listLen - 1) * this.gestureModel.margin; + this.gestureModel.offsetX = this.mainScreenBounds.width - scrollWidth; + this.gestureModel.centerX = (1 - this.mainScreenBounds.width / 2 / scrollWidth) * 100 + '%'; + this.gestureModel.centerY = '100%'; + } + + public setRecentViewParamOnActionUpdate(offsetX: number, offsetY: number) { + Log.showInfo(TAG, `Update offsetX: ${offsetX} offsetY: ${offsetY} scaleX:${this.gestureModel.scaleX}}`) + let translateRatio = 0.6 * Math.pow(this.gestureModel.scaleX, 2) + 0.4; + this.gestureModel.translateX = offsetX * translateRatio; + if (1 + offsetY / this.mainScreenBounds.height * 1.3 > 0.25) { + this.gestureModel.translateY = offsetY; + } + Log.showInfo(TAG, `Update translateX: ${this.gestureModel.translateX} translateY: ${this.gestureModel.translateY}`) + this.gestureModel.scaleX = + 1 + this.gestureModel.translateY / this.mainScreenBounds.height * 1.3; + this.gestureModel.scaleX = Math.max(this.gestureModel.scaleX, 0.25); + this.gestureModel.scaleX = Math.min(this.gestureModel.scaleX, 1); + this.gestureModel.scaleY = this.gestureModel.scaleX; + } + + public setRecentViewParamOnActionEnd(listLen: number) { + let recentViewSceneSpace = 50; + let scrollWidth = listLen * this.mainScreenBounds.width + (listLen - 1) * recentViewSceneSpace; + this.gestureModel.offsetX = this.mainScreenBounds.width - scrollWidth; + } + + public setRecentView() { + this.gestureModel.desktopState = DesktopState.RECENT; + this.gestureModel.translateX = 0; + this.gestureModel.translateY = 0; + this.gestureModel.scaleX = 1; + this.gestureModel.scaleY = 1; + this.gestureModel.centerX = '50%'; + this.gestureModel.centerY = '50%'; + this.gestureModel.borderRadius = 35; + this.gestureModel.offsetX = 0; + this.gestureModel.offsetY = 0; + this.gestureModel.width = "70%" + this.gestureModel.height = "70%" + this.gestureModel.margin = 0 + } +} diff --git a/common/src/main/ets/WindowScene/common/SCBGestureModel.ts b/common/src/main/ets/WindowScene/common/SCBGestureModel.ts new file mode 100644 index 00000000..c86b766d --- /dev/null +++ b/common/src/main/ets/WindowScene/common/SCBGestureModel.ts @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import screenSessionManager from '@ohos.screenSessionManager' +import { SCBSceneSession } from '../scene/session/SCBSceneSession' +import { SCBSceneContainerSession } from '../scene/session/SCBSceneContainerSession' +import { Log } from '../../default/utils/Log' +import { SCBSceneInfo } from '../scene/session/SCBSceneInfo' +import { SCBDividerParam } from '../scene/session/SCBDividerParam' + +const TAG = 'SCBGestureModel' + +export enum DesktopState { + HOME, + APP, + SPLIT, + RECENT, + DRAGGING +} + +/** + * Manage info of gesture + */ +@Observed +export class SCBGestureModel { + desktopState: DesktopState = DesktopState.HOME; + /** + * translateX of RecentView + */ + translateX: number = 0; + + /** + * translateY of RecentView + */ + translateY: number = 0; + + /** + * scaleX of RecentView + */ + scaleX: number = 1; + + /** + * scaleY of RecentView + */ + scaleY: number = 1; + + /** + * centerX of RecentView + */ + centerX: number | string = '50%'; + + /** + * centerY of RecentView + */ + centerY: number | string = '50%'; + + /** + * offsetX of RecentView + */ + offsetX: number = 0; + + /** + * offsetY of RecentView + */ + offsetY: number = 0; + + /** + * borderRadius of scene + */ + borderRadius: number | string = 0; + + height: number | string = '100%'; + + width: number | string = '100%'; + + margin: number | string = 0; + + /** + * init properties of RecentView + */ + public init() { + Log.showInfo(TAG, 'recent view param init is called') + this.translateX = 0; + this.translateY = 0; + this.scaleX = 1; + this.scaleY = 1; + this.centerX = '50%'; + this.centerY = '50%'; + this.offsetX = 0; + this.offsetY = 0; + this.borderRadius = 0; + this.height = "100%" + this.width = "100%" + this.margin = 0 + } + + /** + * Constructor. + * @param session Session of the screen + */ + constructor() { + } + +} diff --git a/common/src/main/ets/WindowScene/scene/session/HWRecentViewParam.ts b/common/src/main/ets/WindowScene/scene/session/HWRecentViewParam.ts deleted file mode 100644 index f7eae59e..00000000 --- a/common/src/main/ets/WindowScene/scene/session/HWRecentViewParam.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * param of RecentView - */ -@Observed -export class HWRecentViewParam { - /** - * translateX of RecentView - */ - translateX: number = 0; - - /** - * translateY of RecentView - */ - translateY: number = 0; - - /** - * scaleX of RecentView - */ - scaleX: number = 1; - - /** - * scaleY of RecentView - */ - scaleY: number = 1; - - /** - * centerX of RecentView - */ - centerX: number | string = '50%'; - - /** - * centerY of RecentView - */ - centerY: number | string = '50%'; - - /** - * offsetX of RecentView - */ - offsetX: number = 0; - - /** - * offsetY of RecentView - */ - offsetY: number = 0; - - /** - * borderRadius of scene - */ - borderRadius: number | string = 0; - - height: number | string = '100%'; - - width: number | string = '100%'; - - margin: number | string = 0; - - /** - * init properties of RecentView - */ - public init() { - this.translateX = 0; - this.translateY = 0; - this.scaleX = 1; - this.scaleY = 1; - this.centerX = '50%'; - this.centerY = '50%'; - this.offsetX = 0; - this.offsetY = 0; - this.borderRadius = 0; - this.height = "100%" - this.width = "100%" - this.margin = 0 - } -} diff --git a/common/src/main/ets/WindowScene/scene/session/HWDividerParam.ts b/common/src/main/ets/WindowScene/scene/session/SCBDividerParam.ts similarity index 83% rename from common/src/main/ets/WindowScene/scene/session/HWDividerParam.ts rename to common/src/main/ets/WindowScene/scene/session/SCBDividerParam.ts index 44694fb1..238bdca9 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWDividerParam.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBDividerParam.ts @@ -13,10 +13,10 @@ * limitations under the License. */ /** - * param of HWDivider + * param of SCBDivider */ @Observed -export class HWDividerParam { +export class SCBDividerParam { /** * translateX of Divider */ @@ -38,26 +38,26 @@ export class HWDividerParam { scaleY: number = 1 /** - * scaleY of primary HWScene + * scaleY of primary SCBScene */ primaryScaleY : number = 1 /** - * scaleY of secondary HWScene + * scaleY of secondary SCBScene */ secondaryScaleY : number = 1 /** - * Height of primary HWScene + * Height of primary SCBScene */ primaryH : string = '100%' /** - * translateY of secondary HWScene + * translateY of secondary SCBScene */ secTransY: number = 0 /** - * blurRadius of primary/secondary HWScene when drag divider + * blurRadius of primary/secondary SCBScene when drag divider */ blurRadius : number = 0 diff --git a/common/src/main/ets/WindowScene/scene/session/HWRootSceneSession.ts b/common/src/main/ets/WindowScene/scene/session/SCBRootSceneSession.ts similarity index 72% rename from common/src/main/ets/WindowScene/scene/session/HWRootSceneSession.ts rename to common/src/main/ets/WindowScene/scene/session/SCBRootSceneSession.ts index 8cb92aeb..032db3a0 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWRootSceneSession.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBRootSceneSession.ts @@ -15,23 +15,26 @@ import sceneSessionManager from '@ohos.sceneSessionManager' -import { HWSceneInfo } from './HWSceneInfo' -import { HWSceneSessionManager } from './HWSceneSessionManager' -import { HWScreenSessionManager } from '../../screen/session/HWScreenSessionManager' -import { HWTransitionEffect } from '../../animation/HWTransitionEffect' +import { SCBSceneInfo } from './SCBSceneInfo' +import { SCBSceneSessionManager } from './SCBSceneSessionManager' +import { SCBScreenSessionManager } from '../../screen/session/SCBScreenSessionManager' +import { SCBGestureManager } from '../../common/SCBGestureManager' import ServiceExtensionContext from 'application/ServiceExtensionContext' /** * Scene session of the root scene. */ -export class HWRootSceneSession { +export class SCBRootSceneSession { readonly session: sceneSessionManager.RootSceneSession + usrId: number = -1 + readonly gestureManager: SCBGestureManager constructor() { this.session = sceneSessionManager.getRootSceneSession() this.session.on('pendingSceneSessionActivation', (info) => { this.onPendingSceneSessionActivation(info) }) + this.gestureManager = SCBGestureManager.getInstance() } /** @@ -44,7 +47,7 @@ export class HWRootSceneSession { } private onPendingSceneSessionActivation(sceneInfo: sceneSessionManager.SceneInfo): void { - let hwSceneInfo = new HWSceneInfo(sceneInfo.bundleName, sceneInfo.abilityName); - HWSceneSessionManager.getInstance().startScene(hwSceneInfo) + let info = new SCBSceneInfo(sceneInfo.bundleName, sceneInfo.abilityName); + SCBSceneSessionManager.getInstance().startScene(info) } } diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneContainerSession.ts b/common/src/main/ets/WindowScene/scene/session/SCBSceneContainerSession.ts similarity index 82% rename from common/src/main/ets/WindowScene/scene/session/HWSceneContainerSession.ts rename to common/src/main/ets/WindowScene/scene/session/SCBSceneContainerSession.ts index f3254147..29d2d239 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneContainerSession.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBSceneContainerSession.ts @@ -14,22 +14,22 @@ */ import screenSessionManager from '@ohos.screenSessionManager' -import { HWSceneSession } from './HWSceneSession' -import { HWDividerParam } from './HWDividerParam' +import { SCBSceneSession } from './SCBSceneSession' +import { SCBDividerParam } from './SCBDividerParam' import { Log } from '../../../default/utils/Log' -const TAG = 'HWSceneContainerSession' +const TAG = 'SCBSceneContainerSession' /** * Session of a scene. */ @Observed -export class HWSceneContainerSession { +export class SCBSceneContainerSession { readonly containerId: number; - primarySession: HWSceneSession = null; - secondarySession: HWSceneSession = null; + primarySession: SCBSceneSession = null; + secondarySession: SCBSceneSession = null; screenBounds: screenSessionManager.RRect; - dividerParam: HWDividerParam = new HWDividerParam(); + dividerParam: SCBDividerParam = new SCBDividerParam(); isSplit: boolean = false; isActive: boolean = false; translateX: number = 0; @@ -44,8 +44,8 @@ export class HWSceneContainerSession { /** * Constructor. */ - constructor(primarySession: HWSceneSession, screenBounds: screenSessionManager.RRect) { - this.containerId = ++HWSceneContainerSession.gContainerId; + constructor(primarySession: SCBSceneSession, screenBounds: screenSessionManager.RRect) { + this.containerId = ++SCBSceneContainerSession.gContainerId; this.primarySession = primarySession; this.secondarySession = null; this.screenBounds = screenBounds; @@ -55,7 +55,7 @@ export class HWSceneContainerSession { * Add scene session to this container. * @param sceneSession The scene session to add. */ - public addSceneSession(sceneSession: HWSceneSession) { + public addSceneSession(sceneSession: SCBSceneSession) { if (sceneSession === null) { Log.showError(TAG, 'Add scene session failed as scene session is null!'); return; @@ -79,7 +79,7 @@ export class HWSceneContainerSession { * Remove scene session from this container. * @param sceneSession The scene session to remove. */ - public removeSceneSession(sceneSession: HWSceneSession) { + public removeSceneSession(sceneSession: SCBSceneSession) { if (sceneSession === null) { Log.showError(TAG, 'Remove scene session failed as scene session is null!'); return; diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneInfo.ts b/common/src/main/ets/WindowScene/scene/session/SCBSceneInfo.ts similarity index 87% rename from common/src/main/ets/WindowScene/scene/session/HWSceneInfo.ts rename to common/src/main/ets/WindowScene/scene/session/SCBSceneInfo.ts index 42a74e14..872cb2e3 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneInfo.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBSceneInfo.ts @@ -13,12 +13,12 @@ * limitations under the License. */ -import { HWTransitionEffect } from '../../animation/HWTransitionEffect' +import { SCBTransitionEffect } from '../../animation/SCBTransitionEffect' /** * Information of a scene. */ -export class HWSceneInfo { +export class SCBSceneInfo { /** * Bundle name. */ @@ -42,7 +42,7 @@ export class HWSceneInfo { /** * Transition effect when scene appearing or disappearing. */ - transitionEffect: HWTransitionEffect = HWTransitionEffect.DEFAULT + transitionEffect: SCBTransitionEffect = SCBTransitionEffect.DEFAULT constructor(bundleName: string, abilityName: string) { this.bundleName = bundleName diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts b/common/src/main/ets/WindowScene/scene/session/SCBSceneSession.ts similarity index 65% rename from common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts rename to common/src/main/ets/WindowScene/scene/session/SCBSceneSession.ts index 53ef4619..9fc0d3c1 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneSession.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBSceneSession.ts @@ -14,17 +14,17 @@ */ import sceneSessionManager from '@ohos.sceneSessionManager' -import { HWSceneInfo } from './HWSceneInfo' -import { HWSceneSessionManager } from './HWSceneSessionManager' -import { HWScreenSessionManager } from '../../screen/session/HWScreenSessionManager' -import { HWTransitionEffect } from '../../animation/HWTransitionEffect' +import { SCBSceneInfo } from './SCBSceneInfo' +import { SCBSceneSessionManager } from './SCBSceneSessionManager' +import { SCBScreenSessionManager } from '../../screen/session/SCBScreenSessionManager' +import { SCBTransitionEffect } from '../../animation/SCBTransitionEffect' /** * Session of a scene. */ @Observed -export class HWSceneSession { - readonly sceneInfo: HWSceneInfo +export class SCBSceneSession { + readonly sceneInfo: SCBSceneInfo readonly session: sceneSessionManager.SceneSession isActive: boolean = true translateX: number = 0 @@ -37,7 +37,7 @@ export class HWSceneSession { * @param session Session of the scene * @param sceneInfo Information of the scene */ - constructor(session: sceneSessionManager.SceneSession, sceneInfo: HWSceneInfo) { + constructor(session: sceneSessionManager.SceneSession, sceneInfo: SCBSceneInfo) { this.sceneInfo = sceneInfo this.session = session this.session.on('pendingSceneSessionActivation', (info) => { @@ -46,12 +46,12 @@ export class HWSceneSession { } private onPendingSceneSessionActivation(sceneInfo: sceneSessionManager.SceneInfo) { - let toSceneInfo = new HWSceneInfo(sceneInfo.bundleName, sceneInfo.abilityName); + let toSceneInfo = new SCBSceneInfo(sceneInfo.bundleName, sceneInfo.abilityName); toSceneInfo.screenId = this.sceneInfo.screenId - toSceneInfo.transitionEffect = HWTransitionEffect.APPEAR_FROM_SCENE - this.sceneInfo.transitionEffect = HWTransitionEffect.DISAPPEAR_FROM_SCENE + toSceneInfo.transitionEffect = SCBTransitionEffect.APPEAR_FROM_SCENE + this.sceneInfo.transitionEffect = SCBTransitionEffect.DISAPPEAR_FROM_SCENE - HWSceneSessionManager.getInstance().startScene(toSceneInfo) -// HWSceneSessionManager.getInstance().requestSceneBackground(this) + SCBSceneSessionManager.getInstance().startScene(toSceneInfo) +// SCBSceneSessionManager.getInstance().requestSceneBackground(this) } } diff --git a/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts b/common/src/main/ets/WindowScene/scene/session/SCBSceneSessionManager.ts similarity index 73% rename from common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts rename to common/src/main/ets/WindowScene/scene/session/SCBSceneSessionManager.ts index 7c3c8973..4cc7c6d6 100644 --- a/common/src/main/ets/WindowScene/scene/session/HWSceneSessionManager.ts +++ b/common/src/main/ets/WindowScene/scene/session/SCBSceneSessionManager.ts @@ -15,46 +15,47 @@ import sceneSessionManager from '@ohos.sceneSessionManager' import ServiceExtensionContext from 'application/ServiceExtensionContext' -import { HWRootSceneSession } from './HWRootSceneSession' -import { HWSceneInfo } from './HWSceneInfo' -import { HWSceneSession } from './HWSceneSession' -import { HWSceneContainerSession } from './HWSceneContainerSession' -import { HWScreenSession, DesktopState } from '../../screen/session/HWScreenSession' -import { HWScreenSessionManager } from '../../screen/session/HWScreenSessionManager' +import { SCBRootSceneSession } from './SCBRootSceneSession' +import { SCBSceneInfo } from './SCBSceneInfo' +import { SCBSceneSession } from './SCBSceneSession' +import { SCBSceneContainerSession } from './SCBSceneContainerSession' +import { SCBScreenSession, DesktopState } from '../../screen/session/SCBScreenSession' +import { SCBScreenSessionManager } from '../../screen/session/SCBScreenSessionManager' +import { SCBGestureModel } from '../../common/SCBGestureModel' import { Log } from '../../../default/utils/Log' -const TAG = 'HWSceneSessionManager'; +const TAG = 'SCBSceneSessionManager'; /** * Scene session manager */ -export class HWSceneSessionManager { - private rootSceneSession: HWRootSceneSession; +export class SCBSceneSessionManager { + private rootSceneSession: SCBRootSceneSession; private constructor() { - this.rootSceneSession = new HWRootSceneSession(); + this.rootSceneSession = new SCBRootSceneSession(); } /** * Get the singleton of the scene session manager. */ - static getInstance(): HWSceneSessionManager { - if (!globalThis.HWSceneSessionManagerInstance) { - globalThis.HWSceneSessionManagerInstance = new HWSceneSessionManager(); + static getInstance(): SCBSceneSessionManager { + if (!globalThis.SCBSceneSessionManagerInstance) { + globalThis.SCBSceneSessionManagerInstance = new SCBSceneSessionManager(); } - return globalThis.HWSceneSessionManagerInstance; + return globalThis.SCBSceneSessionManagerInstance; } - private async requestSceneSessionActivation(sceneSession: HWSceneSession): Promise { + private async requestSceneSessionActivation(sceneSession: SCBSceneSession): Promise { sceneSessionManager.requestSceneSessionActivation(sceneSession.session); } - private async requestSceneSessionBackground(sceneSession: HWSceneSession): Promise { + private async requestSceneSessionBackground(sceneSession: SCBSceneSession): Promise { sceneSessionManager.requestSceneSessionBackground(sceneSession.session); } - private async requestSceneSessionDestruction(sceneSession: HWSceneSession): Promise { + private async requestSceneSessionDestruction(sceneSession: SCBSceneSession): Promise { sceneSessionManager.requestSceneSessionDestruction(sceneSession.session); } @@ -62,7 +63,7 @@ export class HWSceneSessionManager { * Get the session of the root scene. * @return Session of the root scene */ - public getRootSceneSession(): HWRootSceneSession { + public getRootSceneSession(): SCBRootSceneSession { return this.rootSceneSession; } @@ -79,15 +80,15 @@ export class HWSceneSessionManager { * Start a scene. * @param sceneInfo The info of the scene which to be activated */ - public startScene(sceneInfo: HWSceneInfo) { + public startScene(sceneInfo: SCBSceneInfo) { Log.showInfo(TAG, 'start scene:' + ' bundle:' + sceneInfo.bundleName + ' ability:' + sceneInfo.abilityName + ' screenId:' + sceneInfo.screenId + ' isNewInstance:' + sceneInfo.isNewInstance); - let screenSession: HWScreenSession = null; + let screenSession: SCBScreenSession = null; if (sceneInfo.screenId === -1) { - screenSession = HWScreenSessionManager.getInstance().getMainScreenSession(); + screenSession = SCBScreenSessionManager.getInstance().getMainScreenSession(); sceneInfo.screenId = screenSession.session.screenId; } else { - screenSession = HWScreenSessionManager.getInstance().getScreenSession(sceneInfo.screenId); + screenSession = SCBScreenSessionManager.getInstance().getScreenSession(sceneInfo.screenId); } if (screenSession == null) { @@ -100,17 +101,18 @@ export class HWSceneSessionManager { Log.showError(TAG, 'Failed to request scene session!'); return; } - Log.showInfo(TAG,"desktopState: " + screenSession.desktopState ) - if (screenSession.desktopState === DesktopState.HOME) { + let gestureModel = AppStorage.Get("gestureModel") + Log.showInfo(TAG,"desktopState: " + gestureModel?.desktopState ) + if (gestureModel?.desktopState === DesktopState.HOME) { let sceneContainerSession = screenSession.getSceneContainerSession(sceneSession); if (sceneContainerSession === null) { - sceneContainerSession = new HWSceneContainerSession(sceneSession, screenSession.bounds); + sceneContainerSession = new SCBSceneContainerSession(sceneSession, screenSession.bounds); screenSession.addSceneContainerSession(sceneContainerSession); Log.showInfo(TAG,"start scene add new container session: " + sceneContainerSession.containerId) } this.requestSceneContainerActivation(sceneContainerSession); screenSession.enterAppView(sceneContainerSession); - } else if (screenSession.desktopState === DesktopState.SPLIT) { + } else if (gestureModel?.desktopState === DesktopState.SPLIT) { let sceneContainerSession = screenSession.getSceneContainerSession(sceneSession); if (sceneContainerSession !== null) { screenSession.removeSceneContainerSession(sceneContainerSession); @@ -124,29 +126,29 @@ export class HWSceneSessionManager { } } - private requestSceneSession(sceneInfo: HWSceneInfo, screenSession: HWScreenSession): HWSceneSession { + private requestSceneSession(sceneInfo: SCBSceneInfo, screenSession: SCBScreenSession): SCBSceneSession { if (screenSession == null) { Log.showError(TAG, 'The screen session is null!'); return null; } - let hwSceneSession = screenSession.getSceneSession(sceneInfo); - if (hwSceneSession == null || sceneInfo.isNewInstance) { + let scbSceneSession = screenSession.getSceneSession(sceneInfo); + if (scbSceneSession == null || sceneInfo.isNewInstance) { let sceneSession = sceneSessionManager.requestSceneSession({ bundleName: sceneInfo.bundleName, abilityName: sceneInfo.abilityName }); - hwSceneSession = new HWSceneSession(sceneSession, sceneInfo); + scbSceneSession = new SCBSceneSession(sceneSession, sceneInfo); } - return hwSceneSession; + return scbSceneSession; } /** * Request the scene container session activation. * @param sceneContainerSession The session of the scene container which to be activated. */ - public requestSceneContainerActivation(sceneContainerSession: HWSceneContainerSession) { + public requestSceneContainerActivation(sceneContainerSession: SCBSceneContainerSession) { if (sceneContainerSession === null) { Log.showError(TAG, 'The scene container session is null!'); return; @@ -168,7 +170,7 @@ export class HWSceneSessionManager { * Request the scene container session background. * @param sceneContainerSession The session of the scene container which to be background. */ - public requestSceneContainerBackground(sceneContainerSession: HWSceneContainerSession) { + public requestSceneContainerBackground(sceneContainerSession: SCBSceneContainerSession) { if (sceneContainerSession === null) { Log.showError(TAG, 'The scene container session is null!'); return; @@ -190,7 +192,7 @@ export class HWSceneSessionManager { * Request the scene container session destruction. * @param sceneContainerSession The session of the scene container which to be destroyed. */ - public requestSceneContainerDestruction(sceneContainerSession: HWSceneContainerSession) { + public requestSceneContainerDestruction(sceneContainerSession: SCBSceneContainerSession) { if (sceneContainerSession === null) { Log.showError(TAG, 'The scene container session is null!'); return; @@ -207,12 +209,12 @@ export class HWSceneSessionManager { * Request the scene session exit split. * @param sceneSession The session of the scene container which exit split. */ - public requestSceneSessionExitSplit(sceneSession: HWSceneSession) { + public requestSceneSessionExitSplit(sceneSession: SCBSceneSession) { if (sceneSession === null) { Log.showError(TAG, 'The scene session is null!'); return; } - let screenSession = HWScreenSessionManager.getInstance().getScreenSession(sceneSession.sceneInfo.screenId); + let screenSession = SCBScreenSessionManager.getInstance().getScreenSession(sceneSession.sceneInfo.screenId); if (screenSession === null) { Log.showError(TAG, 'Failed to get main Screen Session!'); return; diff --git a/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts b/common/src/main/ets/WindowScene/screen/session/SCBScreenSession.ts similarity index 77% rename from common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts rename to common/src/main/ets/WindowScene/screen/session/SCBScreenSession.ts index 22b382cb..c179fa13 100644 --- a/common/src/main/ets/WindowScene/screen/session/HWScreenSession.ts +++ b/common/src/main/ets/WindowScene/screen/session/SCBScreenSession.ts @@ -14,16 +14,17 @@ */ import screenSessionManager from '@ohos.screenSessionManager' -import { HWSceneSession } from '../../scene/session/HWSceneSession' -import { HWSceneContainerSession } from '../../scene/session/HWSceneContainerSession' -import { HWRecentViewParam } from '../../scene/session/HWRecentViewParam'; +import { SCBSceneSession } from '../../scene/session/SCBSceneSession' +import { SCBSceneContainerSession } from '../../scene/session/SCBSceneContainerSession' import { Log } from '../../../default/utils/Log' -import { HWSceneInfo } from '../../scene/session/HWSceneInfo' +import { SCBSceneInfo } from '../../scene/session/SCBSceneInfo' +import { SCBGestureModel } from '../../common/SCBGestureModel' +import { SCBGestureManager } from '../../common/SCBGestureManager' -const TAG = 'HWScreenSession' +const TAG = 'SCBScreenSession' @Observed -export class SceneContainerSessionArray extends Array { +export class SceneContainerSessionArray extends Array { } export enum DesktopState { @@ -38,7 +39,7 @@ export enum DesktopState { * Session of a screen. */ @Observed -export class HWScreenSession { +export class SCBScreenSession { public readonly session: screenSessionManager.ScreenSession; public bounds: screenSessionManager.RRect = { left: 0, @@ -49,15 +50,16 @@ export class HWScreenSession { }; public rotation: number = 0; public sceneContainerSessionList: SceneContainerSessionArray = new SceneContainerSessionArray(); - public recentViewParam: HWRecentViewParam = new HWRecentViewParam(); - public desktopState: DesktopState = DesktopState.HOME; +// public desktopState: DesktopState = DesktopState.HOME; public enableScroll: boolean = true + private mGestureManager : SCBGestureManager /** * Constructor. * @param session Session of the screen */ constructor(session: screenSessionManager.ScreenSession) { + this.mGestureManager = SCBGestureManager.getInstance(); this.session = session this.session.on('connect', (screenProperty: screenSessionManager.ScreenProperty) => { this.onScreenConnect(screenProperty) @@ -79,6 +81,7 @@ export class HWScreenSession { radius: screenProperty.bounds.radius } this.rotation = screenProperty.rotation + this.mGestureManager.updateMainScreenBounds(this.bounds, this.rotation); Log.showInfo(TAG, `Update screen bounds[${this.bounds.left}, ${this.bounds.top}, ${this.bounds.width}, ${this.bounds.height}]`) } @@ -101,7 +104,7 @@ export class HWScreenSession { * Add the scene container session to this screen. * @param sceneContainerSession The scene container session which will be added to this screen. */ - public addSceneContainerSession(sceneContainerSession: HWSceneContainerSession): void { + public addSceneContainerSession(sceneContainerSession: SCBSceneContainerSession): void { const index = this.sceneContainerSessionList.findIndex(item => { return item.containerId === sceneContainerSession.containerId; }); @@ -115,7 +118,7 @@ export class HWScreenSession { * Remove the scene container session from this screen. * @param sceneContainerSession The scene container session which will be removed from this screen. */ - public removeSceneContainerSession(sceneContainerSession: HWSceneContainerSession): void { + public removeSceneContainerSession(sceneContainerSession: SCBSceneContainerSession): void { const index = this.sceneContainerSessionList.findIndex((item) => { return item.containerId === sceneContainerSession.containerId; }); @@ -130,7 +133,7 @@ export class HWScreenSession { * @param sceneInfo The information of the scene * @return Session of the scene */ - public getSceneSession(sceneInfo: HWSceneInfo): HWSceneSession { + public getSceneSession(sceneInfo: SCBSceneInfo): SCBSceneSession { for (let i = 0; i < this.sceneContainerSessionList.length; ++i) { let primarySession = this.sceneContainerSessionList[i].primarySession; let secondarySession = this.sceneContainerSessionList[i].secondarySession; @@ -148,7 +151,7 @@ export class HWScreenSession { return null; } - public getSceneContainerSession(sceneSession: HWSceneSession): HWSceneContainerSession { + public getSceneContainerSession(sceneSession: SCBSceneSession): SCBSceneContainerSession { if (sceneSession === null) { return null; } @@ -161,7 +164,7 @@ export class HWScreenSession { return this.sceneContainerSessionList[index]; } - public getActiveSceneContainerSession(): HWSceneContainerSession { + public getActiveSceneContainerSession(): SCBSceneContainerSession { const index = this.sceneContainerSessionList.findIndex((item) => { return item.isActive === true; }); @@ -173,13 +176,15 @@ export class HWScreenSession { } public enterHomeView() { - this.desktopState = DesktopState.HOME; - this.recentViewParam.init(); + Log.showInfo(TAG, 'enterHomeView.'); + this.mGestureManager.updateDesktopState(DesktopState.HOME); + this.mGestureManager.initRecentViewParam(); } - public enterAppView(sceneContainerSession: HWSceneContainerSession) { - this.desktopState = DesktopState.APP; - this.recentViewParam.init(); + public enterAppView(sceneContainerSession: SCBSceneContainerSession) { + Log.showInfo(TAG, 'EnterAppView.'); + this.mGestureManager.updateDesktopState(DesktopState.APP); + this.mGestureManager.initRecentViewParam(); sceneContainerSession.init(); // To move the sceneContainerSession to the last of list. @@ -188,27 +193,17 @@ export class HWScreenSession { } public enterRecentView() { - this.desktopState = DesktopState.RECENT; - this.recentViewParam.translateX = 0; - this.recentViewParam.translateY = 0; - this.recentViewParam.scaleX = 1; - this.recentViewParam.scaleY = 1; - this.recentViewParam.centerX = '50%'; - this.recentViewParam.centerY = '50%'; - this.recentViewParam.borderRadius = 35; - this.recentViewParam.offsetX = 0; - this.recentViewParam.offsetY = 0; - this.recentViewParam.width = "70%" - this.recentViewParam.height = "70%" - this.recentViewParam.margin = 0 + this.mGestureManager.setRecentView(); } public enterSplitView() { - this.desktopState = DesktopState.SPLIT; - this.recentViewParam.init(); + Log.showInfo(TAG, 'enterSplitView.'); + this.mGestureManager.updateDesktopState(DesktopState.SPLIT); + this.mGestureManager.initRecentViewParam(); } - public exitSplitView(sceneSession: HWSceneSession) { + public exitSplitView(sceneSession: SCBSceneSession) { + Log.showInfo(TAG, 'exitSplitView.'); const index = this.sceneContainerSessionList.findIndex((item) => { return item.primarySession.session.persistentId === sceneSession.session.persistentId || item.secondarySession.session.persistentId === sceneSession.session.persistentId; @@ -224,12 +219,12 @@ export class HWScreenSession { sceneSession.session.persistentId); return } -// this.desktopState = DesktopState.APP; +// this.desktopState = DesktopState.APP; // recent 内退出分屏保留recent state // this.recentViewParam.init(); currContainerSession.removeSceneSession(sceneSession) currContainerSession.init(); currContainerSession.isSplit = false - let newSceneContainerSession = new HWSceneContainerSession(sceneSession, this.bounds); + let newSceneContainerSession = new SCBSceneContainerSession(sceneSession, this.bounds); newSceneContainerSession.isActive = false; Log.showInfo(TAG, 'exitSplitView before insert list length: ' + this.sceneContainerSessionList.length); this.sceneContainerSessionList.splice(index, 0, newSceneContainerSession); diff --git a/common/src/main/ets/WindowScene/screen/session/HWScreenSessionManager.ts b/common/src/main/ets/WindowScene/screen/session/SCBScreenSessionManager.ts similarity index 84% rename from common/src/main/ets/WindowScene/screen/session/HWScreenSessionManager.ts rename to common/src/main/ets/WindowScene/screen/session/SCBScreenSessionManager.ts index e0be604c..06ae4070 100644 --- a/common/src/main/ets/WindowScene/screen/session/HWScreenSessionManager.ts +++ b/common/src/main/ets/WindowScene/screen/session/SCBScreenSessionManager.ts @@ -14,16 +14,16 @@ */ import screenSessionManager from '@ohos.screenSessionManager' -import { HWScreenSession } from './HWScreenSession' +import { SCBScreenSession } from './SCBScreenSession' import { Log } from '../../../default/utils/Log' -const TAG = 'HWScreenSessionManager' +const TAG = 'SCBScreenSessionManager' /** * Screen session manager. */ -export class HWScreenSessionManager { - private screenSessionList: HWScreenSession[] = [] +export class SCBScreenSessionManager { + private screenSessionList: SCBScreenSession[] = [] private constructor() { this.screenSessionList = AppStorage.SetAndLink('screenSessionList', this.screenSessionList).get() @@ -32,12 +32,12 @@ export class HWScreenSessionManager { /** * Get the singleton of the screen session manager. */ - static getInstance(): HWScreenSessionManager { - if (!globalThis.HWScreenSessionManagerInstance) { - globalThis.HWScreenSessionManagerInstance = new HWScreenSessionManager() + static getInstance(): SCBScreenSessionManager { + if (!globalThis.SCBScreenSessionManagerInstance) { + globalThis.SCBScreenSessionManagerInstance = new SCBScreenSessionManager() } - return globalThis.HWScreenSessionManagerInstance + return globalThis.SCBScreenSessionManagerInstance } /** @@ -67,7 +67,7 @@ export class HWScreenSessionManager { private onScreenConnect(session: screenSessionManager.ScreenSession): void { Log.showInfo(TAG, 'On screen connect.') - let screenSession: HWScreenSession = new HWScreenSession(session) + let screenSession: SCBScreenSession = new SCBScreenSession(session) this.addScreenSession(screenSession) } @@ -76,7 +76,7 @@ export class HWScreenSessionManager { this.removeScreenSession(session.screenId) } - private addScreenSession(screenSession: HWScreenSession) { + private addScreenSession(screenSession: SCBScreenSession) { const screenSessionIndex = this.screenSessionList.findIndex(item => { return item.session.screenId === screenSession.session.screenId }) @@ -105,7 +105,7 @@ export class HWScreenSessionManager { * @param screenId Id of the screen * @return Session of the screen */ - public getScreenSession(screenId: number): HWScreenSession { + public getScreenSession(screenId: number): SCBScreenSession { const screenSessionIndex = this.screenSessionList.findIndex(item => { return item.session.screenId === screenId }) @@ -121,7 +121,7 @@ export class HWScreenSessionManager { * Get the root screen session. * @return Session of the main screen */ - public getMainScreenSession(): HWScreenSession { + public getMainScreenSession(): SCBScreenSession { if (this.screenSessionList.length > 0) { return this.screenSessionList[0] } diff --git a/common/src/main/ets/default/constants/StyleConstants.ts b/common/src/main/ets/default/constants/StyleConstants.ts index d47f508c..12312b2c 100644 --- a/common/src/main/ets/default/constants/StyleConstants.ts +++ b/common/src/main/ets/default/constants/StyleConstants.ts @@ -176,4 +176,5 @@ export class StyleConstants { // the dpi of phone should be 480, but it is 320 currently. // so all dimensions have to be multiplied by 1.5 static readonly DPI_RATIO = 1; + static readonly GESTURE_KEY = 'gestureModel' } \ No newline at end of file diff --git a/common/src/main/ets/default/manager/LauncherAbilityManager.ts b/common/src/main/ets/default/manager/LauncherAbilityManager.ts index d08d998f..b8bea335 100644 --- a/common/src/main/ets/default/manager/LauncherAbilityManager.ts +++ b/common/src/main/ets/default/manager/LauncherAbilityManager.ts @@ -26,8 +26,8 @@ import { CommonConstants } from '../constants/CommonConstants'; import { ResourceManager } from './ResourceManager'; import { EventConstants } from '../constants/EventConstants'; import { BadgeManager } from '../manager/BadgeManager'; -import { HWSceneSessionManager } from '../../WindowScene/scene/session/HWSceneSessionManager' -import { HWSceneInfo } from '../../WindowScene/scene/session/HWSceneInfo' +import { SCBSceneSessionManager } from '../../WindowScene/scene/session/SCBSceneSessionManager' +import { SCBSceneInfo } from '../../WindowScene/scene/session/SCBSceneInfo' const TAG = 'LauncherAbilityManager'; @@ -278,8 +278,8 @@ class LauncherAbilityManager { // Log.showError(TAG, `startApplication promise error: ${JSON.stringify(err)}`); // }); - let sceneInfo = new HWSceneInfo(paramBundleName, paramAbilityName) - HWSceneSessionManager.getInstance().startScene(sceneInfo) + let sceneInfo = new SCBSceneInfo(paramBundleName, paramAbilityName) + SCBSceneSessionManager.getInstance().startScene(sceneInfo) const sysEventInfo = { domain: 'LAUNCHER_APP', diff --git a/product/phone/src/main/ets/MainAbility/MainAbility.ts b/product/phone/src/main/ets/MainAbility/MainAbility.ts index 922d5cb4..32828ff1 100644 --- a/product/phone/src/main/ets/MainAbility/MainAbility.ts +++ b/product/phone/src/main/ets/MainAbility/MainAbility.ts @@ -20,8 +20,8 @@ import { Log } from '@ohos/common'; import { windowManager } from '@ohos/common'; import { RdbStoreManager } from '@ohos/common'; import { FormConstants } from '@ohos/common'; -import { HWSceneSessionManager } from '@ohos/common' -import { HWScreenSessionManager } from '@ohos/common' +import { SCBSceneSessionManager } from '@ohos/common' +import { SCBScreenSessionManager } from '@ohos/common' import { GestureNavigationManager } from '@ohos/gesturenavigation'; import StyleConstants from '../common/constants/StyleConstants'; import { navigationBarCommonEventManager } from '@ohos/common'; @@ -65,8 +65,8 @@ export default class MainAbility extends ServiceExtension { // // load recent // windowManager.createRecentWindow(); - HWScreenSessionManager.getInstance().init(); - HWSceneSessionManager.getInstance().loadContent('pages/EntryView', this.context); + SCBScreenSessionManager.getInstance().init(); + SCBSceneSessionManager.getInstance().loadContent('pages/EntryView', this.context); } private initGlobalConst(): void { diff --git a/product/phone/src/main/ets/WindowScene/HWDesktop.ets b/product/phone/src/main/ets/WindowScene/SCBDesktop.ets similarity index 96% rename from product/phone/src/main/ets/WindowScene/HWDesktop.ets rename to product/phone/src/main/ets/WindowScene/SCBDesktop.ets index 102ccdf0..c9d123e5 100644 --- a/product/phone/src/main/ets/WindowScene/HWDesktop.ets +++ b/product/phone/src/main/ets/WindowScene/SCBDesktop.ets @@ -1,146 +1,146 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Log } from '@ohos/common'; -import { CommonConstants } from '@ohos/common'; -import { EventConstants } from '@ohos/common'; -import { localEventManager } from '@ohos/common'; -import { SettingsModel } from '@ohos/common'; -import { LayoutViewModel } from '@ohos/common'; -import { SmartDock } from '@ohos/smartdock'; -import { PageDesktopLayout } from '@ohos/pagedesktop'; -import { FolderOpenComponent } from '@ohos/bigfolder'; -import { BigFolderConstants } from '@ohos/bigfolder'; -import PhoneStage from '../common/PhoneStage'; - -const TAG = "HWDesktop"; - -@Component -export struct HWDesktop { - @StorageLink('screenWidth') screenWidth: number = 0; - @StorageLink('screenHeight') @Watch('updateScreenInfo') screenHeight: number = 0; - @StorageLink('deviceType') deviceType: string = CommonConstants.DEFAULT_DEVICE_TYPE; - @State workSpaceWidth: number = 0; - @State workSpaceHeight: number = 0; - @State dockHeight: number = 0; - private mStage: PhoneStage = new PhoneStage(); - private mLayoutViewModel: LayoutViewModel; - private navigationBarStatus: string | undefined = '0'; - - aboutToAppear(): void { - Log.showInfo(TAG, 'aboutToAppear'); - this.mStage.onCreate(); - - // init layout config - this.mLayoutViewModel = LayoutViewModel.getInstance(); - this.getWindowSize(); - this.updateScreenSize(); - - this.registerPageDesktopNavigatorStatusChangeEvent(this.mLocalEventListener); - // this.navigationBarStatus = SettingsModel.getInstance().getValue(); - } - - registerPageDesktopNavigatorStatusChangeEvent(listener): void { - localEventManager.registerEventListener(listener, [EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE]); - } - - private readonly mLocalEventListener = { - onReceiveEvent: (event, params) => { - Log.showDebug(TAG, `receive event: ${event}, params: ${params}`); - if (event === EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE) { - this.navigationBarStatus = params; - this.updateScreenInfo(); - } - } - }; - - aboutToDisappear(): void { - this.mStage.onDestroy(); - Log.showInfo(TAG, 'aboutToDisappear'); - } - - onBackPress(): boolean { - Log.showInfo(TAG, 'onBackPress'); - ContextMenu.close(); - AppStorage.SetOrCreate('dialogControllerStatus', !AppStorage.Get('dialogControllerStatus')); - AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE); - AppStorage.SetOrCreate('openFolderStatus', BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE); - return true; - } - - private updateScreenInfo(): void { - Log.showDebug(TAG, 'updateScreenInfo'); - if (this.screenWidth != 0 && this.screenHeight != 0) { - this.mLayoutViewModel.initScreen(this.navigationBarStatus); - globalThis.SmartDockStyleConfig.initConfig(); - globalThis.PhonePageDesktopGridStyleConfig.initConfig(); - globalThis.BigFolderStyleConfigInstance.initConfig(); - globalThis.FormStyleConfigInstance.initConfig(); - this.updateScreenSize(); - } - } - - private async getWindowSize(): Promise { - try { - // TODO Get from screen - this.screenWidth = px2vp(720); - this.screenHeight = px2vp(1280); - AppStorage.SetOrCreate('screenWidth', this.screenWidth); - AppStorage.SetOrCreate('screenHeight', this.screenHeight); - } catch (error) { - Log.showError(TAG, `getWindowWidth or getWindowHeight error: ${error}`); - } - } - - private updateScreenSize(): void { - this.workSpaceWidth = this.screenWidth; - this.workSpaceHeight = this.mLayoutViewModel.getWorkSpaceHeight(); - this.dockHeight = this.mLayoutViewModel.getDockHeight(); - AppStorage.SetOrCreate('workSpaceWidth', this.workSpaceWidth); - AppStorage.SetOrCreate('workSpaceHeight', this.workSpaceHeight); - AppStorage.SetOrCreate('dockHeight', this.dockHeight); - Log.showDebug(TAG, `updateScreenSize product: ${this.deviceType}, screenWidth: ${this.screenWidth}, screenHeight: ${this.screenHeight}, - workSpaceWidth: ${this.workSpaceWidth}, workSpaceHeight: ${this.workSpaceHeight}, dockHeight: ${this.dockHeight}`); - } - - build() { - Stack() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { - Column() { - PageDesktopLayout(); - } - .height(this.workSpaceHeight) - .onAreaChange((oldValue: Area, newValue: Area): void => { - Log.showDebug(TAG, `onAreaChange navigationBarStatus: ${this.navigationBarStatus}`); - if (JSON.stringify(oldValue) == JSON.stringify(newValue)) return; - if (this.navigationBarStatus == "1") { - setTimeout(() => { - SettingsModel.getInstance().setValue(this.navigationBarStatus); - }, 50) - } - }) - - Column() { - SmartDock(); - } - .height(this.dockHeight) - } - - FolderOpenComponent(); - } - .width('100%') - .height('100%') - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Log } from '@ohos/common'; +import { CommonConstants } from '@ohos/common'; +import { EventConstants } from '@ohos/common'; +import { localEventManager } from '@ohos/common'; +import { SettingsModel } from '@ohos/common'; +import { LayoutViewModel } from '@ohos/common'; +import { SmartDock } from '@ohos/smartdock'; +import { PageDesktopLayout } from '@ohos/pagedesktop'; +import { FolderOpenComponent } from '@ohos/bigfolder'; +import { BigFolderConstants } from '@ohos/bigfolder'; +import PhoneStage from '../common/PhoneStage'; + +const TAG = "SCBDesktop"; + +@Component +export struct SCBDesktop { + @StorageLink('screenWidth') screenWidth: number = 0; + @StorageLink('screenHeight') @Watch('updateScreenInfo') screenHeight: number = 0; + @StorageLink('deviceType') deviceType: string = CommonConstants.DEFAULT_DEVICE_TYPE; + @State workSpaceWidth: number = 0; + @State workSpaceHeight: number = 0; + @State dockHeight: number = 0; + private mStage: PhoneStage = new PhoneStage(); + private mLayoutViewModel: LayoutViewModel; + private navigationBarStatus: string | undefined = '0'; + + aboutToAppear(): void { + Log.showInfo(TAG, 'aboutToAppear'); + this.mStage.onCreate(); + + // init layout config + this.mLayoutViewModel = LayoutViewModel.getInstance(); + this.getWindowSize(); + this.updateScreenSize(); + + this.registerPageDesktopNavigatorStatusChangeEvent(this.mLocalEventListener); + // this.navigationBarStatus = SettingsModel.getInstance().getValue(); + } + + registerPageDesktopNavigatorStatusChangeEvent(listener): void { + localEventManager.registerEventListener(listener, [EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE]); + } + + private readonly mLocalEventListener = { + onReceiveEvent: (event, params) => { + Log.showDebug(TAG, `receive event: ${event}, params: ${params}`); + if (event === EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE) { + this.navigationBarStatus = params; + this.updateScreenInfo(); + } + } + }; + + aboutToDisappear(): void { + this.mStage.onDestroy(); + Log.showInfo(TAG, 'aboutToDisappear'); + } + + onBackPress(): boolean { + Log.showInfo(TAG, 'onBackPress'); + ContextMenu.close(); + AppStorage.SetOrCreate('dialogControllerStatus', !AppStorage.Get('dialogControllerStatus')); + AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE); + AppStorage.SetOrCreate('openFolderStatus', BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE); + return true; + } + + private updateScreenInfo(): void { + Log.showDebug(TAG, 'updateScreenInfo'); + if (this.screenWidth != 0 && this.screenHeight != 0) { + this.mLayoutViewModel.initScreen(this.navigationBarStatus); + globalThis.SmartDockStyleConfig.initConfig(); + globalThis.PhonePageDesktopGridStyleConfig.initConfig(); + globalThis.BigFolderStyleConfigInstance.initConfig(); + globalThis.FormStyleConfigInstance.initConfig(); + this.updateScreenSize(); + } + } + + private async getWindowSize(): Promise { + try { + // TODO Get from screen + this.screenWidth = px2vp(720); + this.screenHeight = px2vp(1280); + AppStorage.SetOrCreate('screenWidth', this.screenWidth); + AppStorage.SetOrCreate('screenHeight', this.screenHeight); + } catch (error) { + Log.showError(TAG, `getWindowWidth or getWindowHeight error: ${error}`); + } + } + + private updateScreenSize(): void { + this.workSpaceWidth = this.screenWidth; + this.workSpaceHeight = this.mLayoutViewModel.getWorkSpaceHeight(); + this.dockHeight = this.mLayoutViewModel.getDockHeight(); + AppStorage.SetOrCreate('workSpaceWidth', this.workSpaceWidth); + AppStorage.SetOrCreate('workSpaceHeight', this.workSpaceHeight); + AppStorage.SetOrCreate('dockHeight', this.dockHeight); + Log.showDebug(TAG, `updateScreenSize product: ${this.deviceType}, screenWidth: ${this.screenWidth}, screenHeight: ${this.screenHeight}, + workSpaceWidth: ${this.workSpaceWidth}, workSpaceHeight: ${this.workSpaceHeight}, dockHeight: ${this.dockHeight}`); + } + + build() { + Stack() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { + Column() { + PageDesktopLayout(); + } + .height(this.workSpaceHeight) + .onAreaChange((oldValue: Area, newValue: Area): void => { + Log.showDebug(TAG, `onAreaChange navigationBarStatus: ${this.navigationBarStatus}`); + if (JSON.stringify(oldValue) == JSON.stringify(newValue)) return; + if (this.navigationBarStatus == "1") { + setTimeout(() => { + SettingsModel.getInstance().setValue(this.navigationBarStatus); + }, 50) + } + }) + + Column() { + SmartDock(); + } + .height(this.dockHeight) + } + + FolderOpenComponent(); + } + .width('100%') + .height('100%') + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/WindowScene/HWDivider.ets b/product/phone/src/main/ets/WindowScene/SCBDivider.ets similarity index 88% rename from product/phone/src/main/ets/WindowScene/HWDivider.ets rename to product/phone/src/main/ets/WindowScene/SCBDivider.ets index c09c1b82..1d61a80f 100644 --- a/product/phone/src/main/ets/WindowScene/HWDivider.ets +++ b/product/phone/src/main/ets/WindowScene/SCBDivider.ets @@ -13,17 +13,17 @@ * limitations under the License. */ -import { HWDividerParam, StyleConstants } from '@ohos/common' +import { SCBDividerParam, StyleConstants } from '@ohos/common' import { Log } from '@ohos/common' -import { HWSceneSessionManager, HWSceneContainerSession } from '@ohos/common' +import { SCBSceneSessionManager, SCBSceneContainerSession } from '@ohos/common' import screenSessionManager from '@ohos.screenSessionManager' -const TAG = 'HWDivider' +const TAG = 'SCBDivider' @Component -export struct HWDivider { - @Link dividerParam: HWDividerParam - @Link sceneContainerSession: HWSceneContainerSession; +export struct SCBDivider { + @Link dividerParam: SCBDividerParam + @Link sceneContainerSession: SCBSceneContainerSession; screenBounds: screenSessionManager.RRect buildLog1() { @@ -74,12 +74,12 @@ export struct HWDivider { if (heightRatio < StyleConstants.DEFAULT_SPLIT_EXIT_RATIO) { Log.showInfo(TAG, "exit primarySession with ratio: " + heightRatio) this.dividerParam.init() - HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + SCBSceneSessionManager.getInstance().requestSceneSessionExitSplit( this.sceneContainerSession.primarySession); } else if (heightRatio > (1 - StyleConstants.DEFAULT_SPLIT_EXIT_RATIO)) { this.dividerParam.init() Log.showInfo(TAG, "exit secondarySession with ratio: " + heightRatio) - HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + SCBSceneSessionManager.getInstance().requestSceneSessionExitSplit( this.sceneContainerSession.secondarySession); } })) diff --git a/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets b/product/phone/src/main/ets/WindowScene/SCBGestureNavBar.ets similarity index 44% rename from product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets rename to product/phone/src/main/ets/WindowScene/SCBGestureNavBar.ets index 55b57867..3dd58f40 100644 --- a/product/phone/src/main/ets/WindowScene/HWGestureNavBar.ets +++ b/product/phone/src/main/ets/WindowScene/SCBGestureNavBar.ets @@ -13,20 +13,19 @@ * limitations under the License. */ -import { HWSceneContainerSession, HWDividerParam, HWRecentViewParam } from '@ohos/common'; -import { HWSceneSessionManager } from '@ohos/common'; -import { HWScreenSession, DesktopState } from '@ohos/common'; +import { SCBSceneContainerSession, SCBDividerParam, SCBGestureModel, SCBGestureManager } from '@ohos/common'; +import { SCBSceneSessionManager } from '@ohos/common'; +import { SCBScreenSession } from '@ohos/common'; import { Log } from '@ohos/common'; import { StyleConstants } from '@ohos/common'; -const TAG = 'HWGestureNavBar'; +const TAG = 'SCBGestureNavBar'; @Component -export struct HWGestureNavBar { - @Link sceneContainerSession: HWSceneContainerSession; - @Link screenSession: HWScreenSession; - @Link dividerParam: HWDividerParam; - @Link recentViewParam: HWRecentViewParam; +export struct SCBGestureNavBar { + @Link sceneContainerSession: SCBSceneContainerSession; + @Link screenSession: SCBScreenSession; + @Link dividerParam: SCBDividerParam; build() { // Gesture navigation bar @@ -42,46 +41,26 @@ export struct HWGestureNavBar { .backgroundColor(Color.Transparent) .gesture(PanGesture() .onActionStart((event: GestureEvent) => { - this.screenSession.desktopState = DesktopState.DRAGGING; - this.recentViewParam.margin = 50 - let scrollWidth = - this.screenSession.sceneContainerSessionList.length * this.sceneContainerSession.screenBounds.width + - (this.screenSession.sceneContainerSessionList.length - 1) * this.recentViewParam.margin; - this.recentViewParam.offsetX = this.sceneContainerSession.screenBounds.width - scrollWidth; - - this.recentViewParam.centerX = - (1 - this.sceneContainerSession.screenBounds.width / 2 / scrollWidth) * 100 + '%'; - this.recentViewParam.centerY = '100%'; + SCBGestureManager.getInstance().setRecentViewParamOnActionStart( + this.screenSession.sceneContainerSessionList.length); }) .onActionUpdate((event: GestureEvent) => { - let translateRatio = 0.6 * Math.pow(this.recentViewParam.scaleX, 2) + 0.4; - this.recentViewParam.translateX = event.offsetX * translateRatio; - if (1 + event.offsetY / this.sceneContainerSession.screenBounds.height * 1.3 > 0.25) { - this.recentViewParam.translateY = event.offsetY; - } - - this.recentViewParam.scaleX = - 1 + this.recentViewParam.translateY / this.sceneContainerSession.screenBounds.height * 1.3; - this.recentViewParam.scaleX = Math.max(this.recentViewParam.scaleX, 0.25); - this.recentViewParam.scaleX = Math.min(this.recentViewParam.scaleX, 1); - this.recentViewParam.scaleY = this.recentViewParam.scaleX; + SCBGestureManager.getInstance().setRecentViewParamOnActionUpdate(event.offsetX, event.offsetY) }) .onActionEnd((event: GestureEvent) => { if (event.offsetY < -400) { - HWSceneSessionManager.getInstance().requestSceneContainerBackground(this.sceneContainerSession); + SCBSceneSessionManager.getInstance().requestSceneContainerBackground(this.sceneContainerSession); this.screenSession.enterHomeView(); } else if (event.offsetY < -200) { this.dividerParam.primaryH = ((100 - StyleConstants.DIVIDER_HEIGHT / this.sceneContainerSession.screenBounds.height * 100) / 2) + '%'; if (!this.sceneContainerSession.isSplit) { this.sceneContainerSession.isSplit = true; this.screenSession.enterSplitView(); + } else { + this.screenSession.enterRecentView(); } } else if (event.offsetY < -100) { - let recentViewSceneSpace = 50; - let scrollWidth = - this.screenSession.sceneContainerSessionList.length * this.sceneContainerSession.screenBounds.width + - (this.screenSession.sceneContainerSessionList.length - 1) * recentViewSceneSpace; - this.recentViewParam.offsetX = this.sceneContainerSession.screenBounds.width - scrollWidth; + SCBGestureManager.getInstance().setRecentViewParamOnActionEnd(this.screenSession.sceneContainerSessionList.length) this.screenSession.enterRecentView(); } else { this.screenSession.enterAppView(this.sceneContainerSession); diff --git a/product/phone/src/main/ets/WindowScene/HWScene.ets b/product/phone/src/main/ets/WindowScene/SCBScene.ets similarity index 65% rename from product/phone/src/main/ets/WindowScene/HWScene.ets rename to product/phone/src/main/ets/WindowScene/SCBScene.ets index d82b3507..55b0e6a5 100644 --- a/product/phone/src/main/ets/WindowScene/HWScene.ets +++ b/product/phone/src/main/ets/WindowScene/SCBScene.ets @@ -13,40 +13,43 @@ * limitations under the License. */ -import { HWSceneSession, HWSceneSessionManager, HWDividerParam, HWScreenSession, DesktopState } from '@ohos/common' +import { SCBSceneSession, SCBSceneSessionManager, SCBDividerParam, SCBScreenSession, DesktopState, SCBGestureModel } from '@ohos/common' import { StyleConstants } from '@ohos/common' import { Log } from '@ohos/common' -const TAG = 'HWScene' + +const TAG = 'SCBScene' @Component -export struct HWScene { - @ObjectLink sceneSession: HWSceneSession - @Link dividerParam: HWDividerParam - @ObjectLink screenSession: HWScreenSession; +export struct SCBScene { + @ObjectLink sceneSession: SCBSceneSession + @Link dividerParam: SCBDividerParam + @ObjectLink screenSession: SCBScreenSession; +// @StorageLink('gestureModel') gestureModel: SCBGestureModel = AppStorage.Get("gestureModel") + @StorageLink('gestureModel') gestureModel: SCBGestureModel = AppStorage.Get("gestureModel") - buildLog(sceneSession: HWSceneSession) { + buildLog(sceneSession: SCBSceneSession) { if (sceneSession) { - Log.showInfo(TAG, 'HWSceneSession bundle name: ' + sceneSession.sceneInfo.bundleName + ' id: ' + sceneSession.session.persistentId); + Log.showInfo(TAG, 'SCBSceneSession bundle name: ' + sceneSession.sceneInfo.bundleName + ' id: ' + sceneSession.session.persistentId); } else { - Log.showError(TAG, 'HWSceneSession is null'); + Log.showError(TAG, 'SCBSceneSession is null'); } - Log.showInfo(TAG, 'HWScene build: ' + this.sceneSession?.sceneInfo.bundleName + ' id: ' + this.sceneSession?.session.persistentId); + Log.showInfo(TAG, 'SCBScene build: ' + this.sceneSession?.sceneInfo.bundleName + ' id: ' + this.sceneSession?.session.persistentId); return true } buildLog1() { - Log.showInfo(TAG, 'HWScene panGesture end--------- '); + Log.showInfo(TAG, 'SCBScene panGesture end--------- '); return true } buildLog2() { - Log.showInfo(TAG, 'HWScene translateX begin: ' + this.sceneSession?.translateX + ' id: ' + this.sceneSession?.session.persistentId); + Log.showInfo(TAG, 'SCBScene translateX begin: ' + this.sceneSession?.translateX + ' id: ' + this.sceneSession?.session.persistentId); return true } buildLog3() { - Log.showInfo(TAG, 'HWScene longPress end--------- '); + Log.showInfo(TAG, 'SCBScene longPress end--------- '); return true } build() { @@ -55,7 +58,7 @@ export struct HWScene { if (this.sceneSession !== null) { HostWindowScene(this.sceneSession?.session) .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) - if (this.screenSession.desktopState === DesktopState.RECENT) { + if (this.gestureModel?.desktopState === DesktopState.RECENT) { Stack() { } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) @@ -81,7 +84,7 @@ export struct HWScene { } if (event.offsetX < -200 || event.offsetX > 200) { this.dividerParam.init() - HWSceneSessionManager.getInstance().requestSceneSessionExitSplit( + SCBSceneSessionManager.getInstance().requestSceneSessionExitSplit( this.sceneSession); } this.sceneSession.translateX = 0 diff --git a/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets b/product/phone/src/main/ets/WindowScene/SCBSceneContainer.ets similarity index 71% rename from product/phone/src/main/ets/WindowScene/HWSceneContainer.ets rename to product/phone/src/main/ets/WindowScene/SCBSceneContainer.ets index 2703aee3..16f33987 100644 --- a/product/phone/src/main/ets/WindowScene/HWSceneContainer.ets +++ b/product/phone/src/main/ets/WindowScene/SCBSceneContainer.ets @@ -14,38 +14,39 @@ */ import curves from '@ohos.curves' -import { HWSceneContainerSession, HWDividerParam, HWSceneSession } from '@ohos/common' -import { HWRecentViewParam } from '@ohos/common'; -import { HWScreenSession, DesktopState } from '@ohos/common'; -import { HWSceneSessionManager } from '@ohos/common'; -import { HWScene } from './HWScene' -import { HWGestureNavBar } from './HWGestureNavBar' -import { HWDivider } from './HWDivider' +import { SCBSceneContainerSession, SCBDividerParam, SCBSceneSession, SCBGestureModel } from '@ohos/common' +import { SCBScreenSession, DesktopState } from '@ohos/common'; +import { SCBSceneSessionManager } from '@ohos/common'; +import { SCBScene } from './SCBScene' +import { SCBGestureNavBar } from './SCBGestureNavBar' +import { SCBDivider } from './SCBDivider' import { Log } from '@ohos/common' import { StyleConstants } from '@ohos/common' -const TAG = 'HWSceneContainer' +const TAG = 'SCBSceneContainer' @Component -export struct HWSceneContainer { - @ObjectLink sceneContainerSession: HWSceneContainerSession; - @ObjectLink screenSession: HWScreenSession; - @ObjectLink dividerParam: HWDividerParam; - @Link recentViewParam: HWRecentViewParam; +export struct SCBSceneContainer { + @ObjectLink sceneContainerSession: SCBSceneContainerSession; + @ObjectLink screenSession: SCBScreenSession; +// @StorageLink('gestureModel') gestureModel: SCBGestureModel = AppStorage.Get("gestureModel") + @StorageLink('gestureModel') gestureModel: SCBGestureModel = new SCBGestureModel() + @ObjectLink dividerParam: SCBDividerParam; buildLog1() { Log.showInfo(TAG, " pri Id: " + this.sceneContainerSession.primarySession?.session.persistentId + " sec id: " + this.sceneContainerSession.secondarySession?.session.persistentId + " containerId: " + this.sceneContainerSession.containerId + ' priH: ' + this.dividerParam.primaryH + ' isSplit: ' + this.sceneContainerSession.isSplit) + Log.showInfo(TAG, 'desktopState:' + this.gestureModel?.desktopState); return true } - buildLog2(sceneSession : HWSceneSession) { + buildLog2(sceneSession : SCBSceneSession) { console.log(TAG + " primary active: "+ JSON.stringify(sceneSession?.isActive) + " id: " + sceneSession.session.persistentId + " containerId: " + this.sceneContainerSession.containerId + ' primary transX: ' + this.sceneContainerSession.primarySession?.translateX) return true } - buildLog3(sceneSession : HWSceneSession) { + buildLog3(sceneSession : SCBSceneSession) { console.log(TAG + "secondary active: "+ JSON.stringify(sceneSession?.isActive) + " id: " + sceneSession.session.persistentId + " containerId: " + this.sceneContainerSession.containerId) return true @@ -60,7 +61,7 @@ export struct HWSceneContainer { Column() { if (this.buildLog1()) {} if (this.sceneContainerSession.primarySession && this.buildLog2(this.sceneContainerSession.primarySession)) { - HWScene({ sceneSession: this.sceneContainerSession.primarySession, dividerParam: $dividerParam, screenSession: this.screenSession }) + SCBScene({ sceneSession: this.sceneContainerSession.primarySession, dividerParam: $dividerParam, screenSession: this.screenSession }) .width('100%') .height(this.dividerParam.primaryH) .scale({ y: this.dividerParam.primaryScaleY, centerY: 0 }) @@ -69,13 +70,13 @@ export struct HWSceneContainer { // divider if (this.sceneContainerSession.isSplit) { - HWDivider({ dividerParam: $dividerParam, sceneContainerSession: $sceneContainerSession, + SCBDivider({ dividerParam: $dividerParam, sceneContainerSession: $sceneContainerSession, screenBounds: this.sceneContainerSession.screenBounds }) } // When primary Exit if (this.sceneContainerSession.secondarySession && this.buildLog3(this.sceneContainerSession.secondarySession)) { - HWScene({ sceneSession: this.sceneContainerSession.secondarySession, dividerParam: $dividerParam, screenSession: this.screenSession }) + SCBScene({ sceneSession: this.sceneContainerSession.secondarySession, dividerParam: $dividerParam, screenSession: this.screenSession }) .scale({ y: this.dividerParam.secondaryScaleY, centerY: 0 }) .blur(this.dividerParam.blurRadius) .translate({ y: this.dividerParam.secTransY }) @@ -84,7 +85,7 @@ export struct HWSceneContainer { } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) - if (this.screenSession.desktopState === DesktopState.RECENT) { + if (this.gestureModel?.desktopState === DesktopState.RECENT) { Stack() { } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) @@ -93,10 +94,10 @@ export struct HWSceneContainer { let activeSceneContainerSession = this.screenSession.getActiveSceneContainerSession(); if (activeSceneContainerSession && activeSceneContainerSession.containerId !== this.sceneContainerSession.containerId) { - HWSceneSessionManager.getInstance().requestSceneContainerBackground(activeSceneContainerSession); + SCBSceneSessionManager.getInstance().requestSceneContainerBackground(activeSceneContainerSession); } - HWSceneSessionManager.getInstance().requestSceneContainerActivation(this.sceneContainerSession); + SCBSceneSessionManager.getInstance().requestSceneContainerActivation(this.sceneContainerSession); this.screenSession.enterAppView(this.sceneContainerSession); }) .parallelGesture( @@ -110,7 +111,7 @@ export struct HWSceneContainer { }) .onActionEnd((event: GestureEvent) => { if (event.offsetY < -300) { - HWSceneSessionManager.getInstance().requestSceneContainerDestruction(this.sceneContainerSession); + SCBSceneSessionManager.getInstance().requestSceneContainerDestruction(this.sceneContainerSession); this.screenSession.removeSceneContainerSession(this.sceneContainerSession); if (this.screenSession.sceneContainerSessionList.length == 0) { @@ -122,13 +123,12 @@ export struct HWSceneContainer { })) } - if (this.screenSession.desktopState !== DesktopState.RECENT - && this.screenSession.desktopState !== DesktopState.SPLIT) { - HWGestureNavBar({ + if (this.gestureModel?.desktopState !== DesktopState.RECENT + && this.gestureModel?.desktopState !== DesktopState.SPLIT) { + SCBGestureNavBar({ sceneContainerSession: $sceneContainerSession, screenSession: $screenSession, dividerParam: $dividerParam, - recentViewParam: $recentViewParam, }) } } diff --git a/product/phone/src/main/ets/WindowScene/HWScenePanel.ets b/product/phone/src/main/ets/WindowScene/SCBScenePanel.ets similarity index 66% rename from product/phone/src/main/ets/WindowScene/HWScenePanel.ets rename to product/phone/src/main/ets/WindowScene/SCBScenePanel.ets index 3d272948..8937dedb 100644 --- a/product/phone/src/main/ets/WindowScene/HWScenePanel.ets +++ b/product/phone/src/main/ets/WindowScene/SCBScenePanel.ets @@ -13,20 +13,21 @@ * limitations under the License. */ -import { HWScreenSession, DesktopState } from '@ohos/common'; -import { HWRecentViewParam } from '@ohos/common'; -import { HWSceneContainerSession } from '@ohos/common'; -import { HWSceneSessionManager } from '@ohos/common'; -import { HWSceneContainer } from './HWSceneContainer'; +import { SCBScreenSession, DesktopState, SCBGestureModel, SceneContainerSessionArray, SCBGestureManager} from '@ohos/common'; +import { SCBSceneContainerSession } from '@ohos/common'; +import { SCBSceneSessionManager } from '@ohos/common'; +import { SCBSceneContainer } from './SCBSceneContainer'; import { Log } from '@ohos/common'; import { StyleConstants } from '@ohos/common'; -const TAG = 'HWScenePanel'; +const TAG = 'SCBScenePanel'; @Component -export struct HWScenePanel { - @ObjectLink screenSession: HWScreenSession; - @ObjectLink recentViewParam: HWRecentViewParam; +export struct SCBScenePanel { + @ObjectLink screenSession: SCBScreenSession; + @ObjectLink containerSessionList: SceneContainerSessionArray; +// @StorageLink('gestureModel') gestureModel: SCBGestureModel = AppStorage.Get("gestureModel") + @StorageLink('gestureModel') @Watch("watchTest") gestureModel: SCBGestureModel = new SCBGestureModel() @State recentViewHitTestMode: HitTestMode = HitTestMode.None; @State scrollDirection: ScrollDirection = ScrollDirection.None; @State mBlurRadius: number = 20; @@ -40,79 +41,89 @@ export struct HWScenePanel { @State containerTranslation: number[]=[] @State containerAlpha : number[]=[] @State containerScale: number[]=[] - buildLog(sceneContainerSession: HWSceneContainerSession) { + buildLog(sceneContainerSession: SCBSceneContainerSession) { Log.showInfo(TAG, `sceneContainerSession id: ${sceneContainerSession.containerId}`); Log.showInfo(TAG, `sceneContainerSession isActive: ${sceneContainerSession.isActive}`); + Log.showInfo(TAG, 'desktopState:' + this.gestureModel?.desktopState + ' length: ' + this.containerSessionList.length); return true; } isRecent(): boolean { - Log.showInfo(TAG,"isRecent = " +(this.screenSession.desktopState === DesktopState.RECENT)) - if (this.screenSession.desktopState === this.currentState) { - return this.screenSession.desktopState === DesktopState.RECENT; + Log.showInfo(TAG,"isRecent = " +(this.gestureModel.desktopState === DesktopState.RECENT)) + if (this.gestureModel.desktopState === this.currentState) { + return this.gestureModel.desktopState === DesktopState.RECENT; } - if (this.screenSession.desktopState == DesktopState.RECENT) { + if (this.gestureModel.desktopState == DesktopState.RECENT) { this.initRecentParams(); - this.currentState = this.screenSession.desktopState; + this.currentState = this.gestureModel.desktopState; return true; } else { this.containerTranslation = []; this.containerAlpha = []; this. containerScale = []; - this.currentState = this.screenSession.desktopState; + this.currentState = this.gestureModel.desktopState; Log.showInfo(TAG,"this.containerTranslation = " +this.containerTranslation[this.screenSession.sceneContainerSessionList.length-1]) return false; } } + testBuildLog() { + Log.showInfo(TAG,"HWScenePanel build begin and list len " + this.screenSession.sceneContainerSessionList.length + 'desktopState: ' + this.gestureModel.desktopState + ) + return true + } + watchTest() { + Log.showInfo(TAG,"=================watch test detect!") + } build() { Stack({ alignContent: Alignment.TopStart }) { - if (this.screenSession.desktopState === DesktopState.APP || this.screenSession.desktopState === DesktopState.RECENT) { + if (this.gestureModel.desktopState === DesktopState.APP || this.gestureModel.desktopState === DesktopState.RECENT) { Stack() { + if (this.testBuildLog()) { + + } } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) .blur(this.mBlurRadius) } - Scroll(this.scroller) { // Flex({ direction: FlexDirection.Row }) { Row() { - ForEach(this.screenSession.sceneContainerSessionList, (item: HWSceneContainerSession, index) => { - if (this.isRecent() ||this.screenSession.desktopState === DesktopState.DRAGGING || (this.buildLog(item) && item.isActive)) { - HWSceneContainer({ + ForEach(this.containerSessionList, (item: SCBSceneContainerSession, index) => { + if (this.isRecent() ||this.gestureModel.desktopState === DesktopState.DRAGGING || (this.buildLog(item) && item.isActive)) { + SCBSceneContainer({ sceneContainerSession: item, screenSession: this.screenSession, - dividerParam: item.dividerParam, - recentViewParam: $recentViewParam + dividerParam: item.dividerParam }) - .size({width:this.recentViewParam.width, height:this.recentViewParam.height}) + .size({width:this.gestureModel.width, height:this.gestureModel.height}) .translate({x:this.containerTranslation[index]}) .opacity(this.containerAlpha[index]) .scale({x:this.containerScale[index], y:this.containerScale[index]}) - .margin({left:this.recentViewParam.margin}) + .margin({left:this.gestureModel.margin}) // .clip(true) - .borderRadius(this.recentViewParam.borderRadius) + .borderRadius(this.gestureModel.borderRadius) } - }, (item: HWSceneContainerSession) => item.containerId.toString()) + }, (item: SCBSceneContainerSession) => item.containerId.toString()) } -// .hitTestBehavior(HitTestMode.None) - .translate({ x: this.recentViewParam.translateX, y: this.recentViewParam.translateY }) + .hitTestBehavior(HitTestMode.None) + .translate({ x: this.gestureModel.translateX, y: this.gestureModel.translateY }) .scale({ - x: this.recentViewParam.scaleX, - y: this.recentViewParam.scaleY, - centerX: this.recentViewParam.centerX, - centerY: this.recentViewParam.centerY + x: this.gestureModel.scaleX, + y: this.gestureModel.scaleY, + centerX: this.gestureModel.centerX, + centerY: this.gestureModel.centerY }) - .offset({ x: this.recentViewParam.offsetX, y: this.recentViewParam.offsetY }) + .offset({ x: this.gestureModel.offsetX, y: this.gestureModel.offsetY }) } .size({ width: StyleConstants.PERCENTAGE_100, height: StyleConstants.PERCENTAGE_100 }) .scrollBar(BarState.Off) - .scrollable(this.screenSession.desktopState === DesktopState.RECENT ? ScrollDirection.Horizontal : ScrollDirection.None) + .scrollable(this.gestureModel.desktopState === DesktopState.RECENT ? ScrollDirection.Horizontal : ScrollDirection.None) .edgeEffect(EdgeEffect.Spring) - .hitTestBehavior(this.screenSession.desktopState === DesktopState.RECENT ? HitTestMode.Default : HitTestMode.None) + .hitTestBehavior(this.gestureModel.desktopState === DesktopState.RECENT ? HitTestMode.Default : HitTestMode.None) .onClick(() => { let activeSceneContainerSession = this.screenSession.getActiveSceneContainerSession(); - HWSceneSessionManager.getInstance().requestSceneContainerBackground(activeSceneContainerSession); + SCBSceneSessionManager.getInstance().requestSceneContainerBackground(activeSceneContainerSession); this.screenSession.enterHomeView(); this.containerTranslation= []; this.containerAlpha = []; diff --git a/product/phone/src/main/ets/WindowScene/HWScreen.ets b/product/phone/src/main/ets/WindowScene/SCBScreen.ets similarity index 66% rename from product/phone/src/main/ets/WindowScene/HWScreen.ets rename to product/phone/src/main/ets/WindowScene/SCBScreen.ets index 35b8dfab..7875c551 100644 --- a/product/phone/src/main/ets/WindowScene/HWScreen.ets +++ b/product/phone/src/main/ets/WindowScene/SCBScreen.ets @@ -13,32 +13,32 @@ * limitations under the License. */ -import { HWScenePanel } from './HWScenePanel' -import { HWScreenSession } from '@ohos/common' -import { HWDesktop } from './HWDesktop' -import { HWWallpaper } from './HWWallpaper' -import { HWSystemUi } from './HWSystemUi' +import { SCBScenePanel } from './SCBScenePanel' +import { SCBScreenSession } from '@ohos/common' +import { SCBDesktop } from './SCBDesktop' +import { SCBWallpaper } from './SCBWallpaper' +import { SCBSystemUi } from './SCBSystemUi' @Component -export struct HWScreen { - @ObjectLink screenSession: HWScreenSession +export struct SCBScreen { + @ObjectLink screenSession: SCBScreenSession build() { Screen(this.screenSession.session) { // Wallpaper - HWWallpaper() + SCBWallpaper() // Desktop - HWDesktop() + SCBDesktop() // Scene - HWScenePanel({ + SCBScenePanel({ screenSession: this.screenSession, - recentViewParam: this.screenSession.recentViewParam + containerSessionList: this.screenSession.sceneContainerSessionList }) // Systemui - HWSystemUi({ bounds: this.screenSession.bounds }) + SCBSystemUi({ bounds: this.screenSession.bounds }) } .position({ x: this.screenSession.bounds.left, y: this.screenSession.bounds.top }) .width(this.screenSession.bounds.width) diff --git a/product/phone/src/main/ets/WindowScene/HWSystemUi.ets b/product/phone/src/main/ets/WindowScene/SCBSystemUi.ets similarity index 97% rename from product/phone/src/main/ets/WindowScene/HWSystemUi.ets rename to product/phone/src/main/ets/WindowScene/SCBSystemUi.ets index 2644e95b..5e392221 100644 --- a/product/phone/src/main/ets/WindowScene/HWSystemUi.ets +++ b/product/phone/src/main/ets/WindowScene/SCBSystemUi.ets @@ -21,11 +21,11 @@ import { SCBStatusBar } from '@ohos/phone_statusbar/src/main/ets/pages/SCBStatus import { SCBDropdownPanel } from '@ohos/phone_dropdownpanel/src/main/ets/pages/SCBDropdownPanel'; import { SCBVolumePanel } from '@ohos/default_volumepanel/src/main/ets/pages/SCBVolumePanel'; -const TAG = "HWSystemUi"; +const TAG = "SCBSystemUi"; const MODULE_NAME = "phone-launcher"; @Component -export struct HWSystemUi { +export struct SCBSystemUi { public bounds: screenSessionManager.RRect onBackPress(): boolean { diff --git a/product/phone/src/main/ets/WindowScene/HWWallpaper.ets b/product/phone/src/main/ets/WindowScene/SCBWallpaper.ets similarity index 93% rename from product/phone/src/main/ets/WindowScene/HWWallpaper.ets rename to product/phone/src/main/ets/WindowScene/SCBWallpaper.ets index e9834423..98d14e6e 100644 --- a/product/phone/src/main/ets/WindowScene/HWWallpaper.ets +++ b/product/phone/src/main/ets/WindowScene/SCBWallpaper.ets @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import StyleConstants from '../common/constants/StyleConstants' - -@Component -export struct HWWallpaper { - - build() { - Image(StyleConstants.DEFAULT_BACKGROUND_IMAGE) - .objectFit(ImageFit.Cover) - } +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import StyleConstants from '../common/constants/StyleConstants' + +@Component +export struct SCBWallpaper { + + build() { + Image(StyleConstants.DEFAULT_BACKGROUND_IMAGE) + .objectFit(ImageFit.Cover) + } } \ No newline at end of file diff --git a/product/phone/src/main/ets/pages/EntryView.ets b/product/phone/src/main/ets/pages/EntryView.ets index 25909b7f..9e2b1a21 100644 --- a/product/phone/src/main/ets/pages/EntryView.ets +++ b/product/phone/src/main/ets/pages/EntryView.ets @@ -13,22 +13,23 @@ * limitations under the License. */ -import { HWRootSceneSession } from '@ohos/common' -import { HWSceneSessionManager } from '@ohos/common' -import { HWScreen } from '../WindowScene/HWScreen' -import { HWScreenSession } from '@ohos/common' +import { SCBRootSceneSession } from '@ohos/common' +import { SCBSceneSessionManager } from '@ohos/common' +import { SCBScreen } from '../WindowScene/SCBScreen' +import { SCBScreenSession, SCBGestureModel } from '@ohos/common' @Entry @Component struct EntryView { - @StorageLink('screenSessionList') screenSessionList: HWScreenSession[] = [] - private rootSceneSession: HWRootSceneSession = HWSceneSessionManager.getInstance().getRootSceneSession() + @StorageLink('screenSessionList') screenSessionList: SCBScreenSession[] = [] +// @StorageLink('gestureModel') gestureModel: SCBGestureModel = new SCBGestureModel() + private rootSceneSession: SCBRootSceneSession = SCBSceneSessionManager.getInstance().getRootSceneSession() build() { RootScene(this.rootSceneSession.session) { ForEach(this.screenSessionList, (item) => { - HWScreen({screenSession: item}) - }, (item: HWScreenSession) => item.session.screenId.toString()) + SCBScreen({screenSession: item}) + }, (item: SCBScreenSession) => item.session.screenId.toString()) } } } -- Gitee