Skip to content

Commit

Permalink
add submenu
Browse files Browse the repository at this point in the history
  • Loading branch information
ycw committed May 7, 2024
1 parent 0e01940 commit db1b7af
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 28 deletions.
12 changes: 9 additions & 3 deletions editor/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,14 @@ select {
display: none;
padding: 5px 0;
background: #eee;
width: 150px;
max-height: calc(100% - 80px);
min-width: 150px;
max-height: calc(100vh - 80px);
overflow: auto;
}

#menubar .menu:hover .options {
display: block;
box-shadow: 0 5px 10px -5px #000;
}

#menubar .menu .options hr {
Expand All @@ -397,6 +398,11 @@ select {
background: transparent;
}

#menubar .submenu-title::after {
content: '>';
float: right;
}

#menubar .menu .options .inactive {
color: #bbb;
background-color: transparent;
Expand Down Expand Up @@ -533,7 +539,7 @@ select {
}

#menubar .menu .options {
max-height: calc(100% - 372px);
max-height: calc(100% - 80px);
}

#menubar .menu.right {
Expand Down
56 changes: 40 additions & 16 deletions editor/js/Menubar.Add.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ function MenubarAdd( editor ) {

options.add( new UIHorizontalRule() );


//

const addGeometryRow = new UIRow().setTextContent( strings.getKey( 'menubar/add/mesh' ) ).addClass( 'option' ).addClass( 'submenu-title' );
addGeometryRow.onMouseOver( function () {

const { top, right } = addGeometryRow.dom.getBoundingClientRect();
const { paddingTop } = getComputedStyle( this.dom );
addGeometryPanel.setLeft( right + 'px' );
addGeometryPanel.setTop( top - parseFloat( paddingTop ) + 'px' );
addGeometryPanel.setStyle( 'max-height', [ `calc( 100vh - ${top}px )` ] );
addGeometryPanel.setDisplay( 'block' );

} );
addGeometryRow.onMouseOut( function () {

addGeometryPanel.setDisplay( 'none' );

} );
options.add( addGeometryRow );

const addGeometryPanel = new UIPanel().setPosition( 'fixed' ).addClass( 'options' ).setDisplay( 'none' );
addGeometryRow.add( addGeometryPanel );

// Box

option = new UIRow();
Expand All @@ -53,7 +77,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Capsule

Expand All @@ -70,7 +94,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Circle

Expand All @@ -86,7 +110,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Cylinder

Expand All @@ -102,7 +126,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Dodecahedron

Expand All @@ -118,7 +142,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Icosahedron

Expand All @@ -134,7 +158,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Lathe

Expand All @@ -150,7 +174,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Octahedron

Expand All @@ -166,7 +190,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Plane

Expand All @@ -183,7 +207,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Ring

Expand All @@ -199,7 +223,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Sphere

Expand All @@ -215,7 +239,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Sprite

Expand All @@ -230,7 +254,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, sprite ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Tetrahedron

Expand All @@ -246,7 +270,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Torus

Expand All @@ -262,7 +286,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// TorusKnot

Expand All @@ -278,7 +302,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

// Tube

Expand All @@ -301,7 +325,7 @@ function MenubarAdd( editor ) {
editor.execute( new AddObjectCommand( editor, mesh ) );

} );
options.add( option );
addGeometryPanel.add( option );

//

Expand Down
41 changes: 32 additions & 9 deletions editor/js/Menubar.File.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ function MenubarFile( editor ) {

options.add( new UIHorizontalRule() );


//

const fileExportRow = new UIRow().setTextContent( strings.getKey( 'menubar/file/export' ) ).addClass( 'option' ).addClass( 'submenu-title' );
fileExportRow.onMouseOver( function () {

const { top, right } = this.dom.getBoundingClientRect();
const { paddingTop } = getComputedStyle( this.dom );
fileExportPanel.setLeft( right + 'px' );
fileExportPanel.setTop( top - parseFloat( paddingTop ) + 'px' );
fileExportPanel.setDisplay( 'block' );

} );
fileExportRow.onMouseOut( function () {

fileExportPanel.setDisplay( 'none' );

} );
options.add( fileExportRow );

const fileExportPanel = new UIPanel().setPosition( 'fixed' ).addClass( 'options' ).setDisplay( 'none' );
fileExportRow.add( fileExportPanel );

// Export DRC

option = new UIRow();
Expand Down Expand Up @@ -105,7 +128,7 @@ function MenubarFile( editor ) {
saveArrayBuffer( result, 'model.drc' );

} );
options.add( option );
fileExportPanel.add( option );

// Export GLB

Expand Down Expand Up @@ -136,7 +159,7 @@ function MenubarFile( editor ) {
}, undefined, { binary: true, animations: optimizedAnimations } );

} );
options.add( option );
fileExportPanel.add( option );

// Export GLTF

Expand Down Expand Up @@ -168,7 +191,7 @@ function MenubarFile( editor ) {


} );
options.add( option );
fileExportPanel.add( option );

// Export OBJ

Expand All @@ -193,7 +216,7 @@ function MenubarFile( editor ) {
saveString( exporter.parse( object ), 'model.obj' );

} );
options.add( option );
fileExportPanel.add( option );

// Export PLY (ASCII)

Expand All @@ -213,7 +236,7 @@ function MenubarFile( editor ) {
} );

} );
options.add( option );
fileExportPanel.add( option );

// Export PLY (Binary)

Expand All @@ -233,7 +256,7 @@ function MenubarFile( editor ) {
}, { binary: true } );

} );
options.add( option );
fileExportPanel.add( option );

// Export STL (ASCII)

Expand All @@ -249,7 +272,7 @@ function MenubarFile( editor ) {
saveString( exporter.parse( editor.scene ), 'model.stl' );

} );
options.add( option );
fileExportPanel.add( option );

// Export STL (Binary)

Expand All @@ -265,7 +288,7 @@ function MenubarFile( editor ) {
saveArrayBuffer( exporter.parse( editor.scene, { binary: true } ), 'model-binary.stl' );

} );
options.add( option );
fileExportPanel.add( option );

// Export USDZ

Expand All @@ -281,7 +304,7 @@ function MenubarFile( editor ) {
saveArrayBuffer( await exporter.parseAsync( editor.scene ), 'model.usdz' );

} );
options.add( option );
fileExportPanel.add( option );

//

Expand Down
8 changes: 8 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function Strings( config ) {
'menubar/file': 'File',
'menubar/file/new': 'New',
'menubar/file/import': 'Import',
'menubar/file/export': 'Export',
'menubar/file/export/drc': 'Export DRC',
'menubar/file/export/glb': 'Export GLB',
'menubar/file/export/gltf': 'Export GLTF',
Expand All @@ -59,6 +60,7 @@ function Strings( config ) {

'menubar/add': 'Add',
'menubar/add/group': 'Group',
'menubar/add/mesh': 'Mesh',
'menubar/add/plane': 'Plane',
'menubar/add/box': 'Box',
'menubar/add/capsule': 'Capsule',
Expand Down Expand Up @@ -427,6 +429,7 @@ function Strings( config ) {
'menubar/file': 'Fichier',
'menubar/file/new': 'Nouveau',
'menubar/file/import': 'Importer',
'menubar/file/export': 'Exporter',
'menubar/file/export/drc': 'Exporter DRC',
'menubar/file/export/glb': 'Exporter GLB',
'menubar/file/export/gltf': 'Exporter GLTF',
Expand All @@ -446,6 +449,7 @@ function Strings( config ) {

'menubar/add': 'Ajouter',
'menubar/add/group': 'Groupe',
'menubar/add/mesh': 'Maille',
'menubar/add/plane': 'Plan',
'menubar/add/box': 'Cube',
'menubar/add/capsule': 'Capsule',
Expand Down Expand Up @@ -814,6 +818,7 @@ function Strings( config ) {
'menubar/file': '文件',
'menubar/file/new': '新建',
'menubar/file/import': '导入',
'menubar/file/export': '导出',
'menubar/file/export/drc': '导出DRC',
'menubar/file/export/glb': '导出GLB',
'menubar/file/export/gltf': '导出GLTF',
Expand All @@ -833,6 +838,7 @@ function Strings( config ) {

'menubar/add': '添加',
'menubar/add/group': '组',
'menubar/add/mesh': '网格',
'menubar/add/plane': '平面',
'menubar/add/box': '正方体',
'menubar/add/capsule': '胶囊',
Expand Down Expand Up @@ -1201,6 +1207,7 @@ function Strings( config ) {
'menubar/file': 'ファイル',
'menubar/file/new': '新規',
'menubar/file/import': 'インポート',
'menubar/file/export': 'エクスポート',
'menubar/file/export/drc': 'エクスポート DRC',
'menubar/file/export/glb': 'エクスポート GLB',
'menubar/file/export/gltf': 'エクスポート GLTF',
Expand All @@ -1220,6 +1227,7 @@ function Strings( config ) {

'menubar/add': '追加',
'menubar/add/group': 'グループ',
'menubar/add/mesh': 'メッシュ',
'menubar/add/plane': '平面',
'menubar/add/box': '直方体',
'menubar/add/capsule': 'カプセル',
Expand Down

0 comments on commit db1b7af

Please sign in to comment.