diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 20:04:18 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 20:04:18 +0000 |
commit | 68f1df43323a3a81cd14ed0061e7c3578394d8fd (patch) | |
tree | 256f087178e5c7eb26c636c62fe77d3e38d9c3b6 /chrome/browser/autocomplete | |
parent | d1db1c33270fe5b744d4912167bf843fd1648c40 (diff) | |
download | chromium_src-68f1df43323a3a81cd14ed0061e7c3578394d8fd.zip chromium_src-68f1df43323a3a81cd14ed0061e7c3578394d8fd.tar.gz chromium_src-68f1df43323a3a81cd14ed0061e7c3578394d8fd.tar.bz2 |
[GTK] Added Support for DIM AutoComplete Match Classification specifiers.
BUG=55418
TEST=Type "yout" in the autocomplete and look for "youtube" in the
autocomplete popup. The letters "yout" should be dimmer than the
suggested letters "ube" which should be "normal".
patch by Sheridan Rawlins <scr [at] chromium [dot] org>
original review: http://codereview.chromium.org/3647004/show
Review URL: http://codereview.chromium.org/3770004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc | 32 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view_gtk.h | 4 |
2 files changed, 25 insertions, 11 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc index 5923ec5..5bb4f90 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc @@ -41,8 +41,6 @@ const GdkColor kHoveredBackgroundColor = GDK_COLOR_RGB(0xef, 0xf2, 0xfa); const GdkColor kContentTextColor = GDK_COLOR_RGB(0x00, 0x00, 0x00); const GdkColor kURLTextColor = GDK_COLOR_RGB(0x00, 0x88, 0x00); -const GdkColor kDescriptionTextColor = GDK_COLOR_RGB(0x80, 0x80, 0x80); -const GdkColor kDescriptionSelectedTextColor = GDK_COLOR_RGB(0x78, 0x82, 0xb1); // We have a 1 pixel border around the entire results popup. const int kBorderThickness = 1; @@ -115,6 +113,7 @@ void SetupLayoutForMatch(PangoLayout* layout, const std::wstring& text, AutocompleteMatch::ACMatchClassifications classifications, const GdkColor* base_color, + const GdkColor* dim_color, const GdkColor* url_color, const std::string& prefix_text) { // In RTL, mark text with left-to-right embedding mark if there is no strong @@ -175,6 +174,9 @@ void SetupLayoutForMatch(PangoLayout* layout, } } + if (i->style & ACMatchClassification::DIM) + color = dim_color; + PangoAttribute* fg_attr = pango_attr_foreground_new( color->red, color->green, color->blue); fg_attr->start_index = offset; @@ -389,8 +391,6 @@ void AutocompletePopupViewGtk::Observe(NotificationType type, url_text_color_ = NormalURLColor(content_text_color_); url_selected_text_color_ = SelectedURLColor(selected_content_text_color_, selected_background_color_); - description_text_color_ = content_text_color_; - description_selected_text_color_ = selected_content_text_color_; } else { border_color_ = kBorderColor; background_color_ = kBackgroundColor; @@ -401,10 +401,16 @@ void AutocompletePopupViewGtk::Observe(NotificationType type, selected_content_text_color_ = kContentTextColor; url_text_color_ = kURLTextColor; url_selected_text_color_ = kURLTextColor; - description_text_color_ = kDescriptionTextColor; - description_selected_text_color_ = kDescriptionSelectedTextColor; } + // Calculate dimmed colors. + content_dim_text_color_ = + gtk_util::AverageColors(content_text_color_, + background_color_); + selected_content_dim_text_color_ = + gtk_util::AverageColors(selected_content_text_color_, + selected_background_color_); + // Set the background color, so we don't need to paint it manually. gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, &background_color_); } @@ -600,7 +606,9 @@ gboolean AutocompletePopupViewGtk::HandleExpose(GtkWidget* widget, // Note: We force to URL to LTR for all text directions. SetupLayoutForMatch(layout_, match.contents, match.contents_class, is_selected ? &selected_content_text_color_ : - &content_text_color_, + &content_text_color_, + is_selected ? &selected_content_dim_text_color_ : + &content_dim_text_color_, is_selected ? &url_selected_text_color_ : &url_text_color_, std::string()); @@ -624,9 +632,15 @@ gboolean AutocompletePopupViewGtk::HandleExpose(GtkWidget* widget, if (has_description) { pango_layout_set_width(layout_, (text_width - actual_content_width) * PANGO_SCALE); + + // In Windows, a boolean "force_dim" is passed as true for the + // description. Here, we pass the dim text color for both normal and dim, + // to accomplish the same thing. SetupLayoutForMatch(layout_, match.description, match.description_class, - is_selected ? &description_selected_text_color_ : - &description_text_color_, + is_selected ? &selected_content_dim_text_color_ : + &content_dim_text_color_, + is_selected ? &selected_content_dim_text_color_ : + &content_dim_text_color_, is_selected ? &url_selected_text_color_ : &url_text_color_, std::string(" - ")); diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h index cae3798..53adbc2 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h +++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h @@ -118,10 +118,10 @@ class AutocompletePopupViewGtk : public AutocompletePopupView, GdkColor hovered_background_color_; GdkColor content_text_color_; GdkColor selected_content_text_color_; + GdkColor content_dim_text_color_; + GdkColor selected_content_dim_text_color_; GdkColor url_text_color_; GdkColor url_selected_text_color_; - GdkColor description_text_color_; - GdkColor description_selected_text_color_; // If the user cancels a dragging action (i.e. by pressing ESC), we don't have // a convenient way to release mouse capture. Instead we use this flag to |