mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00: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',
|
||||
'url-history',
|
||||
],
|
||||
suggested: [
|
||||
'ui-url-history-browsable',
|
||||
],
|
||||
|
||||
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 })
|
||||
|
||||
@ -382,7 +382,8 @@ module.GLOBAL_KEYBOARD2 = {
|
||||
'?': '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({
|
||||
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
|
||||
// is bound...
|
||||
//
|
||||
@ -415,13 +409,22 @@ var KeyboardActions = actions.Actions({
|
||||
// NOTE: the target element must be focusable...
|
||||
'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...
|
||||
//
|
||||
// NOTE: if updated the keyboard handler will need to be restarted
|
||||
// for changes to take effect.
|
||||
// XXX EXPERIMENTAL
|
||||
'keyboard-key-pressed-action': false,
|
||||
'keyboard-key-pressed-action': 'off',
|
||||
},
|
||||
|
||||
get keybindings(){
|
||||
@ -429,6 +432,8 @@ var KeyboardActions = actions.Actions({
|
||||
get keyboard(){
|
||||
return this.__keyboard_object },
|
||||
|
||||
|
||||
// Self-test action...
|
||||
testKeyboardDoc: ['- Interface/',
|
||||
{self_test: true},
|
||||
function(){
|
||||
@ -467,6 +472,9 @@ var KeyboardActions = actions.Actions({
|
||||
})
|
||||
}],
|
||||
|
||||
|
||||
// Key bindings ---------------------------------------------------
|
||||
|
||||
// XXX need a clean deep copy to restore...
|
||||
resetKeyBindings: ['Interface/Restore default key bindings',
|
||||
function(){
|
||||
@ -554,11 +562,7 @@ var KeyboardActions = actions.Actions({
|
||||
}],
|
||||
|
||||
|
||||
// keyboard handling...
|
||||
|
||||
pauseKeyboardRepeat: ['- Interface/',
|
||||
function(){
|
||||
this.__keyboard_repeat_paused = true }],
|
||||
// keyboard handling ----------------------------------------------
|
||||
|
||||
toggleKeyboardHandling: ['- Interface/Keyboard handling',
|
||||
toggler.Toggler(null, function(_, state){
|
||||
@ -589,11 +593,11 @@ var KeyboardActions = actions.Actions({
|
||||
// pass keys pressed to .keyPressed(..) action...
|
||||
// XXX EXPERIMENTAL...
|
||||
var keyPressdCall = function(handler){
|
||||
return that.config['keyboard-key-pressed-action'] ?
|
||||
return that.config['keyboard-key-pressed-action'] == 'on' ?
|
||||
function(evt){
|
||||
var e = that.keyPressed.pre(
|
||||
that,
|
||||
[keyboard.joinKey(keyboard.event2key(evt))])
|
||||
[evt, keyboard.joinKey(keyboard.event2key(evt))])
|
||||
|
||||
var res = handler.apply(that, arguments)
|
||||
e.result = res
|
||||
@ -668,9 +672,29 @@ var KeyboardActions = actions.Actions({
|
||||
},
|
||||
['on', 'off'])],
|
||||
|
||||
// NOTE: at this point this is disabled by default, set
|
||||
// .config['keyboard-key-pressed-action'] to true and restart
|
||||
// the handler via .toggleKeyboardHandling('!') for this to work
|
||||
// Drop keys until non are pressed for a timeout...
|
||||
//
|
||||
// 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...
|
||||
// ...not working yet...
|
||||
// XXX not sure if we need this...
|
||||
@ -679,15 +703,19 @@ var KeyboardActions = actions.Actions({
|
||||
// if overdone this can be a mess...
|
||||
keyPressed: ['- Interface/Key pressed event',
|
||||
'This is called by the keyboard handler when a key is pressed, '
|
||||
+'the key is passed as argument.',
|
||||
core.notUserCallable(function(key){
|
||||
+'the actual event and key are passed as argument.',
|
||||
core.notUserCallable(function(evt, key){
|
||||
// This is the keyboard hook protocol root function
|
||||
//
|
||||
// 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:
|
||||
// [ mode ]
|
||||
|
||||
@ -52,22 +52,15 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
||||
'ui',
|
||||
'keyboard',
|
||||
|
||||
//'ui-ribbons-placement',
|
||||
|
||||
// features...
|
||||
'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-partial-ribbons',
|
||||
|
||||
// XXX
|
||||
//'ui-keyboard-control',
|
||||
//'ui-direct-control',
|
||||
//'ui-indirect-control',
|
||||
|
||||
'marks',
|
||||
'ui-range',
|
||||
|
||||
|
||||
@ -330,7 +330,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|
||||
],
|
||||
suggested: [
|
||||
'ui-single-image-local-storage',
|
||||
'ui-single-image-autohide-cursor',
|
||||
'ui-single-image-cursor',
|
||||
],
|
||||
|
||||
actions: SingleImageActions,
|
||||
@ -507,14 +507,14 @@ module.SingleImageViewLocalStorage = core.ImageGridFeatures.Feature({
|
||||
// NOTE: chrome 49 + devtools open appears to prevent the cursor from being hidden...
|
||||
//
|
||||
// XXX hiding cursor on navigation for some reason does not work...
|
||||
var SingleImageAutoHideCursor =
|
||||
module.SingleImageAutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
var SingleImageCursor =
|
||||
module.SingleImageCursor = core.ImageGridFeatures.Feature({
|
||||
title: '',
|
||||
doc: '',
|
||||
|
||||
tag: 'ui-single-image-autohide-cursor',
|
||||
tag: 'ui-single-image-cursor',
|
||||
depends: [
|
||||
'ui-autohide-cursor',
|
||||
'ui-cursor',
|
||||
'ui-single-image',
|
||||
],
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
* - ui-ribbon-manual-align
|
||||
* - ui-animation
|
||||
* manage UI non-css animations...
|
||||
* - ui-autohide-cursor
|
||||
* - ui-cursor
|
||||
* - ui-control
|
||||
* touch/mouse control mechanics
|
||||
*
|
||||
@ -1593,27 +1593,30 @@ module.ShiftAnimation = core.ImageGridFeatures.Feature({
|
||||
// on will re-enable autohide.
|
||||
// NOTE: chrome 49 + devtools open appears to prevent the cursor from
|
||||
// being hidden...
|
||||
var AutoHideCursor =
|
||||
module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
var Cursor =
|
||||
module.Cursor = core.ImageGridFeatures.Feature({
|
||||
title: '',
|
||||
doc: '',
|
||||
|
||||
tag: 'ui-autohide-cursor',
|
||||
tag: 'ui-cursor',
|
||||
depends: [
|
||||
'ui'
|
||||
],
|
||||
|
||||
config: {
|
||||
'cursor-autohide-ignore-keys': [
|
||||
'shift', 'ctrl', 'alt', 'meta',
|
||||
'shift', 'ctrl', 'alt', 'meta',
|
||||
'F5',
|
||||
],
|
||||
|
||||
'cursor-autohide': 'on',
|
||||
'cursor-autohide-on-timeout': 'off',
|
||||
'cursor-autohide-on-keyboard': 'on',
|
||||
|
||||
'cursor-autohide-timeout': 1000,
|
||||
'cursor-show-threshold': 10,
|
||||
|
||||
'cursor-autohide-timeout': 1000,
|
||||
'cursor-keyboard-hide-timeout': 200,
|
||||
},
|
||||
|
||||
actions: actions.Actions({
|
||||
@ -1665,7 +1668,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
.off('mousemove', this.__cursor_show_handler)
|
||||
}
|
||||
})],
|
||||
toggleAutoHideCursor: ['Interface/Cursor auto hiding',
|
||||
toggleAutoHideCursor: ['Interface/Cursor auto-hide',
|
||||
toggler.CSSClassToggler(
|
||||
function(){ return this.ribbons.viewer },
|
||||
'cursor-autohide',
|
||||
@ -1680,7 +1683,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
|
||||
// setup...
|
||||
if(state == 'on'){
|
||||
var timer
|
||||
var m_timer
|
||||
var timeout =
|
||||
that.toggleAutoHideCursorTimeout('?') == 'on' ?
|
||||
(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
|
||||
|| function(){
|
||||
timer && clearTimeout(timer)
|
||||
m_timer && clearTimeout(m_timer)
|
||||
kb_timer && clearTimeout(kb_timer)
|
||||
kb_timer = null
|
||||
|
||||
// hide on timeout...
|
||||
var timeout =
|
||||
@ -1699,7 +1704,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
(that.config['cursor-autohide-timeout'] || 1000)
|
||||
: -1
|
||||
if(timeout && timeout > 0){
|
||||
timer = setTimeout(function(){
|
||||
m_timer = setTimeout(function(){
|
||||
var viewer = that.ribbons.viewer
|
||||
|
||||
// auto-hide is off -- restore...
|
||||
@ -1708,38 +1713,43 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
return
|
||||
}
|
||||
|
||||
timer && that.toggleHiddenCursor('on')
|
||||
m_timer && that.toggleHiddenCursor('on')
|
||||
}, timeout)
|
||||
}
|
||||
})
|
||||
|
||||
// hide on key...
|
||||
// XXX should be usable with mouse, e.g. don't
|
||||
// hide cursor while moving mous with shift
|
||||
// pressed...
|
||||
var kb_timer
|
||||
var key_handler
|
||||
= this.__cursor_autohide_key_handler
|
||||
= (this.__cursor_autohide_key_handler
|
||||
|| function(evt){
|
||||
var viewer = that.ribbons.viewer
|
||||
|
||||
// get key...
|
||||
var key = keyboard.normalizeKey(
|
||||
keyboard.event2key(evt))
|
||||
.join('+')
|
||||
|
||||
// auto-hide is off -- restore...
|
||||
if(!viewer.hasClass('cursor-autohide')){
|
||||
that.toggleHiddenCursor('off')
|
||||
return
|
||||
// prevent creating more than one timer at a time...
|
||||
if(kb_timer){
|
||||
return true
|
||||
}
|
||||
// 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...
|
||||
(that.config['cursor-autohide-ignore-keys']
|
||||
|| []).indexOf(key) < 0
|
||||
&& that.toggleAutoHideCursorKeyboard('?') == 'on'
|
||||
&& that.toggleHiddenCursor('on')
|
||||
// get key...
|
||||
var key = keyboard.normalizeKey(
|
||||
keyboard.event2key(evt))
|
||||
.join('+')
|
||||
|
||||
// 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
|
||||
})
|
||||
|
||||
@ -1772,6 +1782,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
|
||||
this.toggleHiddenCursor('off')
|
||||
}
|
||||
})],
|
||||
|
||||
toggleAutoHideCursorTimeout: ['Interface/Hide cursor on timeout',
|
||||
core.makeConfigToggler('cursor-autohide-on-timeout',
|
||||
['on', 'off'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user