@lvce-editor/title-bar-worker 2.12.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/titleBarWorkerMain.js +85 -48
- package/package.json +1 -1
|
@@ -2450,6 +2450,10 @@ const handleContextMenu = state => {
|
|
|
2450
2450
|
return state;
|
|
2451
2451
|
};
|
|
2452
2452
|
|
|
2453
|
+
const getMenuOffset = (x, clientX, iconWidth) => {
|
|
2454
|
+
return clientX - x - iconWidth;
|
|
2455
|
+
};
|
|
2456
|
+
|
|
2453
2457
|
const getTitleBarIndexFromPosition = (titleBarEntries, x, y) => {
|
|
2454
2458
|
let currentX = 0;
|
|
2455
2459
|
for (let i = 0; i < titleBarEntries.length; i++) {
|
|
@@ -2581,7 +2585,8 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
|
|
|
2581
2585
|
const {
|
|
2582
2586
|
titleBarEntries,
|
|
2583
2587
|
titleBarHeight,
|
|
2584
|
-
x
|
|
2588
|
+
x,
|
|
2589
|
+
iconWidth
|
|
2585
2590
|
} = state;
|
|
2586
2591
|
// TODO race conditions
|
|
2587
2592
|
// TODO send renderer process
|
|
@@ -2597,7 +2602,7 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
|
|
|
2597
2602
|
const offset = totalWidths;
|
|
2598
2603
|
// TODO race condition: another menu might already be open at this point
|
|
2599
2604
|
|
|
2600
|
-
const menuX = x + offset;
|
|
2605
|
+
const menuX = x + offset + iconWidth;
|
|
2601
2606
|
const menuY = titleBarHeight;
|
|
2602
2607
|
const width = getMenuWidth();
|
|
2603
2608
|
const height = getMenuHeight(items);
|
|
@@ -2664,7 +2669,13 @@ const ifElse = (menuOpenFunction, menuClosedFunction) => {
|
|
|
2664
2669
|
const handleMouseOut = ifElse(handleMouseOutMenuOpen, handleMouseOutMenuClosed);
|
|
2665
2670
|
|
|
2666
2671
|
const handlePointerOut = (state, clientX, clientY) => {
|
|
2667
|
-
const
|
|
2672
|
+
const {
|
|
2673
|
+
x,
|
|
2674
|
+
iconWidth,
|
|
2675
|
+
titleBarEntries
|
|
2676
|
+
} = state;
|
|
2677
|
+
const menuX = getMenuOffset(x, clientX, iconWidth);
|
|
2678
|
+
const index = getTitleBarIndexFromPosition(titleBarEntries, menuX);
|
|
2668
2679
|
if (index === -1) {
|
|
2669
2680
|
return state;
|
|
2670
2681
|
}
|
|
@@ -2685,7 +2696,13 @@ const handleMouseOverMenuOpen = async (state, index) => {
|
|
|
2685
2696
|
const handleMouseOver = ifElse(handleMouseOverMenuOpen, handleMouseOverMenuClosed);
|
|
2686
2697
|
|
|
2687
2698
|
const handlePointerOver = (state, clientX, clientY) => {
|
|
2688
|
-
const
|
|
2699
|
+
const {
|
|
2700
|
+
titleBarEntries,
|
|
2701
|
+
x,
|
|
2702
|
+
iconWidth
|
|
2703
|
+
} = state;
|
|
2704
|
+
const menuOffset = getMenuOffset(x, clientX, iconWidth);
|
|
2705
|
+
const index = getTitleBarIndexFromPosition(titleBarEntries, menuOffset);
|
|
2689
2706
|
if (index === -1) {
|
|
2690
2707
|
return state;
|
|
2691
2708
|
}
|
|
@@ -2759,11 +2776,13 @@ const loadContent2 = async state => {
|
|
|
2759
2776
|
const withWidths = addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
|
|
2760
2777
|
const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
|
|
2761
2778
|
const title = 'test';
|
|
2779
|
+
const iconWidth = 30;
|
|
2762
2780
|
return {
|
|
2763
2781
|
...state,
|
|
2764
2782
|
titleBarEntries: withWidths,
|
|
2765
2783
|
buttons,
|
|
2766
|
-
title
|
|
2784
|
+
title,
|
|
2785
|
+
iconWidth
|
|
2767
2786
|
};
|
|
2768
2787
|
};
|
|
2769
2788
|
|
|
@@ -3625,8 +3644,14 @@ const handleClick = async (state, button, index) => {
|
|
|
3625
3644
|
return toggleIndex(state, index);
|
|
3626
3645
|
};
|
|
3627
3646
|
|
|
3628
|
-
const handleClickAt = async (state, button,
|
|
3629
|
-
const
|
|
3647
|
+
const handleClickAt = async (state, button, eventX, eventY) => {
|
|
3648
|
+
const {
|
|
3649
|
+
titleBarEntries,
|
|
3650
|
+
x,
|
|
3651
|
+
iconWidth
|
|
3652
|
+
} = state;
|
|
3653
|
+
const menuOffset = getMenuOffset(x, eventX, iconWidth);
|
|
3654
|
+
const index = getTitleBarIndexFromPosition(titleBarEntries, menuOffset);
|
|
3630
3655
|
if (index === -1) {
|
|
3631
3656
|
return state;
|
|
3632
3657
|
}
|
|
@@ -4018,61 +4043,73 @@ const toggleMenu = async state => {
|
|
|
4018
4043
|
};
|
|
4019
4044
|
|
|
4020
4045
|
const commandMap = {
|
|
4046
|
+
'TitleBar.closeMenu': closeMenu,
|
|
4047
|
+
'TitleBar.create': create,
|
|
4021
4048
|
'TitleBar.create3': create3,
|
|
4049
|
+
'TitleBar.diff2': diff2,
|
|
4022
4050
|
'TitleBar.diff3': diff3,
|
|
4051
|
+
'TitleBar.focus': wrapCommand(focus),
|
|
4052
|
+
'TitleBar.focusFirst': wrapCommand(focusFirst),
|
|
4053
|
+
'TitleBar.focusIndex': wrapCommand(focusLast),
|
|
4054
|
+
'TitleBar.focusLast': wrapCommand(focusIndex),
|
|
4055
|
+
'TitleBar.focusNext': wrapCommand(focusNext),
|
|
4056
|
+
'TitleBar.focusPrevious': wrapCommand(focusPrevious),
|
|
4023
4057
|
'TitleBar.getButtonsVirtualDom': getTitleBarButtonsVirtualDom,
|
|
4058
|
+
'TitleBar.getCommandIds': getCommandIds,
|
|
4059
|
+
'TitleBar.getCommands': getCommandIds,
|
|
4024
4060
|
'TitleBar.getIconVirtualDom': getTitleBarIconVirtualDom,
|
|
4061
|
+
'TitleBar.getKeyBindings': getKeyBindings$1,
|
|
4025
4062
|
'TitleBar.getMenuEntries': getMenuEntries$1,
|
|
4026
4063
|
'TitleBar.getMenuIds': getMenuIds,
|
|
4064
|
+
'TitleBar.getMenus': getMenus,
|
|
4065
|
+
'TitleBar.getTitleBarButtons': getTitleBarButtons,
|
|
4027
4066
|
'TitleBar.getTitleVirtualDom': getTitleVirtualDom,
|
|
4028
|
-
'TitleBar.
|
|
4067
|
+
'TitleBar.getVirtualDom': getTitleBarMenuBarVirtualDom,
|
|
4029
4068
|
'TitleBar.handleButtonsClick': handleClick$1,
|
|
4069
|
+
'TitleBar.handleClick': wrapCommand(handleClick),
|
|
4070
|
+
'TitleBar.handleClickAt': wrapCommand(handleClickAt),
|
|
4030
4071
|
'TitleBar.handleClickClose': wrapCommand(handleClickClose),
|
|
4031
4072
|
'TitleBar.handleClickMinimize': wrapCommand(handleClickMinimize),
|
|
4032
4073
|
'TitleBar.handleClickToggleMaximize': wrapCommand(handleClickToggleMaximize),
|
|
4033
4074
|
'TitleBar.handleContextMenu': handleContextMenu,
|
|
4075
|
+
'TitleBar.handleFocus': wrapCommand(handleFocus),
|
|
4076
|
+
'TitleBar.handleFocusOut': wrapCommand(handleFocusOut),
|
|
4077
|
+
'TitleBar.handleKeyArrowDown': wrapCommand(handleKeyArrowDown),
|
|
4078
|
+
'TitleBar.handleKeyArrowLeft': wrapCommand(handleKeyArrowLeft),
|
|
4079
|
+
'TitleBar.handleKeyArrowRight': wrapCommand(handleKeyArrowRight),
|
|
4080
|
+
'TitleBar.handleKeyArrowUp': wrapCommand(handleKeyArrowUp),
|
|
4081
|
+
'TitleBar.handleKeyEnd': wrapCommand(handleKeyEnd),
|
|
4082
|
+
'TitleBar.handleKeyEnter': wrapCommand(handleKeyEnter),
|
|
4083
|
+
'TitleBar.handleKeyEscape': wrapCommand(handleKeyEscape),
|
|
4084
|
+
'TitleBar.handleKeyHome': wrapCommand(handleKeyHome),
|
|
4085
|
+
'TitleBar.handleKeySpace': wrapCommand(handleKeySpace),
|
|
4086
|
+
'TitleBar.handleMenuClick': wrapCommand(handleMenuClick),
|
|
4087
|
+
'TitleBar.handleMenuMouseOver': wrapCommand(handleMenuMouseOver),
|
|
4088
|
+
'TitleBar.handleMouseOut': wrapCommand(handleMouseOut),
|
|
4089
|
+
'TitleBar.handleMouseOver': wrapCommand(handleMouseOver),
|
|
4090
|
+
'TitleBar.handlePointerOut': wrapCommand(handlePointerOut),
|
|
4091
|
+
'TitleBar.handlePointerOver': wrapCommand(handlePointerOver),
|
|
4092
|
+
'TitleBar.loadContent': wrapCommand(loadContent),
|
|
4093
|
+
'TitleBar.loadContent2': wrapCommand(loadContent2),
|
|
4094
|
+
'TitleBar.render2': render2,
|
|
4034
4095
|
'TitleBar.render3': render3,
|
|
4035
4096
|
'TitleBar.renderEventListeners': renderEventListeners,
|
|
4036
|
-
'
|
|
4037
|
-
'
|
|
4038
|
-
'
|
|
4039
|
-
'
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
'
|
|
4046
|
-
'
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
'TitleBarMenuBar.handleFocus': wrapCommand(handleFocus),
|
|
4053
|
-
'TitleBarMenuBar.handleFocusOut': wrapCommand(handleFocusOut),
|
|
4054
|
-
'TitleBarMenuBar.handleKeyArrowDown': wrapCommand(handleKeyArrowDown),
|
|
4055
|
-
'TitleBarMenuBar.handleKeyArrowLeft': wrapCommand(handleKeyArrowLeft),
|
|
4056
|
-
'TitleBarMenuBar.handleKeyArrowRight': wrapCommand(handleKeyArrowRight),
|
|
4057
|
-
'TitleBarMenuBar.handleKeyArrowUp': wrapCommand(handleKeyArrowUp),
|
|
4058
|
-
'TitleBarMenuBar.handleKeyEnd': wrapCommand(handleKeyEnd),
|
|
4059
|
-
'TitleBarMenuBar.handleKeyEnter': wrapCommand(handleKeyEnter),
|
|
4060
|
-
'TitleBarMenuBar.handleKeyEscape': wrapCommand(handleKeyEscape),
|
|
4061
|
-
'TitleBarMenuBar.handleKeyHome': wrapCommand(handleKeyHome),
|
|
4062
|
-
'TitleBarMenuBar.handleKeySpace': wrapCommand(handleKeySpace),
|
|
4063
|
-
'TitleBarMenuBar.handleMenuClick': wrapCommand(handleMenuClick),
|
|
4064
|
-
'TitleBarMenuBar.handleMenuMouseOver': wrapCommand(handleMenuMouseOver),
|
|
4065
|
-
'TitleBarMenuBar.handleMouseOut': wrapCommand(handleMouseOut),
|
|
4066
|
-
'TitleBarMenuBar.handleMouseOver': wrapCommand(handleMouseOver),
|
|
4067
|
-
'TitleBarMenuBar.handlePointerOut': wrapCommand(handlePointerOut),
|
|
4068
|
-
'TitleBarMenuBar.handlePointerOver': wrapCommand(handlePointerOver),
|
|
4069
|
-
'TitleBarMenuBar.loadContent': wrapCommand(loadContent),
|
|
4070
|
-
'TitleBarMenuBar.render2': render2,
|
|
4071
|
-
'TitleBarMenuBar.saveState': saveState,
|
|
4072
|
-
'TitleBarMenuBar.terminate': terminate,
|
|
4073
|
-
'TitleBarMenuBar.toggleIndex': wrapCommand(toggleIndex),
|
|
4074
|
-
'TitleBarMenuBar.toggleMenu': wrapCommand(toggleMenu)
|
|
4075
|
-
};
|
|
4097
|
+
'TitleBar.saveState': saveState,
|
|
4098
|
+
'TitleBar.terminate': terminate,
|
|
4099
|
+
'TitleBar.toggleIndex': wrapCommand(toggleIndex),
|
|
4100
|
+
'TitleBar.toggleMenu': wrapCommand(toggleMenu)
|
|
4101
|
+
};
|
|
4102
|
+
|
|
4103
|
+
// deprecated, can be removed in the future.
|
|
4104
|
+
// currently enabled for backwards compatability
|
|
4105
|
+
for (const [key, value] of Object.entries(commandMap)) {
|
|
4106
|
+
const [prefix, name] = key.split('.');
|
|
4107
|
+
if (prefix === 'TitleBar') {
|
|
4108
|
+
const alternate = `TitleBarMenuBar.${name}`;
|
|
4109
|
+
// @ts-ignore
|
|
4110
|
+
commandMap[alternate] = value;
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4076
4113
|
|
|
4077
4114
|
const listen = async () => {
|
|
4078
4115
|
registerCommands(commandMap);
|