jahnf / Projecteur

Linux Desktop Application for the Logitech Spotlight device (and similar devices) - Digital Laser Pointer
MIT License
379 stars 33 forks source link

Zoom Feature #28

Closed jahnf closed 4 years ago

jahnf commented 5 years ago

Implement a zoom feature, similar to the one int the Logitech Windows Application.

jahnf commented 5 years ago

I was so free, to assign this to you @rj-jesus, hope that's okay 😉 - also created a feature-branch for this issue: https://github.com/jahnf/Projecteur/tree/feature/zoom

rj-jesus commented 5 years ago

I got some free time today to work on this.

Commit 5d0ba9e9110f27d32cfa07010239df43ee3fa679 adds a sample class which kind of behaves as a magnifying glass.

The main program below can be used to test it

#include <QtGui/QApplication>

#include "magnifyingglass.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    MagnifyingGlass mg(nullptr);

    mg.shootScreen();

    mg.show();

    mg.runTimer();

    return a.exec();
}

Essentially the zoom function is implemented by taking a screenshot of the screen and then just showing portions of it zoomed.

The drawback of this approach is that it won't work when zooming videos (I mean, it will work but will show outdated frames), but this is also the behavior of the original software I tested. I'm not too sure there's a simpler alternative which will work with video.

jahnf commented 5 years ago

Very cool, I hope I have time to try it out tonight or tomorrow - and maybe think about where to integrate it best with the rest.

Zooming into a screenshot that might have outdated information is no problem for a presentation tool - I don't think (correct me if I'm wrong) that is something that can be 'resolved' at the Qt abstraction level.

jahnf commented 5 years ago

So now that you got me inspired, I already have a rough idea: Here is my proposal

zoom-magnifier-proposal

What comes to my mind is also:

maehne commented 5 years ago

How about checking out the implementation of KMag or other magnifier tools, which already provide this kind of effect? KDE Plasma also provides a variation of the effect as desktop effect.

rj-jesus commented 5 years ago

@jahnf I like the possibility to activate/deactivate the zooming option and show it in the spotlight view, but I think what's more important is the ability to do so (show the zoom, the spotlight or the laser) directly from the pointer.

The first time I saw this pointer being used the guy would just select the tool he wanted for the given situation and it felt natural. If he wanted to emphasize on a figure, he would use the spotlight. If he wanted to better show the axis of a plot or a small detail, he would activate the zoom. Otherwise he would just use the typical red laser.

In my opinion it would be great if such control could be achieved with the pointer (hopefully in a natural way).

rj-jesus commented 5 years ago

@maehne I think kmag also works with screenshots (see here). They just take them with enough frequency so that it feels like video.

The thing is, they assume their window can be on top of other windows and they simply erase its background. In a presentation tool this is not possible... So either we hide the zoom window temporarily while grabbing the screen or we end up with some sort of feedback effect where we continuously see that portion of the screen more and more zoomed.

jahnf commented 5 years ago

but I think what's more important is the ability to do so (show the zoom, the spotlight or the laser) directly from the pointer. In my opinion it would be great if such control could be achieved with the pointer (hopefully in a natural way).

@rj-jesus That would be great but I would see that as a separate issue from the zoom itself. Probably a key/gesture mapping from the device to functions/options. Currently the keyboard inputs from the device are completely ignored. And once a feature is available and it is possible to switch it on and off - e.g. the zoom it will be easy to assign it to some device key/gesture.

jahnf commented 5 years ago

@rj-jesus looking at your example, I would suggest some kind of MagnifierItem that is derived form QQuickPaintedItem (https://doc.qt.io/qt-5/qquickpainteditem.html) - there you can use QPainter methods. (QtQuick internally creates a texture from it) , you wouldn't necessarly need to do the do calculations on the shape (ellipse, etc..) since that is easier done in QML. The current position to show and the zoom level could be set via QPROPERTIES and of course some method to set the current screen pixmap.

rj-jesus commented 5 years ago

@jahnf I'm not really familiar with Qt but I'm willing to try once I get some free time available.

jahnf commented 5 years ago

@rj-jesus Sure, give it a shot - also you initiated it :) - It's great that you offered to collaborate. For pointers/hints/code review and questions regarding Qt/QtQuick, don't hesitate to ask.

Also [in|at the end] October I want to allocate some time to this project again (getting towards v0.6 : bringing better diagnostics, better documentation, maybe support for other devices (these chinese ones (avatto)) and also probably a zoom feature ? :wink: )

mayanksuman commented 4 years ago

but I think what's more important is the ability to do so (show the zoom, the spotlight or the laser) directly from the pointer. In my opinion it would be great if such control could be achieved with the pointer (hopefully in a natural way).

@rj-jesus That would be great but I would see that as a separate issue from the zoom itself. Probably a key/gesture mapping from the device to functions/options. Currently the keyboard inputs from the device are completely ignored. And once a feature is available and it is possible to switch it on and off - e.g. the zoom it will be easy to assign it to some device key/gesture.

I think in the device the switching/cycling between modes (pointer, spotlight and zoom lens) is done by double tapping the pointer button.

jahnf commented 4 years ago

@rj-jesus I added a zoom feature with a commit to this branch. Works on two different machines I have. But it would be great if you could give it a try before I merge this feature branch to develop.

rj-jesus commented 4 years ago

Yes I can confirm it works here too! Good job.