Removed 'anonymous' from namespace, added whitespace in thread_restrictions.cc
[chromium-blink-merge.git] / ui / chromeos / ime / candidate_window_view.h
blob6861e1bfdb3a8ffbe8f2fd1383c0b84ff4c4b8ef
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 UI_CHROMEOS_IME_CANDIDATE_WINDOW_VIEW_H_
6 #define UI_CHROMEOS_IME_CANDIDATE_WINDOW_VIEW_H_
8 #include "ui/base/ime/candidate_window.h"
9 #include "ui/chromeos/ui_chromeos_export.h"
10 #include "ui/views/bubble/bubble_delegate.h"
11 #include "ui/views/controls/button/button.h"
13 namespace ui {
14 namespace ime {
16 class CandidateView;
17 class InformationTextArea;
19 // CandidateWindowView is the main container of the candidate window UI.
20 class UI_CHROMEOS_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 // views::BubbleDelegateView:
77 const char* GetClassName() const override;
79 // Overridden from views::ButtonListener:
80 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
82 void SelectCandidateAt(int index_in_page);
83 void UpdateVisibility();
85 // Initializes the candidate views if needed.
86 void MaybeInitializeCandidateViews(
87 const ui::CandidateWindow& candidate_window);
89 // The candidate window data model.
90 ui::CandidateWindow candidate_window_;
92 // The index in the current page of the candidate currently being selected.
93 int selected_candidate_index_in_page_;
95 // The observers of the object.
96 base::ObserverList<Observer> observers_;
98 // Views created in the class will be part of tree of |this|, so these
99 // child views will be deleted when |this| is deleted.
100 InformationTextArea* auxiliary_text_;
101 InformationTextArea* preedit_;
102 views::View* candidate_area_;
104 // The candidate views are used for rendering candidates.
105 std::vector<CandidateView*> candidate_views_;
107 // Current columns size in |candidate_area_|.
108 gfx::Size previous_shortcut_column_size_;
109 gfx::Size previous_candidate_column_size_;
110 gfx::Size previous_annotation_column_size_;
112 // The last cursor bounds.
113 gfx::Rect cursor_bounds_;
115 // The last compostion head bounds.
116 gfx::Rect composition_head_bounds_;
118 // True if the candidate window should be shown with aligning with composition
119 // text as opposed to the cursor.
120 bool should_show_at_composition_head_;
122 // True if the candidate window should be shonw on the upper side of
123 // composition text.
124 bool should_show_upper_side_;
126 // True if the candidate window was open. This is used to determine when to
127 // send OnCandidateWindowOpened and OnCandidateWindowClosed events.
128 bool was_candidate_window_open_;
130 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView);
133 } // namespace ime
134 } // namespace ui
136 #endif // UI_CHROMEOS_IME_CANDIDATE_WINDOW_VIEW_H_