OLD | NEW |
---|---|
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" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 for (size_t view_index = 0; view_index < kNumButtons; ++view_index) { | 385 for (size_t view_index = 0; view_index < kNumButtons; ++view_index) { |
386 if (views[view_index]) { | 386 if (views[view_index]) { |
387 layout->AddView(views[view_index]); | 387 layout->AddView(views[view_index]); |
388 link[link_index++] = kViewToColumnIndex[view_index]; | 388 link[link_index++] = kViewToColumnIndex[view_index]; |
389 } else { | 389 } else { |
390 layout->SkipColumns(1); | 390 layout->SkipColumns(1); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 394 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
395 // Only link the extra view column if it is a button. | 395 // Only link the extra view column if its View type matches the buttons. And |
396 if (views[0] && !CustomButton::AsCustomButton(views[0])) | 396 // if there's only buttons or only the extra view, everything can be linked. |
397 View* either_button_view = ok_button_ ? ok_button_ : cancel_button_; | |
398 if (either_button_view && extra_view_ && | |
msw
2017/05/02 17:20:10
nit: curlies for multi-line conditional?
tapted
2017/05/03 00:16:59
Broke out a separate bool - condition got a little
| |
399 either_button_view->GetClassName() != extra_view_->GetClassName()) | |
msw
2017/05/02 17:20:10
Won't this exclude other cases that we would want
tapted
2017/05/03 00:16:59
Done.
I think, because this is only for Harmony,
msw
2017/05/03 18:21:01
Random dialogs might be using LabelButton for the
| |
397 column_set->LinkColumnSizes(link[1], link[2], -1); | 400 column_set->LinkColumnSizes(link[1], link[2], -1); |
398 else | 401 else |
399 column_set->LinkColumnSizes(link[0], link[1], link[2], -1); | 402 column_set->LinkColumnSizes(link[0], link[1], link[2], -1); |
400 } | 403 } |
401 layout->AddPaddingRow(kFixed, insets.bottom()); | 404 layout->AddPaddingRow(kFixed, insets.bottom()); |
402 } | 405 } |
403 | 406 |
404 void DialogClientView::SetupViews() { | 407 void DialogClientView::SetupViews() { |
405 button_row_container_->RemoveAllChildViews(false /* delete children */); | 408 button_row_container_->RemoveAllChildViews(false /* delete children */); |
406 // If SetupLayout() "stored" a hidden |extra_view_| in |this|, ensure it can | 409 // If SetupLayout() "stored" a hidden |extra_view_| in |this|, ensure it can |
407 // be re-added to the layout when becoming visible. | 410 // be re-added to the layout when becoming visible. |
408 if (extra_view_) | 411 if (extra_view_) |
409 RemoveChildView(extra_view_); | 412 RemoveChildView(extra_view_); |
410 | 413 |
411 UpdateDialogButton(&ok_button_, ui::DIALOG_BUTTON_OK); | 414 UpdateDialogButton(&ok_button_, ui::DIALOG_BUTTON_OK); |
412 UpdateDialogButton(&cancel_button_, ui::DIALOG_BUTTON_CANCEL); | 415 UpdateDialogButton(&cancel_button_, ui::DIALOG_BUTTON_CANCEL); |
413 | 416 |
414 if (extra_view_) | 417 if (extra_view_) |
415 return; | 418 return; |
416 | 419 |
417 extra_view_ = GetDialogDelegate()->CreateExtraView(); | 420 extra_view_ = GetDialogDelegate()->CreateExtraView(); |
418 if (extra_view_) | 421 if (extra_view_) |
419 extra_view_->SetGroup(kButtonGroup); | 422 extra_view_->SetGroup(kButtonGroup); |
420 } | 423 } |
421 | 424 |
422 } // namespace views | 425 } // namespace views |
OLD | NEW |