| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/clock_menu_button.h" | 9 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
| 10 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 10 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 AddChildView(power_view_); | 46 AddChildView(power_view_); |
| 47 | 47 |
| 48 // Window Switcher. | 48 // Window Switcher. |
| 49 window_switcher_view_ = new WindowSwitcherButton(host_); | 49 window_switcher_view_ = new WindowSwitcherButton(host_); |
| 50 AddChildView(window_switcher_view_); | 50 AddChildView(window_switcher_view_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::Size StatusAreaView::GetPreferredSize() { | 53 gfx::Size StatusAreaView::GetPreferredSize() { |
| 54 int result_w = kSeparation; | 54 int result_w = kSeparation; |
| 55 int result_h = 0; | 55 int result_h = 0; |
| 56 for (int i = 0; i < GetChildViewCount(); i++) { | 56 for (int i = 0; i < child_count(); i++) { |
| 57 views::View* cur = GetChildViewAt(i); | 57 views::View* cur = GetChildViewAt(i); |
| 58 if (cur->IsVisible()) { | 58 if (cur->IsVisible()) { |
| 59 gfx::Size cur_size = cur->GetPreferredSize(); | 59 gfx::Size cur_size = cur->GetPreferredSize(); |
| 60 // Add each width. | 60 // Add each width. |
| 61 result_w += cur_size.width() + kSeparation; | 61 result_w += cur_size.width() + kSeparation; |
| 62 // Use max height. | 62 // Use max height. |
| 63 result_h = std::max(result_h, cur_size.height()); | 63 result_h = std::max(result_h, cur_size.height()); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 return gfx::Size(result_w, result_h); | 66 return gfx::Size(result_w, result_h); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void StatusAreaView::Layout() { | 69 void StatusAreaView::Layout() { |
| 70 int cur_x = kSeparation; | 70 int cur_x = kSeparation; |
| 71 for (int i = 0; i < GetChildViewCount(); i++) { | 71 for (int i = 0; i < child_count(); i++) { |
| 72 views::View* cur = GetChildViewAt(i); | 72 views::View* cur = GetChildViewAt(i); |
| 73 if (cur->IsVisible()) { | 73 if (cur->IsVisible()) { |
| 74 gfx::Size cur_size = cur->GetPreferredSize(); | 74 gfx::Size cur_size = cur->GetPreferredSize(); |
| 75 int cur_y = (height() - cur_size.height()) / 2; | 75 int cur_y = (height() - cur_size.height()) / 2; |
| 76 | 76 |
| 77 // Handle odd number of pixels. | 77 // Handle odd number of pixels. |
| 78 cur_y += (height() - cur_size.height()) % 2; | 78 cur_y += (height() - cur_size.height()) % 2; |
| 79 | 79 |
| 80 // Put next in row horizontally, and center vertically. | 80 // Put next in row horizontally, and center vertically. |
| 81 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); | 81 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 void StatusAreaView::MakeButtonsActive(bool active) { | 97 void StatusAreaView::MakeButtonsActive(bool active) { |
| 98 clock_view()->set_active(active); | 98 clock_view()->set_active(active); |
| 99 input_method_view()->set_active(active); | 99 input_method_view()->set_active(active); |
| 100 network_view()->set_active(active); | 100 network_view()->set_active(active); |
| 101 power_view()->set_active(active); | 101 power_view()->set_active(active); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace chromeos | 104 } // namespace chromeos |
| OLD | NEW |