调整部分参数,使得在真机上缩放更合理

This commit is contained in:
JackLee 2026-04-10 14:29:13 +08:00
parent 45226308c2
commit a245b20fd2
11 changed files with 166 additions and 58 deletions

View File

@ -345,7 +345,7 @@ ArkUI_NodeHandle CreateNodeHandle(void* userData) {
// 注册XComponent回调函数 // 注册XComponent回调函数
OH_NativeXComponent_RegisterCallback(nativeXComponent, &NativeMgr::xSurfaceTouchEventCallBack); OH_NativeXComponent_RegisterCallback(nativeXComponent, &NativeMgr::xSurfaceTouchEventCallBack);
//注册XComponent组件鼠标回调事件 //注册XComponent组件鼠标回调事件
OH_NativeXComponent_RegisterMouseEventCallback(nativeXComponent, &NativeMgr::xMouseEventCallBack); //OH_NativeXComponent_RegisterMouseEventCallback(nativeXComponent, &NativeMgr::xMouseEventCallBack);
// nodeAPI->registerNodeEvent(xc, NODE_ON_MOUSE, 1, &xc); // nodeAPI->registerNodeEvent(xc, NODE_ON_MOUSE, 1, &xc);
// nodeAPI->registerNodeEvent(xc, NODE_ON_AXIS, 1, &xc); // nodeAPI->registerNodeEvent(xc, NODE_ON_AXIS, 1, &xc);
// nodeAPI->addNodeEventReceiver(xc, [](ArkUI_NodeEvent *event) { // nodeAPI->addNodeEventReceiver(xc, [](ArkUI_NodeEvent *event) {
@ -456,7 +456,19 @@ napi_value NativeMgr::initNativeNode(napi_env env, napi_callback_info info) {
void NativeMgr::DispatchTouchEvent(OH_NativeXComponent* component, void* window) void NativeMgr::DispatchTouchEvent(OH_NativeXComponent* component, void* window)
{ {
OH_NativeXComponent_TouchEvent touchEvent_;
int32_t ret = OH_NativeXComponent_GetTouchEvent(component, window, &touchEvent_); int32_t ret = OH_NativeXComponent_GetTouchEvent(component, window, &touchEvent_);
std::lock_guard<std::mutex> lock(mapMutex);
//通过时间戳判断事件唯一性.保证单一时间戳只触发一次事件
if(touchEvent_.timeStamp==NativeMgr::timestamp){
return;
}
NativeMgr::timestamp=touchEvent_.timeStamp;
auto renderThread=OCCTMgr::GetInstance()->getRenderThread(crtXCompId);
if(renderThread==nullptr){
HILOG_WARN(NATIVE_TAG, "Render thread not found for rotation.");
return;
}
if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) { if (ret == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
float tiltX = 2.2; float tiltX = 2.2;
float tiltY = 2.2; float tiltY = 2.2;
@ -470,8 +482,37 @@ void NativeMgr::DispatchTouchEvent(OH_NativeXComponent* component, void* window)
"type=%{public}d, force=%{public}f, tiltX=%{public}f, tiltY=%{public}f, toolType=%{public}d", "type=%{public}d, force=%{public}f, tiltX=%{public}f, tiltY=%{public}f, toolType=%{public}d",
touchEvent_.x, touchEvent_.y, touchEvent_.screenX, touchEvent_.x, touchEvent_.y, touchEvent_.screenX,
touchEvent_.screenY, touchEvent_.type, touchEvent_.force, tiltX, tiltY, toolType); touchEvent_.screenY, touchEvent_.type, touchEvent_.force, tiltX, tiltY, toolType);
if (touchEvent_.type == OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UP) { //判断触控点数量
//当触点为1则判定为单指,处理单指对应事件
if(touchEvent_.numPoints==1){
//触屏按下记录按下点坐标
if(touchEvent_.type ==OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_DOWN){
NativeMgr::x=touchEvent_.x;
NativeMgr::y=touchEvent_.y;
}
//按下并移动,计算移动增量需要乘以灵敏度
if (touchEvent_.type == OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_MOVE) {
float dtx=(NativeMgr::x-touchEvent_.x)*0.1;
float dty=(NativeMgr::y-touchEvent_.y)*0.1;
renderThread->setRotation(dtx, dty);
OH_NativeXComponent_GetTouchEvent(component, window, &touchEvent_);
NativeMgr::x=touchEvent_.x;
NativeMgr::y=touchEvent_.y;
}
//的判断为双指,处理双指事件功能(缩放视距)
}
else if(touchEvent_.numPoints==2)
{
//双指同时处于按下状态,并且移动
if(touchEvent_.touchPoints[0].isPressed
&&touchEvent_.touchPoints[1].isPressed){
//当双指按下时候,分别记录每个指的坐标
//双指移动,计算移动位移量,同时根据移动缩放因子计算视距,从调整相机相对于模型的距离.从而实现双指缩放
}else if(touchEvent_.type==OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_MOVE){
}
} }
} else { } else {
OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponent_Native", "touch fail"); OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponent_Native", "touch fail");

View File

@ -85,7 +85,6 @@ private:
std::unordered_map<std::string, NativeMgr*> pluginManagerMap_; std::unordered_map<std::string, NativeMgr*> pluginManagerMap_;
public: public:
// [StartExclude plugin_manager_h_part] // [StartExclude plugin_manager_h_part]
OH_NativeXComponent_TouchEvent touchEvent_;
static std::string crtXCompId; static std::string crtXCompId;
static std::unordered_map<std::string,NXInfo*> NxInfos; static std::unordered_map<std::string,NXInfo*> NxInfos;
std::string modelPath_; std::string modelPath_;
@ -96,6 +95,9 @@ public:
uint64_t afWidth; uint64_t afWidth;
uint64_t afHeight; uint64_t afHeight;
float x;
float y;
int64_t timestamp; int64_t timestamp;
static int32_t hasDraw_; static int32_t hasDraw_;
static int32_t hasChangeColor_; static int32_t hasChangeColor_;

View File

@ -45,14 +45,14 @@ void V3dCa::SetRotation(float xAngle, float yAngle) {
// 从 gp_Ax1 中提取方向向量 (gp_Dir -> gp_Vec) // 从 gp_Ax1 中提取方向向量 (gp_Dir -> gp_Vec)
gp_Vec xRotationAxis = camera->Direction().XYZ().Crossed(currentUp.XYZ()); // 叉积得到X旋转轴 gp_Vec xRotationAxis = camera->Direction().XYZ().Crossed(currentUp.XYZ()); // 叉积得到X旋转轴
if (xRotationAxis.Magnitude() > gp::Resolution()) { // 防止零向量导致的无效四元数 if (xRotationAxis.Magnitude() > gp::Resolution()) { // 防止零向量导致的无效四元数
rotX.SetVectorAndAngle(xRotationAxis, xAngle * M_PI / 180.0); rotX.SetVectorAndAngle(-xRotationAxis, xAngle * M_PI / 180.0);
} else { } else {
rotX.SetIdent(); // 如果叉积为零,则无旋转 rotX.SetIdent(); // 如果叉积为零,则无旋转
} }
// 从 gp_Ax1 中提取方向向量 (gp_Dir -> gp_Vec) // 从 gp_Ax1 中提取方向向量 (gp_Dir -> gp_Vec)
gp_Vec yRotationAxis = currentUp.XYZ(); // Y旋转轴就是当前的Up方向 gp_Vec yRotationAxis = currentUp.XYZ(); // Y旋转轴就是当前的Up方向
if (yRotationAxis.Magnitude() > gp::Resolution()) { if (yRotationAxis.Magnitude() > gp::Resolution()) {
rotY.SetVectorAndAngle(yRotationAxis, yAngle * M_PI / 180.0); rotY.SetVectorAndAngle(-yRotationAxis, yAngle * M_PI / 180.0);
} else { } else {
rotY.SetIdent(); // 如果Up向量无效则无旋转 rotY.SetIdent(); // 如果Up向量无效则无旋转
} }
@ -70,7 +70,7 @@ void V3dCa::SetRotation(float xAngle, float yAngle) {
camera->SetEye(newEye); camera->SetEye(newEye);
camera->SetCenter(rotationCenter); camera->SetCenter(rotationCenter);
camera->SetUp(newUp); camera->SetUp(newUp);
HILOG_ERROR(NATIVE_TAG,"Rotation"); //HILOG_ERROR(NATIVE_TAG,"Rotation");
} }

View File

@ -28,7 +28,7 @@ export struct EventBtn {
@Builder @Builder
build() { build() {
Column({ space: 2 }) { Column() {
//如果该类型是false表示为配普通事件按钮 //如果该类型是false表示为配普通事件按钮
if (this.eventBtn != undefined) { if (this.eventBtn != undefined) {
Button() Button()
@ -56,16 +56,15 @@ export struct EventBtn {
}) })
} }
if (this.eventBtn != undefined) { if (this.eventBtn != undefined) {
Text() Blank()
.width('auto') .width('auto')
.height(edHeigth) .height(edHeigth)
.backgroundColor(Color.Transparent)
Text(this.eventBtn.eName) Text(this.eventBtn.eName)
.fontSize(16) .fontSize(16)
.width('auto') .width('auto')
.height(edHeigth)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.backgroundColor(Color.Transparent) .backgroundColor(Color.Transparent)
.fontColor($r('sys.color.font_emphasize'))
} }
}.padding(1) }.padding(1)
} }
@ -75,9 +74,9 @@ export struct EventBtn {
//功能目录菜单,主要用于针对单一按钮多个功能形式 //功能目录菜单,主要用于针对单一按钮多个功能形式
@ComponentV2 @ComponentV2
export struct MenuBtn { export struct MenuBtn {
@Param menus: Array<TitleButton> | undefined = undefined; @Param menus?: Array<TitleButton>=undefined;
@Local curtIndex:number=0; @Local curtIndex:number=0;
@Local action?:TitleButton= undefined;
@Builder @Builder
BaseMenu (){ BaseMenu (){
Menu() { Menu() {
@ -93,13 +92,13 @@ export struct MenuBtn {
} }
}) })
}.fontSize(20) }.fontSize(20)
.fontColor($r('sys.color.font_emphasize'))
} }
build() { build() {
Column({ space: 0 }) { Column({ space: 0 }) {
if (this.menus != undefined) { if (this.menus != undefined) {
Button() Button()
.bindMenu(this.BaseMenu)
.width(ebWidth) .width(ebWidth)
.height(ebHeigth) .height(ebHeigth)
.backgroundImage($r('app.media.' + this.menus[this.curtIndex].eIcon)) .backgroundImage($r('app.media.' + this.menus[this.curtIndex].eIcon))
@ -108,21 +107,24 @@ export struct MenuBtn {
.backgroundImageSize({ .backgroundImageSize({
width: '90%', // 图片宽度占满按钮 width: '90%', // 图片宽度占满按钮
height: '90%' // 图片高度占满按钮 height: '90%' // 图片高度占满按钮
}).onClick(()=> {
ExecuteCommand((this.menus as Array<TitleButton>)[this.curtIndex] as TitleButton);
}) })
Button() Button()
.type(ButtonType.Normal)
.bindMenu(this.BaseMenu) .bindMenu(this.BaseMenu)
.type(ButtonType.Normal)
.width(ebWidth) .width(ebWidth)
.height(edHeigth) .height(edHeigth)
.backgroundImage($r('app.media.base_chevron_down')) .backgroundImage($r('app.media.base_chevron_down'))
.backgroundImagePosition({ x: '35%', y: '0%' }) .backgroundImagePosition({ x: '35%', y: '0%' })
.backgroundColor(Color.Transparent) .backgroundColor(Color.Transparent)
Text((this.menus[this.curtIndex].eName)) Text((this.menus[this.curtIndex].eName))
.bindMenu(this.BaseMenu)
.fontSize(16) .fontSize(16)
.width('auto') .width('auto')
.height(edHeigth)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.backgroundColor(Color.Transparent)
.fontColor($r('sys.color.font_emphasize'))
} }
} }
.padding(1) .padding(1)
@ -152,6 +154,7 @@ export struct SubColumnMenu {
.size({ height: ebWidth }) .size({ height: ebWidth })
}) })
}.fontSize(20) }.fontSize(20)
.fontColor($r('sys.color.font_emphasize'))
} }
@Builder @Builder
BaseMenu (){ BaseMenu (){
@ -174,6 +177,7 @@ export struct SubColumnMenu {
} }
}) })
}.fontSize(20) }.fontSize(20)
.fontColor($r('sys.color.font_emphasize'))
} }
build(){ build(){
@ -183,7 +187,9 @@ export struct SubColumnMenu {
Image($r('app.media.'+(this.icon!=undefined ? this.icon:(this.menus[this.curtIndex]as TitleButton).eIcon))) Image($r('app.media.'+(this.icon!=undefined ? this.icon:(this.menus[this.curtIndex]as TitleButton).eIcon)))
.height(mwInfo.width*0.01) .height(mwInfo.width*0.01)
if(this.name!=undefined){ if(this.name!=undefined){
Text(this.name).fontSize(16) Text(this.name)
.fontSize(16)
.fontColor($r('sys.color.font_emphasize'))
} }
} }
}.height(mwInfo.width*0.01) }.height(mwInfo.width*0.01)

View File

@ -63,7 +63,7 @@ export struct GroupTextEventMenu {
Blank().width('auto') Blank().width('auto')
Text(this.grpEvent.grpName) Text(this.grpEvent.grpName)
.fontSize(16) .fontSize(16)
.fontColor(Color.Gray) .fontColor($r('sys.color.font_emphasize'))
Blank().width('auto') Blank().width('auto')
Button() Button()
.height(mwInfo.width*0.005) .height(mwInfo.width*0.005)

View File

@ -2,6 +2,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
import { edgeColors, display, AppStorageV2 } from '@kit.ArkUI'; import { edgeColors, display, AppStorageV2 } from '@kit.ArkUI';
import { TitleTab } from './TitleLayout/TitleTab' import { TitleTab } from './TitleLayout/TitleTab'
import { LeftSideTab } from './LeftSideLayout/LeftSideTab' import { LeftSideTab } from './LeftSideLayout/LeftSideTab'
import { RightSideTab } from './RightSideLayout/RightSideTab'
import { ModelViewTab } from './ModelViewTab' import { ModelViewTab } from './ModelViewTab'
import { TitleColumnSub } from './TitleLayout/TitleColumnSub' import { TitleColumnSub } from './TitleLayout/TitleColumnSub'
import { mwInfo } from './DispWinInfo/DispWinInfo' import { mwInfo } from './DispWinInfo/DispWinInfo'
@ -13,29 +14,29 @@ const DOMAIN = 0x0000;
struct Index { struct Index {
@Local startX:number=0; @Local startX:number=0;
@Local isDragging:boolean=false; @Local isDragging:boolean=false;
@Provider('panelWidth') panelWidth:number=mwInfo.width * 0.15; @Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
build() { build() {
//OpenCAX主界面整体布局,采用多行布局 //OpenCAX主界面整体布局,采用多行布局
Column({ space: 0 }) { Column({ space: 0 }) {
//头部导航功能区 //头部导航功能区
TitleTab() TitleTab()
.height(mwInfo.height * 0.08)
//分割线 //分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey) Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
//工具栏 //工具栏
Row() { Row() {
TitleColumnSub(); TitleColumnSub();
Blank().layoutWeight(1)
} }
.width('100%')
.height(mwInfo.height * 0.02) .height(mwInfo.height * 0.02)
.align(Alignment.Start) .align(Alignment.Start)
//分割线 //分割线
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey) Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
Row() { Row() {
//左侧边导航区 //左侧边导航区
LeftSideTab() LeftSideTab()
// 拖拽手柄 // 拖拽手柄
Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey) Divider().vertical(true).strokeWidth(3).lineCap(LineCapStyle.Round).height('100%').backgroundColor(Color.Grey)
.onMouse((event) => { .onMouse((event) => {
if(event.button==MouseButton.Left&&event.action==MouseAction.Press){ if(event.button==MouseButton.Left&&event.action==MouseAction.Press){
@ -43,10 +44,10 @@ struct Index {
this.isDragging = true; this.isDragging = true;
}else if(event.action==MouseAction.Move&&this.isDragging){ }else if(event.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度 // 计算新的宽度
let newWidth = this.panelWidth + (event.screenX - this.startX); let newWidth = this.leftSideWidth + (event.screenX - this.startX);
// 添加最小宽度限制 // 添加最小宽度限制
newWidth = Math.max(newWidth, 0); newWidth = Math.max(newWidth, 0);
this.panelWidth = newWidth; this.leftSideWidth = newWidth;
// 更新起始坐标,实现连续拖动 // 更新起始坐标,实现连续拖动
this.startX = event.screenX; this.startX = event.screenX;
}else if(event.action==MouseAction.Release){ }else if(event.action==MouseAction.Release){
@ -58,6 +59,26 @@ struct Index {
ModelViewTab() ModelViewTab()
}.layoutWeight(1) }.layoutWeight(1)
.align(Alignment.Center) .align(Alignment.Center)
//右拖拽手柄
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.rightSideWidth - (event.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.rightSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
})
//右侧边导航区
RightSideTab()
}.width('100%') }.width('100%')
.height(mwInfo.height * 0.39) .height(mwInfo.height * 0.39)
//分割线 //分割线
@ -68,9 +89,8 @@ struct Index {
}.width('100%') }.width('100%')
.align(Alignment.End) .align(Alignment.End)
.alignItems(HorizontalAlign.Start) .alignItems(HorizontalAlign.Start)
.height(20) .justifyContent(FlexAlign.Center)
}.backgroundColor('#f3f3f0') .height(25)
.width('100%') }.margin({ top:0, left: 0, bottom: 0, right: 0 })
.height('100%')
} }
} }

View File

@ -7,7 +7,7 @@ export struct LeftSideTab {
private leftSideBarTabs: TabsController = new TabsController(); private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0; @Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=true; @Local isExpanded:boolean=true;
@Consumer('panelWidth') panelWidth:number=mwInfo.width * 0.1; @Consumer('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
build() { build() {
Row() { Row() {
@ -25,14 +25,10 @@ export struct LeftSideTab {
.backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off')) .backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off'))
.type(ButtonType.Normal) .type(ButtonType.Normal)
.width(mwInfo.width*0.013) .width(mwInfo.width*0.013)
.height(mwInfo.height*0.013) .height(mwInfo.width*0.013)
.onClick(()=>{ .onClick(()=>{
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
if(this.isExpanded){ this.leftSideWidth=this.isExpanded?mwInfo.width * 0.1:0
this.panelWidth=mwInfo.width * 0.1;
}else{
this.panelWidth=0;
}
}).margin({ top: 2,left:1,bottom:0,right:2}) }).margin({ top: 2,left:1,bottom:0,right:2})
Scroll() { Scroll() {
Flex({ direction: FlexDirection.Column}) { Flex({ direction: FlexDirection.Column}) {
@ -70,8 +66,6 @@ export struct LeftSideTab {
}.borderWidth(1) }.borderWidth(1)
.borderColor(Color.Grey) .borderColor(Color.Grey)
Column({space:1}){ Column({space:1}){
if (this.isExpanded) {
Column() {
Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) { Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) {
ForEach(LeftSideBars, (item: TitleButton, index: number) => { ForEach(LeftSideBars, (item: TitleButton, index: number) => {
TabContent() { TabContent() {
@ -79,10 +73,8 @@ export struct LeftSideTab {
} }
}) })
}.barHeight(0) }.barHeight(0)
} }.width(this.isExpanded?this.leftSideWidth:0)
}
}.width(this.panelWidth)
}.width('auto') }.width('auto')
.backgroundColor('#f3f3f0') .backgroundColor($r('sys.color.background_secondary'))
} }
} }

View File

@ -0,0 +1,46 @@
import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface';
import {LeftSideBars} from '../LayoutInterface/Layout/LeftSideBar'
import { mwInfo } from '../DispWinInfo/DispWinInfo'
@ComponentV2
export struct RightSideTab {
private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=false;
@Consumer('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
build() {
Row() {
Column({space:1}){
Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) {
TabContent() {
}
}.barHeight(0)
}.width(this.isExpanded?this.rightSideWidth:0)
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(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.rightSideWidth=this.isExpanded?mwInfo.width * 0.1:0;
}).margin({ top: 2,left:1,bottom:0,right:2})
Blank().layoutWeight(1)
}.borderWidth(1)
.borderColor(Color.Grey)
}.width('auto')
.backgroundColor($r('sys.color.background_secondary'))
}
}

View File

@ -26,10 +26,10 @@ export struct TitleTab {
.fontSize(16) .fontSize(16)
.fontColor(Color.Black) .fontColor(Color.Black)
.height(mwInfo.height*0.025) .height(mwInfo.height*0.025)
.width(mwInfo.width*0.035)
.bindMenu(BaseMenu(FileMenuData)) .bindMenu(BaseMenu(FileMenuData))
.type(ButtonType.Normal) .type(ButtonType.Normal)
.backgroundColor('#f3f3f0') .backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
ForEach(this.curtModel, (item: TitleModel, index: number) => { ForEach(this.curtModel, (item: TitleModel, index: number) => {
Button(item.cmName) Button(item.cmName)
@ -37,21 +37,21 @@ export struct TitleTab {
.fontColor(Color.Black) .fontColor(Color.Black)
.fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) .fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.height(mwInfo.height*0.025) .height(mwInfo.height*0.025)
.width(mwInfo.width*0.035)
.type(ButtonType.Normal) .type(ButtonType.Normal)
.backgroundColor('#f3f3f0') .backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.onClick(() => { .onClick(() => {
this.titleBarTabs.changeIndex(index); this.titleBarTabs.changeIndex(index);
this.titleBarFocusIndex = index; this.titleBarFocusIndex = index;
}) })
}) })
Blank().layoutWeight(1)
} }
} }
.align(Alignment.Start) .align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal) .scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off) .scrollBar(BarState.Off)
.margin({ top: 2,left:2,bottom:0,right:2}) .margin({ top: 0,left:0,bottom:0,right:0})
.width('100%')
//分割线 //分割线
Divider() Divider()
.vertical(false) .vertical(false)
@ -69,6 +69,7 @@ export struct TitleTab {
}.scrollable(true) }.scrollable(true)
.barHeight(0) .barHeight(0)
.barMode(BarMode.Fixed) .barMode(BarMode.Fixed)
}.width(mwInfo.width) }.width('100%')
.height(mwInfo.height * 0.08)
} }
} }