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/login/network_selection_view.h" | 5 #include "chrome/browser/chromeos/login/network_selection_view.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const int kControlPaddingRow = 15; | 59 const int kControlPaddingRow = 15; |
60 | 60 |
61 // Fixed size for language/network controls height. | 61 // Fixed size for language/network controls height. |
62 const int kSelectionBoxHeight = 29; | 62 const int kSelectionBoxHeight = 29; |
63 | 63 |
64 // Menu button is drawn using our custom icons in resources. See | 64 // Menu button is drawn using our custom icons in resources. See |
65 // TextButtonBorder::Paint() for details. So this offset compensate | 65 // TextButtonBorder::Paint() for details. So this offset compensate |
66 // horizontal size, eaten by those icons. | 66 // horizontal size, eaten by those icons. |
67 const int kMenuHorizontalOffset = -1; | 67 const int kMenuHorizontalOffset = -1; |
68 | 68 |
| 69 // Constants were taken from 'views/controls/menu_button.cc'. |
| 70 const int kDefaultMenuOffsetX = -2; |
| 71 const int kDefaultMenuOffsetY = -4; |
| 72 |
69 // Vertical addition to the menu window to make it appear exactly below | 73 // Vertical addition to the menu window to make it appear exactly below |
70 // MenuButton. | 74 // MenuButton. |
71 const int kMenuVerticalOffset = 3; | 75 const int kMenuVerticalOffset = 3; |
72 | 76 |
73 // Offset that compensates menu width so that it matches | 77 // Offset that compensates menu width so that it matches |
74 // menu button visual width when being in pushed state. | 78 // menu button visual width when being in pushed state. |
75 const int kMenuWidthOffset = 6; | 79 const int kMenuWidthOffset = 6; |
76 | 80 |
77 const SkColor kWelcomeColor = 0xFFCDD3D6; | 81 const SkColor kWelcomeColor = 0xFFCDD3D6; |
78 | 82 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 207 |
204 void NetworkSelectionView::InitLayout() { | 208 void NetworkSelectionView::InitLayout() { |
205 gfx::Size screen_size = delegate_->size(); | 209 gfx::Size screen_size = delegate_->size(); |
206 const int widest_label = std::max( | 210 const int widest_label = std::max( |
207 select_language_label_->GetPreferredSize().width(), | 211 select_language_label_->GetPreferredSize().width(), |
208 select_network_label_->GetPreferredSize().width()); | 212 select_network_label_->GetPreferredSize().width()); |
209 const int dropdown_width = screen_size.width() - 2 * kBorderSize - | 213 const int dropdown_width = screen_size.width() - 2 * kBorderSize - |
210 2 * kPaddingColumnWidth - kMediumPaddingColumnWidth - widest_label; | 214 2 * kPaddingColumnWidth - kMediumPaddingColumnWidth - widest_label; |
211 delegate_->language_switch_menu()->SetFirstLevelMenuWidth( | 215 delegate_->language_switch_menu()->SetFirstLevelMenuWidth( |
212 dropdown_width - kMenuWidthOffset); | 216 dropdown_width - kMenuWidthOffset); |
| 217 network_dropdown_->SetFirstLevelMenuWidth(dropdown_width - kMenuWidthOffset); |
213 | 218 |
214 // Define layout and column set for entire screen (welcome + screen). | 219 // Define layout and column set for entire screen (welcome + screen). |
215 views::GridLayout* screen_layout = new views::GridLayout(this); | 220 views::GridLayout* screen_layout = new views::GridLayout(this); |
216 SetLayoutManager(screen_layout); | 221 SetLayoutManager(screen_layout); |
217 views::ColumnSet* column_set = screen_layout->AddColumnSet(WELCOME_ROW); | 222 views::ColumnSet* column_set = screen_layout->AddColumnSet(WELCOME_ROW); |
218 const int welcome_width = screen_size.width() - 2 * kWelcomeTitlePadding - | 223 const int welcome_width = screen_size.width() - 2 * kWelcomeTitlePadding - |
219 2 * kBorderSize; | 224 2 * kBorderSize; |
220 column_set->AddPaddingColumn(0, kWelcomeTitlePadding + kBorderSize); | 225 column_set->AddPaddingColumn(0, kWelcomeTitlePadding + kBorderSize); |
221 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, | 226 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, |
222 GridLayout::FIXED, welcome_width, welcome_width); | 227 GridLayout::FIXED, welcome_width, welcome_width); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 welcome_label_->SetMultiLine(true); | 286 welcome_label_->SetMultiLine(true); |
282 | 287 |
283 select_language_label_ = new views::Label(); | 288 select_language_label_ = new views::Label(); |
284 select_language_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 289 select_language_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
285 | 290 |
286 languages_menubutton_ = new NotifyingMenuButton( | 291 languages_menubutton_ = new NotifyingMenuButton( |
287 NULL, std::wstring(), delegate_->language_switch_menu(), true, delegate_); | 292 NULL, std::wstring(), delegate_->language_switch_menu(), true, delegate_); |
288 languages_menubutton_->SetFocusable(true); | 293 languages_menubutton_->SetFocusable(true); |
289 languages_menubutton_->SetNormalHasBorder(true); | 294 languages_menubutton_->SetNormalHasBorder(true); |
290 // Menu is positioned by bottom right corner of the MenuButton. | 295 // Menu is positioned by bottom right corner of the MenuButton. |
| 296 // TODO(altimofeev): switch to the absolute offsets (button related) |
291 delegate_->language_switch_menu()->set_menu_offset(kMenuHorizontalOffset, | 297 delegate_->language_switch_menu()->set_menu_offset(kMenuHorizontalOffset, |
292 kMenuVerticalOffset); | 298 kMenuVerticalOffset); |
293 | 299 |
294 select_network_label_ = new views::Label(); | 300 select_network_label_ = new views::Label(); |
295 select_network_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 301 select_network_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
296 | 302 |
297 network_dropdown_ = new NetworkControlWithAccelerators(false, | 303 network_dropdown_ = new NetworkControlWithAccelerators(false, |
298 GetNativeWindow(), | 304 GetNativeWindow(), |
299 delegate_); | 305 delegate_); |
| 306 |
| 307 // TODO(altimofeev): switch to the absolute offsets (button related) |
| 308 network_dropdown_->set_menu_offset( |
| 309 kDefaultMenuOffsetX + kMenuHorizontalOffset, |
| 310 kDefaultMenuOffsetY + kMenuVerticalOffset); |
| 311 |
300 network_dropdown_->SetNormalHasBorder(true); | 312 network_dropdown_->SetNormalHasBorder(true); |
301 network_dropdown_->SetFocusable(true); | 313 network_dropdown_->SetFocusable(true); |
302 | 314 |
303 connecting_network_label_ = new views::Label(); | 315 connecting_network_label_ = new views::Label(); |
304 connecting_network_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 316 connecting_network_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
305 connecting_network_label_->SetVisible(false); | 317 connecting_network_label_->SetVisible(false); |
306 | 318 |
307 proxy_settings_link_ = new views::Link(); | 319 proxy_settings_link_ = new views::Link(); |
308 proxy_settings_link_->SetController(this); | 320 proxy_settings_link_->SetController(this); |
309 proxy_settings_link_->SetVisible(true); | 321 proxy_settings_link_->SetVisible(true); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 l10n_util::GetString(IDS_NETWORK_SELECTION_CONTINUE_BUTTON)); | 436 l10n_util::GetString(IDS_NETWORK_SELECTION_CONTINUE_BUTTON)); |
425 continue_button_->SetEnabled(is_continue_enabled); | 437 continue_button_->SetEnabled(is_continue_enabled); |
426 } | 438 } |
427 | 439 |
428 void NetworkSelectionView::UpdateConnectingNetworkLabel() { | 440 void NetworkSelectionView::UpdateConnectingNetworkLabel() { |
429 connecting_network_label_->SetText(l10n_util::GetStringF( | 441 connecting_network_label_->SetText(l10n_util::GetStringF( |
430 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); | 442 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); |
431 } | 443 } |
432 | 444 |
433 } // namespace chromeos | 445 } // namespace chromeos |
OLD | NEW |