当前位置: 首页 > article >正文

[UI5 常用控件] 06.Splitter,ResponsiveSplitter

文章目录

  • 前言
  • 1. Splitter
    • 1.1 属性
  • 2. ResponsiveSplitter


前言

本章节记录常用控件Splitter,ResponsiveSplitter。主要功能是分割画面布局。
其路径分别是:

  • sap.ui.layout.Splitter
  • sap.ui.layout.ResponsiveSplitter

1. Splitter

1.1 属性

  • orientation : Horizontal,Vertical (横向分割/纵向分割)
  • SplitterLayoutData:size : 尺寸
  • SplitterLayoutData:minSize : 最小尺寸
  • SplitterLayoutData:resizable : 可变尺寸

在这里插入图片描述

  • View
	<Panel headerText="Splitter 布局">
	    <l:Splitter
	        id="mainSplitter"
	        height="500px"
	        width="100%"
	        orientation="Horizontal"
	    >
	        <Button
	            width="100%"
	            text="Content 1"
	        >
	            <layoutData>
	                <l:SplitterLayoutData size="300px" />
	            </layoutData>
	        </Button>
	        <Button
	            width="100%"
	            text="Content 2"
	        >
	            <layoutData>
	                <l:SplitterLayoutData size="auto" />
	            </layoutData>
	        </Button>
	        <Button
	            width="100%"
	            text="Content 3"
	        >
	            <layoutData>
	                <l:SplitterLayoutData
	                    size="30%"
	                    minSize="200px"
	                />
	            </layoutData>
	        </Button>
	    </l:Splitter>
	    <HBox class="sapUiSmallMarginTop sapUiSmallMarginBegin">
	        <Button
	            text="Add content area"
	            press="btnAddContentArea"
	        />
	        <Button
	            text="Remove content area"
	            press="btnRemoveContentArea"
	        />
	        <Button
	            text="Resizable"
	            press="btnSetResizable"
	        />
	        <Button
	            text="Change Orientation"
	            press="btnChangeOrientation"
	        />
	    </HBox>
	</Panel>
  • Controller
	btnAddContentArea: function () {
	    var oLayoutData = new SplitterLayoutData({
	        resizable: true,
	        size: Math.random() > 0.5 ? "auto" : 50 + Math.floor(Math.random() * 300) + "px",
	        maxSize: Math.random() > 0.5 ? "0" : Math.floor(Math.random() * 100) + "px"
	    });
	
	    var oContent = new Button({
	        width: "100%",
	        height: "100%",
	        text: "Content!",
	        layoutData: oLayoutData
	    });
	
	    this.oSplitter.addContentArea(oContent);
	},
	btnRemoveContentArea: function () {
	    
	
	    var oLastContentArea = this.oSplitter.getContentAreas().pop();
	    this.oSplitter.removeContentArea(oLastContentArea);
	    oLastContentArea.destroy();
	},
	btnSetResizable:function(){
	    var oContentArea = this.oSplitter.getContentAreas()[0];
	    var oLayoutData = oContentArea.getLayoutData();
	
	    oLayoutData.setResizable(false)
	},
	btnChangeOrientation: function () {
	    var Orientation = coreLibrary.Orientation;
	    var sOr = this.oSplitter.getOrientation();
	    this.oSplitter.setOrientation(
	        sOr === Orientation.Vertical
	            ? Orientation.Horizontal
	            : Orientation.Vertical
	    );
	}

2. ResponsiveSplitter

  • Splitter另一个替代方案
    在这里插入图片描述

  • View

   <Panel
        headerText="ResponsiveSplitter 布局"
        class="sapUiLargeMarginTop"
    >
        <l:ResponsiveSplitter
            defaultPane="default"
            height="600px"
        >
            <l:PaneContainer resize=".onRootContainerResize">
                <l:SplitPane
                    requiredParentWidth="400"
                    id="default"
                >
                    <l:layoutData>
                        <l:SplitterLayoutData size="40%" />
                    </l:layoutData>
                    <Panel
                        headerText="Minimum parent width 400"
                        height="100%"
                    >
                        <Button
                            text="Area 1"
                            width="50%"
                            type="Success"
                        />
                    </Panel>
                </l:SplitPane>
                <l:PaneContainer
                    orientation="Vertical"
                    resize=".onInnerContainerResize"
                >
                    <l:SplitPane requiredParentWidth="100">
                        <l:layoutData>
                            <l:SplitterLayoutData size="30%" />
                        </l:layoutData>
                        <Panel headerText="Minimum parent width 600">
                            <Button
                                text="Area 2"
                                width="50%"
                                type="Attention"
                            />
                        </Panel>
                    </l:SplitPane>
                    <l:SplitPane requiredParentWidth="800">
                        <l:layoutData>
                            <l:SplitterLayoutData size="70%" />
                        </l:layoutData>
                        <Page title="Minimum parent width 800">
                            <Button
                                text="Area 3"
                                width="50%"
                                type="Emphasized"
                            />

                            <footer>
                                <OverflowToolbar id="otb3">
                                    <Label text="Buttons:" />
                                    <ToolbarSpacer />
                                    <Button
                                        text="New"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Open"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Save"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Save as"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Cut"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Copy"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Paste"
                                        type="Transparent"
                                    />
                                    <Button
                                        text="Undo"
                                        type="Transparent"
                                    />
                                </OverflowToolbar>
                            </footer>
                        </Page>
                    </l:SplitPane>
                </l:PaneContainer>
            </l:PaneContainer>
        </l:ResponsiveSplitter>
    </Panel>
  • Controller
	onRootContainerResize: function (oEvent) {
	    var aOldSizes = oEvent.getParameter("oldSizes"),
	        aNewSizes = oEvent.getParameter("newSizes"),
	        sMessage =  "Root container is resized.";
	
	    if (aOldSizes && aOldSizes.length) {
	        sMessage += "\nOld panes sizes = [" + aOldSizes + "]";
	    }
	
	    sMessage += "\nNew panes sizes = [" + aNewSizes + "]";
	
	    MessageToast.show(sMessage);
	},
	
	onInnerContainerResize: function (oEvent) {
	    var aOldSizes = oEvent.getParameter("oldSizes"),
	        aNewSizes = oEvent.getParameter("newSizes"),
	        sMessage =  "Inner container is resized.";
	
	    if (aOldSizes && aOldSizes.length) {
	        sMessage += "\nOld panes sizes = [" + aOldSizes + "]";
	    }
	
	    sMessage += "\nNew panes sizes = [" + aNewSizes + "]";
	
	    MessageToast.show(sMessage);
	}

http://www.kler.cn/a/229584.html

相关文章:

  • 二分查找算法——山脉数组的峰顶索引
  • 探索网络安全:浅析文件上传漏洞
  • python异常机制
  • js:正则表达式
  • maven的简单介绍
  • 【黑灰产】假钱包推广套路
  • node环境打包js,webpack和rollup两个打包工具打包,能支持vue
  • SpringBoot中使用Spring自带线程池ThreadPoolTaskExecutor与Java8CompletableFuture实现异步任务示例
  • YOLOv8改进 | 检测头篇 | 独创RFAHead检测头超分辨率重构检测头(适用Pose、分割、目标检测)
  • 深度强化学习基础【1】-动态规划问题初探(leetcode算法的63题-不同路径II)
  • 题目:有1,2,3,4共四个数字,能组成多少个不相同而且无重复数字的三位数有多少个,都是多少?lua
  • 忘记 RAG:拥抱Agent设计,让 ChatGPT 更智能更贴近实际
  • 【数据结构和算法】--- 基于c语言排序算法的实现(1)
  • Elasticsearch:基本 CRUD 操作 - Python
  • PyTorch和TensorFlow的简介
  • 画出TCP三次握手和四次挥手的示意图,并且总结TCP和UDP的区别
  • 数字孪生网络攻防模拟与城市安全演练
  • 使用PDFBox实现pdf转其他图片格式
  • JDWP 简介
  • 勒索病毒最新变种.halo勒索病毒来袭,如何恢复受感染的数据?
  • 商汤科技「日日新4.0」正式发布,多维度升级大模型体系,能力比肩GPT-4!
  • CentOS 中文乱码
  • Google Chrome Close AutoUpdate
  • 小程序:类型三级分类
  • 【51单片机】LED的三个基本项目(LED点亮&LED闪烁&LED流水灯)(3)
  • (已解决)vue+element-ui实现个人中心,仿照原神