| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura_shell/launcher/launcher_view.h" | 5 #include "ui/aura_shell/launcher/launcher_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/aura_shell/launcher/launcher_model.h" | 9 #include "ui/aura_shell/launcher/launcher_model.h" |
| 10 #include "ui/aura_shell/launcher/tabbed_launcher_button.h" | 10 #include "ui/aura_shell/launcher/tabbed_launcher_button.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 Resize(); | 116 Resize(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void LauncherView::LauncherItemRemoved(int index) { | 119 void LauncherView::LauncherItemRemoved(int index) { |
| 120 // TODO: to support animations is going to require coordinate conversions. | 120 // TODO: to support animations is going to require coordinate conversions. |
| 121 RemoveChildView(child_at(index + 1)); | 121 RemoveChildView(child_at(index + 1)); |
| 122 Resize(); | 122 Resize(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void LauncherView::LauncherItemImagesChanged(int index) { | 125 void LauncherView::LauncherItemImagesChanged(int index) { |
| 126 // TODO: implement me. | 126 // TODO: implement better coordinate conversion. |
| 127 const LauncherItem& item(model_->items()[index]); |
| 128 if (item.type == TYPE_TABBED) { |
| 129 TabbedLauncherButton* button = |
| 130 static_cast<TabbedLauncherButton*>(child_at(index + 1)); |
| 131 gfx::Size pref = button->GetPreferredSize(); |
| 132 button->SetImages(item.tab_images); |
| 133 if (pref != button->GetPreferredSize()) |
| 134 Resize(); |
| 135 else |
| 136 button->SchedulePaint(); |
| 137 } |
| 127 } | 138 } |
| 128 | 139 |
| 129 void LauncherView::ButtonPressed(views::Button* sender, | 140 void LauncherView::ButtonPressed(views::Button* sender, |
| 130 const views::Event& event) { | 141 const views::Event& event) { |
| 131 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 142 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 132 if (!delegate) | 143 if (!delegate) |
| 133 return; | 144 return; |
| 134 if (sender == new_browser_button_) { | 145 if (sender == new_browser_button_) { |
| 135 delegate->CreateNewWindow(); | 146 delegate->CreateNewWindow(); |
| 136 } else if (sender == show_apps_button_) { | 147 } else if (sender == show_apps_button_) { |
| 137 delegate->ShowApps(); | 148 delegate->ShowApps(); |
| 138 } else { | 149 } else { |
| 139 int index = GetIndexOf(sender); | 150 int index = GetIndexOf(sender); |
| 140 DCHECK_NE(-1, index); | 151 DCHECK_NE(-1, index); |
| 141 // TODO: animations will require coordinate transforms. | 152 // TODO: animations will require coordinate transforms. |
| 142 delegate->LauncherItemClicked(model_->items()[index - 1]); | 153 delegate->LauncherItemClicked(model_->items()[index - 1]); |
| 143 } | 154 } |
| 144 } | 155 } |
| 145 | 156 |
| 146 } // namespace internal | 157 } // namespace internal |
| 147 } // namespace aura_shell | 158 } // namespace aura_shell |
| OLD | NEW |