~jjed/unity/tooltips-redux

« back to all changes in this revision

Viewing changes to launcher/TooltipManager.cpp

  • Committer: Jacob Edwards
  • Date: 2013-03-05 18:43:17 UTC
  • Revision ID: jacob_edwards-20130305184317-22063ordvj2d1wb0
Adhere to Unity brace style

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
   , icon_clicked_(false)
37
37
{}
38
38
 
39
 
void TooltipManager::SetIcon(AbstractLauncherIcon::Ptr const& newIcon) { 
 
39
void TooltipManager::SetIcon(AbstractLauncherIcon::Ptr const& newIcon)
 
40
40
41
  if (icon_ == newIcon)
41
42
    return;
42
43
 
43
44
  // Unlock hover timer, in case the previous icon had no valid tooltip
44
45
  icon_clicked_ = false;
45
46
 
46
 
  if (show_tooltips_) {
 
47
  if (show_tooltips_)
 
48
  {
47
49
    // Show new tooltip, get rid of the old olne
48
50
    if (icon_)
49
51
      icon_->HideTooltip();
50
52
    if (newIcon)
51
53
      newIcon->ShowTooltip();
52
54
  }
53
 
  else if (!newIcon) {
 
55
  else if (!newIcon)
 
56
  {
54
57
    // Stop the hover timer for null launcher space
55
58
    StopTimer();
56
59
  }
57
 
  else { 
 
60
  else
 
61
  { 
58
62
    AbstractLauncherIcon::IconType type = newIcon->GetIconType();
59
63
    if ((type == AbstractLauncherIcon::IconType::HOME ||
60
64
         type == AbstractLauncherIcon::IconType::HUD) &&
61
 
         newIcon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)) {
 
65
         newIcon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE))
 
66
    {
62
67
      // Lock the hover timer for no valid tooltip cases
63
68
      icon_clicked_ = true;
64
69
      StopTimer();
68
73
  icon_ = newIcon;
69
74
}
70
75
 
71
 
void TooltipManager::SetHover(bool on_launcher) { 
72
 
  if (hovered_ == on_launcher) {
 
76
void TooltipManager::SetHover(bool on_launcher)
 
77
 
78
  if (hovered_ == on_launcher)
73
79
    return;
74
 
  }
75
80
  hovered_ = on_launcher;
76
81
 
77
 
  if (show_tooltips_ && !hovered_) {
 
82
  if (show_tooltips_ && !hovered_)
 
83
  {
78
84
    show_tooltips_ = false;
79
85
    if (icon_)
80
86
      icon_->HideTooltip();
81
87
  }
82
88
}
83
89
 
84
 
void TooltipManager::MouseMoved() {
 
90
void TooltipManager::MouseMoved()
 
91
{
85
92
  if (!icon_ || show_tooltips_)
86
93
    return;
87
94
 
88
95
  ResetTimer();
89
96
}
90
97
 
91
 
void TooltipManager::IconClicked() {
 
98
void TooltipManager::IconClicked()
 
99
{
92
100
  StopTimer();
93
101
  if (show_tooltips_ && icon_)
94
102
    icon_->HideTooltip();
97
105
  icon_clicked_ = true;
98
106
}
99
107
 
100
 
void TooltipManager::ResetTimer() {
 
108
void TooltipManager::ResetTimer()
 
109
{
101
110
  if (icon_clicked_)
102
111
    return;
103
112
 
109
118
  });
110
119
}
111
120
 
112
 
void TooltipManager::StopTimer() {
 
121
void TooltipManager::StopTimer()
 
122
{
113
123
  hover_timer_.reset();
114
124
}
115
125