OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/system/tray/special_popup_row.h" | 5 #include "ash/system/tray/special_popup_row.h" |
6 | 6 |
7 #include "ash/system/tray/hover_highlight_view.h" | 7 #include "ash/system/tray/hover_highlight_view.h" |
8 #include "ash/system/tray/throbber_view.h" | 8 #include "ash/system/tray/throbber_view.h" |
9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
10 #include "ash/system/tray/tray_popup_header_button.h" | 10 #include "ash/system/tray/tray_popup_header_button.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); | 75 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); |
76 SetContent(container); | 76 SetContent(container); |
77 } | 77 } |
78 | 78 |
79 void SpecialPopupRow::SetContent(views::View* view) { | 79 void SpecialPopupRow::SetContent(views::View* view) { |
80 CHECK(!content_); | 80 CHECK(!content_); |
81 content_ = view; | 81 content_ = view; |
82 AddChildViewAt(content_, 0); | 82 AddChildViewAt(content_, 0); |
83 } | 83 } |
84 | 84 |
85 void SpecialPopupRow::AddButton(TrayPopupHeaderButton* button) { | 85 void SpecialPopupRow::AddView(views::View* view, bool add_separator) { |
86 if (!button_container_) { | 86 if (!button_container_) { |
87 button_container_ = CreatePopupHeaderButtonsContainer(); | 87 button_container_ = CreatePopupHeaderButtonsContainer(); |
88 AddChildView(button_container_); | 88 AddChildView(button_container_); |
89 } | 89 } |
90 views::Separator* separator = | 90 if (add_separator) { |
91 new views::Separator(views::Separator::VERTICAL); | 91 views::Separator* separator = |
92 separator->SetColor(ash::kBorderDarkColor); | 92 new views::Separator(views::Separator::VERTICAL); |
93 separator->SetBorder( | 93 separator->SetColor(ash::kBorderDarkColor); |
94 views::Border::CreateEmptyBorder(kSeparatorInset, 0, kSeparatorInset, 0)); | 94 separator->SetBorder(views::Border::CreateEmptyBorder(kSeparatorInset, 0, |
95 button_container_->AddChildView(separator); | 95 kSeparatorInset, 0)); |
96 button_container_->AddChildView(button); | 96 button_container_->AddChildView(separator); |
| 97 } |
| 98 button_container_->AddChildView(view); |
97 } | 99 } |
98 | 100 |
99 void SpecialPopupRow::AddThrobber(ThrobberView* throbber) { | 101 void SpecialPopupRow::AddButton(TrayPopupHeaderButton* button) { |
100 if (!button_container_) { | 102 AddView(button, true /* add_separator */); |
101 button_container_ = CreatePopupHeaderButtonsContainer(); | |
102 AddChildView(button_container_); | |
103 } | |
104 button_container_->AddChildView(throbber); | |
105 } | 103 } |
106 | 104 |
107 gfx::Size SpecialPopupRow::GetPreferredSize() const { | 105 gfx::Size SpecialPopupRow::GetPreferredSize() const { |
108 gfx::Size size = views::View::GetPreferredSize(); | 106 gfx::Size size = views::View::GetPreferredSize(); |
109 size.set_height(kSpecialPopupRowHeight); | 107 size.set_height(kSpecialPopupRowHeight); |
110 return size; | 108 return size; |
111 } | 109 } |
112 | 110 |
113 int SpecialPopupRow::GetHeightForWidth(int width) const { | 111 int SpecialPopupRow::GetHeightForWidth(int width) const { |
114 return kSpecialPopupRowHeight; | 112 return kSpecialPopupRowHeight; |
(...skipping 15 matching lines...) Expand all Loading... |
130 container_bounds.ClampToCenteredSize(bounds.size()); | 128 container_bounds.ClampToCenteredSize(bounds.size()); |
131 container_bounds.set_x(content_bounds.width() - container_bounds.width()); | 129 container_bounds.set_x(content_bounds.width() - container_bounds.width()); |
132 button_container_->SetBoundsRect(container_bounds); | 130 button_container_->SetBoundsRect(container_bounds); |
133 | 131 |
134 bounds = content_->bounds(); | 132 bounds = content_->bounds(); |
135 bounds.set_width(button_container_->x()); | 133 bounds.set_width(button_container_->x()); |
136 content_->SetBoundsRect(bounds); | 134 content_->SetBoundsRect(bounds); |
137 } | 135 } |
138 | 136 |
139 } // namespace ash | 137 } // namespace ash |
OLD | NEW |