| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_IME_CANDIDATE_WINDOW_VIEW_H_ | |
| 6 #define ASH_IME_CANDIDATE_WINDOW_VIEW_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ui/base/ime/candidate_window.h" | |
| 10 #include "ui/views/bubble/bubble_delegate.h" | |
| 11 #include "ui/views/controls/button/button.h" | |
| 12 | |
| 13 namespace ash { | |
| 14 namespace ime { | |
| 15 | |
| 16 class CandidateView; | |
| 17 class InformationTextArea; | |
| 18 | |
| 19 // CandidateWindowView is the main container of the candidate window UI. | |
| 20 class ASH_EXPORT CandidateWindowView : public views::BubbleDelegateView, | |
| 21 public views::ButtonListener { | |
| 22 public: | |
| 23 // The object can be monitored by the observer. | |
| 24 class Observer { | |
| 25 public: | |
| 26 virtual ~Observer() {} | |
| 27 // The function is called when a candidate is committed. | |
| 28 virtual void OnCandidateCommitted(int index) = 0; | |
| 29 }; | |
| 30 | |
| 31 explicit CandidateWindowView(gfx::NativeView parent); | |
| 32 ~CandidateWindowView() override; | |
| 33 views::Widget* InitWidget(); | |
| 34 | |
| 35 // Adds the given observer. The ownership is not transferred. | |
| 36 void AddObserver(Observer* observer) { | |
| 37 observers_.AddObserver(observer); | |
| 38 } | |
| 39 | |
| 40 // Removes the given observer. | |
| 41 void RemoveObserver(Observer* observer) { | |
| 42 observers_.RemoveObserver(observer); | |
| 43 } | |
| 44 | |
| 45 // Hides the lookup table. | |
| 46 void HideLookupTable(); | |
| 47 | |
| 48 // Hides the auxiliary text. | |
| 49 void HideAuxiliaryText(); | |
| 50 | |
| 51 // Hides the preedit text. | |
| 52 void HidePreeditText(); | |
| 53 | |
| 54 // Shows the lookup table. | |
| 55 void ShowLookupTable(); | |
| 56 | |
| 57 // Shows the auxiliary text. | |
| 58 void ShowAuxiliaryText(); | |
| 59 | |
| 60 // Shows the preedit text. | |
| 61 void ShowPreeditText(); | |
| 62 | |
| 63 // Updates the preedit text. | |
| 64 void UpdatePreeditText(const base::string16& text); | |
| 65 | |
| 66 // Updates candidates of the candidate window from |candidate_window|. | |
| 67 // Candidates are arranged per |orientation|. | |
| 68 void UpdateCandidates(const ui::CandidateWindow& candidate_window); | |
| 69 | |
| 70 void SetCursorBounds(const gfx::Rect& cursor_bounds, | |
| 71 const gfx::Rect& composition_head); | |
| 72 | |
| 73 private: | |
| 74 friend class CandidateWindowViewTest; | |
| 75 | |
| 76 // Overridden from views::ButtonListener: | |
| 77 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 78 | |
| 79 void SelectCandidateAt(int index_in_page); | |
| 80 void UpdateVisibility(); | |
| 81 | |
| 82 // Initializes the candidate views if needed. | |
| 83 void MaybeInitializeCandidateViews( | |
| 84 const ui::CandidateWindow& candidate_window); | |
| 85 | |
| 86 // The candidate window data model. | |
| 87 ui::CandidateWindow candidate_window_; | |
| 88 | |
| 89 // The index in the current page of the candidate currently being selected. | |
| 90 int selected_candidate_index_in_page_; | |
| 91 | |
| 92 // The observers of the object. | |
| 93 ObserverList<Observer> observers_; | |
| 94 | |
| 95 // Views created in the class will be part of tree of |this|, so these | |
| 96 // child views will be deleted when |this| is deleted. | |
| 97 InformationTextArea* auxiliary_text_; | |
| 98 InformationTextArea* preedit_; | |
| 99 views::View* candidate_area_; | |
| 100 | |
| 101 // The candidate views are used for rendering candidates. | |
| 102 std::vector<CandidateView*> candidate_views_; | |
| 103 | |
| 104 // Current columns size in |candidate_area_|. | |
| 105 gfx::Size previous_shortcut_column_size_; | |
| 106 gfx::Size previous_candidate_column_size_; | |
| 107 gfx::Size previous_annotation_column_size_; | |
| 108 | |
| 109 // The last cursor bounds. | |
| 110 gfx::Rect cursor_bounds_; | |
| 111 | |
| 112 // The last compostion head bounds. | |
| 113 gfx::Rect composition_head_bounds_; | |
| 114 | |
| 115 // True if the candidate window should be shown with aligning with composition | |
| 116 // text as opposed to the cursor. | |
| 117 bool should_show_at_composition_head_; | |
| 118 | |
| 119 // True if the candidate window should be shonw on the upper side of | |
| 120 // composition text. | |
| 121 bool should_show_upper_side_; | |
| 122 | |
| 123 // True if the candidate window was open. This is used to determine when to | |
| 124 // send OnCandidateWindowOpened and OnCandidateWindowClosed events. | |
| 125 bool was_candidate_window_open_; | |
| 126 | |
| 127 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView); | |
| 128 }; | |
| 129 | |
| 130 } // namespace ime | |
| 131 } // namespace ash | |
| 132 | |
| 133 #endif // ASH_IME_CANDIDATE_WINDOW_VIEW_H_ | |
| OLD | NEW |