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 "chrome/browser/ui/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "content/public/browser/web_contents_view.h" | 28 #include "content/public/browser/web_contents_view.h" |
29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
30 #include "grit/ui_resources.h" | 30 #include "grit/ui_resources.h" |
31 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/models/combobox_model.h" | 33 #include "ui/base/models/combobox_model.h" |
34 #include "ui/base/models/menu_model.h" | 34 #include "ui/base/models/menu_model.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/animation/animation_delegate.h" | 36 #include "ui/gfx/animation/animation_delegate.h" |
37 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
38 #include "ui/gfx/color_utils.h" | |
38 #include "ui/gfx/path.h" | 39 #include "ui/gfx/path.h" |
39 #include "ui/gfx/point.h" | 40 #include "ui/gfx/point.h" |
40 #include "ui/gfx/skia_util.h" | 41 #include "ui/gfx/skia_util.h" |
41 #include "ui/views/background.h" | 42 #include "ui/views/background.h" |
42 #include "ui/views/border.h" | 43 #include "ui/views/border.h" |
43 #include "ui/views/bubble/bubble_border.h" | 44 #include "ui/views/bubble/bubble_border.h" |
44 #include "ui/views/bubble/bubble_frame_view.h" | 45 #include "ui/views/bubble/bubble_frame_view.h" |
45 #include "ui/views/controls/button/blue_button.h" | 46 #include "ui/views/controls/button/blue_button.h" |
46 #include "ui/views/controls/button/checkbox.h" | 47 #include "ui/views/controls/button/checkbox.h" |
47 #include "ui/views/controls/button/label_button.h" | 48 #include "ui/views/controls/button/label_button.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 if (!message_view_->visible()) | 572 if (!message_view_->visible()) |
572 return 0; | 573 return 0; |
573 | 574 |
574 return kOverlayImageBottomMargin + | 575 return kOverlayImageBottomMargin + |
575 views::kButtonVEdgeMarginNew + | 576 views::kButtonVEdgeMarginNew + |
576 message_view_->GetHeightForWidth(width) + | 577 message_view_->GetHeightForWidth(width) + |
577 image_view_->GetHeightForWidth(width); | 578 image_view_->GetHeightForWidth(width); |
578 } | 579 } |
579 | 580 |
580 void AutofillDialogViews::OverlayView::UpdateState() { | 581 void AutofillDialogViews::OverlayView::UpdateState() { |
581 const DialogOverlayState& state = delegate_->GetDialogOverlay(); | 582 const DialogOverlayState& state = |
583 delegate_->GetDialogOverlay(GetNativeTheme()); | |
582 | 584 |
583 if (state.image.IsEmpty()) { | 585 if (state.image.IsEmpty()) { |
584 SetVisible(false); | 586 SetVisible(false); |
585 return; | 587 return; |
586 } | 588 } |
587 | 589 |
588 image_view_->SetImage(state.image.ToImageSkia()); | 590 image_view_->SetImage(state.image.ToImageSkia()); |
589 | 591 |
590 message_view_->SetVisible(!state.string.text.empty()); | 592 message_view_->SetVisible(!state.string.text.empty()); |
591 message_view_->SetText(state.string.text); | 593 message_view_->SetText(state.string.text); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 arrow.moveTo(rect.x() - 1, y); | 649 arrow.moveTo(rect.x() - 1, y); |
648 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); | 650 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); |
649 arrow.rLineTo(arrow_half_width, -kArrowHeight); | 651 arrow.rLineTo(arrow_half_width, -kArrowHeight); |
650 arrow.rLineTo(arrow_half_width, kArrowHeight); | 652 arrow.rLineTo(arrow_half_width, kArrowHeight); |
651 arrow.lineTo(rect.right() + 1, y); | 653 arrow.lineTo(rect.right() + 1, y); |
652 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); | 654 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); |
653 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); | 655 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); |
654 arrow.close(); | 656 arrow.close(); |
655 | 657 |
656 SkPaint paint; | 658 SkPaint paint; |
657 paint.setColor(kShadingColor); | 659 SkColor background_color = background()->get_color(); |
660 int background_luminance = color_utils::GetLuminanceForColor(background_colo r); | |
661 int background_alpha = static_cast<int>( | |
662 7 - 15 * (background_luminance - 255) / 255); | |
groby-ooo-7-16
2013/12/10 20:26:49
So we get a negative alpha for high-luma backgroun
Sheridan Rawlins
2013/12/10 20:51:56
No, alpha is always positive - the luminance retur
| |
663 int subtle_border_alpha = static_cast<int>( | |
664 10 - 20 * (background_luminance - 255) / 255); | |
665 | |
666 paint.setColor(color_utils::BlendTowardOppositeLuminance( | |
667 background_color, background_alpha)); | |
658 paint.setStyle(SkPaint::kFill_Style); | 668 paint.setStyle(SkPaint::kFill_Style); |
659 canvas->DrawPath(arrow, paint); | 669 canvas->DrawPath(arrow, paint); |
660 paint.setColor(kSubtleBorderColor); | 670 paint.setColor(color_utils::BlendTowardOppositeLuminance( |
671 background_color, subtle_border_alpha)); | |
661 paint.setStyle(SkPaint::kStroke_Style); | 672 paint.setStyle(SkPaint::kStroke_Style); |
662 canvas->DrawPath(arrow, paint); | 673 canvas->DrawPath(arrow, paint); |
663 } | 674 } |
664 | 675 |
665 PaintChildren(canvas); | 676 PaintChildren(canvas); |
666 } | 677 } |
667 | 678 |
668 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( | 679 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( |
669 const ui::NativeTheme* theme) { | 680 const ui::NativeTheme* theme) { |
670 set_background(views::Background::CreateSolidBackground( | 681 set_background(views::Background::CreateSolidBackground( |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2449 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2460 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2450 : section(section), | 2461 : section(section), |
2451 container(NULL), | 2462 container(NULL), |
2452 manual_input(NULL), | 2463 manual_input(NULL), |
2453 suggested_info(NULL), | 2464 suggested_info(NULL), |
2454 suggested_button(NULL) {} | 2465 suggested_button(NULL) {} |
2455 | 2466 |
2456 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2467 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2457 | 2468 |
2458 } // namespace autofill | 2469 } // namespace autofill |
OLD | NEW |