-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
positioning.lua: add this script #15314
base: master
Are you sure you want to change the base?
Conversation
Download the artifacts for this pull request: |
2521e31
to
85a3d2a
Compare
Can we add default keybindings for those commands? Else it will become dead code. |
Sure I was trying not to burden the original proposal with breaking changes. What about: Move cycle pause to MBTN_LEFT Unfortunately we can't easily set different default key bindings for images if we're set on deprecating input sections. |
I'm using a touchpad but not sure how exactly I'm supposed to keybind it Ctrl+MBTN_LEFT script-binding drag-to-pan. (this one works) |
85a3d2a
to
f0b043f
Compare
thanks for the help..yes the centric-cursor-zoom works great on touchpad. Thanks for adding these...gonna use mpv as main image viewer on mac. These are great additions. Ctrl+Wheel_Down add video-zoom -0.05 #! [Video/Image] > [Scale] > Zoom Out (scroll down) |
Yeah I know it works on a touchpad, by untested touch input I meant devices like tables which populate the EDIT: I was trying a touchpad on Xorg whose backend doesn't implement touch-pos, it should work on Wayland. |
f0b043f
to
d0b0688
Compare
Updated as nanahi requested in #15316. Also, my point in #15316 (comment) of cursor-centric-zoom not needing multiple amounts was moot since you need a negative amount to zoom out (unless you add different script-bindings to zoom in and out). But unfortunately, beyond the bindings being so long that they get cropped in the stats page, they just don't work, because the script-binding runs before change-list updates the script-opt. So something like |
This should be put off until dragging deadzone is supported on macOS. It wasn't implemented in that PR. |
d0b0688
to
ff5071f
Compare
okay, i will look into it. sry that PR kinda went by me. |
How do you intend to support key bindings with different pan and zoom amounts without making them commands? |
The easiest way would be making fast and slow pan parameters as script options.
The problem is that |
As I just wrote changing script-opts within the binding doesn't work, so we would need 8 script bindings + 2 script-opts just to pan: pan-up, pan-right, pan-down, pan-left, pan-up-slow, pan-right-slow, pan-down-slow, pan-left-slow. And what about when someone wants a 3rd speed? How is this better than 1 command?
Hence the JSON array, you send all user arguments as 1 argument to script message. I already do this in console.lua to send 0 1 or 2 arguments to input.lua, and I can add more arguments whenever is necessary. |
I have added support for custom argument for |
13cdd2c
to
8dcc108
Compare
This works great now by depending on #15316. You can easily fork the script and there is no need to add commands to the core, and other scripts can also benefit from the new scale and arg arguments to script-binding. Once macOS supports the dragging deadzone we can bind drag-to-pan to MBTN_RIGHT by default, but there is no hurry. |
etc/input.conf
Outdated
#Alt+LEFT script-binding positioning/pan-x -0.2 # pan to the right | ||
#Alt+RIGHT script-binding positioning/pan-x 0.2 # pan to the left | ||
#Alt+UP script-binding positioning/pan-y -0.2 # pan down | ||
#Alt+DOWN script-binding positioning/pan-y 0.2 # pan up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be changed? Could we use Ctrl+Alt
modifier for new behavior? Also could update numpad bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, up to you if you want to keep video-pan, I never used it and never understood why you would want to move a video beyond the visible window. But it's probably not worth binding both especially since ctrl+alt+arrows is inconvenient to press. I would like to have different default key bindings for images where they can just be bound to arrows but I'm not sure how that could be done if we don't want to use input sections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think there is no reason to change this when there are spare keys available. Also if scripts are disabled these commands now do nothing which isn't good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctrl+alt+arrows is inconvenient to press
I don't see any difference to alt+arrows
. Can't do that realistically with one hand either.
I would like to have different default key bindings for images where they can just be bound to arrows but I'm not sure how that could be done if we don't want to use input sections.
I was thinking some time ago about this, because lots of key bindings could be different based on image/video context. This is different topic tho.
Also if scripts are disabled these commands now do nothing which isn't good.
This is exactly what I worry too. mpv should be usable without lua backed compiled in, we shouldn't replace core features with script counterpart for important key bindings. Not sure if video-pan-
is important, but I would leave it as-is to avoid this issue. For first-party input config we should prefer native / always available features.
#Ctrl+WHEEL_UP script-binding positioning/cursor-centric-zoom 0.1 # zoom in towards the cursor | ||
#Ctrl+WHEEL_DOWN script-binding positioning/cursor-centric-zoom -0.1 # zoom out towards the cursor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be changed? Could we use Ctrl+Alt modifier for new behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to have cursor-centric-zoom on the wheel? It is more convenient, also according to nanahi ctrl+wheel "makes "pinch to zoom" with touchpads and touchscreens work out of box on Windows, since by default applications receive these key inputs for pinch gesture.", so it needs to be bind to ctrl+wheel to work with pinch gestures by default.
I have no idea what numpad bindings have to do with cursor-centric-zoom, the numpad is not a cursor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to have cursor-centric-zoom on the wheel? It is more convenient, also according to nanahi ctrl+wheel "makes "pinch to zoom" with touchpads and touchscreens work out of box on Windows, since by default applications receive these key inputs for pinch gesture.", so it needs to be bind to ctrl+wheel to work with pinch gestures by default.
Ok, if you think it is more convenient this way. I think it is still valuable to control zoom without messing up video positioning completely on each step. But I guess by default it can be cursor centric.
Note that same issues applies, if lua is disabled in mpv build, it probably should fallback to normal video-zoom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still use the Alt key bindings for that, we didn't even have Ctrl+wheel until recently.
I removed the Alt+Arrow bindings so you do want to implement a fallback system just for this? I guess we can define alternative bindings with some keyword that input.c can recognize?
#Alt+BS set video-zoom 0; set panscan 0; set video-pan-x 0; set video-pan-y 0 # reset zoom and pan settings | ||
#Ctrl+WHEEL_UP script-binding positioning/cursor-centric-zoom 0.1 # zoom in towards the cursor | ||
#Ctrl+WHEEL_DOWN script-binding positioning/cursor-centric-zoom -0.1 # zoom out towards the cursor | ||
#Alt+BS set video-zoom 0; no-osd set panscan 0; no-osd set video-pan-x 0; no-osd set video-pan-y 0; no-osd set video-align-x 0; no-osd set video-align-y 0 # reset zoom and pan settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could update numpad bindings the same way.
@@ -588,6 +588,7 @@ static const m_option_t mp_opts[] = { | |||
OPT_CHOICE(lua_load_auto_profiles, {"no", 0}, {"yes", 1}, {"auto", -1}), | |||
.flags = UPDATE_BUILTIN_SCRIPTS}, | |||
{"load-select", OPT_BOOL(lua_load_select), .flags = UPDATE_BUILTIN_SCRIPTS}, | |||
{"load-positioning", OPT_BOOL(lua_load_positioning), .flags = UPDATE_BUILTIN_SCRIPTS}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used int defualt input.conf, I don't know if it is good to allow unloading this script. But maybe needed in some cases.
EDIT: We should probably merge all those load-
into one string list option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--load options let you use a fork of that script in your scripts directory which was one of the arguments for making this a script. They are also convenient for development without recompiling.
etc/input.conf
Outdated
@@ -31,6 +31,7 @@ | |||
#MBTN_LEFT ignore # don't do anything | |||
#MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen | |||
#MBTN_RIGHT cycle pause # toggle pause/playback mode | |||
#MBTN_MID script-binding positioning/align-to-cursor # pan the whole image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align-to-cursor
should not be bound to mouse by default because I can't reset panning with only mouse. At least add a modifier for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assumption is that #15320 will merged first, so it won't do anything by default until you zoom in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also affects panscan and I think the dragging behavior is annoying for the purpose of panscan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use MBTN_MID_DBL
to reset. I agree though there should be a way to undo the change with mouse only.
Browsers also enter panning mode with middle mouse button, without modifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bound MBTN_MID_DBL
to reset align and pan. When MBNT_RIGHT
will drag-to-pan
I guess can we also bind MBTN_RIGHT_DBL
to reset?
e759b4a
to
67ec8ae
Compare
This script provides script bindings to pan videos and images, making mpv a better image viewer out of the box.
Alt+BS prints "video-pan-y: 0" which seems arbitrary. Make it print video-zoom: 0 which is the most important property that gets reset.
This is useful because positioning.lua uses video-align.
67ec8ae
to
0b629e6
Compare
Probably not worth adding to etc/restore-old-bindings.conf since it's an extension of add video-zoom.
Also bind MBTN_MID_DBL to allow resetting align and pan with the mouse. Once the dragging deadzone is supported on macOS, cycle pause can be moved to MBTN_LEFT and drag-to-pan can be bound to MBTN_RIGHT.
0b629e6
to
1581d81
Compare
This script provides script messages and bindings to pan videos and images, making mpv a better image viewer out of the box.
I've had this script for 3 years in my image config so why not upstream it to view images better out of the box. Credits to occivink for the original ideas of the bindings.
I also have a mouse gesture and a oneshot double page mode in my script but those may not be worth upstreaming.
For the reasoning behind the
suppress_osd
naming, see #9051 (comment)Touch input in
cursor-centric-zoom
is untested.For negative zoom, I think we need a global option like
--auto-recenter-video
(implemented invo_get_src_dst_rects()
?) to reset video-align to 0 when the image is smaller than the OSD, so that it also applies when changing video-zoom/panscan/video-unscaled/video-aspect-override/video-scale/changing file. Then positioning.lua should do nothing when that option is true and the image is smaller than the OSD. In my config, I use