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/chromeos/power/power_status_view.h" | 5 #include "ash/common/system/chromeos/power/power_status_view.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/system/chromeos/power/power_status.h" | 8 #include "ash/common/system/chromeos/power/power_status.h" |
9 #include "ash/common/system/chromeos/power/tray_power.h" | 9 #include "ash/common/system/chromeos/power/tray_power.h" |
10 #include "ash/common/system/tray/fixed_sized_image_view.h" | 10 #include "ash/common/system/tray/fixed_sized_image_view.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 TrayPopupItemStyle::FontStyle::SYSTEM_INFO); | 148 TrayPopupItemStyle::FontStyle::SYSTEM_INFO); |
149 style.SetupLabel(percentage_label_); | 149 style.SetupLabel(percentage_label_); |
150 style.SetupLabel(separator_label_); | 150 style.SetupLabel(separator_label_); |
151 style.SetupLabel(time_status_label_); | 151 style.SetupLabel(time_status_label_); |
152 } | 152 } |
153 | 153 |
154 void PowerStatusView::ChildPreferredSizeChanged(views::View* child) { | 154 void PowerStatusView::ChildPreferredSizeChanged(views::View* child) { |
155 PreferredSizeChanged(); | 155 PreferredSizeChanged(); |
156 } | 156 } |
157 | 157 |
158 gfx::Size PowerStatusView::GetPreferredSize() const { | |
159 gfx::Size size = views::View::GetPreferredSize(); | |
160 return gfx::Size(size.width(), GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | |
161 } | |
162 | |
163 int PowerStatusView::GetHeightForWidth(int width) const { | |
164 return GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT); | |
165 } | |
166 | |
167 void PowerStatusView::Layout() { | 158 void PowerStatusView::Layout() { |
168 views::View::Layout(); | 159 views::View::Layout(); |
169 | 160 |
170 // Move the time_status_label_, separator_label_, and percentage_label_ | 161 // Move the time_status_label_, separator_label_, and percentage_label_ |
171 // closer to each other. | 162 // closer to each other. |
172 if (percentage_label_ && separator_label_ && time_status_label_ && | 163 if (percentage_label_ && separator_label_ && time_status_label_ && |
173 percentage_label_->visible() && time_status_label_->visible()) { | 164 percentage_label_->visible() && time_status_label_->visible()) { |
174 separator_label_->SetX(percentage_label_->bounds().right() + 1); | 165 separator_label_->SetX(percentage_label_->bounds().right() + 1); |
175 time_status_label_->SetX(separator_label_->bounds().right() + 1); | 166 time_status_label_->SetX(separator_label_->bounds().right() + 1); |
176 } | 167 } |
177 } | 168 } |
178 | 169 |
179 void PowerStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 170 void PowerStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
180 UpdateStyle(); | 171 UpdateStyle(); |
181 } | 172 } |
182 | 173 |
183 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 174 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
184 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 175 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) |
185 return; | 176 return; |
186 | 177 |
187 node_data->role = ui::AX_ROLE_LABEL_TEXT; | 178 node_data->role = ui::AX_ROLE_LABEL_TEXT; |
188 node_data->SetName(accessible_name_); | 179 node_data->SetName(accessible_name_); |
189 } | 180 } |
190 | 181 |
191 } // namespace ash | 182 } // namespace ash |
OLD | NEW |