From 5c804ff64d5c5d9b4ca1291e79c41240dce98cd8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 31 May 2020 20:12:58 +0300 Subject: [PATCH] tweaaks + docs... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/core.js | 43 +++++++++++++++++++++++++------- ui (gen4)/features/marks.js | 4 +-- ui (gen4)/features/ui-widgets.js | 42 +++++++++++-------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index beba8d8b..c66a6cd6 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -487,21 +487,46 @@ var IntrospectionActions = actions.Actions({ return !!action.__event__ }), // XXX revise... - // XXX this is a bit restrictive, need to be able to setup mode - // aliases/handlers, i.e. setting {mode: 'advanced'} and either - // getting the actual value from .config or calling a mode handler... - // ...might also be nice to use a toggler as handler: - // {mode: 'toggleBrowseAdvanced'} getActionMode: ['- Interface/', doc`Get action browse mode... Get and action's .mode(..) method and return its result. - Expected values: - 'disabled' - actions is disabled - 'hidden' - actions is hidden + Action .mode can be: + - action method. + - alias, name of action to get the + method from. - NOTE: other values are ignored. + The action .mode(..) method is called in the context of actions. + + Basic example: + someAction: ['Path/To/Some action', + {mode: function(){ ... }}, + function(){ + ... + }], + someOtherAction: ['Path/To/Some action', + // alias + {mode: 'someAction'}, + function(){ + ... + }], + + + Usage pattern: + // for cases where we need to define an explicit mode... + actionModeX: ['- System/', + {mode: function(){ + return this.actionModeX() }}, + core.notUserCallable(function(){ + return ... + })], + someAction: [ + // use the mode... + {mode: 'actionModeX'}, + function(){ + ... + }], `, function(action, mode_cache){ var m = action diff --git a/ui (gen4)/features/marks.js b/ui (gen4)/features/marks.js index 424fb760..b1b58d26 100755 --- a/ui (gen4)/features/marks.js +++ b/ui (gen4)/features/marks.js @@ -266,7 +266,7 @@ var ImageMarkActions = actions.Actions({ function(mode){ this.nextTagged('marked', mode) }], cropMarked: ['Mark|Crop/Crop $marked images', - {mode: function(target){ + {mode: function(){ return this.marked.length == 0 && 'disabled' }}, 'crop: "marked" ...'], //function(flatten){ this.cropTagged('marked', flatten) }], @@ -274,7 +274,7 @@ var ImageMarkActions = actions.Actions({ removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop', {mode: function(target){ - return (this.marked.length == 0 || !this.cropped) && 'disabled' }}, + return (this.marked.length == 0 || !this.cropped) && 'disabled' }}, 'removeFromCrop: marked'], rotateMarkedCW: ['Mark/Rotate marked clockwise', diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 540fcbc3..5bcad2d6 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -2615,34 +2615,20 @@ var BrowseActionsActions = actions.Actions({ Action mode (disabled/hidden) and also be controlled dynamically: - - .mode() action method is called with actions as base. - Example: - someAction: ['Path/To/Some action', - {mode: function(){ ... }}, - function(){ - ... - }], - someOtherAction: ['Path/To/Some action', - // alias - {mode: 'someAction'}, - function(){ - ... - }], - .mode can be: - - action method. - - alias, name of action to get the - method from. + Expected modes: + 'hidden' - hide the action from dialog + 'disabled' - disable the action in dialog + ... - other values are ignored - .mode() can return: - 'disabled' - item will be disabled. - 'hidden' - item will be both hidden and disabled. + NOTE: disabling in path has priority over .mode(), thus + it is possible to hide/disable an enabled item but not + possible to enable a disabled by default path. + NOTE: .mode() can be defined in any action in chain, + though only the last one is called... + + For more info see .getActionMode(..) - NOTE: disabling in path has priority over .mode(), thus - it is possible to hide/disable an enabled item but not - possible to enable a disabled by default path. - NOTE: .mode() can be defined in any action in chain, - though only the last one is called... options format: @@ -2951,7 +2937,7 @@ var BrowseActionsActions = actions.Actions({ // XXX revise... advancedBrowseModeAction: ['- System/', - core.doc`Placeholder advanced action + core.doc`advanced action (placeholder) This is mainly used to indicate other actions as advanced mode only. @@ -2965,14 +2951,14 @@ var BrowseActionsActions = actions.Actions({ `, {mode: function(){ return this.advancedBrowseModeAction() }}, - core.notUserCallable(function(){ + function(){ // Placeholder action, not for direct use... // // See doc for more info: // .showDoc('advancedBrowseModeAction') return this.config['browse-advanced-mode'] != 'on' && 'hidden' - || 'visible' })], + || 'visible' }], toggleBrowseAdvanced: ['System|Interface/-99: Advanced menu items', core.doc`Toggle advanced menu items...