deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.44k stars 192 forks source link

Request - Add a Laptop mode #278

Open niccolofavari opened 3 years ago

niccolofavari commented 3 years ago

Hello, would it be possible to add a "Laptop mode"? Perhaps something similar to what GameMaker Studio does? Here's an edited excerpt from the manual.

Laptop mode makes it a much better experience when using a touchpad, simplifying the 3 main mouse interactions: Pan, zoom and scroll. It uses two modifier keys to do this: Left Ctrl / Command and Left Alt.

When laptop mode is on, Left Ctrl / Command and Left Alt are "reserved" for mouse interactions like panning the world editor, where Left Ctrl / Command is zoom, Left Alt is scroll and pan. Scrolling in laptop mode should behave just like panning, so it should be intuitive and precise enough so that one does not need to use the scrollbar. When holding these buttons, you simply have to move the mouse - not click nor drag, just move - and that if there is a general shortcut that normally requires the use of the Ctrl / Command or Alt keys, one would use the Right keys of the keyboard instead.

Laptop mode could be turned on/off from the GUI.

deepnight commented 3 years ago

Hi! Nice idea and understand the approach, but all 3 toggle keys are already binded for important edit functions: rectangle actions, flood-filling and selection/copy.

Most laptops nowadays handle multi-touch on trackpad pretty well. From my tests (on Surface and Asus laptops), zooming works fine with 2-fingers vertical swipes and 2-fingers pinches (depends on how the trackpad handles this move).

I think it should be possible to also support 2-fingers to pan the view 🤔

Does multi-touch works on yours?

niccolofavari commented 3 years ago

I understand those keys are already taken but, for example, GameMaker solves this by making a distinction between left/right ctrl/command/alt. Would it be feasible?

Also the Laptop mode could be simply turned off by clicking a GUI menu button, allowing normal usage of the modifier keys, and then back on again to pan. I think panning is the real deal here as zoom already works (but the laptop mode zoom is usually more precise due to how touchpad drivers handle the two finger scrolling in windows).

To answer your question, my touchpad should support multiple touches (up to three, I think). But as of now I'm unable to scroll/pan in the editor, unless I zoom out/in moving the pointer around to recenter the pivot point of the zoom.

It would be way easier to just press alt and move the mouse. Or at least make a pan tool like in some graphic editor? Those with a hand icon... Some tool use the spacebar to pan...

Though, personally, I'd prefer a proper laptop mode with an easy on/off switch in the gui. Pressing Ctrl/alt and then just moving the pointer is very precise.

Thank you, Cheers!

niccolofavari commented 3 years ago

Hey Sébastien, have you given some thoughts to this? Specifically the part where it says "if there is a general shortcut that normally requires the use of the Ctrl / Command or Alt keys, one would use the Right keys of the keyboard instead."

deepnight commented 2 years ago

I'm a bit late on this one, but in 0.10 update, you'll be able to:

niccolofavari commented 2 years ago

This is good news. Thank you

deepnight commented 2 years ago

After some research, it seems like trackpad gestures support is kind of hacky nowadays. Not sure I'll be able to support 2-fingers panning 🤔

I was able to push some sort of better support for trackpad Pinch gesture (to zoom in/out), but this will probably need some testing on various platforms.

niccolofavari commented 2 years ago

I reiterate the idea of using a special key for panning and a special key for zooming, with no mouse clicks at all. I don't want to sound annoying but to me it looks like the best option.

The free GameMaker version has a very intuitive laptop mode; you could take a look at it. Those keys CAN be used for other things; one could briefly disable laptop mode from the toolbar, or use the right ctrl/alt instead of the left ones.

No need to left or right click. Just press a key and move the pointer. No pinch, no swipes. It truly is effortless (from a user perspective)

Geokureli commented 1 year ago

Most laptops nowadays handle multi-touch on trackpad pretty well. From my tests (on Surface and Asus laptops), zooming works fine with 2-fingers vertical swipes and 2-fingers pinches (depends on how the trackpad handles this move).

I think it should be possible to also support 2-fingers to pan the view 🤔

Does multi-touch works on yours?

Would like to add that 2-finger vertical drag to zoom work on both my macbook and lenovo touchpads, but my preferred setup - which I see on most programs I use - is that 2-finger drags should scroll/pan, and pinching (and whatever the reverse of pinching is) should control zoom. I can make this a separate issue if needed, but it seemed relevant, here

zommerfelds commented 1 year ago

@Geokureli in my experience 2-finger drags do the same as scrolling, which in most software I just tested on Windows is zooming. Maybe this is a Mac thing?

My 2 cents about this issue is that I would much prefer if spacebar would pan without having to push down the mouse (double tap). I think Gimp does this, but I'm not sure. Most computer setups probably have a way to execute a scroll, be it with a mouse or a touchpad, so IMO the space+right click seems unecessary. But the way deepnight implemented seems to be standard in many software tools, so I guess that's fine.

Geokureli commented 1 year ago

maybe there should be a setting? I pan far more than I zoom, therefore requiring both hands to pan seems odd to me. Though tbh, since nearly all trackpads have pinch to zoom, now, apps using 2 finger drag to scroll always seem like they just didnt think about trackpads to begin with

hk0i commented 10 months ago

Not sure if related or already answered somewhere else, but there's no way to "right click" on Mac OS with the trackpad.

Default right click on track pad is a single double finger tap/click, but the old-school way is ctrl clicking... is there a way to implement a ctrl-click and drag to allow us to drag with the touchpad also? -- Ctrl click and drag doesn't seem to be doing anything right now.

Or maybe add a proper erase/brush set of tools to handle this?

Edit: Or a button to hold down to enable erase mode, it could be any arbitrary letter key, since it's possible to click and drag easily by pressing trackpad or using a 3 finger gesture.

Geokureli commented 10 months ago

Not sure if related or already answered somewhere else, but there's no way to "right click" on Mac OS with the trackpad.

Default right click on track pad is a single double finger tap/click, but the old-school way is ctrl clicking

I'm confused as these comments are conflicting to me, two-finger click IS right click, just as control+Click is, and LDtk has no issue supporting both of these, compared to a mouse with a right click button

is there a way to implement a ctrl-click and drag to allow us to drag with the touchpad also? -- Ctrl click and drag doesn't seem to be doing anything right now.

Do you mean ctrl+click and drag to pan the camera? because space does this already.

Or maybe add a proper erase/brush set of tools to handle this? Edit: Or a button to hold down to enable erase mode, it could be any arbitrary letter key, since it's possible to click and drag easily by pressing trackpad or using a 3 finger gesture.

This all seems unrelated to this particular issue, if I understand correctly

hk0i commented 10 months ago

Thank you for your patience it was very late and I wasn't so detailed in my original explanation 🙏

Background

Mac trackpads only have a single button for left click only. Technically newer models have 0 physical buttons, but pressing down still acts as a left click

Main Problem:

On a Mac trackpad:

  1. How can I right click and move the mouse to continually erase tiles?
  2. How can I right click and drag to erase rectangles of tiles?

Do you mean ctrl+click and drag to pan the camera? because space does this already.

I mean there's no way to hold down the right mouse button and move the cursor at the same time on a Mac trackpad. You can tap one tile at a time to erase, but you can't "paint" with the erase tool, you have to release the mouse button between each press and tap each tile individually.

There's also no way to drag out a rectangle with the erase tool for the same reason.

If I press ctrl + shift + right click (attempt to simulate right click + mouse move) I can paint bucket erase a region, but if I ctrl + shift and drag left mouse button it just draws instead of erasing.

Drawing tiles is easy because left click + drag on the trackpad is supported natively by Mac OS, but there is no right-click and drag gesture on the mouse pad to activate and right button + mouse move functionality:

Demo

erase

  1. First I draw an L shape
  2. I try to erase the L shape by holding down ctrl and dragging (trying to simulate right click + mouse move)
  3. I use the right button gesture to tap 1 tile at a time
  4. I demonstrate bucket erasing two times, using shift + ctrl + click (works perfectly)
  5. I draw out a rectangular region
  6. I try to erase a rectangular region (shift + ctrl + drag), but it draws new tiles instead of erasing tiles

Mac OS workaround

After searching a bit more I found there's currently a way in Mac OS to map the lower right region of the trackpad to a right click in Mac settings but it's very uncomfortable and difficult to use since it requires two hands on the trackpad - one to press the lower right region of the trackpad, and the other hand to move the cursor. It also disables the two finger tap to click, which I prefer not to disable if possible (this is how I normally right click)

image

Edit

On second glance, it looks like ctrl + left clicking on a single tile doesn't activate the right click erase functionality, so this may be the root cause of why ctrl + click + drag doesn't work?

Geokureli commented 10 months ago

Mac's Control+Click works as a right click on hud items, for instance it shows the context menu on layers, but not inside levels or anything involving tiles:

  • First I draw an L shape
  • I try to erase the L shape by holding down ctrl and dragging (trying to simulate right click + mouse move)
  • I use the right button gesture to tap 1 tile at a time
  • I demonstrate bucket erasing two times, using shift + ctrl + click (works perfectly)
  • I draw out a rectangular region
  • I try to erase a rectangular region (shift + ctrl + drag), but it draws new tiles instead of erasing tiles

I can do all of the above with two-finger clicks, but not with control-clicks, I notice that when I press command or control in the level the same thing happens, the level resize anchors (the dots on the corners and edges) disappear, and as you mention above:

On second glance, it looks like ctrl + left clicking on a single tile doesn't activate the right click erase functionality, so this may be the root cause of why ctrl + click + drag doesn't work?

My guess is that the program is specifically looking for the Mac Control or Command presses to perform the functions of the windows ctrl modifier key, and is preventing the system behavior of the control key, which is to right click. My suggestion is that it should only check the Command key on Mac, and leave Control alone, as this key is almost always meant to serve system-level functions rather than application-level functions (Side note, I see that Control+Right/Left arrow still works as expected)

I typically never use control click in light of two finger click/drags, which is why I never had issues with right click in general, I also still think this is a separate issue entirely and deserves it's own page. The point of this issue is that two-finger scrolls should pan, rather than zoom, since pinch/stretch already allows us to zoom in LDtk on macbook trackpad and most of my windows trackpads too. I also should point out mac's two-finger scroll is different from two-finger right-click drag, as a scroll does not involve clicking the trackpad before dragging. The trackpad on my Asus laptop running windows 11 behaves the exact same way in this regard, and I believe this is becoming a standard

To summarize, I'd like it if LDtk detected whether input was coming from a trackpad, and if so, detected horizontal/vertical scroll for panning rather than zooming or at least added a control option to toggle this behavior. I'll make a new issue for @hk0i 's issue with the control key