实现窗口的resize
This commit is contained in:
parent
0aa38f5133
commit
6f52ed7c1b
@ -17,8 +17,29 @@ export const controlPanel = reactive({
|
|||||||
if (this.currentIndex === index) {
|
if (this.currentIndex === index) {
|
||||||
this.currentIndex = -1;
|
this.currentIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
|
if (horizontalResizer.width < 5) {
|
||||||
|
horizontalResizer.width = 200;
|
||||||
|
}
|
||||||
this.currentIndex = index;
|
this.currentIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const horizontalResizer = reactive({
|
||||||
|
active: false,
|
||||||
|
hover: false,
|
||||||
|
width: 200,
|
||||||
|
mousedown() {
|
||||||
|
this.active = true;
|
||||||
|
document.addEventListener('mousemove', resize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function resize(event) {
|
||||||
|
// 50 是 --right-nav-width
|
||||||
|
const computedWidth = window.innerWidth - event.clientX - 50;
|
||||||
|
if (computedWidth >= 0 && computedWidth <= 2000) {
|
||||||
|
horizontalResizer.width = computedWidth;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="netlist-right-nav">
|
<div class="netlist-right-nav">
|
||||||
|
|
||||||
|
<div class="horizontal-scalable-wrapper" :style="resizerWrapperStyle"
|
||||||
|
v-show="controlPanel.currentIndex > -1">
|
||||||
|
<div class="horizontal-resizer"
|
||||||
|
@mousedown="horizontalResizer.mousedown()"
|
||||||
|
@mouseenter="horizontalResizer.hover = true"
|
||||||
|
@mouseleave="horizontalResizer.hover = false"
|
||||||
|
:class="{ 'active': horizontalResizer.active || horizontalResizer.hover }"
|
||||||
|
></div>
|
||||||
<div class="netlist-function-panel">
|
<div class="netlist-function-panel">
|
||||||
<TreeView
|
<TreeView
|
||||||
v-show="controlPanel.currentIndex === 0"></TreeView>
|
v-show="controlPanel.currentIndex === 0"></TreeView>
|
||||||
@ -9,6 +17,7 @@
|
|||||||
<About
|
<About
|
||||||
v-show="controlPanel.currentIndex === 2"></About>
|
v-show="controlPanel.currentIndex === 2"></About>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="netlist-function-option">
|
<div class="netlist-function-option">
|
||||||
<div class="netlist-control-panel-wrapper">
|
<div class="netlist-control-panel-wrapper">
|
||||||
@ -29,17 +38,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineComponent, reactive } from 'vue';
|
import { computed, defineComponent, onMounted, reactive } from 'vue';
|
||||||
|
|
||||||
import TreeView from '@/components/treeview';
|
import TreeView from '@/components/treeview';
|
||||||
import Setting from '@/components/setting';
|
import Setting from '@/components/setting';
|
||||||
import About from '@/components/about';
|
import About from '@/components/about';
|
||||||
import { emitter } from '@/hook/global';
|
import { emitter } from '@/hook/global';
|
||||||
import { controlPanel } from './right-nav';
|
import { controlPanel, horizontalResizer, resize } from './right-nav';
|
||||||
|
|
||||||
defineComponent({ name: 'right-nav' });
|
defineComponent({ name: 'right-nav' });
|
||||||
|
|
||||||
|
|
||||||
emitter.on('right-nav', index => {
|
emitter.on('right-nav', index => {
|
||||||
if (controlPanel.currentIndex === index) {
|
if (controlPanel.currentIndex === index) {
|
||||||
controlPanel.currentIndex = -1;
|
controlPanel.currentIndex = -1;
|
||||||
@ -48,6 +56,18 @@ emitter.on('right-nav', index => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('mouseup', () => {
|
||||||
|
horizontalResizer.active = false;
|
||||||
|
document.removeEventListener('mousemove', resize);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const resizerWrapperStyle = computed(() => ({
|
||||||
|
width: horizontalResizer.width + 'px'
|
||||||
|
}));
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -64,6 +84,27 @@ emitter.on('right-nav', index => {
|
|||||||
background-color: var(--sidebar);
|
background-color: var(--sidebar);
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
box-shadow: var(--gray-box-shadow-1);
|
box-shadow: var(--gray-box-shadow-1);
|
||||||
|
z-index: 200;
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horizontal-scalable-wrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horizontal-resizer {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
width: 2px;
|
||||||
|
height: 100%;
|
||||||
|
cursor: ew-resize;
|
||||||
|
transition: var(--animation-5s);
|
||||||
|
z-index: 201;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horizontal-resizer.active {
|
||||||
|
background-color: var(--main-color);
|
||||||
|
transition: var(--animation-5s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.netlist-function-option {
|
.netlist-function-option {
|
||||||
@ -71,6 +112,7 @@ emitter.on('right-nav', index => {
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: var(--sidebar);
|
background-color: var(--sidebar);
|
||||||
box-shadow: var(--gray-box-shadow-1);
|
box-shadow: var(--gray-box-shadow-1);
|
||||||
|
z-index: 201;
|
||||||
}
|
}
|
||||||
|
|
||||||
.netlist-control-panel-wrapper {
|
.netlist-control-panel-wrapper {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="netlist-tree-view">
|
<div class="netlist-tree-view">
|
||||||
<div class="netlist-module-info">
|
<div class="netlist-module-info">
|
||||||
<div class="netlist-signal-title">{{ t('module') }}</div>
|
<div class="netlist-signal-title">{{ t('module') }}</div>
|
||||||
<hr>
|
<hr style="width: 100%;">
|
||||||
<el-scrollbar height="86vh" style="padding-right: 7px;">
|
<el-scrollbar height="86vh" style="padding-right: 7px;">
|
||||||
<modules
|
<modules
|
||||||
v-for="mod of treeviewData.modules"
|
v-for="mod of treeviewData.modules"
|
||||||
@ -15,15 +15,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent, onMounted } from 'vue';
|
||||||
import modules from './modules.vue';
|
import modules from './modules.vue';
|
||||||
import { treeviewData } from './tree';
|
import { resize, treeviewData, verticalResizer } from './tree';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
defineComponent({ name: 'tree-view' });
|
defineComponent({ name: 'tree-view' });
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('mouseup', () => {
|
||||||
|
verticalResizer.active = false;
|
||||||
|
document.removeEventListener('mousemove', resize);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -88,6 +95,7 @@ defineComponent({ name: 'tree-view' });
|
|||||||
transition: height .5s ease-in-out;
|
transition: height .5s ease-in-out;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
min-width: 220px;
|
min-width: 220px;
|
||||||
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
14
src/components/treeview/info.vue
Normal file
14
src/components/treeview/info.vue
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
|
defineComponent({ name: 'treeview-item-info' });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
@ -9,7 +9,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 渲染这个 module scope 有的组件 -->
|
<!-- 渲染这个 module scope 有的组件 -->
|
||||||
<div v-if="ports.length > 0 || cells.length > 0" class="netlist-subtree-wrapper">
|
<div
|
||||||
|
v-if="ports.length > 0 || cells.length > 0"
|
||||||
|
v-show="expandManage.expanded"
|
||||||
|
class="netlist-subtree-wrapper"
|
||||||
|
>
|
||||||
<div style="width: 20px;"></div>
|
<div style="width: 20px;"></div>
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
<!-- ports -->
|
<!-- ports -->
|
||||||
@ -33,6 +37,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import { globalLookup } from '@/hook/global';
|
||||||
import { ModuleView } from '@/hook/render/yosys';
|
import { ModuleView } from '@/hook/render/yosys';
|
||||||
import { defineComponent, reactive } from 'vue';
|
import { defineComponent, reactive } from 'vue';
|
||||||
|
|
||||||
@ -77,16 +82,12 @@ function clickItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExpandStatus() {
|
function getExpandStatus() {
|
||||||
if (ports.length === 0 && cells.length === 0) {
|
return module.name === globalLookup.topModuleName;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const expandManage = reactive({
|
const expandManage = reactive({
|
||||||
expanded: getExpandStatus(),
|
expanded: getExpandStatus(),
|
||||||
expandTagClass: ports.length === 0 && cells.length === 0 ? '' : 'collapse-tag',
|
expandTagClass: getExpandStatus() ? 'expand-tag' : 'collapse-tag',
|
||||||
click() {
|
click() {
|
||||||
this.expanded = !this.expanded;
|
this.expanded = !this.expanded;
|
||||||
if (this.expandTagClass) {
|
if (this.expandTagClass) {
|
||||||
@ -146,6 +147,7 @@ function makeIconClass() {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
transition: var(--animation-3s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.expand-tag {
|
.expand-tag {
|
||||||
|
@ -11,3 +11,16 @@ export const treeviewData = reactive({
|
|||||||
modules: []
|
modules: []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const verticalResizer = reactive({
|
||||||
|
height: 500,
|
||||||
|
active: false,
|
||||||
|
hover: false,
|
||||||
|
mousedown() {
|
||||||
|
this.active = true;
|
||||||
|
document.addEventListener('mousemove', resize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function resize(event) {
|
||||||
|
verticalResizer.height = event.clientY;
|
||||||
|
}
|
@ -11,7 +11,7 @@ export const globalSetting = reactive({
|
|||||||
renderAnimation: true
|
renderAnimation: true
|
||||||
});
|
});
|
||||||
|
|
||||||
export const globalLookup = {
|
export const globalLookup = reactive({
|
||||||
/**
|
/**
|
||||||
* @type {SkinManager}
|
* @type {SkinManager}
|
||||||
*/
|
*/
|
||||||
@ -36,8 +36,14 @@ export const globalLookup = {
|
|||||||
/**
|
/**
|
||||||
* @description 当前选择的实体,可以是 wire,也可以是 cell
|
* @description 当前选择的实体,可以是 wire,也可以是 cell
|
||||||
*/
|
*/
|
||||||
currentSelectEntity: undefined
|
currentSelectEntity: undefined,
|
||||||
};
|
|
||||||
|
/**
|
||||||
|
* @description 右侧 treeview 选择的需要展示数据的实体
|
||||||
|
* @type {Record<string, string>}
|
||||||
|
*/
|
||||||
|
currentSelectEntityInfo: {}
|
||||||
|
});
|
||||||
|
|
||||||
function loadSetting() {
|
function loadSetting() {
|
||||||
const settingString = localStorage.getItem('setting')
|
const settingString = localStorage.getItem('setting')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user