1- import { UIPanel , UIRow } from './libs/ui.js' ;
1+ import { UIHorizontalRule , UIPanel , UIRow } from './libs/ui.js' ;
22
33function MenubarView ( editor ) {
44
@@ -19,7 +19,7 @@ function MenubarView( editor ) {
1919
2020 // Fullscreen
2121
22- const option = new UIRow ( ) ;
22+ let option = new UIRow ( ) ;
2323 option . setClass ( 'option' ) ;
2424 option . setTextContent ( strings . getKey ( 'menubar/view/fullscreen' ) ) ;
2525 option . onClick ( function ( ) {
@@ -103,6 +103,100 @@ function MenubarView( editor ) {
103103
104104 }
105105
106+ //
107+
108+ options . add ( new UIHorizontalRule ( ) ) ;
109+
110+ // Appearance
111+
112+ const appearanceStates = {
113+
114+ gridHelper : true ,
115+ cameraHelpers : true ,
116+ lightHelpers : true ,
117+ skeletonHelpers : true
118+
119+ } ;
120+
121+ const appearanceSubmenuTitle = new UIRow ( ) . setTextContent ( 'Appearance' ) . addClass ( 'option' ) . addClass ( 'submenu-title' ) ;
122+ appearanceSubmenuTitle . onMouseOver ( function ( ) {
123+
124+ const { top, right } = appearanceSubmenuTitle . dom . getBoundingClientRect ( ) ;
125+ const { paddingTop } = getComputedStyle ( this . dom ) ;
126+ appearanceSubmenu . setLeft ( right + 'px' ) ;
127+ appearanceSubmenu . setTop ( top - parseFloat ( paddingTop ) + 'px' ) ;
128+ appearanceSubmenu . setStyle ( 'max-height' , [ `calc( 100vh - ${ top } px )` ] ) ;
129+ appearanceSubmenu . setDisplay ( 'block' ) ;
130+
131+ } ) ;
132+ appearanceSubmenuTitle . onMouseOut ( function ( ) {
133+
134+ appearanceSubmenu . setDisplay ( 'none' ) ;
135+
136+ } ) ;
137+ options . add ( appearanceSubmenuTitle ) ;
138+
139+ const appearanceSubmenu = new UIPanel ( ) . setPosition ( 'fixed' ) . addClass ( 'options' ) . setDisplay ( 'none' ) ;
140+ appearanceSubmenuTitle . add ( appearanceSubmenu ) ;
141+
142+ // Appearance / Grid Helper
143+
144+ option = new UIRow ( ) . addClass ( 'option' ) . addClass ( 'toggle' ) . setTextContent ( 'Grid Helper' ) . onClick ( function ( ) {
145+
146+ appearanceStates . gridHelper = ! appearanceStates . gridHelper ;
147+
148+ this . toggleClass ( 'toggle-on' , appearanceStates . gridHelper ) ;
149+
150+ signals . showHelpersChanged . dispatch ( appearanceStates ) ;
151+
152+ } ) . toggleClass ( 'toggle-on' , appearanceStates . gridHelper ) ;
153+
154+ appearanceSubmenu . add ( option ) ;
155+
156+ // Appearance / Camera Helpers
157+
158+ option = new UIRow ( ) . addClass ( 'option' ) . addClass ( 'toggle' ) . setTextContent ( 'Camera Helpers' ) . onClick ( function ( ) {
159+
160+ appearanceStates . cameraHelpers = ! appearanceStates . cameraHelpers ;
161+
162+ this . toggleClass ( 'toggle-on' , appearanceStates . cameraHelpers ) ;
163+
164+ signals . showHelpersChanged . dispatch ( appearanceStates ) ;
165+
166+ } ) . toggleClass ( 'toggle-on' , appearanceStates . cameraHelpers ) ;
167+
168+ appearanceSubmenu . add ( option ) ;
169+
170+ // Appearance / Light Helpers
171+
172+ option = new UIRow ( ) . addClass ( 'option' ) . addClass ( 'toggle' ) . setTextContent ( 'Light Helpers' ) . onClick ( function ( ) {
173+
174+ appearanceStates . lightHelpers = ! appearanceStates . lightHelpers ;
175+
176+ this . toggleClass ( 'toggle-on' , appearanceStates . lightHelpers ) ;
177+
178+ signals . showHelpersChanged . dispatch ( appearanceStates ) ;
179+
180+ } ) . toggleClass ( 'toggle-on' , appearanceStates . lightHelpers ) ;
181+
182+ appearanceSubmenu . add ( option ) ;
183+
184+ // Appearance / Skeleton Helpers
185+
186+ option = new UIRow ( ) . addClass ( 'option' ) . addClass ( 'toggle' ) . setTextContent ( 'Skeleton Helpers' ) . onClick ( function ( ) {
187+
188+ appearanceStates . skeletonHelpers = ! appearanceStates . skeletonHelpers ;
189+
190+ this . toggleClass ( 'toggle-on' , appearanceStates . skeletonHelpers ) ;
191+
192+ signals . showHelpersChanged . dispatch ( appearanceStates ) ;
193+
194+ } ) . toggleClass ( 'toggle-on' , appearanceStates . skeletonHelpers ) ;
195+
196+ appearanceSubmenu . add ( option ) ;
197+
198+ //
199+
106200 return container ;
107201
108202}
0 commit comments