修复鼠标旋转模型
增加侧边栏图标和布局
This commit is contained in:
parent
1fe0238d87
commit
a99ebe39da
@ -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(event.button==OH_NATIVEXCOMPONENT_LEFT_BUTTON&&event.action==OH_NATIVEXCOMPONENT_MOUSE_PRESS){
|
||||||
if(NativeManager::isMouseMiddleBtnPressed){
|
if(NativeManager::isMouseMiddleBtnPressed){
|
||||||
NativeManager::isMouseMiddleBtnPressed=false;
|
NativeManager::isMouseMiddleBtnPressed=false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//记录按下时候的X.Y坐标
|
//记录按下时候的X.Y坐标
|
||||||
NativeManager::lastMouseX_=event.x;
|
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, "AtButton:%{public}d",event.button);
|
||||||
HILOG_WARN(NATIVE_TAG, "AtButtonAction:%{public}d",event.action);
|
HILOG_WARN(NATIVE_TAG, "AtButtonAction:%{public}d",event.action);
|
||||||
HILOG_WARN(NATIVE_TAG, "AtisMouseMiddleBtnPressed:%{public}d",NativeManager::isMouseMiddleBtnPressed);
|
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 deltaX = curtX - NativeManager::lastMouseX_;
|
||||||
float deltaY = curtY - NativeManager::lastMouseY_;
|
float deltaY = curtY - NativeManager::lastMouseY_;
|
||||||
// 将像素移动量映射到旋转角度
|
// 将像素移动量映射到旋转角度
|
||||||
// 这里的系数可以根据需要调整灵敏度
|
// 这里的系数可以根据需要调整灵敏度
|
||||||
float rotationSpeed = 0.005f;
|
float rotationSpeed = 0.003f;
|
||||||
float angleX = deltaX * rotationSpeed;
|
float angleX = deltaX * rotationSpeed;
|
||||||
float angleY = deltaY * rotationSpeed;
|
float angleY = deltaY * rotationSpeed;
|
||||||
// 通知渲染线程执行旋转
|
// 通知渲染线程执行旋转
|
||||||
|
|||||||
@ -24,4 +24,23 @@ export struct Expandable {
|
|||||||
.alignSelf(ItemAlign.Center)
|
.alignSelf(ItemAlign.Center)
|
||||||
}.width('100%')
|
}.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;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,9 @@
|
|||||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||||
import { edgeColors,display } from '@kit.ArkUI';
|
import { edgeColors,display } from '@kit.ArkUI';
|
||||||
import {TitleTab} from './TitleTabLayout/TitleTab'
|
import {TitleTab} from './TitleLayout/TitleTab'
|
||||||
import {LeftSideTab} from './leftSideTab'
|
import {LeftSideTab} from './LeftSideTab'
|
||||||
import {ModelViewTab} from './modelViewTab'
|
import {ModelViewTab} from './modelViewTab'
|
||||||
import {TitleColumnSub} from './TitleTabLayout/TitleColumnSub'
|
import {TitleColumnSub} from './TitleLayout/TitleColumnSub'
|
||||||
const DOMAIN = 0x0000;
|
const DOMAIN = 0x0000;
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@ -12,29 +12,35 @@ struct Index {
|
|||||||
|
|
||||||
build() {
|
build() {
|
||||||
//OpenCAX主界面整体布局,采用多行布局
|
//OpenCAX主界面整体布局,采用多行布局
|
||||||
Column({space:1}) {
|
Column({space:0}) {
|
||||||
//头部导航功能区
|
//头部导航功能区
|
||||||
TitleTab().height('auto').borderWidth('1vp')
|
TitleTab()
|
||||||
|
.height('auto')
|
||||||
|
.borderWidth(2)
|
||||||
|
.borderRadius(5)
|
||||||
//工具栏
|
//工具栏
|
||||||
Row() {
|
Row() {
|
||||||
TitleColumnSub();
|
TitleColumnSub();
|
||||||
}.height('4%')
|
}.height('4%')
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.borderWidth('1vp')
|
.borderWidth(2)
|
||||||
|
.borderRadius(5)
|
||||||
.align(Alignment.Start)
|
.align(Alignment.Start)
|
||||||
|
.margin({ top: -2,left:0,bottom:0,right:0})
|
||||||
Row() {
|
Row() {
|
||||||
//左侧边导航区
|
//左侧边导航区
|
||||||
LeftSideTab().borderWidth('1vp').width('20%');
|
LeftSideTab().width("15%");
|
||||||
//中间操作区域
|
//中间操作区域
|
||||||
Row() {
|
Row() {
|
||||||
ModelViewTab()
|
ModelViewTab()
|
||||||
}.width('80%')
|
}.width('90%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
.borderWidth('1vp')
|
.borderWidth(1)
|
||||||
.align(Alignment.Center)
|
.align(Alignment.Center)
|
||||||
}.height('80%')
|
}.height('80%')
|
||||||
.padding(1)
|
.borderWidth(2)
|
||||||
.padding(1)
|
.borderRadius(5)
|
||||||
|
.margin({ top: -2,left:0,bottom:0,right:0})
|
||||||
Column(){
|
Column(){
|
||||||
Text('状态栏').height('100%').width('100%')
|
Text('状态栏').height('100%').width('100%')
|
||||||
}.height('5%').borderWidth(1)
|
}.height('5%').borderWidth(1)
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { TitleButton } from "../Interface/ButtonInterface";
|
||||||
|
import { ModelType } from "./ModelType";
|
||||||
|
|
||||||
|
export let LeftSideBars:Array<TitleButton>=[
|
||||||
|
{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:""},
|
||||||
|
]
|
||||||
81
entry/src/main/ets/pages/LeftSideTab.ets
Normal file
81
entry/src/main/ets/pages/LeftSideTab.ets
Normal file
@ -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')
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -77,7 +77,6 @@ export struct TitleTab {
|
|||||||
TabContent() {
|
TabContent() {
|
||||||
TitleTabContent({curtLayout:item})
|
TitleTabContent({curtLayout:item})
|
||||||
}.align(Alignment.Start)
|
}.align(Alignment.Start)
|
||||||
.padding(1)
|
|
||||||
.margin({ top: 0,left:0,bottom:0,right:0})
|
.margin({ top: 0,left:0,bottom:0,right:0})
|
||||||
})
|
})
|
||||||
}.scrollable(false)
|
}.scrollable(false)
|
||||||
@ -15,7 +15,7 @@ export struct TitleTabContent {
|
|||||||
//迭代生成行容器
|
//迭代生成行容器
|
||||||
ForEach(this.curtLayout?.cmEvents, (row_items: Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>, mIndex: number) => {
|
ForEach(this.curtLayout?.cmEvents, (row_items: Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>, mIndex: number) => {
|
||||||
//行的按钮组容器
|
//行的按钮组容器
|
||||||
Row(){
|
Row({ space: 1 }){
|
||||||
ForEach(row_items, (row_item: TitleButton|Array<TitleGroup>|Array<TitleButton>, index: number) => {
|
ForEach(row_items, (row_item: TitleButton|Array<TitleGroup>|Array<TitleButton>, index: number) => {
|
||||||
if(!Array.isArray(row_item)){//TitleButton
|
if(!Array.isArray(row_item)){//TitleButton
|
||||||
//单按钮
|
//单按钮
|
||||||
@ -44,6 +44,7 @@ export struct TitleTabContent {
|
|||||||
//功能组名
|
//功能组名
|
||||||
GroupTextEventMenu({grpEvent:group_item})
|
GroupTextEventMenu({grpEvent:group_item})
|
||||||
}.borderWidth(1)
|
}.borderWidth(1)
|
||||||
|
.borderRadius(5)
|
||||||
.borderColor(Color.Grey)
|
.borderColor(Color.Grey)
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
@ -63,6 +64,6 @@ export struct TitleTabContent {
|
|||||||
.borderColor(Color.Gray)
|
.borderColor(Color.Gray)
|
||||||
})
|
})
|
||||||
}.margin({ top: 1,left:1,bottom:1,right:1})
|
}.margin({ top: 1,left:1,bottom:1,right:1})
|
||||||
.borderWidth(1)
|
//.borderWidth(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,60 +0,0 @@
|
|||||||
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
||||||
|
|
||||||
|
|
||||||
interface LeftSideTabName {
|
|
||||||
//标签名
|
|
||||||
str: string;
|
|
||||||
//图标名
|
|
||||||
ico: string;
|
|
||||||
//页面名
|
|
||||||
page:string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component
|
|
||||||
export struct LeftSideTab {
|
|
||||||
@State leftSideBarTabsName:Array<LeftSideTabName>=[
|
|
||||||
{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')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BIN
entry/src/main/resources/base/media/base_expand_off.png
Normal file
BIN
entry/src/main/resources/base/media/base_expand_off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
entry/src/main/resources/base/media/base_expand_on.png
Normal file
BIN
entry/src/main/resources/base/media/base_expand_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
entry/src/main/resources/base/media/left_side_assembly.bmp
Normal file
BIN
entry/src/main/resources/base/media/left_side_assembly.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
Loading…
Reference in New Issue
Block a user