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

Side by Side Diff: chrome/browser/views/options/content_page_view.cc

Issue 2812026: Auto-size the views version of the options dialog. (Closed)
Patch Set: Fix autosizing issue with gtk pref pages in chromeos options dialog. Created 10 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
OLDNEW
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/views/options/content_page_view.h" 5 #include "chrome/browser/views/options/content_page_view.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <vsstyle.h> 9 #include <vsstyle.h>
10 #include <vssym32.h> 10 #include <vssym32.h>
(...skipping 23 matching lines...) Expand all
34 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
35 #include "grit/locale_settings.h" 35 #include "grit/locale_settings.h"
36 #include "views/controls/button/radio_button.h" 36 #include "views/controls/button/radio_button.h"
37 #include "views/grid_layout.h" 37 #include "views/grid_layout.h"
38 #include "views/standard_layout.h" 38 #include "views/standard_layout.h"
39 #include "views/widget/widget.h" 39 #include "views/widget/widget.h"
40 #include "views/window/window.h" 40 #include "views/window/window.h"
41 41
42 namespace { 42 namespace {
43 43
44 const int kPasswordSavingRadioGroup = 1; 44 // All the options pages are in the same view hierarchy. This means we need to
45 const int kFormAutofillRadioGroup = 2; 45 // make sure group identifiers don't collide across different pages.
46 const int kPasswordSavingRadioGroup = 201;
47 const int kFormAutofillRadioGroup = 202;
46 48
47 // Background color for the status label when it's showing an error. 49 // Background color for the status label when it's showing an error.
48 static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a); 50 static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a);
49 51
50 static views::Background* CreateErrorBackground() { 52 static views::Background* CreateErrorBackground() {
51 return views::Background::CreateSolidBackground(kSyncLabelErrorBgColor); 53 return views::Background::CreateSolidBackground(kSyncLabelErrorBgColor);
52 } 54 }
53 55
54 } // namespace 56 } // namespace
55 57
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 is_using_default_theme_.GetValue().length() > 0); 247 is_using_default_theme_.GetValue().length() > 0);
246 } 248 }
247 } 249 }
248 250
249 /////////////////////////////////////////////////////////////////////////////// 251 ///////////////////////////////////////////////////////////////////////////////
250 // ContentsPageView, views::View overrides: 252 // ContentsPageView, views::View overrides:
251 253
252 void ContentPageView::Layout() { 254 void ContentPageView::Layout() {
253 if (is_initialized()) 255 if (is_initialized())
254 UpdateSyncControls(); 256 UpdateSyncControls();
255 // We need to Layout twice - once to get the width of the contents box...
256 View::Layout();
257 passwords_asktosave_radio_->SetBounds(
258 0, 0, passwords_group_->GetContentsWidth(), 0);
259 passwords_neversave_radio_->SetBounds(
260 0, 0, passwords_group_->GetContentsWidth(), 0);
261 if (is_initialized()) {
262 sync_status_label_->SetBounds(
263 0, 0, sync_group_->GetContentsWidth(), 0);
264 }
265 // ... and twice to get the height of multi-line items correct.
266 View::Layout(); 257 View::Layout();
267 } 258 }
268 259
269 260
270 /////////////////////////////////////////////////////////////////////////////// 261 ///////////////////////////////////////////////////////////////////////////////
271 // ContentsPageView, ProfileSyncServiceObserver implementation: 262 // ContentsPageView, ProfileSyncServiceObserver implementation:
272 263
273 void ContentPageView::OnStateChanged() { 264 void ContentPageView::OnStateChanged() {
274 // If the UI controls are not yet initialized, then don't do anything. This 265 // If the UI controls are not yet initialized, then don't do anything. This
275 // can happen if the Options dialog is up, but the Content tab is not yet 266 // can happen if the Options dialog is up, but the Content tab is not yet
(...skipping 25 matching lines...) Expand all
301 views::View* contents = new views::View; 292 views::View* contents = new views::View;
302 GridLayout* layout = new GridLayout(contents); 293 GridLayout* layout = new GridLayout(contents);
303 contents->SetLayoutManager(layout); 294 contents->SetLayoutManager(layout);
304 295
305 const int single_column_view_set_id = 0; 296 const int single_column_view_set_id = 0;
306 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); 297 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
307 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, 298 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
308 GridLayout::USE_PREF, 0, 0); 299 GridLayout::USE_PREF, 0, 0);
309 300
310 layout->StartRow(0, single_column_view_set_id); 301 layout->StartRow(0, single_column_view_set_id);
311 layout->AddView(passwords_asktosave_radio_); 302 layout->AddView(passwords_asktosave_radio_, 1, 1,
303 GridLayout::FILL, GridLayout::LEADING);
312 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 304 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
313 layout->StartRow(0, single_column_view_set_id); 305 layout->StartRow(0, single_column_view_set_id);
314 layout->AddView(passwords_neversave_radio_); 306 layout->AddView(passwords_neversave_radio_, 1, 1,
307 GridLayout::FILL, GridLayout::LEADING);
315 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); 308 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
316 layout->StartRow(0, single_column_view_set_id); 309 layout->StartRow(0, single_column_view_set_id);
317 layout->AddView(show_passwords_button_); 310 layout->AddView(show_passwords_button_);
318 311
319 passwords_group_ = new OptionsGroupView( 312 passwords_group_ = new OptionsGroupView(
320 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"", 313 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"",
321 true); 314 true);
322 } 315 }
323 316
324 void ContentPageView::InitFormAutofillGroup() { 317 void ContentPageView::InitFormAutofillGroup() {
(...skipping 24 matching lines...) Expand all
349 const int fill_column_view_set_id = 0; 342 const int fill_column_view_set_id = 0;
350 const int leading_column_view_set_id = 1; 343 const int leading_column_view_set_id = 1;
351 ColumnSet* column_set = layout->AddColumnSet(fill_column_view_set_id); 344 ColumnSet* column_set = layout->AddColumnSet(fill_column_view_set_id);
352 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 345 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
353 GridLayout::USE_PREF, 0, 0); 346 GridLayout::USE_PREF, 0, 0);
354 column_set = layout->AddColumnSet(leading_column_view_set_id); 347 column_set = layout->AddColumnSet(leading_column_view_set_id);
355 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, 348 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
356 GridLayout::USE_PREF, 0, 0); 349 GridLayout::USE_PREF, 0, 0);
357 350
358 layout->StartRow(0, fill_column_view_set_id); 351 layout->StartRow(0, fill_column_view_set_id);
359 layout->AddView(form_autofill_enable_radio_); 352 layout->AddView(form_autofill_enable_radio_, 1, 1,
353 GridLayout::FILL, GridLayout::LEADING);
360 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 354 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
361 layout->StartRow(0, fill_column_view_set_id); 355 layout->StartRow(0, fill_column_view_set_id);
362 layout->AddView(form_autofill_disable_radio_); 356 layout->AddView(form_autofill_disable_radio_, 1, 1,
357 GridLayout::FILL, GridLayout::LEADING);
363 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 358 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
364 layout->StartRow(0, leading_column_view_set_id); 359 layout->StartRow(0, leading_column_view_set_id);
365 layout->AddView(change_autofill_settings_button_); 360 layout->AddView(change_autofill_settings_button_);
366 361
367 form_autofill_group_ = new OptionsGroupView( 362 form_autofill_group_ = new OptionsGroupView(
368 contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME), 363 contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME),
369 L"", true); 364 L"", true);
370 } 365 }
371 366
372 void ContentPageView::InitThemesGroup() { 367 void ContentPageView::InitThemesGroup() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 445
451 const int single_column_view_set_id = 0; 446 const int single_column_view_set_id = 0;
452 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); 447 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
453 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 448 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
454 GridLayout::USE_PREF, 0, 0); 449 GridLayout::USE_PREF, 0, 0);
455 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 450 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
456 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, 451 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
457 GridLayout::USE_PREF, 0, 0); 452 GridLayout::USE_PREF, 0, 0);
458 453
459 layout->StartRow(0, single_column_view_set_id); 454 layout->StartRow(0, single_column_view_set_id);
460 layout->AddView(sync_status_label_, 3, 1); 455 layout->AddView(sync_status_label_, 3, 1,
456 GridLayout::FILL, GridLayout::LEADING);
461 layout->StartRow(0, single_column_view_set_id); 457 layout->StartRow(0, single_column_view_set_id);
462 layout->AddView(sync_action_link_, 3, 1); 458 layout->AddView(sync_action_link_, 3, 1);
463 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 459 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
464 layout->StartRow(0, single_column_view_set_id); 460 layout->StartRow(0, single_column_view_set_id);
465 layout->AddView(sync_start_stop_button_); 461 layout->AddView(sync_start_stop_button_);
466 layout->AddView(sync_customize_button_); 462 layout->AddView(sync_customize_button_);
467 463
468 sync_group_ = new OptionsGroupView(contents, 464 sync_group_ = new OptionsGroupView(contents,
469 l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true); 465 l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true);
470 } 466 }
(...skipping 26 matching lines...) Expand all
497 sync_action_link_->SetVisible(!link_label.empty()); 493 sync_action_link_->SetVisible(!link_label.empty());
498 494
499 if (status_has_error) { 495 if (status_has_error) {
500 sync_status_label_->set_background(CreateErrorBackground()); 496 sync_status_label_->set_background(CreateErrorBackground());
501 sync_action_link_->set_background(CreateErrorBackground()); 497 sync_action_link_->set_background(CreateErrorBackground());
502 } else { 498 } else {
503 sync_status_label_->set_background(NULL); 499 sync_status_label_->set_background(NULL);
504 sync_action_link_->set_background(NULL); 500 sync_action_link_->set_background(NULL);
505 } 501 }
506 } 502 }
OLDNEW
« no previous file with comments | « chrome/browser/views/options/advanced_contents_view.cc ('k') | chrome/browser/views/options/general_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698