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