归一化拖拽分割线改变窗口大小

修改部分文件夹名字
This commit is contained in:
JackLee 2026-04-16 20:06:15 +08:00
parent 5781a4dc9d
commit 1c7e28fa1c
12 changed files with 101 additions and 62 deletions

View File

@ -215,11 +215,14 @@ void RenderThread::setClearColor(float r, float g, float b, float a) {
void RenderThread::resizeWindow(int width, int height) {
std::lock_guard<std::mutex> lock(commandMutex_);
RenderCommand cmd(CMD_RESIZE);
cmd.param2 = static_cast<float>(width);
cmd.param3 = static_cast<float>(height);
commandQueue_.push(cmd);
commandCondition_.notify_one();
// RenderCommand cmd(CMD_RESIZE);
// cmd.param2 = static_cast<float>(width);
// cmd.param3 = static_cast<float>(height);
// commandQueue_.push(cmd);
// commandCondition_.notify_one();
rdWidth = static_cast<float>(width);
rdHeight = static_cast<float>(height);
render->resize(rdWidth,rdHeight);
}
void RenderThread::registerRenderCompleteCallback(Callback callback) {

View File

@ -1,14 +1,20 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { OverlayManager } from '@kit.ArkUI';
import { TitleTab } from './TitleLayout/TitleTab'
import { LeftSideTab } from './LeftSideLayout/LeftSideTab'
import { RightSideTab } from './RightSideLayout/RightSideTab'
import { TitleTab } from './TitleTabs/TitleTab'
import { LeftSideTab } from './LeftSide/LeftSideTab'
import { RightSideTab } from './RightSide/RightSideTab'
import { ModelViewTab } from './ModelViewTab'
import { TitleColumnSub } from './TitleLayout/TitleColumnSub'
import { TitleColumnSub } from './TitleTabs/TitleColumnSub'
import { mwInfo } from './DispWinInfo/DispWinInfo'
const DOMAIN = 0x0000;
//分割线类型,分左和右
enum DividerType{
LeftSide,
RightSide
}
@Entry
@ComponentV2
struct Index {
@ -17,6 +23,50 @@ struct Index {
@Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
@Local overlayState:boolean=true;
//利用分割线拖动改变区域容器大小.鼠标和触控整合
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.screenX; // 记录起始坐标
this.isDragging = true;
}else if(mouseEvent.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.leftSideWidth + (mouseEvent.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.leftSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = mouseEvent.screenX;
}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.screenX; // 记录起始坐标
this.isDragging = true;
}else if(mouseEvent.action==MouseAction.Move&&this.isDragging){
// 计算新的宽度
let newWidth = this.rightSideWidth - (mouseEvent.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.rightSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = mouseEvent.screenX;
}else if(mouseEvent.action==MouseAction.Release){
this.isDragging = false;
}
}
}
}
build() {
Stack({ alignContent: Alignment.Top }) {
//OpenCAX主界面整体布局,采用多行布局
@ -40,20 +90,10 @@ struct Index {
// 左拖拽手柄
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.leftSideWidth + (event.screenX - this.startX);
// 添加最小宽度限制
newWidth = Math.max(newWidth, 0);
this.leftSideWidth = newWidth;
// 更新起始坐标,实现连续拖动
this.startX = event.screenX;
}else if(event.action==MouseAction.Release){
this.isDragging = false;
}
this.dividerChangeSize(event,DividerType.LeftSide)
})
.onTouch((event) => {
this.dividerChangeSize(event,DividerType.LeftSide)
})
//中间操作区域
Row() {
@ -63,20 +103,10 @@ struct Index {
//右拖拽手柄
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;
}
this.dividerChangeSize(event,DividerType.RightSide)
})
.onTouch((event) => {
this.dividerChangeSize(event,DividerType.RightSide)
})
//右侧边导航区
RightSideTab().width(this.overlayState?this.rightSideWidth:'0%')

View File

@ -10,17 +10,17 @@ export let TitleDefaultBars:Array<TitleModel>=
{cmName:'主页',cmPage:'',cmTips:'',cmEvents:
[[[{ grpName:'文件', grpBtn:
[
{btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'Execute_NewFileWindow',page:'pages/EventSubWin/File/SWNewFile',type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'Execute_OpenFile',page:'pages/EventSubWin/File/SWOpenFile',type:EventType.PAGE,args:[]}},
[
{btnModel:[ModelType.BASE],btnName:'保存',btnNamed:'',btnIcon:'base_save_file',btnTips:'保存',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'Execute_SaveAsFileWindow',page:'pages/EventSubWin/File/SWSaveAsFile',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'保存全部',btnNamed:'',btnIcon:'base_saveall_file',btnTips:'保存全部',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
] as Array<TitleButton>,
{btnModel:[ModelType.BASE],btnName:'关闭',btnNamed:'',btnIcon:'base_close_file',btnTips:'关闭',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'Execute_ImportFileWindow',page:'pages/EventSubWin/File/SWImportFile',type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'Execute_ExportFileWindow',page:'pages/EventSubWin/File/SWExportFile',type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'Execute_CreateSubWindow_Options',page:'pages/EventSubWin/Options',type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'帮助',btnNamed:'',btnIcon:'base_help_file',btnTips:'帮助',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
], grpMenu:GroupActionMenu }] as Array<TitleGroup>]]},
MatrixModel,

View File

@ -25,7 +25,7 @@ export struct LeftSideTab {
.height(mwInfo.width*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.leftSideWidth=this.isExpanded?mwInfo.width * 0.1:0
this.leftSideWidth=this.isExpanded?mwInfo.width * 0.1:mwInfo.width*0.013
}).margin({ top: 2,left:1,bottom:0,right:2})
Scroll() {
Flex({ direction: FlexDirection.Column}) {

View File

@ -6,7 +6,7 @@ import { mwInfo } from '../DispWinInfo/DispWinInfo'
export struct RightSideTab {
private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=false;
@Local isExpanded:boolean=true;
@Consumer('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
build() {
@ -17,9 +17,8 @@ export struct RightSideTab {
}
}.barHeight(0)
Blank().layoutWeight(1)
}.width(this.isExpanded?this.rightSideWidth:0)
}.width(this.isExpanded?this.rightSideWidth-mwInfo.width*0.013:'0%')
//右边按钮列
Column({space:1}){
Button()
.backgroundImagePosition({ x: '5%', y: '5%' })
@ -34,10 +33,11 @@ export struct RightSideTab {
.height(mwInfo.width*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.rightSideWidth=this.isExpanded?mwInfo.width * 0.1:0;
this.rightSideWidth=this.isExpanded?mwInfo.width * 0.1:mwInfo.width*0.013;
}).margin({ top: 2,left:1,bottom:0,right:2})
Blank().layoutWeight(1)
}.borderWidth(1)
.width(mwInfo.width*0.013)
}.width('auto')
}
}

View File

@ -6,6 +6,15 @@ import {TitleTabContent} from './TitleTabContent'
import { mwInfo } from '../DispWinInfo/DispWinInfo'
import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface';
import { BaseMenu } from '../CustomController/Menu';
import {
TabSegmentButtonV2,
CapsuleSegmentButtonV2,
MultiCapsuleSegmentButtonV2,
SegmentButtonV2Items,
SegmentButtonV2Item,
SegmentButtonV2ItemOptions,
} from '@kit.ArkUI';
@Entry
@ComponentV2
@ -13,31 +22,29 @@ export struct TitleTab {
//顶部导航组件
private titleBarTabs: TabsController = new TabsController();
//当前的顶部导航选择页
@Local titleBarFocusIndex: number = 0;
//TabBar默认焦点
@Local titleBarDefaultFocusIndex: number = 0;
@Local selectedIndex: number = 0; // 当前选中的索引
//模块Bar栏
@Provider('curtModel') curtModel:Array<TitleModel>|undefined= TitleTabData.mModels.get(this.titleBarFocusIndex)
@Provider('curtModel') curtModel:Array<TitleModel>|undefined= TitleTabData.mModels.get(this.selectedIndex)
@Builder
build() {
Flex({ direction: FlexDirection.Column }){
Scroll() {
Row({space:0}) {
Button((FileMenuData.aMenus[0] as TitleButton).btnName)
.width('7%')
.fontSize(18)
.fontSize(16)
.fontColor($r('sys.color.font'))
.bindMenu(BaseMenu(FileMenuData))
.type(ButtonType.Normal)
.backgroundColor(Color.Transparent)
ForEach(this.curtModel, (item: TitleModel, index: number) => {
Button(){
Column(){
Text(item.cmName)
.height('95%')
.fontSize(18)
.fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.fontSize(index === this.selectedIndex ? 20 : 16)
.fontWeight(index === this.selectedIndex ? FontWeight.Bold : FontWeight.Normal)
.backgroundColor(Color.Transparent)
Divider()
@ -47,16 +54,16 @@ export struct TitleTab {
.lineCap(LineCapStyle.Round)
.color(Color.Grey)
.align(Alignment.Top)
.visibility(index === this.titleBarFocusIndex?Visibility.Visible:Visibility.Hidden)
.visibility(index === this.selectedIndex?Visibility.Visible:Visibility.Hidden)
}.width('100%')
.height('100%')
}
.width('7%')
.backgroundColor(index === this.titleBarFocusIndex ? $r('sys.color.container_modal_button_normal_baseboard') : Color.Transparent)
.backgroundColor(index === this.selectedIndex ? $r('sys.color.container_modal_button_normal_baseboard') : Color.Transparent)
.type(ButtonType.Normal)
.onClick(() => {
this.titleBarTabs.changeIndex(index);
this.titleBarFocusIndex = index;
this.selectedIndex = index;
})
})
Blank().layoutWeight(1)
@ -75,7 +82,7 @@ export struct TitleTab {
.width('100%')
.backgroundColor(Color.Grey)
Tabs({barPosition: BarPosition.Start, index: this.titleBarDefaultFocusIndex,controller: this.titleBarTabs}){
Tabs({barPosition: BarPosition.Start, index: this.selectedIndex,controller: this.titleBarTabs}){
ForEach(this.curtModel,(item:TitleModel, index: number)=>{
TabContent() {
TitleTabContent({curtLayout:item})
@ -88,7 +95,6 @@ export struct TitleTab {
.barMode(BarMode.Fixed)
}.margin({ top:0, left: 0, bottom: 0, right: 0 })
//.backgroundColor($r('sys.color.background_secondary'))
.borderRadius(15)
.backgroundBlurStyle(BlurStyle.Thin,
{ colorMode: ThemeColorMode.LIGHT, adaptiveColor: AdaptiveColor.DEFAULT, scale: 1.0 })
}