123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import { UIPanel, UIRow } from './libs/ui.js';
- function MenubarView( editor ) {
- const signals = editor.signals;
- const strings = editor.strings;
- const container = new UIPanel();
- container.setClass( 'menu' );
- const title = new UIPanel();
- title.setClass( 'title' );
- title.setTextContent( strings.getKey( 'menubar/view' ) );
- container.add( title );
- const options = new UIPanel();
- options.setClass( 'options' );
- container.add( options );
- // Fullscreen
- const option = new UIRow();
- option.setClass( 'option' );
- option.setTextContent( strings.getKey( 'menubar/view/fullscreen' ) );
- option.onClick( function () {
- if ( document.fullscreenElement === null ) {
- document.documentElement.requestFullscreen();
- } else if ( document.exitFullscreen ) {
- document.exitFullscreen();
- }
- // Safari
- if ( document.webkitFullscreenElement === null ) {
- document.documentElement.webkitRequestFullscreen();
- } else if ( document.webkitExitFullscreen ) {
- document.webkitExitFullscreen();
- }
- } );
- options.add( option );
- // XR (Work in progress)
- if ( 'xr' in navigator ) {
- if ( 'offerSession' in navigator.xr ) {
- signals.offerXR.dispatch( 'immersive-ar' );
- } else {
- navigator.xr.isSessionSupported( 'immersive-ar' )
- .then( function ( supported ) {
- if ( supported ) {
- const option = new UIRow();
- option.setClass( 'option' );
- option.setTextContent( 'AR' );
- option.onClick( function () {
- signals.enterXR.dispatch( 'immersive-ar' );
- } );
- options.add( option );
- } else {
- navigator.xr.isSessionSupported( 'immersive-vr' )
- .then( function ( supported ) {
- if ( supported ) {
- const option = new UIRow();
- option.setClass( 'option' );
- option.setTextContent( 'VR' );
- option.onClick( function () {
- signals.enterXR.dispatch( 'immersive-vr' );
- } );
- options.add( option );
- }
- } );
- }
- } );
- }
- }
- return container;
- }
- export { MenubarView };
|