| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/autocomplete/autocomplete_edit_view_gtk.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/multi_animation.h" | |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 16 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 17 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 19 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 20 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 22 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
| 23 #include "chrome/browser/defaults.h" | 22 #include "chrome/browser/defaults.h" |
| 24 #include "chrome/browser/gtk/gtk_util.h" | 23 #include "chrome/browser/gtk/gtk_util.h" |
| 25 #include "chrome/browser/gtk/view_id_util.h" | 24 #include "chrome/browser/gtk/view_id_util.h" |
| 26 #include "chrome/browser/instant/instant_controller.h" | 25 #include "chrome/browser/instant/instant_controller.h" |
| 27 #include "chrome/browser/platform_util.h" | 26 #include "chrome/browser/platform_util.h" |
| 28 #include "chrome/browser/tab_contents/tab_contents.h" | 27 #include "chrome/browser/tab_contents/tab_contents.h" |
| 29 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 28 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 30 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
| 31 #include "gfx/color_utils.h" | 30 #include "gfx/color_utils.h" |
| 32 #include "gfx/font.h" | 31 #include "gfx/font.h" |
| 33 #include "gfx/gtk_util.h" | 32 #include "gfx/gtk_util.h" |
| 34 #include "gfx/skia_utils_gtk.h" | 33 #include "gfx/skia_utils_gtk.h" |
| 35 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
| 36 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 37 #include "net/base/escape.h" | 36 #include "net/base/escape.h" |
| 38 #include "third_party/undoview/undo_view.h" | 37 #include "third_party/undoview/undo_view.h" |
| 38 #include "ui/base/animation/multi_animation.h" |
| 39 | 39 |
| 40 #if defined(TOOLKIT_VIEWS) | 40 #if defined(TOOLKIT_VIEWS) |
| 41 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 41 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
| 42 #include "chrome/browser/views/location_bar/location_bar_view.h" | 42 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 43 #else | 43 #else |
| 44 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 44 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
| 45 #include "chrome/browser/gtk/gtk_theme_provider.h" | 45 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 46 #include "chrome/browser/gtk/location_bar_view_gtk.h" | 46 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 instant_mark_ = | 374 instant_mark_ = |
| 375 gtk_text_buffer_create_mark(text_buffer_, NULL, &start_iter, FALSE); | 375 gtk_text_buffer_create_mark(text_buffer_, NULL, &start_iter, FALSE); |
| 376 | 376 |
| 377 // Hooking up this handler after setting up above hacks for Instant view, so | 377 // Hooking up this handler after setting up above hacks for Instant view, so |
| 378 // that we won't filter out the special ZWP mark itself. | 378 // that we won't filter out the special ZWP mark itself. |
| 379 g_signal_connect(text_buffer_, "insert-text", | 379 g_signal_connect(text_buffer_, "insert-text", |
| 380 G_CALLBACK(&HandleInsertTextThunk), this); | 380 G_CALLBACK(&HandleInsertTextThunk), this); |
| 381 | 381 |
| 382 AdjustVerticalAlignmentOfInstantView(); | 382 AdjustVerticalAlignmentOfInstantView(); |
| 383 | 383 |
| 384 MultiAnimation::Parts parts; | 384 ui::MultiAnimation::Parts parts; |
| 385 parts.push_back(MultiAnimation::Part( | 385 parts.push_back(ui::MultiAnimation::Part( |
| 386 InstantController::kAutoCommitPauseTimeMS, Tween::ZERO)); | 386 InstantController::kAutoCommitPauseTimeMS, ui::Tween::ZERO)); |
| 387 parts.push_back(MultiAnimation::Part( | 387 parts.push_back(ui::MultiAnimation::Part( |
| 388 InstantController::kAutoCommitFadeInTimeMS, Tween::EASE_IN)); | 388 InstantController::kAutoCommitFadeInTimeMS, ui::Tween::EASE_IN)); |
| 389 instant_animation_.reset(new MultiAnimation(parts)); | 389 instant_animation_.reset(new ui::MultiAnimation(parts)); |
| 390 instant_animation_->set_continuous(false); | 390 instant_animation_->set_continuous(false); |
| 391 | 391 |
| 392 #if !defined(TOOLKIT_VIEWS) | 392 #if !defined(TOOLKIT_VIEWS) |
| 393 registrar_.Add(this, | 393 registrar_.Add(this, |
| 394 NotificationType::BROWSER_THEME_CHANGED, | 394 NotificationType::BROWSER_THEME_CHANGED, |
| 395 NotificationService::AllSources()); | 395 NotificationService::AllSources()); |
| 396 theme_provider_->InitThemesFor(this); | 396 theme_provider_->InitThemesFor(this); |
| 397 #else | 397 #else |
| 398 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe | 398 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe |
| 399 // themes. | 399 // themes. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 791 } |
| 792 | 792 |
| 793 void AutocompleteEditViewGtk::Observe(NotificationType type, | 793 void AutocompleteEditViewGtk::Observe(NotificationType type, |
| 794 const NotificationSource& source, | 794 const NotificationSource& source, |
| 795 const NotificationDetails& details) { | 795 const NotificationDetails& details) { |
| 796 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 796 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
| 797 | 797 |
| 798 SetBaseColor(); | 798 SetBaseColor(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void AutocompleteEditViewGtk::AnimationEnded(const Animation* animation) { | 801 void AutocompleteEditViewGtk::AnimationEnded(const ui::Animation* animation) { |
| 802 controller_->OnCommitSuggestedText(GetText()); | 802 controller_->OnCommitSuggestedText(GetText()); |
| 803 } | 803 } |
| 804 | 804 |
| 805 void AutocompleteEditViewGtk::AnimationProgressed(const Animation* animation) { | 805 void AutocompleteEditViewGtk::AnimationProgressed(const ui::Animation* animation
) { |
| 806 UpdateInstantViewColors(); | 806 UpdateInstantViewColors(); |
| 807 } | 807 } |
| 808 | 808 |
| 809 void AutocompleteEditViewGtk::AnimationCanceled(const Animation* animation) { | 809 void AutocompleteEditViewGtk::AnimationCanceled(const ui::Animation* animation)
{ |
| 810 UpdateInstantViewColors(); | 810 UpdateInstantViewColors(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void AutocompleteEditViewGtk::SetBaseColor() { | 813 void AutocompleteEditViewGtk::SetBaseColor() { |
| 814 #if defined(TOOLKIT_VIEWS) | 814 #if defined(TOOLKIT_VIEWS) |
| 815 bool use_gtk = false; | 815 bool use_gtk = false; |
| 816 #else | 816 #else |
| 817 bool use_gtk = theme_provider_->UseGtkTheme(); | 817 bool use_gtk = theme_provider_->UseGtkTheme(); |
| 818 #endif | 818 #endif |
| 819 | 819 |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 // baseline, so we need to move the |instant_view_| down to make sure it | 2149 // baseline, so we need to move the |instant_view_| down to make sure it |
| 2150 // has the same baseline as the |text_view_|. | 2150 // has the same baseline as the |text_view_|. |
| 2151 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); | 2151 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); |
| 2152 int height; | 2152 int height; |
| 2153 pango_layout_get_size(layout, NULL, &height); | 2153 pango_layout_get_size(layout, NULL, &height); |
| 2154 PangoLayoutIter* iter = pango_layout_get_iter(layout); | 2154 PangoLayoutIter* iter = pango_layout_get_iter(layout); |
| 2155 int baseline = pango_layout_iter_get_baseline(iter); | 2155 int baseline = pango_layout_iter_get_baseline(iter); |
| 2156 pango_layout_iter_free(iter); | 2156 pango_layout_iter_free(iter); |
| 2157 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); | 2157 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); |
| 2158 } | 2158 } |
| OLD | NEW |