OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include "ash/launcher/launcher_button.h" | 7 #include "ash/launcher/launcher_button.h" |
8 #include "ash/launcher/launcher_delegate.h" | 8 #include "ash/launcher/launcher_delegate.h" |
9 #include "ash/launcher/launcher_model.h" | 9 #include "ash/launcher/launcher_model.h" |
10 #include "ash/launcher/launcher_window_cycler.h" | 10 #include "ash/launcher/launcher_window_cycler.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 views::CustomButton::BS_PUSHED, | 253 views::CustomButton::BS_PUSHED, |
254 rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW_PUSHED).ToSkBitmap()); | 254 rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW_PUSHED).ToSkBitmap()); |
255 overflow_button_->SetAccessibleName( | 255 overflow_button_->SetAccessibleName( |
256 l10n_util::GetStringUTF16(IDS_AURA_LAUNCHER_OVERFLOW_NAME)); | 256 l10n_util::GetStringUTF16(IDS_AURA_LAUNCHER_OVERFLOW_NAME)); |
257 ConfigureChildView(overflow_button_); | 257 ConfigureChildView(overflow_button_); |
258 AddChildView(overflow_button_); | 258 AddChildView(overflow_button_); |
259 | 259 |
260 // We'll layout when our bounds change. | 260 // We'll layout when our bounds change. |
261 } | 261 } |
262 | 262 |
| 263 gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { |
| 264 int index = model_->ItemIndexByID(id); |
| 265 if (index == -1 || !view_model_->view_at(index)->visible()) |
| 266 return gfx::Rect(); |
| 267 const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index)); |
| 268 DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type); |
| 269 LauncherButton* button = |
| 270 static_cast<LauncherButton*>(view_model_->view_at(index)); |
| 271 gfx::Rect icon_bounds = button->GetIconBounds(); |
| 272 return gfx::Rect(ideal_bounds.x() + icon_bounds.x(), |
| 273 ideal_bounds.y() + icon_bounds.y(), |
| 274 icon_bounds.width(), icon_bounds.height()); |
| 275 } |
| 276 |
263 void LauncherView::LayoutToIdealBounds() { | 277 void LauncherView::LayoutToIdealBounds() { |
264 IdealBounds ideal_bounds; | 278 IdealBounds ideal_bounds; |
265 CalculateIdealBounds(&ideal_bounds); | 279 CalculateIdealBounds(&ideal_bounds); |
266 ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); | 280 ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); |
267 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); | 281 overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); |
268 } | 282 } |
269 | 283 |
270 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { | 284 void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { |
271 int available_width = width(); | 285 int available_width = width(); |
272 if (!available_width) | 286 if (!available_width) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 // code. | 744 // code. |
731 if (launcher_menu_runner_->RunMenuAt( | 745 if (launcher_menu_runner_->RunMenuAt( |
732 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 746 source->GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
733 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) | 747 views::MenuItemView::TOPLEFT, 0) == views::MenuRunner::MENU_DELETED) |
734 return; | 748 return; |
735 #endif | 749 #endif |
736 } | 750 } |
737 | 751 |
738 } // namespace internal | 752 } // namespace internal |
739 } // namespace ash | 753 } // namespace ash |
OLD | NEW |