Skip to content

Commit 282e32c

Browse files
authored
Merge pull request #482 from smartdevicelink/feature/menu-manager
Feature/menu manager
2 parents e313f5e + b4b4603 commit 282e32c

30 files changed

+4678
-2
lines changed

examples/js/hello-sdl/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,33 @@
126126
.setFilePath(this._filePath));
127127
screenManager.changeLayout(new SDL.rpc.structs.TemplateConfiguration()
128128
.setTemplate(SDL.rpc.enums.PredefinedLayout.NON_MEDIA));
129+
130+
// add menus
131+
const menuListener = new SDL.manager.screen.menu.MenuSelectionListener()
132+
.setOnTriggered(triggerSource => {
133+
console.log(triggerSource);
134+
});
135+
const voice1 = ['Hello Menu One'];
136+
const mainCell1 = new SDL.manager.screen.menu.MenuCell('Hello Menu 1')
137+
.setIcon(new SDL.manager.file.filetypes.SdlArtwork('sdl-logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
138+
.setFilePath(this._filePath))
139+
.setVoiceCommands(voice1)
140+
.setMenuSelectionListener(menuListener);
141+
142+
// submenu cells
143+
const subCell1 = new SDL.manager.screen.menu.MenuCell('Submenu 1')
144+
.setMenuSelectionListener(menuListener);
145+
146+
const subCell2 = new SDL.manager.screen.menu.MenuCell('Submenu 2')
147+
.setMenuSelectionListener(menuListener);
148+
149+
const mainCell2 = new SDL.manager.screen.menu.MenuCell('Hello Menu 2')
150+
.setSubCells([subCell1, subCell2])
151+
._setCellId(4);
152+
153+
const cellList = [mainCell1, mainCell2];
154+
155+
screenManager.setMenu(cellList);
129156
}
130157

131158
async _onHmiStatusListener (onHmiStatus) {

examples/node/hello-sdl-tcp/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ class AppClient {
121121
.setFilePath(this._filePath));
122122
screenManager.changeLayout(new SDL.rpc.structs.TemplateConfiguration()
123123
.setTemplate(SDL.rpc.enums.PredefinedLayout.NON_MEDIA));
124+
125+
// add menus
126+
const menuListener = new SDL.manager.screen.menu.MenuSelectionListener()
127+
.setOnTriggered(triggerSource => {
128+
console.log(triggerSource);
129+
});
130+
const voice1 = ['Hello Menu One'];
131+
const mainCell1 = new SDL.manager.screen.menu.MenuCell('Hello Menu 1')
132+
.setIcon(new SDL.manager.file.filetypes.SdlArtwork('sdl-logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
133+
.setFilePath(this._filePath))
134+
.setVoiceCommands(voice1)
135+
.setMenuSelectionListener(menuListener);
136+
137+
// submenu cells
138+
const subCell1 = new SDL.manager.screen.menu.MenuCell('Submenu 1')
139+
.setMenuSelectionListener(menuListener);
140+
141+
const subCell2 = new SDL.manager.screen.menu.MenuCell('Submenu 2')
142+
.setMenuSelectionListener(menuListener);
143+
144+
const mainCell2 = new SDL.manager.screen.menu.MenuCell('Hello Menu 2')
145+
.setSubCells([subCell1, subCell2])
146+
._setCellId(4);
147+
148+
const cellList = [mainCell1, mainCell2];
149+
150+
screenManager.setMenu(cellList);
124151
}
125152

126153
async _onHmiStatusListener (onHmiStatus) {

examples/node/hello-sdl/AppClient.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ class AppClient {
108108
_onConnected () {
109109
this._managersReady = true;
110110
this._checkReadyState();
111+
const screenManager = this._sdlManager.getScreenManager();
112+
113+
// add menus
114+
const menuListener = new SDL.manager.screen.menu.MenuSelectionListener()
115+
.setOnTriggered(triggerSource => {
116+
console.log(triggerSource);
117+
});
118+
const voice1 = ['Hello Menu One'];
119+
const mainCell1 = new SDL.manager.screen.menu.MenuCell('Hello Menu 1')
120+
.setIcon(new SDL.manager.file.filetypes.SdlArtwork('sdl-logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
121+
.setFilePath(this._filePath))
122+
.setVoiceCommands(voice1)
123+
.setMenuSelectionListener(menuListener);
124+
125+
// submenu cells
126+
const subCell1 = new SDL.manager.screen.menu.MenuCell('Submenu 1')
127+
.setMenuSelectionListener(menuListener);
128+
129+
const subCell2 = new SDL.manager.screen.menu.MenuCell('Submenu 2')
130+
.setMenuSelectionListener(menuListener);
131+
132+
const mainCell2 = new SDL.manager.screen.menu.MenuCell('Hello Menu 2')
133+
.setSubCells([subCell1, subCell2])
134+
._setCellId(4);
135+
136+
const cellList = [mainCell1, mainCell2];
137+
138+
screenManager.setMenu(cellList);
111139
}
112140

113141
_onHmiStatusListener (onHmiStatus) {

examples/webengine/hello-sdl/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,33 @@
131131
.setFilePath(sdlManifest.appIcon));
132132
screenManager.changeLayout(new SDL.rpc.structs.TemplateConfiguration()
133133
.setTemplate(SDL.rpc.enums.PredefinedLayout.NON_MEDIA));
134+
135+
// add menus
136+
const menuListener = new SDL.manager.screen.menu.MenuSelectionListener()
137+
.setOnTriggered(triggerSource => {
138+
console.log(triggerSource);
139+
});
140+
const voice1 = ['Hello Menu One'];
141+
const mainCell1 = new SDL.manager.screen.menu.MenuCell('Hello Menu 1')
142+
.setIcon(new SDL.manager.file.filetypes.SdlArtwork('sdl-logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
143+
.setFilePath(sdlManifest.appIcon))
144+
.setVoiceCommands(voice1)
145+
.setMenuSelectionListener(menuListener);
146+
147+
// submenu cells
148+
const subCell1 = new SDL.manager.screen.menu.MenuCell('Submenu 1')
149+
.setMenuSelectionListener(menuListener);
150+
151+
const subCell2 = new SDL.manager.screen.menu.MenuCell('Submenu 2')
152+
.setMenuSelectionListener(menuListener);
153+
154+
const mainCell2 = new SDL.manager.screen.menu.MenuCell('Hello Menu 2')
155+
.setSubCells([subCell1, subCell2])
156+
._setCellId(4);
157+
158+
const cellList = [mainCell1, mainCell2];
159+
160+
screenManager.setMenu(cellList);
134161
}
135162

136163
async _onSystemCapabilityUpdatedRpcListener (capabilityMessage) {

lib/js/src/manager/screen/_ScreenManagerBase.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { _SubscribeButtonManager } from './_SubscribeButtonManager';
3838
import { Enum } from '../../util/Enum';
3939
import { _AlertManager } from './_AlertManager.js';
4040
import { _ChoiceSetManagerBase } from './choiceset/_ChoiceSetManagerBase';
41+
import { _MenuManagerBase } from './menu/_MenuManagerBase';
4142

4243
class _ScreenManagerBase extends _SubManagerBase {
4344
/**
@@ -56,6 +57,7 @@ class _ScreenManagerBase extends _SubManagerBase {
5657
this._textAndGraphicManager = new _TextAndGraphicManager(lifecycleManager, this._fileManager, this._softButtonManager);
5758
this._alertManager = new _AlertManager(lifecycleManager, this._fileManager);
5859
this._choiceSetManagerBase = new _ChoiceSetManagerBase(lifecycleManager, this._fileManager);
60+
this._menuManagerBase = new _MenuManagerBase(lifecycleManager, this._fileManager);
5961
}
6062
this._voiceCommandManager = new _VoiceCommandManager(lifecycleManager);
6163
this._subscribeButtonManager = new _SubscribeButtonManager(lifecycleManager);
@@ -73,6 +75,7 @@ class _ScreenManagerBase extends _SubManagerBase {
7375
this._subscribeButtonManager.start(),
7476
this._alertManager.start(),
7577
this._choiceSetManagerBase.start(),
78+
this._menuManagerBase.start(),
7679
]);
7780
this._transitionToState(_SubManagerBase.READY);
7881
await super.start();
@@ -91,6 +94,7 @@ class _ScreenManagerBase extends _SubManagerBase {
9194
_ScreenManagerBase._softButtonIDBySoftButtonManager = null;
9295
_ScreenManagerBase._softButtonIDByAlertManager = null;
9396
this._choiceSetManagerBase.dispose();
97+
this._menuManagerBase.dispose();
9498
super.dispose();
9599
}
96100

@@ -648,6 +652,74 @@ class _ScreenManagerBase extends _SubManagerBase {
648652
}
649653
return true;
650654
}
655+
656+
/**
657+
* The list of currently set menu cells
658+
* @returns {MenuCell[]} - An array of the currently set menu cells
659+
*/
660+
getMenu () {
661+
return this._menuManagerBase._getMenuCells();
662+
}
663+
664+
/**
665+
* Creates and sends all associated Menu RPCs
666+
* Note: the manager will store a deep copy the menuCells internally to be able to handle future updates correctly
667+
* @param {MenuCell[]} menuCells - The menu cells that are to be sent to the head unit, including their sub-cells.
668+
*/
669+
setMenu (menuCells) {
670+
this._menuManagerBase._setMenuCells(menuCells);
671+
}
672+
673+
/**
674+
* Sets the behavior of how menus are updated. For explanations of the differences, see {@link DynamicMenuUpdatesMode}
675+
* @param {DynamicMenuUpdatesMode} value - The update mode
676+
*/
677+
setDynamicMenuUpdatesMode (value) {
678+
this._menuManagerBase._setDynamicMenuUpdatesMode(value);
679+
}
680+
681+
/**
682+
* Gets the dynamic menu update mode
683+
* @returns {DynamicMenuUpdatesMode} - The currently set DynamicMenuUpdatesMode. It defaults to ON_WITH_COMPAT_MODE if not set.
684+
*/
685+
getDynamicMenuUpdatesMode () {
686+
return this._menuManagerBase._getDynamicMenuUpdatesMode();
687+
}
688+
689+
/**
690+
* Requires SDL RPC Version 6.0.0 or greater
691+
* Opens the Main Menu.
692+
* @returns {Boolean} - Whether the request was able to be sent
693+
*/
694+
openMenu () {
695+
return this._menuManagerBase._openMenu();
696+
}
697+
698+
/**
699+
* Requires SDL RPC Version 6.0.0 or greater
700+
* Opens a subMenu. The cell you pass in must be constructed with submenu cells
701+
* @param {MenuCell} cell - A submenu cell whose sub menu you wish to open
702+
* @returns {Boolean} - Whether the request was able to be sent
703+
*/
704+
openSubMenu (cell) {
705+
return this._menuManagerBase._openSubMenu(cell);
706+
}
707+
708+
/**
709+
* The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
710+
* @param {MenuConfiguration} menuConfiguration - The default menuConfiguration
711+
*/
712+
setMenuConfiguration (menuConfiguration) {
713+
this._menuManagerBase._setMenuConfiguration(menuConfiguration);
714+
}
715+
716+
/**
717+
* The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
718+
* @returns {MenuConfiguration} - The currently set MenuConfiguration
719+
*/
720+
getMenuConfiguration () {
721+
return this._menuManagerBase._getMenuConfiguration();
722+
}
651723
}
652724

653725
class _ManagerLocation extends Enum {

0 commit comments

Comments
 (0)