mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
minor changes to how the cursor is hidden + open path from history + docs and refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a3f38bc6ff
commit
867336f7d5
@ -671,12 +671,58 @@ module.URLHistoryUI = core.ImageGridFeatures.Feature({
|
|||||||
'ui',
|
'ui',
|
||||||
'url-history',
|
'url-history',
|
||||||
],
|
],
|
||||||
|
suggested: [
|
||||||
|
'ui-url-history-browsable',
|
||||||
|
],
|
||||||
|
|
||||||
actions: URLHistoryUIActions,
|
actions: URLHistoryUIActions,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
var URLHistoryUIBrowsable =
|
||||||
|
module.URLHistoryUIBrowsable = core.ImageGridFeatures.Feature({
|
||||||
|
title: '',
|
||||||
|
doc: '',
|
||||||
|
|
||||||
|
tag: 'ui-url-history-browsable',
|
||||||
|
depends: [
|
||||||
|
'ui',
|
||||||
|
'url-history',
|
||||||
|
'ui-fs-loader',
|
||||||
|
],
|
||||||
|
|
||||||
|
handlers: [
|
||||||
|
['listURLHistory',
|
||||||
|
function(dialog){
|
||||||
|
var that = this
|
||||||
|
|
||||||
|
// this will take care of any number of child dialogs...
|
||||||
|
var onOpen = function(){
|
||||||
|
// we are the top dialog --> close...
|
||||||
|
if(that.modal.client === dialog){
|
||||||
|
dialog.close()
|
||||||
|
|
||||||
|
// child dialog, ask to close us when opening...
|
||||||
|
} else {
|
||||||
|
that.modal.client.open(onOpen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.browsePath = function(){
|
||||||
|
that.browsePath(this.selected).open(onOpen) }
|
||||||
|
|
||||||
|
// clone the bindings so as not to mess up the global browser...
|
||||||
|
dialog.keybindings = JSON.parse(JSON.stringify(dialog.keybindings))
|
||||||
|
|
||||||
|
dialog.keyboard.handler('General', 'O', 'browsePath')
|
||||||
|
}]],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */ return module })
|
* vim:set ts=4 sw=4 : */ return module })
|
||||||
|
|||||||
@ -382,7 +382,8 @@ module.GLOBAL_KEYBOARD2 = {
|
|||||||
'?': 'browseKeyboardBindings',
|
'?': 'browseKeyboardBindings',
|
||||||
|
|
||||||
|
|
||||||
W: 'testAction -- XXX DEBUG: remove when done...',
|
//W: 'testAction -- XXX DEBUG: remove when done...',
|
||||||
|
W: 'nonAction -- XXX DEBUG: remove when done...',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,13 +394,6 @@ module.GLOBAL_KEYBOARD2 = {
|
|||||||
|
|
||||||
var KeyboardActions = actions.Actions({
|
var KeyboardActions = actions.Actions({
|
||||||
config: {
|
config: {
|
||||||
// limit key repeat to one per N milliseconds.
|
|
||||||
//
|
|
||||||
// Set this to -1 or null to run keys without any limitations.
|
|
||||||
'max-key-repeat-rate': 0,
|
|
||||||
|
|
||||||
'keyboard-repeat-pause-check': 100,
|
|
||||||
|
|
||||||
// Sets the target element to which the keyboard event handler
|
// Sets the target element to which the keyboard event handler
|
||||||
// is bound...
|
// is bound...
|
||||||
//
|
//
|
||||||
@ -415,13 +409,22 @@ var KeyboardActions = actions.Actions({
|
|||||||
// NOTE: the target element must be focusable...
|
// NOTE: the target element must be focusable...
|
||||||
'keyboard-event-source': 'window',
|
'keyboard-event-source': 'window',
|
||||||
|
|
||||||
// If true enable .keyPressed(..) action calling on keyboard
|
// limit key repeat to one per N milliseconds.
|
||||||
|
//
|
||||||
|
// Set this to -1 or null to run keys without any limitations.
|
||||||
|
'max-key-repeat-rate': 0,
|
||||||
|
|
||||||
|
// The amount of keyboard "quiet" time to wait for when
|
||||||
|
// .pauseKeyboardRepeat(..) is called...
|
||||||
|
'keyboard-repeat-pause-check': 100,
|
||||||
|
|
||||||
|
// If 'on' enable .keyPressed(..) action calling on keyboard
|
||||||
// activity...
|
// activity...
|
||||||
//
|
//
|
||||||
// NOTE: if updated the keyboard handler will need to be restarted
|
// NOTE: if updated the keyboard handler will need to be restarted
|
||||||
// for changes to take effect.
|
// for changes to take effect.
|
||||||
// XXX EXPERIMENTAL
|
// XXX EXPERIMENTAL
|
||||||
'keyboard-key-pressed-action': false,
|
'keyboard-key-pressed-action': 'off',
|
||||||
},
|
},
|
||||||
|
|
||||||
get keybindings(){
|
get keybindings(){
|
||||||
@ -429,6 +432,8 @@ var KeyboardActions = actions.Actions({
|
|||||||
get keyboard(){
|
get keyboard(){
|
||||||
return this.__keyboard_object },
|
return this.__keyboard_object },
|
||||||
|
|
||||||
|
|
||||||
|
// Self-test action...
|
||||||
testKeyboardDoc: ['- Interface/',
|
testKeyboardDoc: ['- Interface/',
|
||||||
{self_test: true},
|
{self_test: true},
|
||||||
function(){
|
function(){
|
||||||
@ -467,6 +472,9 @@ var KeyboardActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
|
// Key bindings ---------------------------------------------------
|
||||||
|
|
||||||
// XXX need a clean deep copy to restore...
|
// XXX need a clean deep copy to restore...
|
||||||
resetKeyBindings: ['Interface/Restore default key bindings',
|
resetKeyBindings: ['Interface/Restore default key bindings',
|
||||||
function(){
|
function(){
|
||||||
@ -554,11 +562,7 @@ var KeyboardActions = actions.Actions({
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
// keyboard handling...
|
// keyboard handling ----------------------------------------------
|
||||||
|
|
||||||
pauseKeyboardRepeat: ['- Interface/',
|
|
||||||
function(){
|
|
||||||
this.__keyboard_repeat_paused = true }],
|
|
||||||
|
|
||||||
toggleKeyboardHandling: ['- Interface/Keyboard handling',
|
toggleKeyboardHandling: ['- Interface/Keyboard handling',
|
||||||
toggler.Toggler(null, function(_, state){
|
toggler.Toggler(null, function(_, state){
|
||||||
@ -589,11 +593,11 @@ var KeyboardActions = actions.Actions({
|
|||||||
// pass keys pressed to .keyPressed(..) action...
|
// pass keys pressed to .keyPressed(..) action...
|
||||||
// XXX EXPERIMENTAL...
|
// XXX EXPERIMENTAL...
|
||||||
var keyPressdCall = function(handler){
|
var keyPressdCall = function(handler){
|
||||||
return that.config['keyboard-key-pressed-action'] ?
|
return that.config['keyboard-key-pressed-action'] == 'on' ?
|
||||||
function(evt){
|
function(evt){
|
||||||
var e = that.keyPressed.pre(
|
var e = that.keyPressed.pre(
|
||||||
that,
|
that,
|
||||||
[keyboard.joinKey(keyboard.event2key(evt))])
|
[evt, keyboard.joinKey(keyboard.event2key(evt))])
|
||||||
|
|
||||||
var res = handler.apply(that, arguments)
|
var res = handler.apply(that, arguments)
|
||||||
e.result = res
|
e.result = res
|
||||||
@ -668,9 +672,29 @@ var KeyboardActions = actions.Actions({
|
|||||||
},
|
},
|
||||||
['on', 'off'])],
|
['on', 'off'])],
|
||||||
|
|
||||||
// NOTE: at this point this is disabled by default, set
|
// Drop keys until non are pressed for a timeout...
|
||||||
// .config['keyboard-key-pressed-action'] to true and restart
|
//
|
||||||
// the handler via .toggleKeyboardHandling('!') for this to work
|
// This is useful for stopping repeating (held down) keys after some
|
||||||
|
// event.
|
||||||
|
pauseKeyboardRepeat: ['- Interface/',
|
||||||
|
function(){ this.__keyboard_repeat_paused = true }],
|
||||||
|
|
||||||
|
// Keyboard activity event...
|
||||||
|
//
|
||||||
|
// This is triggered when a key passes to .keyboard. The .pre stage
|
||||||
|
// is run before the key is handled, .post is run just after.
|
||||||
|
//
|
||||||
|
// Option .config['keyboard-key-pressed-action'] controls if this is
|
||||||
|
// called, when false the functionality is disabled.
|
||||||
|
//
|
||||||
|
// Care must be taken when using binding to this (especially the
|
||||||
|
// .pre stage) as this may introduce a lag into user input.
|
||||||
|
//
|
||||||
|
// NOTE: updates to .config['keyboard-key-pressed-action'] will take
|
||||||
|
// effect after handler restart via .toggleKeyboardHandling('!')
|
||||||
|
// or cycling it off and back on...
|
||||||
|
// NOTE: his is called by the handler created in .toggleKeyboardHandling(..)
|
||||||
|
//
|
||||||
// XXX EXPERIMENTAL: event for actions to be able to handle keys...
|
// XXX EXPERIMENTAL: event for actions to be able to handle keys...
|
||||||
// ...not working yet...
|
// ...not working yet...
|
||||||
// XXX not sure if we need this...
|
// XXX not sure if we need this...
|
||||||
@ -679,15 +703,19 @@ var KeyboardActions = actions.Actions({
|
|||||||
// if overdone this can be a mess...
|
// if overdone this can be a mess...
|
||||||
keyPressed: ['- Interface/Key pressed event',
|
keyPressed: ['- Interface/Key pressed event',
|
||||||
'This is called by the keyboard handler when a key is pressed, '
|
'This is called by the keyboard handler when a key is pressed, '
|
||||||
+'the key is passed as argument.',
|
+'the actual event and key are passed as argument.',
|
||||||
core.notUserCallable(function(key){
|
core.notUserCallable(function(evt, key){
|
||||||
// This is the keyboard hook protocol root function
|
// This is the keyboard hook protocol root function
|
||||||
//
|
//
|
||||||
// Not for direct use.
|
// Not for direct use.
|
||||||
})],
|
})],
|
||||||
|
toggleKeyPressedHandling: ['Interface/keyPressed event',
|
||||||
|
core.makeConfigToggler('keyboard-key-pressed-action',
|
||||||
|
['off', 'on'],
|
||||||
|
function(){ this.toggleKeyboardHandling('!') })],
|
||||||
|
|
||||||
|
|
||||||
// interface stuff...
|
// Interface stuff ------------------------------------------------
|
||||||
|
|
||||||
// XXX key editor:
|
// XXX key editor:
|
||||||
// [ mode ]
|
// [ mode ]
|
||||||
|
|||||||
@ -52,22 +52,15 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
|||||||
'ui',
|
'ui',
|
||||||
'keyboard',
|
'keyboard',
|
||||||
|
|
||||||
//'ui-ribbons-placement',
|
|
||||||
|
|
||||||
// features...
|
// features...
|
||||||
'ui-ribbon-auto-align',
|
'ui-ribbon-auto-align',
|
||||||
//'ui-ribbon-align-to-order',
|
|
||||||
//'ui-ribbon-align-to-first',
|
|
||||||
//'ui-ribbon-manual-align',
|
|
||||||
|
|
||||||
|
'ui-cursor',
|
||||||
|
'ui-animation',
|
||||||
|
|
||||||
'ui-single-image',
|
'ui-single-image',
|
||||||
'ui-partial-ribbons',
|
'ui-partial-ribbons',
|
||||||
|
|
||||||
// XXX
|
|
||||||
//'ui-keyboard-control',
|
|
||||||
//'ui-direct-control',
|
|
||||||
//'ui-indirect-control',
|
|
||||||
|
|
||||||
'marks',
|
'marks',
|
||||||
'ui-range',
|
'ui-range',
|
||||||
|
|
||||||
|
|||||||
@ -330,7 +330,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|
|||||||
],
|
],
|
||||||
suggested: [
|
suggested: [
|
||||||
'ui-single-image-local-storage',
|
'ui-single-image-local-storage',
|
||||||
'ui-single-image-autohide-cursor',
|
'ui-single-image-cursor',
|
||||||
],
|
],
|
||||||
|
|
||||||
actions: SingleImageActions,
|
actions: SingleImageActions,
|
||||||
@ -507,14 +507,14 @@ module.SingleImageViewLocalStorage = core.ImageGridFeatures.Feature({
|
|||||||
// NOTE: chrome 49 + devtools open appears to prevent the cursor from being hidden...
|
// NOTE: chrome 49 + devtools open appears to prevent the cursor from being hidden...
|
||||||
//
|
//
|
||||||
// XXX hiding cursor on navigation for some reason does not work...
|
// XXX hiding cursor on navigation for some reason does not work...
|
||||||
var SingleImageAutoHideCursor =
|
var SingleImageCursor =
|
||||||
module.SingleImageAutoHideCursor = core.ImageGridFeatures.Feature({
|
module.SingleImageCursor = core.ImageGridFeatures.Feature({
|
||||||
title: '',
|
title: '',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'ui-single-image-autohide-cursor',
|
tag: 'ui-single-image-cursor',
|
||||||
depends: [
|
depends: [
|
||||||
'ui-autohide-cursor',
|
'ui-cursor',
|
||||||
'ui-single-image',
|
'ui-single-image',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
* - ui-ribbon-manual-align
|
* - ui-ribbon-manual-align
|
||||||
* - ui-animation
|
* - ui-animation
|
||||||
* manage UI non-css animations...
|
* manage UI non-css animations...
|
||||||
* - ui-autohide-cursor
|
* - ui-cursor
|
||||||
* - ui-control
|
* - ui-control
|
||||||
* touch/mouse control mechanics
|
* touch/mouse control mechanics
|
||||||
*
|
*
|
||||||
@ -1593,27 +1593,30 @@ module.ShiftAnimation = core.ImageGridFeatures.Feature({
|
|||||||
// on will re-enable autohide.
|
// on will re-enable autohide.
|
||||||
// NOTE: chrome 49 + devtools open appears to prevent the cursor from
|
// NOTE: chrome 49 + devtools open appears to prevent the cursor from
|
||||||
// being hidden...
|
// being hidden...
|
||||||
var AutoHideCursor =
|
var Cursor =
|
||||||
module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
module.Cursor = core.ImageGridFeatures.Feature({
|
||||||
title: '',
|
title: '',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'ui-autohide-cursor',
|
tag: 'ui-cursor',
|
||||||
depends: [
|
depends: [
|
||||||
'ui'
|
'ui'
|
||||||
],
|
],
|
||||||
|
|
||||||
config: {
|
config: {
|
||||||
'cursor-autohide-ignore-keys': [
|
'cursor-autohide-ignore-keys': [
|
||||||
'shift', 'ctrl', 'alt', 'meta',
|
'shift', 'ctrl', 'alt', 'meta',
|
||||||
|
'F5',
|
||||||
],
|
],
|
||||||
|
|
||||||
'cursor-autohide': 'on',
|
'cursor-autohide': 'on',
|
||||||
'cursor-autohide-on-timeout': 'off',
|
'cursor-autohide-on-timeout': 'off',
|
||||||
'cursor-autohide-on-keyboard': 'on',
|
'cursor-autohide-on-keyboard': 'on',
|
||||||
|
|
||||||
'cursor-autohide-timeout': 1000,
|
|
||||||
'cursor-show-threshold': 10,
|
'cursor-show-threshold': 10,
|
||||||
|
|
||||||
|
'cursor-autohide-timeout': 1000,
|
||||||
|
'cursor-keyboard-hide-timeout': 200,
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: actions.Actions({
|
actions: actions.Actions({
|
||||||
@ -1665,7 +1668,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
.off('mousemove', this.__cursor_show_handler)
|
.off('mousemove', this.__cursor_show_handler)
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
toggleAutoHideCursor: ['Interface/Cursor auto hiding',
|
toggleAutoHideCursor: ['Interface/Cursor auto-hide',
|
||||||
toggler.CSSClassToggler(
|
toggler.CSSClassToggler(
|
||||||
function(){ return this.ribbons.viewer },
|
function(){ return this.ribbons.viewer },
|
||||||
'cursor-autohide',
|
'cursor-autohide',
|
||||||
@ -1680,7 +1683,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
// setup...
|
// setup...
|
||||||
if(state == 'on'){
|
if(state == 'on'){
|
||||||
var timer
|
var m_timer
|
||||||
var timeout =
|
var timeout =
|
||||||
that.toggleAutoHideCursorTimeout('?') == 'on' ?
|
that.toggleAutoHideCursorTimeout('?') == 'on' ?
|
||||||
(that.config['cursor-autohide-timeout'] || 1000)
|
(that.config['cursor-autohide-timeout'] || 1000)
|
||||||
@ -1691,7 +1694,9 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
= this.__cursor_autohide_mouse_handler
|
= this.__cursor_autohide_mouse_handler
|
||||||
= (this.__cursor_autohide_mouse_handler
|
= (this.__cursor_autohide_mouse_handler
|
||||||
|| function(){
|
|| function(){
|
||||||
timer && clearTimeout(timer)
|
m_timer && clearTimeout(m_timer)
|
||||||
|
kb_timer && clearTimeout(kb_timer)
|
||||||
|
kb_timer = null
|
||||||
|
|
||||||
// hide on timeout...
|
// hide on timeout...
|
||||||
var timeout =
|
var timeout =
|
||||||
@ -1699,7 +1704,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
(that.config['cursor-autohide-timeout'] || 1000)
|
(that.config['cursor-autohide-timeout'] || 1000)
|
||||||
: -1
|
: -1
|
||||||
if(timeout && timeout > 0){
|
if(timeout && timeout > 0){
|
||||||
timer = setTimeout(function(){
|
m_timer = setTimeout(function(){
|
||||||
var viewer = that.ribbons.viewer
|
var viewer = that.ribbons.viewer
|
||||||
|
|
||||||
// auto-hide is off -- restore...
|
// auto-hide is off -- restore...
|
||||||
@ -1708,38 +1713,43 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
timer && that.toggleHiddenCursor('on')
|
m_timer && that.toggleHiddenCursor('on')
|
||||||
}, timeout)
|
}, timeout)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// hide on key...
|
// hide on key...
|
||||||
// XXX should be usable with mouse, e.g. don't
|
var kb_timer
|
||||||
// hide cursor while moving mous with shift
|
|
||||||
// pressed...
|
|
||||||
var key_handler
|
var key_handler
|
||||||
= this.__cursor_autohide_key_handler
|
= this.__cursor_autohide_key_handler
|
||||||
= (this.__cursor_autohide_key_handler
|
= (this.__cursor_autohide_key_handler
|
||||||
|| function(evt){
|
|| function(evt){
|
||||||
var viewer = that.ribbons.viewer
|
// prevent creating more than one timer at a time...
|
||||||
|
if(kb_timer){
|
||||||
// get key...
|
return true
|
||||||
var key = keyboard.normalizeKey(
|
|
||||||
keyboard.event2key(evt))
|
|
||||||
.join('+')
|
|
||||||
|
|
||||||
// auto-hide is off -- restore...
|
|
||||||
if(!viewer.hasClass('cursor-autohide')){
|
|
||||||
that.toggleHiddenCursor('off')
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
// avoid this from delaying the keyboard handler...
|
||||||
|
kb_timer = setTimeout(function(){
|
||||||
|
kb_timer = null
|
||||||
|
var viewer = that.ribbons.viewer
|
||||||
|
|
||||||
// hide if mode is on and non-ignored key...
|
// get key...
|
||||||
(that.config['cursor-autohide-ignore-keys']
|
var key = keyboard.normalizeKey(
|
||||||
|| []).indexOf(key) < 0
|
keyboard.event2key(evt))
|
||||||
&& that.toggleAutoHideCursorKeyboard('?') == 'on'
|
.join('+')
|
||||||
&& that.toggleHiddenCursor('on')
|
|
||||||
|
|
||||||
|
// auto-hide is off -- restore...
|
||||||
|
if(!viewer.hasClass('cursor-autohide')){
|
||||||
|
that.toggleHiddenCursor('off')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide if mode is on and non-ignored key...
|
||||||
|
(that.config['cursor-autohide-ignore-keys']
|
||||||
|
|| []).indexOf(key) < 0
|
||||||
|
&& that.toggleAutoHideCursorKeyboard('?') == 'on'
|
||||||
|
&& that.toggleHiddenCursor('on')
|
||||||
|
}, that.config['cursor-keyboard-hide-timeout'] || 15)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1772,6 +1782,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
|||||||
this.toggleHiddenCursor('off')
|
this.toggleHiddenCursor('off')
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
|
||||||
toggleAutoHideCursorTimeout: ['Interface/Hide cursor on timeout',
|
toggleAutoHideCursorTimeout: ['Interface/Hide cursor on timeout',
|
||||||
core.makeConfigToggler('cursor-autohide-on-timeout',
|
core.makeConfigToggler('cursor-autohide-on-timeout',
|
||||||
['on', 'off'],
|
['on', 'off'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user