Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: chrome/browser/chromeos/status/status_area_view.cc

Issue 7349021: Convert some more view methods to the ui/views style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/capslock_menu_button.h" 9 #include "chrome/browser/chromeos/status/capslock_menu_button.h"
10 #include "chrome/browser/chromeos/status/clock_menu_button.h" 10 #include "chrome/browser/chromeos/status/clock_menu_button.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // Power. 58 // Power.
59 power_view_ = new PowerMenuButton(host_); 59 power_view_ = new PowerMenuButton(host_);
60 AddChildView(power_view_); 60 AddChildView(power_view_);
61 } 61 }
62 62
63 gfx::Size StatusAreaView::GetPreferredSize() { 63 gfx::Size StatusAreaView::GetPreferredSize() {
64 int result_w = 0; 64 int result_w = 0;
65 int result_h = 0; 65 int result_h = 0;
66 66
67 for (int i = 0; i < child_count(); i++) { 67 for (int i = 0; i < child_count(); i++) {
68 views::View* cur = GetChildViewAt(i); 68 views::View* cur = child_at(i);
69 gfx::Size cur_size = cur->GetPreferredSize(); 69 gfx::Size cur_size = cur->GetPreferredSize();
70 if (cur->IsVisible() && !cur_size.IsEmpty()) { 70 if (cur->IsVisible() && !cur_size.IsEmpty()) {
71 if (result_w == 0) 71 if (result_w == 0)
72 result_w = kSeparation; 72 result_w = kSeparation;
73 73
74 // Add each width. 74 // Add each width.
75 result_w += cur_size.width() + kSeparation; 75 result_w += cur_size.width() + kSeparation;
76 // Use max height. 76 // Use max height.
77 result_h = std::max(result_h, cur_size.height()); 77 result_h = std::max(result_h, cur_size.height());
78 } 78 }
79 } 79 }
80 return gfx::Size(result_w, result_h); 80 return gfx::Size(result_w, result_h);
81 } 81 }
82 82
83 void StatusAreaView::Layout() { 83 void StatusAreaView::Layout() {
84 int cur_x = kSeparation; 84 int cur_x = kSeparation;
85 for (int i = 0; i < child_count(); i++) { 85 for (int i = 0; i < child_count(); i++) {
86 views::View* cur = GetChildViewAt(i); 86 views::View* cur = child_at(i);
87 gfx::Size cur_size = cur->GetPreferredSize(); 87 gfx::Size cur_size = cur->GetPreferredSize();
88 if (cur->IsVisible() && !cur_size.IsEmpty()) { 88 if (cur->IsVisible() && !cur_size.IsEmpty()) {
89 int cur_y = (height() - cur_size.height()) / 2; 89 int cur_y = (height() - cur_size.height()) / 2;
90 90
91 // Handle odd number of pixels. 91 // Handle odd number of pixels.
92 cur_y += (height() - cur_size.height()) % 2; 92 cur_y += (height() - cur_size.height()) % 2;
93 93
94 // Put next in row horizontally, and center vertically. 94 // Put next in row horizontally, and center vertically.
95 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); 95 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height());
96 cur_x += cur_size.width() + kSeparation; 96 cur_x += cur_size.width() + kSeparation;
(...skipping 10 matching lines...) Expand all
107 } 107 }
108 108
109 void StatusAreaView::MakeButtonsActive(bool active) { 109 void StatusAreaView::MakeButtonsActive(bool active) {
110 clock_view()->set_active(active); 110 clock_view()->set_active(active);
111 input_method_view()->set_active(active); 111 input_method_view()->set_active(active);
112 network_view()->set_active(active); 112 network_view()->set_active(active);
113 power_view()->set_active(active); 113 power_view()->set_active(active);
114 } 114 }
115 115
116 } // namespace chromeos 116 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698