diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp index c0257ce5..c75c344f 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeManager.cpp @@ -216,6 +216,7 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) { if(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){ if(NativeManager::isMouseMiddleBtnPressed){ NativeManager::isMouseMiddleBtnPressed=false; + return; } //记录按下时候的X.Y坐标 NativeManager::lastMouseX_=event.x; @@ -226,13 +227,13 @@ void NativeManager::OnMouseEvent(OH_NativeXComponent *component, void *window) { HILOG_WARN(NATIVE_TAG, "AtButton:%{public}d",event.button); HILOG_WARN(NATIVE_TAG, "AtButtonAction:%{public}d",event.action); HILOG_WARN(NATIVE_TAG, "AtisMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed); - }else if(NativeManager::isMouseMiddleBtnPressed&&event.action==OH_NATIVEXCOMPONENT_MOUSE_MOVE){ + }else if(event.action==OH_NATIVEXCOMPONENT_MOUSE_MOVE&&NativeManager::isMouseMiddleBtnPressed){ // 计算鼠标移动距离 float deltaX = curtX - NativeManager::lastMouseX_; float deltaY = curtY - NativeManager::lastMouseY_; // 将像素移动量映射到旋转角度 // 这里的系数可以根据需要调整灵敏度 - float rotationSpeed = 0.005f; + float rotationSpeed = 0.003f; float angleX = deltaX * rotationSpeed; float angleY = deltaY * rotationSpeed; // 通知渲染线程执行旋转 diff --git a/entry/src/main/ets/pages/CustomStyle/Expandable.ets b/entry/src/main/ets/pages/CustomStyle/Expandable.ets index 87a6efa3..b8f868d8 100644 --- a/entry/src/main/ets/pages/CustomStyle/Expandable.ets +++ b/entry/src/main/ets/pages/CustomStyle/Expandable.ets @@ -24,4 +24,23 @@ export struct Expandable { .alignSelf(ItemAlign.Center) }.width('100%') } +} + +@ComponentV2 +export struct LeftSideTabExpan { + // 控制内容区域显示与隐藏的状态 + @Consumer('isSubExpanded') isSubExpanded: boolean=true; + build(){ + // 标题行 + Row({ space: 0 }) { + // 切换按钮,显示向上或向下箭头 + Button(this.isSubExpanded ? '◀' : '▶') + .type(ButtonType.Normal) + .fontSize(12) + .onClick(() => { + // 点击按钮时,切换 isSubExpanded 状态 + this.isSubExpanded = !this.isSubExpanded; + }) + } + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index fab1a726..84a026be 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,9 +1,9 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { edgeColors,display } from '@kit.ArkUI'; -import {TitleTab} from './TitleTabLayout/TitleTab' -import {LeftSideTab} from './leftSideTab' +import {TitleTab} from './TitleLayout/TitleTab' +import {LeftSideTab} from './LeftSideTab' import {ModelViewTab} from './modelViewTab' -import {TitleColumnSub} from './TitleTabLayout/TitleColumnSub' +import {TitleColumnSub} from './TitleLayout/TitleColumnSub' const DOMAIN = 0x0000; @Entry @@ -12,29 +12,35 @@ struct Index { build() { //OpenCAX主界面整体布局,采用多行布局 - Column({space:1}) { + Column({space:0}) { //头部导航功能区 - TitleTab().height('auto').borderWidth('1vp') + TitleTab() + .height('auto') + .borderWidth(2) + .borderRadius(5) //工具栏 Row() { TitleColumnSub(); }.height('4%') .width('100%') - .borderWidth('1vp') + .borderWidth(2) + .borderRadius(5) .align(Alignment.Start) + .margin({ top: -2,left:0,bottom:0,right:0}) Row() { //左侧边导航区 - LeftSideTab().borderWidth('1vp').width('20%'); + LeftSideTab().width("15%"); //中间操作区域 Row() { ModelViewTab() - }.width('80%') + }.width('90%') .height('100%') - .borderWidth('1vp') + .borderWidth(1) .align(Alignment.Center) }.height('80%') - .padding(1) - .padding(1) + .borderWidth(2) + .borderRadius(5) + .margin({ top: -2,left:0,bottom:0,right:0}) Column(){ Text('状态栏').height('100%').width('100%') }.height('5%').borderWidth(1) diff --git a/entry/src/main/ets/pages/LayoutInterface/Layout/LeftSideBar.ets b/entry/src/main/ets/pages/LayoutInterface/Layout/LeftSideBar.ets new file mode 100644 index 00000000..7480a876 --- /dev/null +++ b/entry/src/main/ets/pages/LayoutInterface/Layout/LeftSideBar.ets @@ -0,0 +1,8 @@ +import { TitleButton } from "../Interface/ButtonInterface"; +import { ModelType } from "./ModelType"; + +export let LeftSideBars:Array=[ + {eModel:[ModelType.BASE],eName:"装配导航器",eNamed:"",ePage:'',eIcon:"left_side_assembly",eTips:"正三轴测图",eEvent:""}, + {eModel:[ModelType.BASE],eName:"约束导航器",eNamed:"",ePage:'',eIcon:"left_side_mate_components",eTips:"前视图",eEvent:""}, + {eModel:[ModelType.BASE],eName:"部件导航器",eNamed:"",ePage:'',eIcon:"base_model_cad",eTips:"前视图",eEvent:""}, +] \ No newline at end of file diff --git a/entry/src/main/ets/pages/LeftSideLayout/LeftSideLayout.ets b/entry/src/main/ets/pages/LeftSideLayout/LeftSideLayout.ets new file mode 100644 index 00000000..e69de29b diff --git a/entry/src/main/ets/pages/LeftSideTab.ets b/entry/src/main/ets/pages/LeftSideTab.ets new file mode 100644 index 00000000..e362b55e --- /dev/null +++ b/entry/src/main/ets/pages/LeftSideTab.ets @@ -0,0 +1,81 @@ +import { TitleButton } from './LayoutInterface/Interface/ButtonInterface'; +import {LeftSideBars} from './LayoutInterface/Layout/LeftSideBar' +@ComponentV2 +export struct LeftSideTab { + + private leftSideBarTabs: TabsController = new TabsController(); + @Local leftSideBarFocusIndex: number = 0; + @Local isExpanded:boolean=true; + @Local leftWidth:number=0; + + build() { + Row() { + Column({space:1}){ + Button() + .borderWidth(1) + .borderColor(Color.Grey) + .borderRadius(5) + .backgroundImagePosition({ x: '5%', y: '5%' }) + .backgroundColor(Color.Transparent) + .backgroundImageSize({ + width: '90%', // 图片宽度占满按钮 + height: '90%' // 图片高度占满按钮 + }) + .backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off')) + .type(ButtonType.Normal) + .width(50) + .height(50) + .onClick(()=>{ + this.isExpanded = !this.isExpanded; + }).margin({ top: 2,left:1,bottom:0,right:2}) + Scroll() { + Flex({ direction: FlexDirection.Column}) { + ForEach(LeftSideBars, (item: TitleButton, index: number) => { + Column({ space: 0 }) { + Button() + .borderWidth(1) + .borderColor(Color.Grey) + .borderRadius(5) + .backgroundImagePosition({ x: '5%', y: '5%' }) + .backgroundColor(Color.Transparent) + .backgroundImageSize({ + width: '90%', // 图片宽度占满按钮 + height: '90%' // 图片高度占满按钮 + }) + .backgroundImage($r('app.media.'+item.eIcon)) + .fontWeight(index === this.leftSideBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) + .height(50) + .width(50) + .type(ButtonType.Normal) + .onClick(() => { + this.leftSideBarTabs.changeIndex(index); + this.leftSideBarFocusIndex = index; + }) + }.margin({ top: 2,left:0,bottom:0,right:0}) + }) + Blank().height('95%') + } + } + .align(Alignment.Start) + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.Off) + .width(50) + .height('100%') + } + Column({space:1}){ + if (this.isExpanded) { + Column() { + Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) { + ForEach(LeftSideBars, (item: TitleButton, index: number) => { + TabContent() { + Text(item.eName) + .fontSize(30) + } + }) + }.barHeight(0) + } + } + } + }.width('auto') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/TitleTabLayout/README.md b/entry/src/main/ets/pages/TitleLayout/README.md similarity index 100% rename from entry/src/main/ets/pages/TitleTabLayout/README.md rename to entry/src/main/ets/pages/TitleLayout/README.md diff --git a/entry/src/main/ets/pages/TitleTabLayout/TitleColumnSub.ets b/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets similarity index 100% rename from entry/src/main/ets/pages/TitleTabLayout/TitleColumnSub.ets rename to entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets diff --git a/entry/src/main/ets/pages/TitleTabLayout/TitleTab.ets b/entry/src/main/ets/pages/TitleLayout/TitleTab.ets similarity index 99% rename from entry/src/main/ets/pages/TitleTabLayout/TitleTab.ets rename to entry/src/main/ets/pages/TitleLayout/TitleTab.ets index ce3c0ab6..d08b3687 100644 --- a/entry/src/main/ets/pages/TitleTabLayout/TitleTab.ets +++ b/entry/src/main/ets/pages/TitleLayout/TitleTab.ets @@ -77,7 +77,6 @@ export struct TitleTab { TabContent() { TitleTabContent({curtLayout:item}) }.align(Alignment.Start) - .padding(1) .margin({ top: 0,left:0,bottom:0,right:0}) }) }.scrollable(false) diff --git a/entry/src/main/ets/pages/TitleTabLayout/TitleTabContent.ets b/entry/src/main/ets/pages/TitleLayout/TitleTabContent.ets similarity index 96% rename from entry/src/main/ets/pages/TitleTabLayout/TitleTabContent.ets rename to entry/src/main/ets/pages/TitleLayout/TitleTabContent.ets index 2f665594..6c232c7a 100644 --- a/entry/src/main/ets/pages/TitleTabLayout/TitleTabContent.ets +++ b/entry/src/main/ets/pages/TitleLayout/TitleTabContent.ets @@ -15,7 +15,7 @@ export struct TitleTabContent { //迭代生成行容器 ForEach(this.curtLayout?.cmEvents, (row_items: Array|Array>, mIndex: number) => { //行的按钮组容器 - Row(){ + Row({ space: 1 }){ ForEach(row_items, (row_item: TitleButton|Array|Array, index: number) => { if(!Array.isArray(row_item)){//TitleButton //单按钮 @@ -44,6 +44,7 @@ export struct TitleTabContent { //功能组名 GroupTextEventMenu({grpEvent:group_item}) }.borderWidth(1) + .borderRadius(5) .borderColor(Color.Grey) }) }else{ @@ -63,6 +64,6 @@ export struct TitleTabContent { .borderColor(Color.Gray) }) }.margin({ top: 1,left:1,bottom:1,right:1}) - .borderWidth(1) + //.borderWidth(1) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/leftSideTab.ets b/entry/src/main/ets/pages/leftSideTab.ets deleted file mode 100644 index f95673db..00000000 --- a/entry/src/main/ets/pages/leftSideTab.ets +++ /dev/null @@ -1,60 +0,0 @@ -import { hilog } from '@kit.PerformanceAnalysisKit'; - - -interface LeftSideTabName { - //标签名 - str: string; - //图标名 - ico: string; - //页面名 - page:string; -} - -@Component -export struct LeftSideTab { - @State leftSideBarTabsName:Array=[ - {str:'建模树',ico:'',page:''}, - {str:'组装树',ico:'',page:''}, - ] - private leftSideBarTabs: TabsController = new TabsController(); - @State leftSideBarFocusIndex: number = 0; - build() { - Row() { - Scroll() { - Flex({ direction: FlexDirection.Column }) { - ForEach(this.leftSideBarTabsName, (item: LeftSideTabName, index: number) => { - Column({ space: 5 }) { - Button(item.str) - .fontWeight(index === this.leftSideBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) - .height(50) - .width(50) - .padding(5) - .type(ButtonType.Normal) - } - .padding({ left: 5, right: 5 }) - .margin({ top: 2,left:2,bottom:2,right:2}) - .onClick(() => { - this.leftSideBarTabs.changeIndex(index); - this.leftSideBarFocusIndex = index; - }) - }) - Blank().height('80%') - } - } - .align(Alignment.Start) - .scrollable(ScrollDirection.Vertical) - .scrollBar(BarState.Off) - .width('30%') - - Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) { - ForEach(this.leftSideBarTabsName, (item: LeftSideTabName, index: number) => { - TabContent() { - Text(item.str) - .fontSize(30) - } - }) - }.barHeight(0) - .width('70%') - }.borderWidth('1') - } -} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/base_expand_off.png b/entry/src/main/resources/base/media/base_expand_off.png new file mode 100644 index 00000000..ce5bdb98 Binary files /dev/null and b/entry/src/main/resources/base/media/base_expand_off.png differ diff --git a/entry/src/main/resources/base/media/base_expand_on.png b/entry/src/main/resources/base/media/base_expand_on.png new file mode 100644 index 00000000..124bc7a3 Binary files /dev/null and b/entry/src/main/resources/base/media/base_expand_on.png differ diff --git a/entry/src/main/resources/base/media/left_side_assembly.bmp b/entry/src/main/resources/base/media/left_side_assembly.bmp new file mode 100644 index 00000000..9fbfbed0 Binary files /dev/null and b/entry/src/main/resources/base/media/left_side_assembly.bmp differ diff --git a/entry/src/main/resources/base/media/left_side_mate_components.bmp b/entry/src/main/resources/base/media/left_side_mate_components.bmp new file mode 100644 index 00000000..283f1358 Binary files /dev/null and b/entry/src/main/resources/base/media/left_side_mate_components.bmp differ