OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_area_view.h" | 5 #include "chrome/browser/chromeos/status_area_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
27 #include "views/controls/menu/menu.h" | 27 #include "views/controls/menu/menu.h" |
28 #include "views/controls/menu/simple_menu_model.h" | 28 #include "views/controls/menu/simple_menu_model.h" |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Number of pixels to pad on the left border. | 32 // Number of pixels to pad on the left border. |
33 const int kLeftBorder = 1; | 33 const int kLeftBorder = 1; |
34 // Number of pixels to separate the clock from the next item on the right. | 34 // Number of pixels to separate the clock from the next item on the right. |
35 const int kClockSeparation = 4; | 35 const int kClockSeparation = 4; |
36 // Number of pixels to adjust the y value of the clock. | |
Evan Stade
2009/10/23 18:06:29
this change releated?
DaveMoore
2009/10/23 18:11:10
Yes...it was correcting for bad positioning.
| |
37 const int kClockYAdjustment = 2; | |
38 | 36 |
39 // BrowserWindowGtk tiles its image with this offset | 37 // BrowserWindowGtk tiles its image with this offset |
40 const int kCustomFrameBackgroundVerticalOffset = 15; | 38 const int kCustomFrameBackgroundVerticalOffset = 15; |
41 | 39 |
42 class OptionsMenuModel : public views::SimpleMenuModel, | 40 class OptionsMenuModel : public views::SimpleMenuModel, |
43 public views::SimpleMenuModel::Delegate { | 41 public views::SimpleMenuModel::Delegate { |
44 public: | 42 public: |
45 // These extra command IDs must be unique when combined with the options, | 43 // These extra command IDs must be unique when combined with the options, |
46 // so we just pick up the numbering where that stops. | 44 // so we just pick up the numbering where that stops. |
47 enum OtherCommands { | 45 enum OtherCommands { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 void StatusAreaView::Layout() { | 164 void StatusAreaView::Layout() { |
167 int cur_x = kLeftBorder; | 165 int cur_x = kLeftBorder; |
168 for (int i = 0; i < GetChildViewCount(); i++) { | 166 for (int i = 0; i < GetChildViewCount(); i++) { |
169 views::View* cur = GetChildViewAt(i); | 167 views::View* cur = GetChildViewAt(i); |
170 gfx::Size cur_size = cur->GetPreferredSize(); | 168 gfx::Size cur_size = cur->GetPreferredSize(); |
171 int cur_y = (height() - cur_size.height()) / 2; | 169 int cur_y = (height() - cur_size.height()) / 2; |
172 | 170 |
173 // Handle odd number of pixels. | 171 // Handle odd number of pixels. |
174 cur_y += (height() - cur_size.height()) % 2; | 172 cur_y += (height() - cur_size.height()) % 2; |
175 | 173 |
176 // Adjustment to make clock line up right. | |
177 if (cur == clock_view_) | |
178 cur_y += kClockYAdjustment; | |
179 | |
180 // Put next in row horizontally, and center vertically. | 174 // Put next in row horizontally, and center vertically. |
181 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); | 175 cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height()); |
182 | 176 |
183 cur_x += cur_size.width(); | 177 cur_x += cur_size.width(); |
184 | 178 |
185 // Buttons have built in padding, but clock doesn't. | 179 // Buttons have built in padding, but clock doesn't. |
186 if (cur == clock_view_) | 180 if (cur == clock_view_) |
187 cur_x += kClockSeparation; | 181 cur_x += kClockSeparation; |
188 } | 182 } |
189 } | 183 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 } | 271 } |
278 | 272 |
279 void StatusAreaView::ExecuteCommand(int command_id) { | 273 void StatusAreaView::ExecuteCommand(int command_id) { |
280 browser_->ExecuteCommand(command_id); | 274 browser_->ExecuteCommand(command_id); |
281 } | 275 } |
282 | 276 |
283 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { | 277 void StatusAreaView::RunMenu(views::View* source, const gfx::Point& pt) { |
284 CreateAppMenu(); | 278 CreateAppMenu(); |
285 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 279 app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
286 } | 280 } |
OLD | NEW |