Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "app/gfx/chrome_canvas.h" | 9 #include "app/gfx/chrome_canvas.h" |
| 10 #include "app/gfx/color_utils.h" | 10 #include "app/gfx/color_utils.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 static const SkColor kTextColor = | 32 static const SkColor kTextColor = |
| 33 color_utils::GetSysSkColor(COLOR_WINDOWTEXT); | 33 color_utils::GetSysSkColor(COLOR_WINDOWTEXT); |
| 34 static const SkColor kSelectedTextColor = | 34 static const SkColor kSelectedTextColor = |
| 35 color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); | 35 color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); |
| 36 static const SkColor kDimTextColor = | 36 static const SkColor kDimTextColor = |
| 37 color_utils::GetSysSkColor(COLOR_GRAYTEXT); | 37 color_utils::GetSysSkColor(COLOR_GRAYTEXT); |
| 38 static const SkColor kSelectedDimTextColor = | 38 static const SkColor kSelectedDimTextColor = |
| 39 color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); | 39 color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT); |
| 40 static const SkColor kStandardURLColor = SkColorSetRGB(0, 0x80, 0); | 40 static const SkColor kStandardURLColor = SkColorSetRGB(0, 0x80, 0); |
| 41 static const SkColor kHighlightURLColor = SkColorSetRGB(0xD0, 0xFF, 0xD0); | 41 static const SkColor kHighlightURLColor = SkColorSetRGB(0xD0, 0xFF, 0xD0); |
| 42 static const int kPopupTransparency = 235; | 42 static const int kGlassPopupTransparency = 240; |
|
Peter Kasting
2009/05/12 22:17:42
I don't understand. Why did you make this 240? 2
| |
| 43 static const int kOpaquePopupTransparency = 255; | |
| 43 static const int kHoverRowAlpha = 0x40; | 44 static const int kHoverRowAlpha = 0x40; |
| 44 // The minimum distance between the top and bottom of the icon and the top or | 45 // The minimum distance between the top and bottom of the icon and the top or |
| 45 // bottom of the row. "Minimum" is used because the vertical padding may be | 46 // bottom of the row. "Minimum" is used because the vertical padding may be |
| 46 // larger, depending on the size of the text. | 47 // larger, depending on the size of the text. |
| 47 static const int kIconVerticalPadding = 2; | 48 static const int kIconVerticalPadding = 2; |
| 48 // The minimum distance between the top and bottom of the text and the top or | 49 // The minimum distance between the top and bottom of the text and the top or |
| 49 // bottom of the row. See comment about the use of "minimum" for | 50 // bottom of the row. See comment about the use of "minimum" for |
| 50 // kIconVerticalPadding. | 51 // kIconVerticalPadding. |
| 51 static const int kTextVerticalPadding = 3; | 52 static const int kTextVerticalPadding = 3; |
| 52 // The padding at the left edge of the row, left of the icon. | 53 // The padding at the left edge of the row, left of the icon. |
| 53 static const int kRowLeftPadding = 6; | 54 static const int kRowLeftPadding = 6; |
| 54 // The padding on the right edge of the row, right of the text. | 55 // The padding on the right edge of the row, right of the text. |
| 55 static const int kRowRightPadding = 3; | 56 static const int kRowRightPadding = 3; |
| 56 // The horizontal distance between the right edge of the icon and the left edge | 57 // The horizontal distance between the right edge of the icon and the left edge |
| 57 // of the text. | 58 // of the text. |
| 58 static const int kIconTextSpacing = 9; | 59 static const int kIconTextSpacing = 9; |
| 60 // The size delta between the font used for the edit and the result rows. Passed | |
| 61 // to ChromeFont::DeriveFont. | |
| 62 static const int kEditFontAdjust = -1; | |
| 59 | 63 |
| 60 class AutocompleteResultView : public views::View { | 64 class AutocompleteResultView : public views::View { |
| 61 public: | 65 public: |
| 62 AutocompleteResultView(AutocompleteResultViewModel* model, | 66 AutocompleteResultView(AutocompleteResultViewModel* model, |
| 63 int model_index, | 67 int model_index, |
| 64 const ChromeFont& font); | 68 const ChromeFont& font); |
| 65 virtual ~AutocompleteResultView(); | 69 virtual ~AutocompleteResultView(); |
| 66 | 70 |
| 67 // Overridden from views::View: | 71 // Overridden from views::View: |
| 68 virtual void Paint(ChromeCanvas* canvas); | 72 virtual void Paint(ChromeCanvas* canvas); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 AutocompletePopupContentsView::AutocompletePopupContentsView( | 647 AutocompletePopupContentsView::AutocompletePopupContentsView( |
| 644 const ChromeFont& font, | 648 const ChromeFont& font, |
| 645 AutocompleteEditViewWin* edit_view, | 649 AutocompleteEditViewWin* edit_view, |
| 646 AutocompleteEditModel* edit_model, | 650 AutocompleteEditModel* edit_model, |
| 647 Profile* profile, | 651 Profile* profile, |
| 648 AutocompletePopupPositioner* popup_positioner) | 652 AutocompletePopupPositioner* popup_positioner) |
| 649 : popup_(new AutocompletePopupWin(this)), | 653 : popup_(new AutocompletePopupWin(this)), |
| 650 model_(new AutocompletePopupModel(this, edit_model, profile)), | 654 model_(new AutocompletePopupModel(this, edit_model, profile)), |
| 651 edit_view_(edit_view), | 655 edit_view_(edit_view), |
| 652 popup_positioner_(popup_positioner), | 656 popup_positioner_(popup_positioner), |
| 653 edit_font_(font) { | 657 result_font_(font.DeriveFont(kEditFontAdjust)) { |
| 654 set_border(new PopupBorder); | 658 set_border(new PopupBorder); |
| 655 } | 659 } |
| 656 | 660 |
| 657 void AutocompletePopupContentsView::UpdateResultViewsFromResult( | 661 void AutocompletePopupContentsView::UpdateResultViewsFromResult( |
| 658 const AutocompleteResult& result) { | 662 const AutocompleteResult& result) { |
| 659 RemoveAllChildViews(true); | 663 RemoveAllChildViews(true); |
| 660 for (size_t i = 0; i < result.size(); ++i) | 664 for (size_t i = 0; i < result.size(); ++i) |
| 661 AddChildView(new AutocompleteResultView(this, i, edit_font_)); | 665 AddChildView(new AutocompleteResultView(this, i, result_font_)); |
| 662 Layout(); | 666 Layout(); |
| 663 } | 667 } |
| 664 | 668 |
| 665 gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const { | 669 gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const { |
| 666 gfx::Insets insets; | 670 gfx::Insets insets; |
| 667 border()->GetInsets(&insets); | 671 border()->GetInsets(&insets); |
| 668 gfx::Rect contents_bounds = popup_positioner_->GetPopupBounds(); | 672 gfx::Rect contents_bounds = popup_positioner_->GetPopupBounds(); |
| 669 int child_count = GetChildViewCount(); | 673 int child_count = GetChildViewCount(); |
| 670 int height = 0; | 674 int height = 0; |
| 671 for (int i = 0; i < child_count; ++i) | 675 for (int i = 0; i < child_count; ++i) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 ScopedGDIObject<HRGN> popup_region; | 851 ScopedGDIObject<HRGN> popup_region; |
| 848 popup_region.Set(contents_path.CreateHRGN()); | 852 popup_region.Set(contents_path.CreateHRGN()); |
| 849 bb.hRgnBlur = popup_region.Get(); | 853 bb.hRgnBlur = popup_region.Get(); |
| 850 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); | 854 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); |
| 851 } | 855 } |
| 852 | 856 |
| 853 void AutocompletePopupContentsView::MakeCanvasTransparent( | 857 void AutocompletePopupContentsView::MakeCanvasTransparent( |
| 854 ChromeCanvas* canvas) { | 858 ChromeCanvas* canvas) { |
| 855 // Allow the window blur effect to show through the popup background. | 859 // Allow the window blur effect to show through the popup background. |
| 856 SkPaint paint; | 860 SkPaint paint; |
| 857 paint.setColor(SkColorSetARGB(kPopupTransparency, 255, 255, 255)); | 861 SkColor transparency = win_util::ShouldUseVistaFrame() ? |
| 862 kGlassPopupTransparency : kOpaquePopupTransparency; | |
| 863 paint.setColor(SkColorSetARGB(transparency, 255, 255, 255)); | |
| 858 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); | 864 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); |
| 859 paint.setStyle(SkPaint::kFill_Style); | 865 paint.setStyle(SkPaint::kFill_Style); |
| 860 canvas->FillRectInt(0, 0, canvas->getDevice()->width(), | 866 canvas->FillRectInt(0, 0, canvas->getDevice()->width(), |
| 861 canvas->getDevice()->height(), paint); | 867 canvas->getDevice()->height(), paint); |
| 862 } | 868 } |
| OLD | NEW |