Menubar.File.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Menubar.File = function ( signals ) {
  2. var container = new UI.Panel();
  3. container.setFloat( 'left' );
  4. container.setWidth( '50px' );
  5. container.setCursor( 'pointer' );
  6. container.onMouseOver( function () { options.setDisplay( '' ) } );
  7. container.onMouseOut( function () { options.setDisplay( 'none' ) } );
  8. container.onClick( function () { options.setDisplay( 'none' ) } );
  9. var title = new UI.Panel();
  10. title.setTextContent( 'File' ).setColor( '#666' );
  11. title.setMargin( '0px' );
  12. title.setPadding( '8px' )
  13. container.add( title );
  14. //
  15. var options = new UI.Panel();
  16. options.setWidth( '140px' );
  17. options.setBackgroundColor( '#ddd' );
  18. options.setPadding( '0px' );
  19. options.setBorderTop( 'solid 1px #ccc' );
  20. options.setStyle( 'box-shadow', [ '0 3px 6px rgba(0,0,0,0.1), 3px 3px 6px rgba(0,0,0,0.2)' ] );
  21. options.setDisplay( 'none' );
  22. container.add( options );
  23. // open
  24. var option = new UI.Panel();
  25. option.setTextContent( 'Open' ).setColor( '#666' ).setPadding( '6px 12px' );
  26. option.onClick( function () { alert( 'Open' ) } );
  27. options.add( option );
  28. addHoverStyle( option );
  29. // reset scene
  30. var option = new UI.Panel();
  31. option.setTextContent( 'Reset' ).setColor( '#666' ).setPadding( '6px 12px' );
  32. option.onClick( function () { signals.resetScene.dispatch(); } );
  33. options.add( option );
  34. addHoverStyle( option );
  35. // export geometry
  36. var option = new UI.Panel();
  37. option.setTextContent( 'Export Geometry' ).setColor( '#666' ).setPadding( '6px 12px' );
  38. option.onClick( function () { signals.exportGeometry.dispatch(); } );
  39. options.add( option );
  40. addHoverStyle( option );
  41. // export scene
  42. var option = new UI.Panel();
  43. option.setTextContent( 'Export Scene' ).setColor( '#666' ).setPadding( '6px 12px' );
  44. option.onClick( function () { signals.exportScene.dispatch(); } );
  45. options.add( option );
  46. addHoverStyle( option );
  47. // export OBJ
  48. var option = new UI.Panel();
  49. option.setTextContent( 'Export OBJ' ).setColor( '#666' ).setPadding( '6px 12px' );
  50. option.onClick( function () { alert( 'Export OBJ' ) } );
  51. options.add( option );
  52. addHoverStyle( option );
  53. //
  54. function addHoverStyle( element ) {
  55. element.onMouseOver( function () { element.setBackgroundColor( '#356' ).setColor( '#eee' ); } );
  56. element.onMouseOut( function () { element.setBackgroundColor( 'transparent' ).setColor( '#666' ) } );
  57. }
  58. return container;
  59. }