@@ -63,6 +63,9 @@ interface ILayoutRuntimeState {
6363 readonly zenMode : {
6464 readonly transitionDisposables : DisposableMap < string , IDisposable > ;
6565 } ;
66+ readonly creatorMode : {
67+ readonly transitionDisposables : DisposableMap < string , IDisposable > ;
68+ }
6669}
6770
6871interface IEditorToOpen {
@@ -136,6 +139,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
136139 private readonly _onDidChangeZenMode = this . _register ( new Emitter < boolean > ( ) ) ;
137140 readonly onDidChangeZenMode = this . _onDidChangeZenMode . event ;
138141
142+ private readonly _onDidChangeCreatorMode = this . _register ( new Emitter < boolean > ( ) ) ;
143+ readonly onDidChangeCreatorMode = this . _onDidChangeCreatorMode . event ;
144+
145+
139146 private readonly _onDidChangeMainEditorCenteredLayout = this . _register ( new Emitter < boolean > ( ) ) ;
140147 readonly onDidChangeMainEditorCenteredLayout = this . _onDidChangeMainEditorCenteredLayout . event ;
141148
@@ -666,6 +673,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
666673 } ,
667674 zenMode : {
668675 transitionDisposables : new DisposableMap ( ) ,
676+ } ,
677+ creatorMode : {
678+ transitionDisposables : new DisposableMap ( ) ,
669679 }
670680 } ;
671681
@@ -1466,6 +1476,228 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
14661476 this . _onDidChangeZenMode . fire ( this . isZenModeActive ( ) ) ;
14671477 }
14681478
1479+
1480+ // Helper methods to check and set Creator Mode state
1481+ private isCreatorModeActive ( ) : boolean {
1482+ return this . stateModel . getRuntimeValue ( LayoutStateKeys . CREATOR_MODE_ACTIVE ) ;
1483+ }
1484+
1485+ private setCreatorModeActive ( active : boolean ) {
1486+ this . stateModel . setRuntimeValue ( LayoutStateKeys . CREATOR_MODE_ACTIVE , active ) ;
1487+ }
1488+
1489+ // Enter Creator Mode
1490+ enterCreatorMode ( restoring = false ) : void {
1491+ console . log ( "Entering Creator Mode" ) ;
1492+ if ( this . isCreatorModeActive ( ) ) {
1493+ console . warn ( 'Creator Mode is already active' ) ;
1494+ return ; // Already in Creator Mode
1495+ }
1496+
1497+ this . setCreatorModeActive ( true ) ;
1498+ this . state . runtime . creatorMode . transitionDisposables . clearAndDisposeAll ( ) ;
1499+
1500+ const setLineNumbers = ( lineNumbers ?: LineNumbersType ) => {
1501+ for ( const editor of this . mainPartEditorService . visibleTextEditorControls ) {
1502+ // To properly reset line numbers we need to read the configuration for each editor respecting it's uri.
1503+ if ( ! lineNumbers && isCodeEditor ( editor ) && editor . hasModel ( ) ) {
1504+ const model = editor . getModel ( ) ;
1505+ lineNumbers = this . configurationService . getValue ( 'editor.lineNumbers' , { resource : model . uri , overrideIdentifier : model . getLanguageId ( ) } ) as LineNumbersType | undefined ;
1506+ }
1507+ if ( ! lineNumbers ) {
1508+ lineNumbers = this . configurationService . getValue ( 'editor.lineNumbers' ) as LineNumbersType | undefined ;
1509+ }
1510+
1511+ editor . updateOptions ( { lineNumbers } ) ;
1512+ }
1513+ } ;
1514+
1515+ // Check if we need to go to full screen
1516+ let toggleMainWindowFullScreen = false ;
1517+ // TODO: Create Creator Mode specific configuration service
1518+ const config = getCreatorModeConfiguration ( this . configurationService ) ;
1519+ const creatorModeExitInfo = this . stateModel . getRuntimeValue ( LayoutStateKeys . CREATOR_MODE_EXIT_INFO ) ;
1520+
1521+ if ( ! restoring ) {
1522+ // Store current state to restore when exiting
1523+ toggleMainWindowFullScreen = ! this . state . runtime . mainWindowFullscreen && config . fullScreen && ! isIOS ;
1524+
1525+ creatorModeExitInfo . transitionedToFullScreen = toggleMainWindowFullScreen ;
1526+ creatorModeExitInfo . transitionedToCenteredEditorLayout = ! this . isMainEditorLayoutCentered ( ) && config . centerLayout ;
1527+ creatorModeExitInfo . handleNotificationsDoNotDisturbMode = this . notificationService . getFilter ( ) === NotificationsFilter . OFF ;
1528+ creatorModeExitInfo . wasVisible . sideBar = this . isVisible ( Parts . SIDEBAR_PART ) ;
1529+ creatorModeExitInfo . wasVisible . panel = this . isVisible ( Parts . PANEL_PART ) ;
1530+ creatorModeExitInfo . wasVisible . auxiliaryBar = this . isVisible ( Parts . AUXILIARYBAR_PART ) ;
1531+ this . stateModel . setRuntimeValue ( LayoutStateKeys . CREATOR_MODE_EXIT_INFO , creatorModeExitInfo ) ;
1532+ }
1533+
1534+ // TODO: Configure what should be hidden in Creator Mode
1535+ this . setPanelHidden ( true , true ) ;
1536+ this . setAuxiliaryBarHidden ( true , true ) ;
1537+ this . setSideBarHidden ( true , true ) ;
1538+
1539+ if ( config . hideActivityBar ) {
1540+ this . setActivityBarHidden ( true , true ) ;
1541+ }
1542+
1543+ if ( config . hideStatusBar ) {
1544+ this . setStatusBarHidden ( true , true ) ;
1545+ }
1546+
1547+ if ( config . hideLineNumbers ) {
1548+ setLineNumbers ( 'off' ) ;
1549+ this . state . runtime . creatorMode . transitionDisposables . set ( 'hideLineNumbers' , this . mainPartEditorService . onDidVisibleEditorsChange ( ( ) => setLineNumbers ( 'off' ) ) ) ;
1550+ }
1551+
1552+ if ( config . showTabs !== this . editorGroupService . partOptions . showTabs ) {
1553+ this . state . runtime . creatorMode . transitionDisposables . set ( 'showTabs' , this . editorGroupService . mainPart . enforcePartOptions ( { showTabs : config . showTabs } ) ) ;
1554+ }
1555+
1556+ if ( config . silentNotifications && creatorModeExitInfo . handleNotificationsDoNotDisturbMode ) {
1557+ this . notificationService . setFilter ( NotificationsFilter . ERROR ) ;
1558+ }
1559+
1560+ if ( config . centerLayout ) {
1561+ this . centerMainEditorLayout ( true , true ) ;
1562+ }
1563+
1564+ // TODO: Set up Creator Mode specific configuration
1565+ // Creator Mode Configuration Changes
1566+ this . state . runtime . creatorMode . transitionDisposables . set ( 'configurationChange' , this . configurationService . onDidChangeConfiguration ( e => {
1567+ // Handle configuration changes for Creator Mode
1568+ // Activity Bar
1569+ if ( e . affectsConfiguration ( 'creatorMode.hideActivityBar' ) ) {
1570+ const creatorModeHideActivityBar = this . configurationService . getValue < boolean > ( 'creatorMode.hideActivityBar' ) ;
1571+ this . setActivityBarHidden ( creatorModeHideActivityBar , true ) ;
1572+ }
1573+
1574+ // Status Bar
1575+ if ( e . affectsConfiguration ( 'creatorMode.hideStatusBar' ) ) {
1576+ const creatorModeHideStatusBar = this . configurationService . getValue < boolean > ( 'creatorMode.hideStatusBar' ) ;
1577+ this . setStatusBarHidden ( creatorModeHideStatusBar , true ) ;
1578+ }
1579+
1580+ // Center Layout
1581+ if ( e . affectsConfiguration ( 'creatorMode.centerLayout' ) ) {
1582+ const creatorModeCenterLayout = this . configurationService . getValue < boolean > ( 'creatorMode.centerLayout' ) ;
1583+ this . centerMainEditorLayout ( creatorModeCenterLayout , true ) ;
1584+ }
1585+
1586+ // Show Tabs
1587+ if ( e . affectsConfiguration ( 'creatorMode.showTabs' ) ) {
1588+ const creatorModeShowTabs = this . configurationService . getValue < EditorTabsMode | undefined > ( 'creatorMode.showTabs' ) ?? 'multiple' ;
1589+ this . state . runtime . creatorMode . transitionDisposables . set ( 'showTabs' , this . editorGroupService . mainPart . enforcePartOptions ( { showTabs : creatorModeShowTabs } ) ) ;
1590+ }
1591+
1592+ // Notifications
1593+ if ( e . affectsConfiguration ( 'creatorMode.silentNotifications' ) ) {
1594+ const creatorModeSilentNotifications = ! ! this . configurationService . getValue ( 'creatorMode.silentNotifications' ) ;
1595+ if ( creatorModeExitInfo . handleNotificationsDoNotDisturbMode ) {
1596+ this . notificationService . setFilter ( creatorModeSilentNotifications ? NotificationsFilter . ERROR : NotificationsFilter . OFF ) ;
1597+ }
1598+ }
1599+
1600+ // Line Numbers
1601+ if ( e . affectsConfiguration ( 'creatorMode.hideLineNumbers' ) ) {
1602+ const lineNumbersType = this . configurationService . getValue < boolean > ( 'creatorMode.hideLineNumbers' ) ? 'off' : undefined ;
1603+ setLineNumbers ( lineNumbersType ) ;
1604+ this . state . runtime . creatorMode . transitionDisposables . set ( 'hideLineNumbers' , this . mainPartEditorService . onDidVisibleEditorsChange ( ( ) => setLineNumbers ( lineNumbersType ) ) ) ;
1605+ }
1606+ } ) ) ;
1607+
1608+ // Layout and toggle fullscreen if needed
1609+ this . layout ( ) ;
1610+ if ( toggleMainWindowFullScreen ) {
1611+ this . hostService . toggleFullScreen ( mainWindow ) ;
1612+ }
1613+
1614+ // Fire event for Creator Mode activation
1615+ this . _onDidChangeCreatorMode . fire ( true ) ;
1616+ }
1617+
1618+ // Exit Creator Mode
1619+ exitCreatorMode ( ) : void {
1620+ if ( ! this . isCreatorModeActive ( ) ) {
1621+ return ; // Not in Creator Mode
1622+ }
1623+
1624+ this . setCreatorModeActive ( false ) ;
1625+ this . state . runtime . creatorMode . transitionDisposables . clearAndDisposeAll ( ) ;
1626+
1627+ // Reset line numbers
1628+ const setLineNumbers = ( ) => {
1629+ for ( const editor of this . mainPartEditorService . visibleTextEditorControls ) {
1630+ if ( isCodeEditor ( editor ) && editor . hasModel ( ) ) {
1631+ const model = editor . getModel ( ) ;
1632+ const lineNumbers = this . configurationService . getValue ( 'editor.lineNumbers' , { resource : model . uri , overrideIdentifier : model . getLanguageId ( ) } ) as LineNumbersType | undefined ;
1633+ editor . updateOptions ( { lineNumbers } ) ;
1634+ } else {
1635+ const lineNumbers = this . configurationService . getValue ( 'editor.lineNumbers' ) as LineNumbersType | undefined ;
1636+ editor . updateOptions ( { lineNumbers } ) ;
1637+ }
1638+ }
1639+ } ;
1640+
1641+ const creatorModeExitInfo = this . stateModel . getRuntimeValue ( LayoutStateKeys . CREATOR_MODE_EXIT_INFO ) ;
1642+ let toggleMainWindowFullScreen = false ;
1643+
1644+ // Restore previous state
1645+ if ( creatorModeExitInfo . wasVisible . panel ) {
1646+ this . setPanelHidden ( false , true ) ;
1647+ }
1648+
1649+ if ( creatorModeExitInfo . wasVisible . auxiliaryBar ) {
1650+ this . setAuxiliaryBarHidden ( false , true ) ;
1651+ }
1652+
1653+ if ( creatorModeExitInfo . wasVisible . sideBar ) {
1654+ this . setSideBarHidden ( false , true ) ;
1655+ }
1656+
1657+ if ( ! this . stateModel . getRuntimeValue ( LayoutStateKeys . ACTIVITYBAR_HIDDEN , true ) ) {
1658+ this . setActivityBarHidden ( false , true ) ;
1659+ }
1660+
1661+ if ( ! this . stateModel . getRuntimeValue ( LayoutStateKeys . STATUSBAR_HIDDEN , true ) ) {
1662+ this . setStatusBarHidden ( false , true ) ;
1663+ }
1664+
1665+ if ( creatorModeExitInfo . transitionedToCenteredEditorLayout ) {
1666+ this . centerMainEditorLayout ( false , true ) ;
1667+ }
1668+
1669+ if ( creatorModeExitInfo . handleNotificationsDoNotDisturbMode ) {
1670+ this . notificationService . setFilter ( NotificationsFilter . OFF ) ;
1671+ }
1672+
1673+ setLineNumbers ( ) ;
1674+ this . focus ( ) ;
1675+
1676+ toggleMainWindowFullScreen = creatorModeExitInfo . transitionedToFullScreen && this . state . runtime . mainWindowFullscreen ;
1677+
1678+ // Layout and toggle fullscreen if needed
1679+ this . layout ( ) ;
1680+ if ( toggleMainWindowFullScreen ) {
1681+ this . hostService . toggleFullScreen ( mainWindow ) ;
1682+ }
1683+
1684+ // Fire event for Creator Mode deactivation
1685+ this . _onDidChangeCreatorMode . fire ( false ) ;
1686+ }
1687+
1688+ toggleCreatorMode ( skipLayout ?: boolean ) : void {
1689+ if ( this . isCreatorModeActive ( ) ) {
1690+ this . exitCreatorMode ( ) ;
1691+ } else {
1692+ this . enterCreatorMode ( ) ;
1693+ }
1694+
1695+ if ( ! skipLayout ) {
1696+ this . layout ( ) ;
1697+ }
1698+ }
1699+
1700+
14691701 private setStatusBarHidden ( hidden : boolean , skipLayout ?: boolean ) : void {
14701702 this . stateModel . setRuntimeValue ( LayoutStateKeys . STATUSBAR_HIDDEN , hidden ) ;
14711703
@@ -2517,6 +2749,12 @@ function getZenModeConfiguration(configurationService: IConfigurationService): Z
25172749 return configurationService . getValue < ZenModeConfiguration > ( WorkbenchLayoutSettings . ZEN_MODE_CONFIG ) ;
25182750}
25192751
2752+ type CreatorModeConfiguration = ZenModeConfiguration ;
2753+
2754+ function getCreatorModeConfiguration ( configurationService : IConfigurationService ) : CreatorModeConfiguration {
2755+ return configurationService . getValue < CreatorModeConfiguration > ( WorkbenchLayoutSettings . ZEN_MODE_CONFIG ) ;
2756+ }
2757+
25202758//#endregion
25212759
25222760//#region Layout State Model
@@ -2570,6 +2808,20 @@ const LayoutStateKeys = {
25702808 } ,
25712809 } ) ,
25722810
2811+ // Creator Mode
2812+ CREATOR_MODE_ACTIVE : new RuntimeStateKey < boolean > ( 'creatorMode.active' , StorageScope . WORKSPACE , StorageTarget . MACHINE , false ) ,
2813+ CREATOR_MODE_EXIT_INFO : new RuntimeStateKey ( 'creatorMode.exitInfo' , StorageScope . WORKSPACE , StorageTarget . MACHINE , {
2814+ transitionedToCenteredEditorLayout : false ,
2815+ transitionedToFullScreen : false ,
2816+ handleNotificationsDoNotDisturbMode : false ,
2817+ wasVisible : {
2818+ auxiliaryBar : false ,
2819+ panel : false ,
2820+ sideBar : false ,
2821+ } ,
2822+ } ) ,
2823+
2824+
25732825 // Part Sizing
25742826 GRID_SIZE : new InitializationStateKey ( 'grid.size' , StorageScope . PROFILE , StorageTarget . MACHINE , { width : 800 , height : 600 } ) ,
25752827 SIDEBAR_SIZE : new InitializationStateKey < number > ( 'sideBar.size' , StorageScope . PROFILE , StorageTarget . MACHINE , 200 ) ,
0 commit comments