OpenCAX/entry/src/main/ets/pages/Index.ets
2026-03-20 16:13:48 +08:00

78 lines
2.9 KiB
Plaintext

import { hilog } from '@kit.PerformanceAnalysisKit';
import { edgeColors, display, AppStorageV2 } from '@kit.ArkUI';
import { TitleTab } from './TitleLayout/TitleTab'
import { LeftSideTab } from './LeftSideLayout/LeftSideTab'
import { ModelViewTab } from './modelViewTab'
import { TitleColumnSub } from './TitleLayout/TitleColumnSub'
import { MainWindowInfo } from './AppStorageV2Class'
const DOMAIN = 0x0000;
@Entry
@ComponentV2
struct Index {
@Local mwInfo: MainWindowInfo = AppStorageV2.connect<MainWindowInfo>(MainWindowInfo, () => new MainWindowInfo())!;
@Local startX:number=0;
@Local isDragging:boolean=false;
@Provider('panelWidth') panelWidth:number=this.mwInfo.mainWindowWidth * 0.15;
build() {
//OpenCAX主界面整体布局,采用多行布局
Column({ space: 0 }) {
//头部导航功能区
TitleTab()
.height(this.mwInfo.mainWindowHeight * 0.1)
.borderRadius(5)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏
Row() {
TitleColumnSub();
}
.width('100%')
.height(this.mwInfo.mainWindowHeight * 0.03)
.align(Alignment.Start)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() {
//左侧边导航区
LeftSideTab()
// 拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
this.startX = event.screenX; // 记录起始坐标
this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.panelWidth + (event.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.panelWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//中间操作区域
Row() {
ModelViewTab()
}.layoutWeight(1)
.align(Alignment.Center)
}.width('100%')
.height(this.mwInfo.mainWindowHeight * 0.36)
//分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
///状态栏
Column() {
Text('状态栏')
}.width('100%')
.align(Alignment.End)
.alignItems(HorizontalAlign.Start)
.height(this.mwInfo.mainWindowHeight * 0.05)
}.backgroundColor('#f3f3f0')
.width('100%')
.height('100%')
}
}