| 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 "chrome/browser/ui/views/avatar_menu.h" | 5 #include "chrome/browser/ui/views/avatar_menu.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 45 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(ScaledImageButton); | 48 DISALLOW_COPY_AND_ASSIGN(ScaledImageButton); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // A view that displays avatar icons in a grid. | 51 // A view that displays avatar icons in a grid. |
| 52 class AvatarIconGridView : public views::View, public views::ButtonListener { | 52 class AvatarIconGridView : public views::View, public views::ButtonListener { |
| 53 public: | 53 public: |
| 54 AvatarIconGridView(Profile* profile, views::MenuItemView* menu); | 54 AvatarIconGridView(Profile* profile, views::MenuItemView* menu); |
| 55 ~AvatarIconGridView(); | 55 virtual ~AvatarIconGridView(); |
| 56 | 56 |
| 57 virtual void Layout() OVERRIDE; | 57 virtual void Layout() OVERRIDE; |
| 58 virtual gfx::Size GetPreferredSize() OVERRIDE; | 58 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 59 virtual void ButtonPressed(views::Button* sender, | 59 virtual void ButtonPressed(views::Button* sender, |
| 60 const views::Event& event) OVERRIDE; | 60 const views::Event& event) OVERRIDE; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Sets the profile's avatar icon to the icon at the given index. | 63 // Sets the profile's avatar icon to the icon at the given index. |
| 64 void SetAvatarIconToIndex(int icon_index); | 64 void SetAvatarIconToIndex(int icon_index); |
| 65 | 65 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // deleted while we're running we won't prematurely delete the menu. | 190 // deleted while we're running we won't prematurely delete the menu. |
| 191 // TODO(sky): fix this, the menu should really take ownership of the menu | 191 // TODO(sky): fix this, the menu should really take ownership of the menu |
| 192 // (57890). | 192 // (57890). |
| 193 scoped_refptr<AvatarMenu> dont_delete_while_running(this); | 193 scoped_refptr<AvatarMenu> dont_delete_while_running(this); |
| 194 gfx::Point screen_loc; | 194 gfx::Point screen_loc; |
| 195 views::View::ConvertPointToScreen(host, &screen_loc); | 195 views::View::ConvertPointToScreen(host, &screen_loc); |
| 196 gfx::Rect bounds(screen_loc, host->size()); | 196 gfx::Rect bounds(screen_loc, host->size()); |
| 197 root_->RunMenuAt(host->GetWidget()->GetNativeWindow(), host, bounds, | 197 root_->RunMenuAt(host->GetWidget()->GetNativeWindow(), host, bounds, |
| 198 views::MenuItemView::TOPLEFT, true); | 198 views::MenuItemView::TOPLEFT, true); |
| 199 } | 199 } |
| OLD | NEW |