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/chromeos/status/status_area_view.h" | 5 #include "chrome/browser/chromeos/status/status_area_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "chrome/browser/chromeos/status/caps_lock_menu_button.h" | 9 #include "chrome/browser/chromeos/status/caps_lock_menu_button.h" |
10 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 10 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 power_view_ = new PowerMenuButton(host_); | 54 power_view_ = new PowerMenuButton(host_); |
55 AddChildView(power_view_); | 55 AddChildView(power_view_); |
56 } | 56 } |
57 | 57 |
58 gfx::Size StatusAreaView::GetPreferredSize() { | 58 gfx::Size StatusAreaView::GetPreferredSize() { |
59 int result_w = 0; | 59 int result_w = 0; |
60 int result_h = 0; | 60 int result_h = 0; |
61 | 61 |
62 for (int i = 0; i < child_count(); i++) { | 62 for (int i = 0; i < child_count(); i++) { |
63 views::View* cur = GetChildViewAt(i); | 63 views::View* cur = child_at(i); |
64 gfx::Size cur_size = cur->GetPreferredSize(); | 64 gfx::Size cur_size = cur->GetPreferredSize(); |
65 if (cur->IsVisible() && !cur_size.IsEmpty()) { | 65 if (cur->IsVisible() && !cur_size.IsEmpty()) { |
66 if (result_w == 0) | 66 if (result_w == 0) |
67 result_w = kSeparation; | 67 result_w = kSeparation; |
68 | 68 |
69 // Add each width. | 69 // Add each width. |
70 result_w += cur_size.width() + kSeparation; | 70 result_w += cur_size.width() + kSeparation; |
71 // Use max height. | 71 // Use max height. |
72 result_h = std::max(result_h, cur_size.height()); | 72 result_h = std::max(result_h, cur_size.height()); |
73 } | 73 } |
74 } | 74 } |
75 return gfx::Size(result_w, result_h); | 75 return gfx::Size(result_w, result_h); |
76 } | 76 } |
77 | 77 |
78 void StatusAreaView::Layout() { | 78 void StatusAreaView::Layout() { |
79 int cur_x = kSeparation; | 79 int cur_x = kSeparation; |
80 for (int i = 0; i < child_count(); i++) { | 80 for (int i = 0; i < child_count(); i++) { |
81 views::View* cur = GetChildViewAt(i); | 81 views::View* cur = child_at(i); |
82 gfx::Size cur_size = cur->GetPreferredSize(); | 82 gfx::Size cur_size = cur->GetPreferredSize(); |
83 if (cur->IsVisible() && !cur_size.IsEmpty()) { | 83 if (cur->IsVisible() && !cur_size.IsEmpty()) { |
84 int cur_y = (height() - cur_size.height()) / 2; | 84 int cur_y = (height() - cur_size.height()) / 2; |
85 | 85 |
86 // Handle odd number of pixels. | 86 // Handle odd number of pixels. |
87 cur_y += (height() - cur_size.height()) % 2; | 87 cur_y += (height() - cur_size.height()) % 2; |
88 | 88 |
89 // Put next in row horizontally, and center vertically. | 89 // Put next in row horizontally, and center vertically. |
90 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); | 90 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); |
91 cur_x += cur_size.width() + kSeparation; | 91 cur_x += cur_size.width() + kSeparation; |
(...skipping 10 matching lines...) Expand all Loading... |
102 } | 102 } |
103 | 103 |
104 void StatusAreaView::MakeButtonsActive(bool active) { | 104 void StatusAreaView::MakeButtonsActive(bool active) { |
105 clock_view()->set_active(active); | 105 clock_view()->set_active(active); |
106 input_method_view()->set_active(active); | 106 input_method_view()->set_active(active); |
107 network_view()->set_active(active); | 107 network_view()->set_active(active); |
108 power_view()->set_active(active); | 108 power_view()->set_active(active); |
109 } | 109 } |
110 | 110 |
111 } // namespace chromeos | 111 } // namespace chromeos |
OLD | NEW |