~townsend/unity/fix-dash-page-up-down

« back to all changes in this revision

Viewing changes to src/Launcher.cpp

  • Committer: Neil Jagdish Patel
  • Date: 2010-11-09 18:26:09 UTC
  • mfrom: (572.1.33 unity)
  • mto: (572.1.56 unity-3.0)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: neil.patel@canonical.com-20101109182609-dqu51lkgrn6ifd02
[merge] trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
        _anim_handle = g_timeout_add (1000 / 60 - 1, &Launcher::AnimationTimeout, this);
291
291
}
292
292
 
 
293
bool Launcher::IconNeedsAnimation (LauncherIcon *icon, struct timeval current)
 
294
{
 
295
    struct timeval enter_time = icon->ShowTime ();
 
296
    if (TimeDelta (&current, &enter_time) < ANIM_DURATION_SHORT)
 
297
        return true;
 
298
    
 
299
    struct timeval hide_time = icon->HideTime ();
 
300
    if (TimeDelta (&current, &hide_time) < ANIM_DURATION_SHORT)
 
301
        return true;
 
302
    
 
303
    struct timeval running_time = icon->RunningTime ();
 
304
    if (TimeDelta (&current, &running_time) < ANIM_DURATION_SHORT)
 
305
        return true;
 
306
    
 
307
    if (icon->Urgent ())
 
308
    {
 
309
        struct timeval urgent_time = icon->UrgentTime ();
 
310
        if (TimeDelta (&current, &urgent_time) < (ANIM_DURATION_LONG * 4))
 
311
            return true;
 
312
    }
 
313
    
 
314
    return false;
 
315
}
 
316
 
293
317
bool Launcher::AnimationInProgress ()
294
318
{
295
319
    // performance here can be improved by caching the longer remaining animation found and short circuiting to that each time
317
341
    // animations happening on specific icons
318
342
    LauncherModel::iterator it;
319
343
    for (it = _model->begin  (); it != _model->end (); it++)
320
 
    {
321
 
        struct timeval enter_time = (*it)->ShowTime ();
322
 
        if (TimeDelta (&current, &enter_time) < ANIM_DURATION_SHORT)
323
 
            return true;
324
 
        
325
 
        struct timeval hide_time = (*it)->HideTime ();
326
 
        if (TimeDelta (&current, &hide_time) < ANIM_DURATION_SHORT)
327
 
            return true;
328
 
        
329
 
        struct timeval running_time = (*it)->RunningTime ();
330
 
        if (TimeDelta (&current, &running_time) < ANIM_DURATION_SHORT)
331
 
            return true;
332
 
    }
 
344
        if (IconNeedsAnimation (*it, current))
 
345
            return true;
333
346
    
334
347
    return false;
335
348
}
477
490
        if (icon->Running ())
478
491
        {
479
492
          arg.backlight_intensity = running_progress * BACKLIGHT_STRENGTH;
 
493
          
 
494
          if (icon->Urgent ())
 
495
          {
 
496
              struct timeval urgent_time = icon->UrgentTime ();
 
497
              int urgent_ms = TimeDelta (&current, &urgent_time);
 
498
              double urgent_progress = (double) MIN (1.0f, (float) urgent_ms / (float) (ANIM_DURATION_LONG * 4));
 
499
              
 
500
              arg.backlight_intensity *= 0.5f + (float) (std::cos (M_PI * 4.0f * urgent_progress)) * 0.5f;
 
501
          }
480
502
        }
481
503
        else
482
504
        {