2023-10-06 18:22:04 +00:00
|
|
|
# SPDX-FileCopyrightText: (C) 2023 TheFGFSEagle <thefgfseagle@gmail.com>
|
2022-09-26 07:58:24 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var menubar = nil;
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _addItem = func(parent, itemGhost) {
|
|
|
|
var item = parent.createItem(
|
|
|
|
text: itemGhost.label,
|
|
|
|
cb: itemGhost.fire,
|
|
|
|
cb_me: itemGhost,
|
|
|
|
shortcut: itemGhost.shortcut,
|
|
|
|
enabled: itemGhost.enabled,
|
|
|
|
);
|
|
|
|
}
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _addMenu = func(parent, menuGhost) {
|
|
|
|
var menu = parent.createMenu(menuGhost.label);
|
|
|
|
foreach (var item; menuGhost.items) {
|
|
|
|
_addItem(menu, item);
|
|
|
|
}
|
|
|
|
}
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _createMenuBar = func(menubarGhost) {
|
|
|
|
if (menubar != nil) {
|
|
|
|
menubar.del();
|
|
|
|
menubar = nil;
|
|
|
|
}
|
|
|
|
menubar = canvas.gui.MenuBar.new();
|
|
|
|
foreach (var menu; menubarGhost.menus) {
|
|
|
|
_addMenu(menubar, menu);
|
|
|
|
}
|
|
|
|
menubar.show();
|
|
|
|
}
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _destroyMenuBar = func(menubarGhost) {
|
|
|
|
if (menubar != nil) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
menubar.del();
|
|
|
|
menubar = nil;
|
|
|
|
}
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _showMenuBar = func(menubarGhost) {
|
|
|
|
if (menubar == nil) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
menubar.show();
|
|
|
|
}
|
2022-09-26 07:58:24 +00:00
|
|
|
|
2023-10-06 18:22:04 +00:00
|
|
|
var _hideMenuBar = func(menubarGhost) {
|
|
|
|
if (menubar == nil) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
menubar.hide();
|
2022-09-26 07:58:24 +00:00
|
|
|
}
|
|
|
|
|