ForCAX/entry/src/main/ets/pages/Index.ets
JackLee 8b779ebf86 InitEnv 初始化环境检测<br>
InitFonts      初始化字体<br>
InitOpts       初始化软件设置<br>
InitSubAbility 初始化子窗口的Ability<br>
InitEventHub   初始化事件总线<br>
InitGlobalDWI  初始化设备分辨率,窗体尺寸<br>
InitHub        调用子初始化文件入口<br>

InitSubAbility InitOpts InitEventHub未完成
2026-04-24 15:29:40 +08:00

134 lines
5.1 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 { uiMode } 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.1;
@Provider('RightSideWidth') rightSideWidth:number=mdwInfo.winHeight * 0.1;
//利用分割线拖动改变区域容器大小.鼠标和触控整合
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, 0);
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, 0);
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?'15%':'0%')
//TitleTab().height('15%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏
Row() {
TitleColumnSub()
}.height('4%')
.align(Alignment.Start)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() {
//左侧边导航区
LeftSideTab().width(uiMode.state?this.leftSideWidth:'0%')
// 左拖拽手柄
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(uiMode.state?this.rightSideWidth:'0%')
}.height(uiMode.state?'77%':'92%')
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
Column() {
Text('状态栏').fontSize(16)
}.width('100%')
.align(Alignment.End)
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.height('4%')
}
TitleTab()
.height(uiMode.state?'15%':'0%')
.backgroundColor(Color.Transparent)
.backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}.width('100%')
.height('100%')
.backgroundColor(Color.Transparent)
.backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}
}