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 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chromeos/dbus/ibus/ibus_lookup_table.h" | 10 #include "chromeos/ime/candidate_window.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Font; | 14 class Font; |
15 } | 15 } |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 class IBusLookupTable; | |
19 namespace input_method { | 18 namespace input_method { |
20 | 19 |
21 class CandidateView; | 20 class CandidateView; |
| 21 class CandidateWindow; |
22 class HidableArea; | 22 class HidableArea; |
23 class InformationTextArea; | 23 class InformationTextArea; |
24 | 24 |
25 // CandidateWindowView is the main container of the candidate window UI. | 25 // CandidateWindowView is the main container of the candidate window UI. |
26 class CandidateWindowView : public views::View { | 26 class CandidateWindowView : public views::View { |
27 public: | 27 public: |
28 // The object can be monitored by the observer. | 28 // The object can be monitored by the observer. |
29 class Observer { | 29 class Observer { |
30 public: | 30 public: |
31 virtual ~Observer() {} | 31 virtual ~Observer() {} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void UpdateAuxiliaryText(const std::string& utf8_text); | 90 void UpdateAuxiliaryText(const std::string& utf8_text); |
91 | 91 |
92 // Updates the preedit text. | 92 // Updates the preedit text. |
93 void UpdatePreeditText(const std::string& utf8_text); | 93 void UpdatePreeditText(const std::string& utf8_text); |
94 | 94 |
95 // Returns true if we should update candidate views in the window. For | 95 // Returns true if we should update candidate views in the window. For |
96 // instance, if we are going to show the same candidates as before, we | 96 // instance, if we are going to show the same candidates as before, we |
97 // don't have to update candidate views. This happens when the user just | 97 // don't have to update candidate views. This happens when the user just |
98 // moves the cursor in the same page in the candidate window. | 98 // moves the cursor in the same page in the candidate window. |
99 static bool ShouldUpdateCandidateViews( | 99 static bool ShouldUpdateCandidateViews( |
100 const IBusLookupTable& old_table, | 100 const CandidateWindow& old_candidate_window, |
101 const IBusLookupTable& new_table); | 101 const CandidateWindow& new_candidate_window); |
102 | 102 |
103 // Updates candidates of the candidate window from |lookup_table|. | 103 // Updates candidates of the candidate window from |candidate_window|. |
104 // Candidates are arranged per |orientation|. | 104 // Candidates are arranged per |orientation|. |
105 void UpdateCandidates(const IBusLookupTable& lookup_table); | 105 void UpdateCandidates(const CandidateWindow& candidate_window); |
106 | 106 |
107 // Resizes and moves the parent frame. The two actions should be | 107 // Resizes and moves the parent frame. The two actions should be |
108 // performed consecutively as resizing may require the candidate window | 108 // performed consecutively as resizing may require the candidate window |
109 // to move. For instance, we may need to move the candidate window from | 109 // to move. For instance, we may need to move the candidate window from |
110 // below the cursor to above the cursor, if the candidate window becomes | 110 // below the cursor to above the cursor, if the candidate window becomes |
111 // too big to be shown near the bottom of the screen. This function | 111 // too big to be shown near the bottom of the screen. This function |
112 // needs to be called when the visible contents of the candidate window | 112 // needs to be called when the visible contents of the candidate window |
113 // are modified. | 113 // are modified. |
114 void ResizeAndMoveParentFrame(); | 114 void ResizeAndMoveParentFrame(); |
115 | 115 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 148 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
149 | 149 |
150 private: | 150 private: |
151 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, | 151 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, |
152 UpdateCandidatesTest_CursorVisibility); | 152 UpdateCandidatesTest_CursorVisibility); |
153 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest); | 153 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest); |
154 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, | 154 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, |
155 DoNotChangeRowHeightWithLabelSwitchTest); | 155 DoNotChangeRowHeightWithLabelSwitchTest); |
156 | 156 |
157 // Initializes the candidate views if needed. | 157 // Initializes the candidate views if needed. |
158 void MaybeInitializeCandidateViews(const IBusLookupTable& lookup_table); | 158 void MaybeInitializeCandidateViews(const CandidateWindow& candidate_window); |
159 | 159 |
160 // Returns the appropriate area (header or footer) to put auxiliary texts. | 160 // Returns the appropriate area (header or footer) to put auxiliary texts. |
161 InformationTextArea* GetAuxiliaryTextArea(); | 161 InformationTextArea* GetAuxiliaryTextArea(); |
162 | 162 |
163 // Returns true if the candidate window is open. The suggestion window does | 163 // Returns true if the candidate window is open. The suggestion window does |
164 // not count as the candidate window. | 164 // not count as the candidate window. |
165 bool IsCandidateWindowOpen() const; | 165 bool IsCandidateWindowOpen() const; |
166 | 166 |
167 // Notifies observers if the candidate window's opened/closed state has | 167 // Notifies observers if the candidate window's opened/closed state has |
168 // changed from the previous call to this function. | 168 // changed from the previous call to this function. |
169 void NotifyIfCandidateWindowOpenedOrClosed(); | 169 void NotifyIfCandidateWindowOpenedOrClosed(); |
170 | 170 |
171 // The lookup table (candidates). | 171 // The candidate window. |
172 IBusLookupTable lookup_table_; | 172 CandidateWindow candidate_window_; |
173 | 173 |
174 // The index in the current page of the candidate currently being selected. | 174 // The index in the current page of the candidate currently being selected. |
175 int selected_candidate_index_in_page_; | 175 int selected_candidate_index_in_page_; |
176 | 176 |
177 // The observers of the object. | 177 // The observers of the object. |
178 ObserverList<Observer> observers_; | 178 ObserverList<Observer> observers_; |
179 | 179 |
180 // The parent frame. | 180 // The parent frame. |
181 views::Widget* parent_frame_; | 181 views::Widget* parent_frame_; |
182 | 182 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // if should be, shows parent_frame and if not, hides parent_frame. | 227 // if should be, shows parent_frame and if not, hides parent_frame. |
228 void UpdateParentArea(); | 228 void UpdateParentArea(); |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView); | 230 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace input_method | 233 } // namespace input_method |
234 } // namespace chromeos | 234 } // namespace chromeos |
235 | 235 |
236 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ | 236 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_ |
OLD | NEW |