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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
| 14 #include "app/animation_delegate.h" |
14 #include "app/gtk_signal.h" | 15 #include "app/gtk_signal.h" |
15 #include "app/gtk_signal_registrar.h" | 16 #include "app/gtk_signal_registrar.h" |
16 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
17 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
19 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
20 #include "chrome/browser/gtk/owned_widget_gtk.h" | 21 #include "chrome/browser/gtk/owned_widget_gtk.h" |
21 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 22 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
22 #include "chrome/common/notification_observer.h" | 23 #include "chrome/common/notification_observer.h" |
23 #include "chrome/common/notification_registrar.h" | 24 #include "chrome/common/notification_registrar.h" |
24 #include "chrome/common/page_transition_types.h" | 25 #include "chrome/common/page_transition_types.h" |
25 #include "gfx/rect.h" | 26 #include "gfx/rect.h" |
26 #include "webkit/glue/window_open_disposition.h" | 27 #include "webkit/glue/window_open_disposition.h" |
27 | 28 |
28 class AutocompleteEditController; | 29 class AutocompleteEditController; |
29 class AutocompleteEditModel; | 30 class AutocompleteEditModel; |
30 class AutocompletePopupView; | 31 class AutocompletePopupView; |
| 32 class MultiAnimation; |
31 class Profile; | 33 class Profile; |
32 class TabContents; | 34 class TabContents; |
33 | 35 |
34 namespace gfx{ | 36 namespace gfx{ |
35 class Font; | 37 class Font; |
36 } | 38 } |
37 | 39 |
38 namespace views { | 40 namespace views { |
39 class View; | 41 class View; |
40 } | 42 } |
41 | 43 |
42 #if !defined(TOOLKIT_VIEWS) | 44 #if !defined(TOOLKIT_VIEWS) |
43 class GtkThemeProvider; | 45 class GtkThemeProvider; |
44 #endif | 46 #endif |
45 | 47 |
46 class AutocompleteEditViewGtk : public AutocompleteEditView, | 48 class AutocompleteEditViewGtk : public AutocompleteEditView, |
47 public NotificationObserver { | 49 public NotificationObserver, |
| 50 public AnimationDelegate { |
48 public: | 51 public: |
49 // Modeled like the Windows CHARRANGE. Represent a pair of cursor position | 52 // Modeled like the Windows CHARRANGE. Represent a pair of cursor position |
50 // offsets. Since GtkTextIters are invalid after the buffer is changed, we | 53 // offsets. Since GtkTextIters are invalid after the buffer is changed, we |
51 // work in character offsets (not bytes). | 54 // work in character offsets (not bytes). |
52 struct CharRange { | 55 struct CharRange { |
53 CharRange() : cp_min(0), cp_max(0) { } | 56 CharRange() : cp_min(0), cp_max(0) { } |
54 CharRange(int n, int x) : cp_min(n), cp_max(x) { } | 57 CharRange(int n, int x) : cp_min(n), cp_max(x) { } |
55 | 58 |
56 // Returns the start/end of the selection. | 59 // Returns the start/end of the selection. |
57 int selection_min() const { return std::min(cp_min, cp_max); } | 60 int selection_min() const { return std::min(cp_min, cp_max); } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual void OnBeforePossibleChange(); | 142 virtual void OnBeforePossibleChange(); |
140 virtual bool OnAfterPossibleChange(); | 143 virtual bool OnAfterPossibleChange(); |
141 virtual gfx::NativeView GetNativeView() const; | 144 virtual gfx::NativeView GetNativeView() const; |
142 virtual CommandUpdater* GetCommandUpdater(); | 145 virtual CommandUpdater* GetCommandUpdater(); |
143 | 146 |
144 // Overridden from NotificationObserver: | 147 // Overridden from NotificationObserver: |
145 virtual void Observe(NotificationType type, | 148 virtual void Observe(NotificationType type, |
146 const NotificationSource& source, | 149 const NotificationSource& source, |
147 const NotificationDetails& details); | 150 const NotificationDetails& details); |
148 | 151 |
| 152 // Overridden from AnimationDelegate. |
| 153 virtual void AnimationEnded(const Animation* animation); |
| 154 virtual void AnimationProgressed(const Animation* animation); |
| 155 virtual void AnimationCanceled(const Animation* animation); |
| 156 |
| 157 // Sets the colors of the text view according to the theme. |
149 void SetBaseColor(); | 158 void SetBaseColor(); |
| 159 // Sets the colors of the instant suggestion view according to the theme and |
| 160 // the animation state. |
| 161 void UpdateInstantViewColors(); |
150 | 162 |
151 void SetInstantSuggestion(const std::string& suggestion); | 163 void SetInstantSuggestion(const std::string& suggestion); |
152 bool CommitInstantSuggestion(); | 164 bool CommitInstantSuggestion(); |
153 | 165 |
154 // Used by LocationBarViewGtk to inform AutocompleteEditViewGtk if the tab to | 166 // Used by LocationBarViewGtk to inform AutocompleteEditViewGtk if the tab to |
155 // search should be enabled or not. See the comment of |enable_tab_to_search_| | 167 // search should be enabled or not. See the comment of |enable_tab_to_search_| |
156 // for details. | 168 // for details. |
157 void set_enable_tab_to_search(bool enable) { | 169 void set_enable_tab_to_search(bool enable) { |
158 enable_tab_to_search_ = enable; | 170 enable_tab_to_search_ = enable; |
159 } | 171 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 GtkTextTag* secure_scheme_tag_; | 354 GtkTextTag* secure_scheme_tag_; |
343 GtkTextTag* security_error_scheme_tag_; | 355 GtkTextTag* security_error_scheme_tag_; |
344 GtkTextTag* normal_text_tag_; | 356 GtkTextTag* normal_text_tag_; |
345 | 357 |
346 // Objects for the instant suggestion text view. | 358 // Objects for the instant suggestion text view. |
347 GtkTextTag* instant_anchor_tag_; | 359 GtkTextTag* instant_anchor_tag_; |
348 | 360 |
349 // A widget for displaying instant suggestion text. It'll be attached to a | 361 // A widget for displaying instant suggestion text. It'll be attached to a |
350 // child anchor in the |text_buffer_| object. | 362 // child anchor in the |text_buffer_| object. |
351 GtkWidget* instant_view_; | 363 GtkWidget* instant_view_; |
| 364 // Animation from instant suggest (faded text) to autocomplete (selected |
| 365 // text). |
| 366 scoped_ptr<MultiAnimation> instant_animation_; |
352 | 367 |
353 // A mark to split the content and the instant anchor. Wherever the end | 368 // A mark to split the content and the instant anchor. Wherever the end |
354 // iterator of the text buffer is required, the iterator to this mark should | 369 // iterator of the text buffer is required, the iterator to this mark should |
355 // be used. | 370 // be used. |
356 GtkTextMark* instant_mark_; | 371 GtkTextMark* instant_mark_; |
357 | 372 |
358 scoped_ptr<AutocompleteEditModel> model_; | 373 scoped_ptr<AutocompleteEditModel> model_; |
359 scoped_ptr<AutocompletePopupView> popup_view_; | 374 scoped_ptr<AutocompletePopupView> popup_view_; |
360 AutocompleteEditController* controller_; | 375 AutocompleteEditController* controller_; |
361 ToolbarModel* toolbar_model_; | 376 ToolbarModel* toolbar_model_; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // The view that is going to be focused next. Only valid while handling | 493 // The view that is going to be focused next. Only valid while handling |
479 // "focus-out" events. | 494 // "focus-out" events. |
480 GtkWidget* going_to_focus_; | 495 GtkWidget* going_to_focus_; |
481 | 496 |
482 GtkSignalRegistrar signals_; | 497 GtkSignalRegistrar signals_; |
483 | 498 |
484 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 499 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
485 }; | 500 }; |
486 | 501 |
487 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 502 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
OLD | NEW |