OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MODE_INDICATOR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chromeos/ime/input_method_manager.h" | 9 #include "chromeos/ime/input_method_manager.h" |
10 | 10 #include "ui/gfx/rect.h" |
11 namespace gfx { | |
12 class Rect; | |
13 } // namespace gfx | |
14 | 11 |
15 namespace chromeos { | 12 namespace chromeos { |
16 namespace input_method { | 13 namespace input_method { |
17 | 14 |
18 class ModeIndicatorWidget; | 15 class ModeIndicatorObserver; |
19 | 16 |
20 // ModeIndicatorController is the controller of ModeIndicatiorWidget on the | 17 // ModeIndicatorController is the controller of ModeIndicatiorDelegateView |
21 // MVC model. | 18 // on the MVC model. |
22 class ModeIndicatorController | 19 class ModeIndicatorController |
23 : public InputMethodManager::Observer { | 20 : public InputMethodManager::Observer { |
24 public: | 21 public: |
25 // This class takes the ownership of |mi_widget|. | 22 // This class takes the ownership of |mi_widget|. |
26 explicit ModeIndicatorController(ModeIndicatorWidget* mi_widget); | 23 explicit ModeIndicatorController(InputMethodManager* imm); |
27 virtual ~ModeIndicatorController(); | 24 virtual ~ModeIndicatorController(); |
28 | 25 |
29 // Set cursor bounds, which is the base point to display this indicator. | 26 // Set cursor bounds, which is the base point to display this indicator. |
30 // Bacisally this indicator is displayed underneath the cursor. | 27 // Bacisally this indicator is displayed underneath the cursor. |
31 void SetCursorBounds(const gfx::Rect& cursor_location); | 28 void SetCursorBounds(const gfx::Rect& cursor_location); |
32 | 29 |
33 // Notify the focus state to the mode indicator. | 30 // Notify the focus state to the mode indicator. |
34 void FocusStateChanged(bool is_focused); | 31 void FocusStateChanged(bool is_focused); |
35 | 32 |
36 private: | 33 private: |
37 // InputMethodManager::Observer implementation. | 34 // InputMethodManager::Observer implementation. |
38 virtual void InputMethodChanged(InputMethodManager* manager, | 35 virtual void InputMethodChanged(InputMethodManager* manager, |
39 bool show_message) OVERRIDE; | 36 bool show_message) OVERRIDE; |
40 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE; | 37 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE; |
41 | 38 |
42 // Show the mode inidicator with the current ime's short name if all | 39 // Show the mode inidicator with the current ime's short name if all |
43 // the conditions are cleared. | 40 // the conditions are cleared. |
44 void ShowModeIndicator(InputMethodManager* manager); | 41 void ShowModeIndicator(); |
45 | 42 |
46 scoped_ptr<ModeIndicatorWidget> mi_widget_; | 43 InputMethodManager* imm_; |
| 44 |
| 45 // Cursor bounds representing the anchor rect of the mode indicator. |
| 46 gfx::Rect cursor_bounds_; |
47 | 47 |
48 // True on a text field is focused. | 48 // True on a text field is focused. |
49 bool is_focused_; | 49 bool is_focused_; |
50 | 50 |
| 51 // Observer of the widgets created by BubbleDelegateView. This is used to |
| 52 // close the previous widget when a new widget is created. |
| 53 scoped_ptr<ModeIndicatorObserver> mi_observer_; |
| 54 |
51 DISALLOW_COPY_AND_ASSIGN(ModeIndicatorController); | 55 DISALLOW_COPY_AND_ASSIGN(ModeIndicatorController); |
52 }; | 56 }; |
53 | 57 |
54 } // namespace input_method | 58 } // namespace input_method |
55 } // namespace chromeos | 59 } // namespace chromeos |
56 | 60 |
57 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_ | 61 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_ |
OLD | NEW |