127 lines
4.9 KiB
Plaintext
127 lines
4.9 KiB
Plaintext
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
import { TitleTab } from './titletabs/TitleTab'
|
|
import { LeftSideTab } from './leftside/LeftSideTab'
|
|
import { RightSideTab } from './rightside/RightSideTab'
|
|
import { View } from './view/View'
|
|
import { TitleColumnSub } from './titletabs/TitleColumnSub'
|
|
import { mdwInfo } from './dispwininfo/DispWinInfo'
|
|
import { sideState } from './eventhub/EventBase'
|
|
const DOMAIN = 0x0000;
|
|
|
|
//分割线类型,分左和右
|
|
enum DividerType{
|
|
LeftSide,
|
|
RightSide
|
|
}
|
|
|
|
@Entry
|
|
@ComponentV2
|
|
struct Index {
|
|
@Local startX:number=0;
|
|
@Local isDragging:boolean=false;
|
|
@Provider('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.087;
|
|
@Provider('RightSideWidth') rightSideWidth:number=mdwInfo.winWidth * 0.087;
|
|
|
|
//利用分割线拖动改变区域容器大小.鼠标和触控整合
|
|
dividerChangeSize(event:MouseEvent|TouchEvent,dividerType:DividerType){
|
|
let screenX: number;
|
|
//鼠标事件
|
|
if((event as MouseEvent)){
|
|
const mouseEvent = event as MouseEvent;
|
|
//左边分割线
|
|
if(dividerType==DividerType.LeftSide){
|
|
if(mouseEvent.button==MouseButton.Left&&mouseEvent.action==MouseAction.Press){
|
|
this.startX = mouseEvent.windowX; // 记录起始坐标
|
|
this.isDragging = true;
|
|
}else if(mouseEvent.action==MouseAction.Move&&this.isDragging){
|
|
// 计算新的宽度
|
|
let newWidth = this.leftSideWidth + (mouseEvent.windowX - this.startX);
|
|
// 添加最小宽度限制
|
|
newWidth = Math.max(newWidth, mdwInfo.winWidth*0.013);
|
|
this.leftSideWidth = newWidth;
|
|
// 更新起始坐标,实现连续拖动
|
|
this.startX = mouseEvent.windowX;
|
|
}else if(mouseEvent.action==MouseAction.Release){
|
|
this.isDragging = false;
|
|
}
|
|
}
|
|
else if(dividerType==DividerType.RightSide) //右分割线
|
|
{
|
|
if(mouseEvent.button==MouseButton.Left&&mouseEvent.action==MouseAction.Press){
|
|
this.startX = mouseEvent.windowX; // 记录起始坐标
|
|
this.isDragging = true;
|
|
}else if(mouseEvent.action==MouseAction.Move&&this.isDragging){
|
|
// 计算新的宽度
|
|
let newWidth = this.rightSideWidth - (mouseEvent.windowX - this.startX);
|
|
// 添加最小宽度限制
|
|
newWidth = Math.max(newWidth, mdwInfo.winWidth*0.013);
|
|
this.rightSideWidth = newWidth;
|
|
// 更新起始坐标,实现连续拖动
|
|
this.startX = mouseEvent.windowX;
|
|
}else if(mouseEvent.action==MouseAction.Release){
|
|
this.isDragging = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
build() {
|
|
Stack({ alignContent: Alignment.Top }) {
|
|
//OpenCAX主界面整体布局,采用多行布局
|
|
Column() {
|
|
//头部导航功能区
|
|
//Blank().height(uiMode.state?mdwInfo.displayHeight*0.07:0)
|
|
TitleTab().height(sideState.headSide?mdwInfo.displayHeight*0.075:0)
|
|
//分割线
|
|
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
|
//工具栏
|
|
Row() {
|
|
TitleColumnSub()
|
|
}.height(mdwInfo.displayHeight*0.02)
|
|
.align(Alignment.Start)
|
|
//分割线
|
|
Divider().vertical(false).strokeWidth(2).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
|
Row() {
|
|
//左侧边导航区
|
|
LeftSideTab().width(sideState.leftSide?this.leftSideWidth:mdwInfo.winWidth*0.013)
|
|
// 左拖拽手柄
|
|
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
|
|
.onMouse((event) => {
|
|
this.dividerChangeSize(event,DividerType.LeftSide)
|
|
})
|
|
.onTouch((event) => {
|
|
this.dividerChangeSize(event,DividerType.LeftSide)
|
|
})
|
|
//中间操作区域
|
|
Row() {
|
|
View()
|
|
}.layoutWeight(1)
|
|
.align(Alignment.Center)
|
|
//右拖拽手柄
|
|
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
|
|
.onMouse((event) => {
|
|
this.dividerChangeSize(event,DividerType.RightSide)
|
|
})
|
|
.onTouch((event) => {
|
|
this.dividerChangeSize(event,DividerType.RightSide)
|
|
})
|
|
//右侧边导航区
|
|
RightSideTab().width(sideState.rightSide?this.rightSideWidth:mdwInfo.winWidth*0.013)
|
|
}.layoutWeight(1)
|
|
//分割线
|
|
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
|
///状态栏
|
|
Row() {
|
|
Text('状态栏').fontSize(16)
|
|
}.width('100%')
|
|
.justifyContent(FlexAlign.Start)
|
|
.height(mdwInfo.displayHeight*0.02)
|
|
.backgroundColor(Color.Transparent)
|
|
}
|
|
//TitleTab().height(uiMode.state?mdwInfo.displayHeight*0.07:0)
|
|
|
|
}.width('100%')
|
|
.height('100%')
|
|
}
|
|
}
|