~brandontschaefer/unity/lp.1157329-fix

« back to all changes in this revision

Viewing changes to launcher/LauncherIcon.cpp

  • Committer: Tarmac
  • Author(s): Andrea Azzarone
  • Date: 2013-03-18 20:13:22 UTC
  • mfrom: (3221.3.3 unity)
  • Revision ID: tarmac-20130318201322-abehn0rsvpuyutvf
Add fade animation for launcher tooltips. Fixes: https://bugs.launchpad.net/bugs/1155672.

Approved by PS Jenkins bot, Marco Trevisan (Treviño).

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
const std::string CENTER_STABILIZE_TIMEOUT = "center-stabilize-timeout";
63
63
const std::string PRESENT_TIMEOUT = "present-timeout";
64
64
const std::string QUIRK_DELAY_TIMEOUT = "quirk-delay-timeout";
 
65
 
 
66
const unsigned TOOLTIP_FADE_DURATION = 80;
65
67
}
66
68
 
67
69
NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon);
86
88
  , _parent_geo(max_num_monitors)
87
89
  , _saved_center(max_num_monitors)
88
90
  , _allow_quicklist_to_show(true)
 
91
  , _tooltip_fade_animator(TOOLTIP_FADE_DURATION)
89
92
{
90
93
  for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i)
91
94
  {
115
118
  mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown));
116
119
  mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp));
117
120
  mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick));
 
121
 
 
122
  _tooltip_fade_animator.updated.connect([this] (double opacity) {
 
123
    if (_tooltip)
 
124
    {
 
125
      _tooltip->SetOpacity(opacity);
 
126
 
 
127
      if (opacity == 0.0f && _tooltip_fade_animator.GetStartValue() > _tooltip_fade_animator.GetFinishValue())
 
128
      {
 
129
        _tooltip->ShowWindow(false);
 
130
        _tooltip->SetOpacity(0.0f);
 
131
      }
 
132
    }
 
133
  });
118
134
}
119
135
 
120
136
LauncherIcon::~LauncherIcon()
143
159
void LauncherIcon::LoadTooltip()
144
160
{
145
161
  _tooltip = new Tooltip();
 
162
  _tooltip->SetOpacity(0.0f);
146
163
  AddChild(_tooltip.GetPointer());
147
164
 
148
165
  _tooltip->text = tooltip_text();
522
539
  _tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
523
540
  _tooltip->ShowWindow(!tooltip_text().empty());
524
541
  tooltip_visible.emit(_tooltip);
 
542
 
 
543
  if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running)
 
544
    _tooltip_fade_animator.Reverse();
 
545
  else
 
546
    _tooltip_fade_animator.SetStartValue(0.0f).SetFinishValue(1.0f).Start();
525
547
}
526
548
 
527
549
void
669
691
void LauncherIcon::HideTooltip()
670
692
{
671
693
  if (_tooltip)
672
 
    _tooltip->ShowWindow(false);
 
694
  {
 
695
    if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running)
 
696
      _tooltip_fade_animator.Reverse();
 
697
    else
 
698
      _tooltip_fade_animator.SetStartValue(1.0f).SetFinishValue(0.0f).Start();
 
699
  }
 
700
 
673
701
  tooltip_visible.emit(nux::ObjectPtr<nux::View>(nullptr));
674
702
}
675
703