| 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/gtk/autofill/autofill_popup_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 controller_->Hide(); | 110 controller_->Hide(); |
| 111 return FALSE; | 111 return FALSE; |
| 112 } | 112 } |
| 113 | 113 |
| 114 gboolean AutofillPopupViewGtk::HandleButtonRelease(GtkWidget* widget, | 114 gboolean AutofillPopupViewGtk::HandleButtonRelease(GtkWidget* widget, |
| 115 GdkEventButton* event) { | 115 GdkEventButton* event) { |
| 116 // We only care about the left click. | 116 // We only care about the left click. |
| 117 if (event->button != 1) | 117 if (event->button != 1) |
| 118 return FALSE; | 118 return FALSE; |
| 119 | 119 |
| 120 controller_->MouseClicked(event->x, event->y); | 120 controller_->PointPreselected(event->x, event->y); |
| 121 return TRUE; | 121 return TRUE; |
| 122 } | 122 } |
| 123 | 123 |
| 124 gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget, | 124 gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget, |
| 125 GdkEventExpose* event) { | 125 GdkEventExpose* event) { |
| 126 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget))); | 126 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget))); |
| 127 gdk_cairo_rectangle(cr, &event->area); | 127 gdk_cairo_rectangle(cr, &event->area); |
| 128 cairo_clip(cr); | 128 cairo_clip(cr); |
| 129 | 129 |
| 130 // This assert is kinda ugly, but it would be more currently unneeded work | 130 // This assert is kinda ugly, but it would be more currently unneeded work |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 DrawAutofillEntry(cr, i, line_rect); | 151 DrawAutofillEntry(cr, i, line_rect); |
| 152 } | 152 } |
| 153 | 153 |
| 154 cairo_destroy(cr); | 154 cairo_destroy(cr); |
| 155 | 155 |
| 156 return TRUE; | 156 return TRUE; |
| 157 } | 157 } |
| 158 | 158 |
| 159 gboolean AutofillPopupViewGtk::HandleLeave(GtkWidget* widget, | 159 gboolean AutofillPopupViewGtk::HandleLeave(GtkWidget* widget, |
| 160 GdkEventCrossing* event) { | 160 GdkEventCrossing* event) { |
| 161 controller_->MouseExitedPopup(); | 161 controller_->PreselectionCleared(); |
| 162 | 162 |
| 163 return FALSE; | 163 return FALSE; |
| 164 } | 164 } |
| 165 | 165 |
| 166 gboolean AutofillPopupViewGtk::HandleMotion(GtkWidget* widget, | 166 gboolean AutofillPopupViewGtk::HandleMotion(GtkWidget* widget, |
| 167 GdkEventMotion* event) { | 167 GdkEventMotion* event) { |
| 168 controller_->MouseHovered(event->x, event->y); | 168 controller_->PointPreselected(event->x, event->y); |
| 169 | 169 |
| 170 return TRUE; | 170 return TRUE; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void AutofillPopupViewGtk::SetUpLayout() { | 173 void AutofillPopupViewGtk::SetUpLayout() { |
| 174 pango_layout_set_width(layout_, window_->allocation.width * PANGO_SCALE); | 174 pango_layout_set_width(layout_, window_->allocation.width * PANGO_SCALE); |
| 175 pango_layout_set_height(layout_, window_->allocation.height * PANGO_SCALE); | 175 pango_layout_set_height(layout_, window_->allocation.height * PANGO_SCALE); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void AutofillPopupViewGtk::SetLayoutText(const string16& text, | 178 void AutofillPopupViewGtk::SetLayoutText(const string16& text, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 205 cairo_line_to(cairo_context, | 205 cairo_line_to(cairo_context, |
| 206 separator_rect.width(), | 206 separator_rect.width(), |
| 207 separator_rect.y() + separator_rect.height()); | 207 separator_rect.y() + separator_rect.height()); |
| 208 cairo_stroke(cairo_context); | 208 cairo_stroke(cairo_context); |
| 209 cairo_restore(cairo_context); | 209 cairo_restore(cairo_context); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context, | 212 void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context, |
| 213 size_t index, | 213 size_t index, |
| 214 const gfx::Rect& entry_rect) { | 214 const gfx::Rect& entry_rect) { |
| 215 if (controller_->selected_line() == static_cast<int>(index)) { | 215 if (controller_->preselected_line() == static_cast<int>(index)) { |
| 216 gdk_cairo_set_source_color(cairo_context, &kHoveredBackgroundColor); | 216 gdk_cairo_set_source_color(cairo_context, &kHoveredBackgroundColor); |
| 217 cairo_rectangle(cairo_context, entry_rect.x(), entry_rect.y(), | 217 cairo_rectangle(cairo_context, entry_rect.x(), entry_rect.y(), |
| 218 entry_rect.width(), entry_rect.height()); | 218 entry_rect.width(), entry_rect.height()); |
| 219 cairo_fill(cairo_context); | 219 cairo_fill(cairo_context); |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Draw the value. | 222 // Draw the value. |
| 223 SetLayoutText(controller_->names()[index], | 223 SetLayoutText(controller_->names()[index], |
| 224 controller_->GetNameFontForRow(index), | 224 controller_->GetNameFontForRow(index), |
| 225 controller_->IsWarning(index) ? kWarningColor : kNameColor); | 225 controller_->IsWarning(index) ? kWarningColor : kNameColor); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 pango_cairo_show_layout(cairo_context, layout_); | 285 pango_cairo_show_layout(cairo_context, layout_); |
| 286 cairo_restore(cairo_context); | 286 cairo_restore(cairo_context); |
| 287 } | 287 } |
| 288 | 288 |
| 289 AutofillPopupView* AutofillPopupView::Create( | 289 AutofillPopupView* AutofillPopupView::Create( |
| 290 AutofillPopupController* controller) { | 290 AutofillPopupController* controller) { |
| 291 return new AutofillPopupViewGtk(controller); | 291 return new AutofillPopupViewGtk(controller); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace autofill | 294 } // namespace autofill |
| OLD | NEW |