This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Bouncing icon equation is wrong, animation doesn't look good

Tags: kwin kwin kwin
(comma "," separated)
alecail
Registered Member
Posts
14
Karma
0
OS
The bouncing icon animation that is displayed near the cursor when an application is starting is just wrong.
This looks like a bad-looking back and forth linear animation with a useless area-conversating, cartoonesque squashing deformation when it hits an imaginary ground.
The correct equation is y= h-k*t*t (free fall equation, t=time, h=initial height, k=some constant), with t mapped between [ -f(h,k), f(h,k)];
Possibly with an exponential decay if you want to make it a bit realistic.
Can you tell me exactly where the computation takes place ?
You can see a correct implementation of this effect in the Mac OS X Dock:
http://www.youtube.com/watch?v=phnpSzjzVzw

Last edited by alecail on Fri Mar 30, 2012 7:04 pm, edited 1 time in total.
alecail
Registered Member
Posts
14
Karma
0
OS
I took the time to implement a proof of concept, as a moving QLabel inside a MainWindow. This uses the Qt Animation Framework:

Code: Select all
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
#include <QAnimationGroup>
#include <QPropertyAnimation>
#include <QEasingCurve>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow){

    ui->setupUi(this);
    QImage * ball = new QImage("/usr/share/pixmaps/amarok.xpm");

    int dim=ball->width();
    int heightRatio=2;

    int width=dim; int height=dim;

    QLabel * lab = new QLabel(this); lab->setObjectName("ball");
    lab->setGeometry(0,0,width,height);
    lab->setPixmap(QPixmap::fromImage(*ball));

    QPropertyAnimation * animation = new QPropertyAnimation(this);
    animation->setStartValue(0); animation->setEndValue(1);
    animation->setEndValue(1000);animation->setDuration(1000);
    animation->setEasingCurve(QEasingCurve::OutBounce);
// good-looking animation thanks to the QEasingCurve::OutBounce

    animation->setTargetObject(lab); animation->setPropertyName("geometry");
    animation->setKeyValueAt(0, QVariant(QRect(0,0,width,height)));
    animation->setKeyValueAt(1, QVariant(QRect(0,heightRatio*height,width,height)));

    animation->setLoopCount(-1); animation->start(); }
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
Cool! Do you think you can record a video of that?

I suggest that you post it somewhere where developers can see it. It would be awesome if you submit a patch to ReviewBoard (Git); I guess the animation is somewhere in workspace but I'm not sure.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
alecail
Registered Member
Posts
14
Karma
0
OS
Hans wrote:Cool! Do you think you can record a video of that?

I suggest that you post it somewhere where developers can see it. It would be awesome if you submit a patch to ReviewBoard (Git); I guess the animation is somewhere in workspace but I'm not sure.


Here is a link to a video I did: http://www.youtube.com/watch?v=fbkaDb_TU4U
I think everything is in the link you gave me; but is this place a good place to post stuffs like I just did ?
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
ReviewBoard is for patches that are to be committed. Since you have a proof of concept, it may be better to contact the developers first and see what they think about it. Not sure where this belongs though, you could try the plasma-devel mailing list and see if their redirect you somewhere else.

Regarding the animation, I personally find the transition from "down" to "up" a bit too fast, which gives it a "choppy" feel. In Mac OS X it looks like the icon "jumps" up when it wants attention if I remember correctly.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
alecail
Registered Member
Posts
14
Karma
0
OS
Hans wrote:ReviewBoard is for patches that are to be committed. Since you have a proof of concept, it may be better to contact the developers first and see what they think about it. Not sure where this belongs though, you could try the plasma-devel mailing list and see if their redirect you somewhere else.

Regarding the animation, I personally find the transition from "down" to "up" a bit too fast, which gives it a "choppy" feel. In Mac OS X it looks like the icon "jumps" up when it wants attention if I remember correctly.


OK, I'm going to subscribe to this mailing list.

Here is a variation of the animation. This one can be played in loop.
http://youtu.be/svGpqqvoPwE
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
alecail wrote:OK, I'm going to subscribe to this mailing list.


Awesome!

Here is a variation of the animation. This one can be played in loop.
http://youtu.be/svGpqqvoPwE


This looks much better, great work. I hope you'll get help to implement it in KDE Workspaces. (Personally I've never been a fan of the bouncing icon and always disable it, but yours looks more "professional" in my opinion.)


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The relevant code in question will be located inside KWin, not sure where however.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
alecail
Registered Member
Posts
14
Karma
0
OS
bcooksley wrote:The relevant code in question will be located inside KWin, not sure where however.


I've found exactly where:
kde-workspace-4.8.1/kwin/effects/startupfeedback/startupfeedback.cpp
Code: Select all
static const int FRAME_TO_BOUNCE_YOFFSET[] = {
    -5, -1, 2, 5, 8, 10, 12, 13, 15, 15, 15, 15, 14, 12, 10, 8, 5, 2, -1, -5
};
static const QSize BOUNCE_SIZES[] = {
    QSize(16, 16), QSize(14, 18), QSize(12, 20), QSize(18, 14), QSize(20, 12)
};
static const int FRAME_TO_BOUNCE_TEXTURE[] = {
    0, 0, 0, 1, 2, 2, 1, 0, 3, 4, 4, 3, 0, 1, 2, 2, 1, 0, 0, 0
};

The FRAME_TO_BOUNCE_YOFFSET[] is in fact physically correct, which means that it respects the free-fall equation.
What makes the animation looks bad is the BOUNCE_SIZES[], which specifies how much the icon is resized, according to the current frame.
I've made a video showing the animation without the squashing effect, and another variation (initial vertical impulse + bounce).

It can be removed here:
Code: Select all
void StartupFeedbackEffect::prepareTextures(const QPixmap& pix)
{
    switch(m_type) {
    case BouncingFeedback:
        for (int i = 0; i < 5; ++i) {
            delete m_bouncingTextures[i];
// prevent the icon from being resized to a bad aspect ratio
// always use the original size
            m_bouncingTextures[i] = new GLTexture(pix);

        }
        break;
    case BlinkingFeedback:
    case PassiveFeedback:
        m_texture = new GLTexture(pix);
        break;
    default:
        // for safety
        m_active = false;
        break;
    }
}

See results at:
http://www.youtube.com/watch?v=tL8MhPun ... e=youtu.be
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
Moved to KWin, hopefully the developers will take a look. :)


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If you have a patch to improve the bouncing code in KWin to look more realistic, I would recommend opening a Review Request against KWin (repository kde-workspace) on git.reviewboard.kde.org.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]