Standardize usage of virtual/override/final specifiers.
[chromium-blink-merge.git] / ash / ime / candidate_window_view.h
blob99800f8efb831cebf220248cf5a6697b3df504b6
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.
5 #ifndef ASH_IME_CANDIDATE_WINDOW_VIEW_H_
6 #define ASH_IME_CANDIDATE_WINDOW_VIEW_H_
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"
13 namespace ash {
14 namespace ime {
16 class CandidateView;
17 class InformationTextArea;
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;
31 explicit CandidateWindowView(gfx::NativeView parent);
32 ~CandidateWindowView() override;
33 views::Widget* InitWidget();
35 // Adds the given observer. The ownership is not transferred.
36 void AddObserver(Observer* observer) {
37 observers_.AddObserver(observer);
40 // Removes the given observer.
41 void RemoveObserver(Observer* observer) {
42 observers_.RemoveObserver(observer);
45 // Hides the lookup table.
46 void HideLookupTable();
48 // Hides the auxiliary text.
49 void HideAuxiliaryText();
51 // Hides the preedit text.
52 void HidePreeditText();
54 // Shows the lookup table.
55 void ShowLookupTable();
57 // Shows the auxiliary text.
58 void ShowAuxiliaryText();
60 // Shows the preedit text.
61 void ShowPreeditText();
63 // Updates the preedit text.
64 void UpdatePreeditText(const base::string16& text);
66 // Updates candidates of the candidate window from |candidate_window|.
67 // Candidates are arranged per |orientation|.
68 void UpdateCandidates(const ui::CandidateWindow& candidate_window);
70 void SetCursorBounds(const gfx::Rect& cursor_bounds,
71 const gfx::Rect& composition_head);
73 private:
74 friend class CandidateWindowViewTest;
76 // Overridden from views::ButtonListener:
77 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
79 void SelectCandidateAt(int index_in_page);
80 void UpdateVisibility();
82 // Initializes the candidate views if needed.
83 void MaybeInitializeCandidateViews(
84 const ui::CandidateWindow& candidate_window);
86 // The candidate window data model.
87 ui::CandidateWindow candidate_window_;
89 // The index in the current page of the candidate currently being selected.
90 int selected_candidate_index_in_page_;
92 // The observers of the object.
93 ObserverList<Observer> observers_;
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_;
101 // The candidate views are used for rendering candidates.
102 std::vector<CandidateView*> candidate_views_;
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_;
109 // The last cursor bounds.
110 gfx::Rect cursor_bounds_;
112 // The last compostion head bounds.
113 gfx::Rect composition_head_bounds_;
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_;
119 // True if the candidate window should be shonw on the upper side of
120 // composition text.
121 bool should_show_upper_side_;
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_;
127 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView);
130 } // namespace ime
131 } // namespace ash
133 #endif // ASH_IME_CANDIDATE_WINDOW_VIEW_H_