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

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 2855623004: Don't allow Checkboxes to participate in equal-sized-buttons in Harmony dialogs. (Closed)
Patch Set: Just checkboxes Created 3 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 11 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/views/background.h" 12 #include "ui/views/background.h"
13 #include "ui/views/border.h" 13 #include "ui/views/border.h"
14 #include "ui/views/controls/button/blue_button.h" 14 #include "ui/views/controls/button/blue_button.h"
15 #include "ui/views/controls/button/checkbox.h"
15 #include "ui/views/controls/button/custom_button.h" 16 #include "ui/views/controls/button/custom_button.h"
16 #include "ui/views/controls/button/label_button.h" 17 #include "ui/views/controls/button/label_button.h"
17 #include "ui/views/controls/button/md_text_button.h" 18 #include "ui/views/controls/button/md_text_button.h"
18 #include "ui/views/layout/grid_layout.h" 19 #include "ui/views/layout/grid_layout.h"
19 #include "ui/views/layout/layout_provider.h" 20 #include "ui/views/layout/layout_provider.h"
20 #include "ui/views/style/platform_style.h" 21 #include "ui/views/style/platform_style.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 #include "ui/views/window/dialog_delegate.h" 23 #include "ui/views/window/dialog_delegate.h"
23 24
24 namespace views { 25 namespace views {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 for (size_t view_index = 0; view_index < kNumButtons; ++view_index) { 386 for (size_t view_index = 0; view_index < kNumButtons; ++view_index) {
386 if (views[view_index]) { 387 if (views[view_index]) {
387 layout->AddView(views[view_index]); 388 layout->AddView(views[view_index]);
388 link[link_index++] = kViewToColumnIndex[view_index]; 389 link[link_index++] = kViewToColumnIndex[view_index];
389 } else { 390 } else {
390 layout->SkipColumns(1); 391 layout->SkipColumns(1);
391 } 392 }
392 } 393 }
393 394
394 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 395 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
395 // Only link the extra view column if it is a button. 396 // If |views[0]| is non-null, it is a visible |extra_view_| and its column
396 if (views[0] && !CustomButton::AsCustomButton(views[0])) 397 // will be in |link[0]|. Skip that if it is not a button, or if it is a
398 // Checkbox (which extends LabelButton). Otherwise, link everything.
399 bool skip_first_link =
400 views[0] && (!CustomButton::AsCustomButton(views[0]) ||
401 views[0]->GetClassName() == Checkbox::kViewClassName);
402 if (skip_first_link)
397 column_set->LinkColumnSizes(link[1], link[2], -1); 403 column_set->LinkColumnSizes(link[1], link[2], -1);
398 else 404 else
399 column_set->LinkColumnSizes(link[0], link[1], link[2], -1); 405 column_set->LinkColumnSizes(link[0], link[1], link[2], -1);
400 } 406 }
401 layout->AddPaddingRow(kFixed, insets.bottom()); 407 layout->AddPaddingRow(kFixed, insets.bottom());
402 } 408 }
403 409
404 void DialogClientView::SetupViews() { 410 void DialogClientView::SetupViews() {
405 button_row_container_->RemoveAllChildViews(false /* delete children */); 411 button_row_container_->RemoveAllChildViews(false /* delete children */);
406 // If SetupLayout() "stored" a hidden |extra_view_| in |this|, ensure it can 412 // If SetupLayout() "stored" a hidden |extra_view_| in |this|, ensure it can
407 // be re-added to the layout when becoming visible. 413 // be re-added to the layout when becoming visible.
408 if (extra_view_) 414 if (extra_view_)
409 RemoveChildView(extra_view_); 415 RemoveChildView(extra_view_);
410 416
411 UpdateDialogButton(&ok_button_, ui::DIALOG_BUTTON_OK); 417 UpdateDialogButton(&ok_button_, ui::DIALOG_BUTTON_OK);
412 UpdateDialogButton(&cancel_button_, ui::DIALOG_BUTTON_CANCEL); 418 UpdateDialogButton(&cancel_button_, ui::DIALOG_BUTTON_CANCEL);
413 419
414 if (extra_view_) 420 if (extra_view_)
415 return; 421 return;
416 422
417 extra_view_ = GetDialogDelegate()->CreateExtraView(); 423 extra_view_ = GetDialogDelegate()->CreateExtraView();
418 if (extra_view_) 424 if (extra_view_)
419 extra_view_->SetGroup(kButtonGroup); 425 extra_view_->SetGroup(kButtonGroup);
420 } 426 }
421 427
422 } // namespace views 428 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view_unittest.cc » ('j') | ui/views/window/dialog_client_view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698