| 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/common/system/tray/tray_item_more.h" | 5 #include "ash/common/system/tray/tray_item_more.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/fixed_sized_image_view.h" | 7 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 8 #include "ash/common/system/tray/system_tray_item.h" | 8 #include "ash/common/system/tray/system_tray_item.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "grit/ash_resources.h" | 10 #include "grit/ash_resources.h" |
| 11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
| 14 #include "ui/views/controls/image_view.h" | 14 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 16 #include "ui/views/layout/box_layout.h" | 16 #include "ui/views/layout/box_layout.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) | 20 TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) |
| 21 : owner_(owner), | 21 : owner_(owner), |
| 22 show_more_(show_more), | 22 show_more_(show_more), |
| 23 icon_(NULL), | 23 icon_(NULL), |
| 24 label_(NULL), | 24 label_(NULL), |
| 25 more_(NULL) { | 25 more_(NULL) { |
| 26 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 26 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 27 kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems)); | 27 kTrayPopupPaddingHorizontal, 0, |
| 28 kTrayPopupPaddingBetweenItems)); |
| 28 | 29 |
| 29 icon_ = new FixedSizedImageView(0, kTrayPopupItemHeight); | 30 icon_ = new FixedSizedImageView(0, kTrayPopupItemHeight); |
| 30 AddChildView(icon_); | 31 AddChildView(icon_); |
| 31 | 32 |
| 32 label_ = new views::Label; | 33 label_ = new views::Label; |
| 33 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 34 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 34 AddChildView(label_); | 35 AddChildView(label_); |
| 35 | 36 |
| 36 if (show_more) { | 37 if (show_more) { |
| 37 more_ = new views::ImageView; | 38 more_ = new views::ImageView; |
| 38 more_->EnableCanvasFlippingForRTLUI(true); | 39 more_->EnableCanvasFlippingForRTLUI(true); |
| 39 more_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 40 more_->SetImage(ui::ResourceBundle::GetSharedInstance() |
| 40 IDR_AURA_UBER_TRAY_MORE).ToImageSkia()); | 41 .GetImageNamed(IDR_AURA_UBER_TRAY_MORE) |
| 42 .ToImageSkia()); |
| 41 AddChildView(more_); | 43 AddChildView(more_); |
| 42 } | 44 } |
| 43 } | 45 } |
| 44 | 46 |
| 45 TrayItemMore::~TrayItemMore() { | 47 TrayItemMore::~TrayItemMore() {} |
| 46 } | |
| 47 | 48 |
| 48 void TrayItemMore::SetLabel(const base::string16& label) { | 49 void TrayItemMore::SetLabel(const base::string16& label) { |
| 49 label_->SetText(label); | 50 label_->SetText(label); |
| 50 Layout(); | 51 Layout(); |
| 51 SchedulePaint(); | 52 SchedulePaint(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void TrayItemMore::SetImage(const gfx::ImageSkia* image_skia) { | 55 void TrayItemMore::SetImage(const gfx::ImageSkia* image_skia) { |
| 55 icon_->SetImage(image_skia); | 56 icon_->SetImage(image_skia); |
| 56 SchedulePaint(); | 57 SchedulePaint(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 | 100 |
| 100 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { | 101 void TrayItemMore::GetAccessibleState(ui::AXViewState* state) { |
| 101 ActionableView::GetAccessibleState(state); | 102 ActionableView::GetAccessibleState(state); |
| 102 if (!accessible_name_.empty()) | 103 if (!accessible_name_.empty()) |
| 103 state->name = accessible_name_; | 104 state->name = accessible_name_; |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace ash | 107 } // namespace ash |
| OLD | NEW |