Update optimize_png_files.sh to work on msysgit bash.
[chromium-blink-merge.git] / ash / ime / candidate_window_view.h
blobee2c51000222e2013b4ef9799fdb79bdecaca1c6
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 virtual ~CandidateWindowView();
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 virtual void ButtonPressed(views::Button* sender,
78 const ui::Event& event) OVERRIDE;
80 void SelectCandidateAt(int index_in_page);
81 void UpdateVisibility();
83 // Initializes the candidate views if needed.
84 void MaybeInitializeCandidateViews(
85 const ui::CandidateWindow& candidate_window);
87 // The candidate window data model.
88 ui::CandidateWindow candidate_window_;
90 // The index in the current page of the candidate currently being selected.
91 int selected_candidate_index_in_page_;
93 // The observers of the object.
94 ObserverList<Observer> observers_;
96 // Views created in the class will be part of tree of |this|, so these
97 // child views will be deleted when |this| is deleted.
98 InformationTextArea* auxiliary_text_;
99 InformationTextArea* preedit_;
100 views::View* candidate_area_;
102 // The candidate views are used for rendering candidates.
103 std::vector<CandidateView*> candidate_views_;
105 // Current columns size in |candidate_area_|.
106 gfx::Size previous_shortcut_column_size_;
107 gfx::Size previous_candidate_column_size_;
108 gfx::Size previous_annotation_column_size_;
110 // The last cursor bounds.
111 gfx::Rect cursor_bounds_;
113 // The last compostion head bounds.
114 gfx::Rect composition_head_bounds_;
116 // True if the candidate window should be shown with aligning with composition
117 // text as opposed to the cursor.
118 bool should_show_at_composition_head_;
120 // True if the candidate window should be shonw on the upper side of
121 // composition text.
122 bool should_show_upper_side_;
124 // True if the candidate window was open. This is used to determine when to
125 // send OnCandidateWindowOpened and OnCandidateWindowClosed events.
126 bool was_candidate_window_open_;
128 DISALLOW_COPY_AND_ASSIGN(CandidateWindowView);
131 } // namespace ime
132 } // namespace ash
134 #endif // ASH_IME_CANDIDATE_WINDOW_VIEW_H_