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_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_ |
7 | 7 |
8 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" | 8 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" | 12 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" |
13 #include "chrome/browser/chromeos/input_method/ibus_controller.h" | 13 #include "chrome/browser/chromeos/input_method/ibus_controller.h" |
14 #include "chrome/browser/chromeos/input_method/infolist_window_view.h" | 14 #include "chrome/browser/chromeos/input_method/infolist_window_view.h" |
15 #include "chromeos/dbus/ibus/ibus_panel_service.h" | 15 #include "chromeos/dbus/ibus/ibus_panel_service.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 class Widget; | 18 class Widget; |
19 } // namespace views | 19 } // namespace views |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 // TODO(nona): remove ibus namespace | |
23 namespace ibus { | |
24 class IBusLookupTable; | 22 class IBusLookupTable; |
25 } // namespace ibus | 23 |
26 namespace input_method { | 24 namespace input_method { |
27 | 25 |
28 class DelayableWidget; | 26 class DelayableWidget; |
29 | 27 |
30 // The implementation of CandidateWindowController. | 28 // The implementation of CandidateWindowController. |
31 // CandidateWindowController controls the CandidateWindow. | 29 // CandidateWindowController controls the CandidateWindow. |
32 class CandidateWindowControllerImpl | 30 class CandidateWindowControllerImpl |
33 : public CandidateWindowController, | 31 : public CandidateWindowController, |
34 public CandidateWindowView::Observer, | 32 public CandidateWindowView::Observer, |
35 public ibus::IBusPanelCandidateWindowHandlerInterface, | 33 public IBusPanelCandidateWindowHandlerInterface, |
36 public IBusController::Observer { | 34 public IBusController::Observer { |
37 public: | 35 public: |
38 CandidateWindowControllerImpl(); | 36 CandidateWindowControllerImpl(); |
39 virtual ~CandidateWindowControllerImpl(); | 37 virtual ~CandidateWindowControllerImpl(); |
40 | 38 |
41 // CandidateWindowController overrides: | 39 // CandidateWindowController overrides: |
42 virtual bool Init(IBusController* controller) OVERRIDE; | 40 virtual bool Init(IBusController* controller) OVERRIDE; |
43 virtual void Shutdown(IBusController* controller) OVERRIDE; | 41 virtual void Shutdown(IBusController* controller) OVERRIDE; |
44 virtual void AddObserver( | 42 virtual void AddObserver( |
45 CandidateWindowController::Observer* observer) OVERRIDE; | 43 CandidateWindowController::Observer* observer) OVERRIDE; |
46 virtual void RemoveObserver( | 44 virtual void RemoveObserver( |
47 CandidateWindowController::Observer* observer) OVERRIDE; | 45 CandidateWindowController::Observer* observer) OVERRIDE; |
48 | 46 |
49 protected: | 47 protected: |
50 // Returns infolist window position. This function handles right or bottom | 48 // Returns infolist window position. This function handles right or bottom |
51 // position overflow. Usually, infolist window is clipped with right-top of | 49 // position overflow. Usually, infolist window is clipped with right-top of |
52 // candidate window, but the position should be changed based on position | 50 // candidate window, but the position should be changed based on position |
53 // overflow. If right of infolist window is out of screen, infolist window is | 51 // overflow. If right of infolist window is out of screen, infolist window is |
54 // shown left-top of candidate window. If bottom of infolist window is out of | 52 // shown left-top of candidate window. If bottom of infolist window is out of |
55 // screen, infolist window is shown with clipping to bottom of screen. | 53 // screen, infolist window is shown with clipping to bottom of screen. |
56 // Infolist window does not overflow top and left direction. | 54 // Infolist window does not overflow top and left direction. |
57 static gfx::Point GetInfolistWindowPosition( | 55 static gfx::Point GetInfolistWindowPosition( |
58 const gfx::Rect& candidate_window_rect, | 56 const gfx::Rect& candidate_window_rect, |
59 const gfx::Rect& screen_rect, | 57 const gfx::Rect& screen_rect, |
60 const gfx::Size& infolist_winodw_size); | 58 const gfx::Size& infolist_winodw_size); |
61 | 59 |
62 // Converts |lookup_table| to infolist entries. |focused_index| become | 60 // Converts |lookup_table| to infolist entries. |focused_index| become |
63 // InfolistWindowView::InvalidFocusIndex if there is no selected entries. | 61 // InfolistWindowView::InvalidFocusIndex if there is no selected entries. |
64 static void ConvertLookupTableToInfolistEntry( | 62 static void ConvertLookupTableToInfolistEntry( |
65 const ibus::IBusLookupTable& lookup_table, | 63 const IBusLookupTable& lookup_table, |
66 std::vector<InfolistWindowView::Entry>* infolist_entries, | 64 std::vector<InfolistWindowView::Entry>* infolist_entries, |
67 size_t* focused_index); | 65 size_t* focused_index); |
68 | 66 |
69 // Returns true if given |new_entries| is different from |old_entries| and | 67 // Returns true if given |new_entries| is different from |old_entries| and |
70 // should update current window. | 68 // should update current window. |
71 static bool ShouldUpdateInfolist( | 69 static bool ShouldUpdateInfolist( |
72 const std::vector<InfolistWindowView::Entry>& old_entries, | 70 const std::vector<InfolistWindowView::Entry>& old_entries, |
73 size_t old_focused_index, | 71 size_t old_focused_index, |
74 const std::vector<InfolistWindowView::Entry>& new_entries, | 72 const std::vector<InfolistWindowView::Entry>& new_entries, |
75 size_t new_focused_index); | 73 size_t new_focused_index); |
76 | 74 |
77 private: | 75 private: |
78 // CandidateWindowView::Observer implementation. | 76 // CandidateWindowView::Observer implementation. |
79 virtual void OnCandidateCommitted(int index, int button, int flags) OVERRIDE; | 77 virtual void OnCandidateCommitted(int index, int button, int flags) OVERRIDE; |
80 virtual void OnCandidateWindowOpened() OVERRIDE; | 78 virtual void OnCandidateWindowOpened() OVERRIDE; |
81 virtual void OnCandidateWindowClosed() OVERRIDE; | 79 virtual void OnCandidateWindowClosed() OVERRIDE; |
82 | 80 |
83 // Creates the candidate window view. | 81 // Creates the candidate window view. |
84 void CreateView(); | 82 void CreateView(); |
85 | 83 |
86 // ibus::IBusPanelCandidateWindowHandlerInterface overrides. | 84 // IBusPanelCandidateWindowHandlerInterface overrides. |
87 virtual void HideAuxiliaryText() OVERRIDE; | 85 virtual void HideAuxiliaryText() OVERRIDE; |
88 virtual void HideLookupTable() OVERRIDE; | 86 virtual void HideLookupTable() OVERRIDE; |
89 virtual void HidePreeditText() OVERRIDE; | 87 virtual void HidePreeditText() OVERRIDE; |
90 virtual void SetCursorLocation(const ibus::Rect& cursor_position, | 88 virtual void SetCursorLocation(const ibus::Rect& cursor_position, |
91 const ibus::Rect& composition_head) OVERRIDE; | 89 const ibus::Rect& composition_head) OVERRIDE; |
92 virtual void UpdateAuxiliaryText(const std::string& utf8_text, | 90 virtual void UpdateAuxiliaryText(const std::string& utf8_text, |
93 bool visible) OVERRIDE; | 91 bool visible) OVERRIDE; |
94 virtual void UpdateLookupTable(const ibus::IBusLookupTable& lookup_table, | 92 virtual void UpdateLookupTable(const IBusLookupTable& lookup_table, |
95 bool visible) OVERRIDE; | 93 bool visible) OVERRIDE; |
96 virtual void UpdatePreeditText(const std::string& utf8_text, | 94 virtual void UpdatePreeditText(const std::string& utf8_text, |
97 unsigned int cursor, bool visible) OVERRIDE; | 95 unsigned int cursor, bool visible) OVERRIDE; |
98 | 96 |
99 // IBusController::Observer override | 97 // IBusController::Observer override |
100 virtual void PropertyChanged() OVERRIDE; | 98 virtual void PropertyChanged() OVERRIDE; |
101 virtual void OnConnected() OVERRIDE; | 99 virtual void OnConnected() OVERRIDE; |
102 virtual void OnDisconnected() OVERRIDE; | 100 virtual void OnDisconnected() OVERRIDE; |
103 | 101 |
104 // Updates infolist bounds, if current bounds is up-to-date, this function | 102 // Updates infolist bounds, if current bounds is up-to-date, this function |
(...skipping 18 matching lines...) Expand all Loading... |
123 | 121 |
124 ObserverList<CandidateWindowController::Observer> observers_; | 122 ObserverList<CandidateWindowController::Observer> observers_; |
125 | 123 |
126 DISALLOW_COPY_AND_ASSIGN(CandidateWindowControllerImpl); | 124 DISALLOW_COPY_AND_ASSIGN(CandidateWindowControllerImpl); |
127 }; | 125 }; |
128 | 126 |
129 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL
_H_ | 127 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL
_H_ |
130 | 128 |
131 } // namespace input_method | 129 } // namespace input_method |
132 } // namespace chromeos | 130 } // namespace chromeos |
OLD | NEW |