refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-31 17:53:14 +03:00
parent 65eaddb321
commit 1d649283cf
8 changed files with 62 additions and 38 deletions

View File

@ -124,7 +124,7 @@ var NWHostActions = actions.Actions({
// XXX add ability to use devtools on background page (node context)...
// XXX get the devtools stage...
showDevTools: ['Interface|Development/Show Dev Tools',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(action){
if(action == '?'){
// XXX get the devtools stage...
@ -145,7 +145,7 @@ var NWHostActions = actions.Actions({
}],
toggleSplashScreen: ['Interface/',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
}],
})
@ -246,7 +246,7 @@ var ElectronHostActions = actions.Actions({
// XXX should this be a toggler???
showDevTools: ['Interface|Development/Show Dev Tools',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(action){
var w = electron.remote.getCurrentWindow()
@ -277,7 +277,7 @@ var ElectronHostActions = actions.Actions({
// XXX make this a real toggler...
toggleSplashScreen: ['Interface/',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(action){
var splash = this.splash = (!this.splash || this.splash.isDestroyed()) ?
electron.remote.getGlobal('splash')
@ -560,7 +560,7 @@ var WindowedAppControlActions = actions.Actions({
}],
toggleSplashScreenShowing: ['Interface/Splash screen on start',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler('show-splash-screen',
['on', 'off'],
function(action){

View File

@ -832,7 +832,7 @@ actions.Actions({
// NOTE: resetting this option will clear the last direction...
toggleShiftsAffectDirection: ['Interface/Shifts affect direction',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler('shifts-affect-direction',
['off', 'on'],
function(action){

View File

@ -1282,7 +1282,7 @@ var CollectionActions = actions.Actions({
// Config and interface stuff...
//
toggleCollectionCropRetention: ['Interface/Collection crop save mode',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler(
'collection-save-crop-state',
[

View File

@ -352,7 +352,7 @@ var LocationActions = actions.Actions({
core.doc`Toggle index synchronization method
NOTE: this will not show disabled methods.`,
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.Toggler(null,
function(_, state){
var dict = this.location_sync_methods

View File

@ -28,7 +28,7 @@ var PreCacheActions = actions.Actions({
// NOTE: this will not work from chrome when loading from a local fs...
// XXX experimental...
startCacheWorker: ['Interface/',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
// a worker is started already...
if(this.cacheWorker != null){
@ -63,7 +63,7 @@ var PreCacheActions = actions.Actions({
this.cacheWorker.url = url
}],
stopCacheWorker: ['Interface/',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
if(this.cacheWorker){
this.cacheWorker.terminate()

View File

@ -893,12 +893,12 @@ var StatusLogActions = actions.Actions({
// XXX should this be here or in a separate feature???
statusLog: ['Interface/Show status log',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
// XXX use list
}],
clearStatusLog: ['Interface/Clear status log',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
delete this.__status_log
}],

View File

@ -904,7 +904,7 @@ var DialogsActions = actions.Actions({
listDialogs: ['Interface|System/Dialog/Dialog list...',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
makeUIDialog(function(){
var actions = this
@ -931,7 +931,7 @@ var DialogsActions = actions.Actions({
})],
toggleOverlayBlur: ['Interface/Dialog overlay blur',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.CSSClassToggler(
function(){ return this.dom },
'overlay-blur-enabled',
@ -2587,7 +2587,7 @@ var BrowseActionsActions = actions.Actions({
// ...this would help with the (global) search -- switch to
// flat if searching in root mode...
browseActions: ['Interface/Dialog/Actions...',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.doc`Browse actions dialog...
This uses action definition to build and present an action tree.
@ -2949,6 +2949,31 @@ var BrowseActionsActions = actions.Actions({
this.keyboard.handler('General', 'ctrl-a', 'toggleAdvanced')
}) })],
// XXX revise...
advancedBrowseModeAction: ['- System/',
core.doc`Placeholder advanced action
This is mainly used to indicate other actions as advanced mode only.
Example:
someAction: ['Menu/Path/Some action',
// show up only in advanced browse mode...
{mode: 'advancedBrowseModeAction'},
function(){
...
}],
`,
{mode: function(){
return this.advancedBrowseModeAction() }},
core.notUserCallable(function(){
// Placeholder action, not for direct use...
//
// See doc for more info:
// .showDoc('advancedBrowseModeAction')
return this.config['browse-advanced-mode'] != 'on'
&& 'hidden'
|| 'visible' })],
toggleBrowseAdvanced: ['System|Interface/-99: Advanced menu items',
core.doc`Toggle advanced menu items...
@ -2958,7 +2983,7 @@ var BrowseActionsActions = actions.Actions({
- return 'hidden' when needed
or:
- link to an action that behaves in a desired way:
{mode: 'toggleBrowseActionKeys',}
{mode: 'advancedBrowseModeAction',}
See .toggleBrowseActionKeys(..) for an example.
`,
@ -2967,8 +2992,7 @@ var BrowseActionsActions = actions.Actions({
['off', 'on'])],
toggleBrowseActionKeys: ['Interface/Show keys in menu',
{mode: function(){
return this.config['browse-advanced-mode'] != 'on' && 'hidden' }},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler(
'browse-actions-keys',
['on', 'off'],
@ -3013,7 +3037,7 @@ module.ContextActionMenu = core.ImageGridFeatures.Feature({
actions: actions.Actions({
showContextMenu: ['Interface/Show context menu...',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
uiDialog(function(){
return this.current ?
this.browseActions('/Image/')
@ -3172,13 +3196,13 @@ var ButtonsActions = actions.Actions({
},
toggleMainButtons: ['Interface/Main buttons',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
makeButtonControlsToggler('main-buttons')],
toggleSecondaryButtons: ['Interface/Secondary buttons',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
makeButtonControlsToggler('secondary-buttons')],
toggleAppButtons: ['Interface/App buttons',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
makeButtonControlsToggler('app-buttons')],
toggleSideButtons: ['Interface/70: Touch buttons',
@ -3195,7 +3219,7 @@ var ButtonsActions = actions.Actions({
})()],
toggleButtonHighlightColor: ['Interface/Theme/Button highlight color',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler(
'button-highlight-color',
function(){ return this.config['button-highlight-colors'] },

View File

@ -361,7 +361,7 @@ module.ViewerActions = actions.Actions({
.centerImage(target)
.centerRibbon(target) }],
alignRibbons: ['Interface/Align ribbons',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(target, scale, now){
if(target == 'now'){
now = true
@ -392,7 +392,7 @@ module.ViewerActions = actions.Actions({
// XXX skip off-screen ribbons (???)
// XXX should the timeout be configurable???
alignByOrder: ['Interface/Align ribbons by image order',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(target, scale, now){
if(target == 'now'){
now = true
@ -457,7 +457,7 @@ module.ViewerActions = actions.Actions({
}
}],
alignByFirst: ['Interface/Align ribbons except current to first image',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(target){
target = target == 'now' ? null : target
@ -656,7 +656,7 @@ module.ViewerActions = actions.Actions({
// XXX make this play nice with crops...
// ...should this be a crop???
toggleRibbonList: ['Interface|Ribbon/Ribbons as images view',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
if(this._full_data == null){
// XXX do a better name here...
@ -697,7 +697,7 @@ module.ViewerActions = actions.Actions({
function(angle){ }],
toggleImageRendering: ['Interface/Image rendering',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.CSSClassToggler(
function(){ return this.dom },
['crisp-resize', 'default-resize'],
@ -936,7 +936,7 @@ module.Cursor = core.ImageGridFeatures.Feature({
actions: actions.Actions({
toggleHiddenCursor: ['Interface/Cursor hidden',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.CSSClassToggler(
function(){ return this.dom },
'cursor-hidden',
@ -1011,7 +1011,7 @@ module.Cursor = core.ImageGridFeatures.Feature({
// .config['cursor-show-threshold']
//
toggleAutoHideCursor: ['Interface/Cursor auto-hide',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.CSSClassToggler(
function(){ return this.dom },
'cursor-autohide',
@ -1127,13 +1127,13 @@ module.Cursor = core.ImageGridFeatures.Feature({
})],
toggleAutoHideCursorTimeout: ['Interface/Hide cursor on timeout',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler('cursor-autohide-on-timeout',
['on', 'off'],
function(){
this.toggleAutoHideCursor('!') })],
toggleAutoHideCursorKeyboard: ['Interface/Hide cursor on keyboard',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler('cursor-autohide-on-keyboard',
['on', 'off'],
function(){
@ -1224,7 +1224,7 @@ var ControlActions = actions.Actions({
from reaching the viewer.
NOTE: this defines the focus/blur handlers on the window object.`,
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
core.makeConfigToggler('lock-unfocused',
['off', 'on'],
function(state){
@ -1378,7 +1378,7 @@ var ControlActions = actions.Actions({
// XXX depends on .ribbons...
// XXX uses: .focusImage(..)
toggleImageClickHandling: ['Interface/Image click handling',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.Toggler(null,
function(_, new_state){
return new_state ?
@ -1631,7 +1631,7 @@ var ControlActions = actions.Actions({
// XXX depends on .ribbons...
// XXX uses: .focusImage(..)
toggleRibbonPanHandling: ['Interface/Ribbon pan handling',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.Toggler(null,
function(_, new_state){
return new_state ?
@ -1871,7 +1871,7 @@ var ControlActions = actions.Actions({
// XXX depends on .ribbons...
// XXX uses: .focusImage(..)
toggleMouseWheelHandling: ['Interface/Mouse wheel handling',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
toggler.Toggler(null,
function(_, new_state){
return new_state ?
@ -1976,7 +1976,7 @@ var ControlActions = actions.Actions({
})],
togglePinchHandling: ['Interface/Pinch zoom handling',
{mode: 'toggleBrowseActionKeys'},
{mode: 'advancedBrowseModeAction'},
function(){
// XXX
}],
@ -1986,7 +1986,7 @@ var ControlActions = actions.Actions({
// ...allow ui features to control this...
// XXX depends on .ribbons...
toggleSwipeHandling: ['Interface/Swipe handling',
//{mode: 'toggleBrowseActionKeys'},
//{mode: 'advancedBrowseModeAction'},
toggler.Toggler(null,
function(_, state){
return state ?