OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "ash/ime/candidate_window_view.h" | 5 #include "ash/ime/candidate_window_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/ime/candidate_view.h" | 9 #include "ash/ime/candidate_view.h" |
10 #include "ash/ime/candidate_window_constants.h" | 10 #include "ash/ime/candidate_window_constants.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class CandidateWindowBorder : public views::BubbleBorder { | 28 class CandidateWindowBorder : public views::BubbleBorder { |
29 public: | 29 public: |
30 explicit CandidateWindowBorder(gfx::NativeView parent) | 30 explicit CandidateWindowBorder(gfx::NativeView parent) |
31 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER, | 31 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER, |
32 views::BubbleBorder::NO_SHADOW, | 32 views::BubbleBorder::NO_SHADOW, |
33 SK_ColorTRANSPARENT), | 33 SK_ColorTRANSPARENT), |
34 parent_(parent), | 34 parent_(parent), |
35 offset_(0) { | 35 offset_(0) { |
36 set_paint_arrow(views::BubbleBorder::PAINT_NONE); | 36 set_paint_arrow(views::BubbleBorder::PAINT_NONE); |
37 } | 37 } |
38 virtual ~CandidateWindowBorder() {} | 38 ~CandidateWindowBorder() override {} |
39 | 39 |
40 void set_offset(int offset) { offset_ = offset; } | 40 void set_offset(int offset) { offset_ = offset; } |
41 | 41 |
42 private: | 42 private: |
43 // Overridden from views::BubbleBorder: | 43 // Overridden from views::BubbleBorder: |
44 virtual gfx::Rect GetBounds(const gfx::Rect& anchor_rect, | 44 gfx::Rect GetBounds(const gfx::Rect& anchor_rect, |
45 const gfx::Size& content_size) const override { | 45 const gfx::Size& content_size) const override { |
46 gfx::Rect bounds(content_size); | 46 gfx::Rect bounds(content_size); |
47 bounds.set_origin(gfx::Point( | 47 bounds.set_origin(gfx::Point( |
48 anchor_rect.x() - offset_, | 48 anchor_rect.x() - offset_, |
49 is_arrow_on_top(arrow()) ? | 49 is_arrow_on_top(arrow()) ? |
50 anchor_rect.bottom() : anchor_rect.y() - content_size.height())); | 50 anchor_rect.bottom() : anchor_rect.y() - content_size.height())); |
51 | 51 |
52 // It cannot use the normal logic of arrow offset for horizontal offscreen, | 52 // It cannot use the normal logic of arrow offset for horizontal offscreen, |
53 // because the arrow must be in the content's edge. But CandidateWindow has | 53 // because the arrow must be in the content's edge. But CandidateWindow has |
54 // to be visible even when |anchor_rect| is out of the screen. | 54 // to be visible even when |anchor_rect| is out of the screen. |
55 gfx::Rect work_area = gfx::Screen::GetNativeScreen()-> | 55 gfx::Rect work_area = gfx::Screen::GetNativeScreen()-> |
56 GetDisplayNearestWindow(parent_).work_area(); | 56 GetDisplayNearestWindow(parent_).work_area(); |
57 if (bounds.right() > work_area.right()) | 57 if (bounds.right() > work_area.right()) |
58 bounds.set_x(work_area.right() - bounds.width()); | 58 bounds.set_x(work_area.right() - bounds.width()); |
59 if (bounds.x() < work_area.x()) | 59 if (bounds.x() < work_area.x()) |
60 bounds.set_x(work_area.x()); | 60 bounds.set_x(work_area.x()); |
61 | 61 |
62 return bounds; | 62 return bounds; |
63 } | 63 } |
64 | 64 |
65 virtual gfx::Insets GetInsets() const override { | 65 gfx::Insets GetInsets() const override { return gfx::Insets(); } |
66 return gfx::Insets(); | |
67 } | |
68 | 66 |
69 gfx::NativeView parent_; | 67 gfx::NativeView parent_; |
70 int offset_; | 68 int offset_; |
71 | 69 |
72 DISALLOW_COPY_AND_ASSIGN(CandidateWindowBorder); | 70 DISALLOW_COPY_AND_ASSIGN(CandidateWindowBorder); |
73 }; | 71 }; |
74 | 72 |
75 // Computes the page index. For instance, if the page size is 9, and the | 73 // Computes the page index. For instance, if the page size is 9, and the |
76 // cursor is pointing to 13th candidate, the page index will be 1 (2nd | 74 // cursor is pointing to 13th candidate, the page index will be 1 (2nd |
77 // page, as the index is zero-origin). Returns -1 on error. | 75 // page, as the index is zero-origin). Returns -1 on error. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 SetBorder(views::Border::CreateSolidSidedBorder( | 121 SetBorder(views::Border::CreateSolidSidedBorder( |
124 (position == TOP) ? 1 : 0, | 122 (position == TOP) ? 1 : 0, |
125 0, | 123 0, |
126 (position == BOTTOM) ? 1 : 0, | 124 (position == BOTTOM) ? 1 : 0, |
127 0, | 125 0, |
128 GetNativeTheme()->GetSystemColor( | 126 GetNativeTheme()->GetSystemColor( |
129 ui::NativeTheme::kColorId_MenuBorderColor))); | 127 ui::NativeTheme::kColorId_MenuBorderColor))); |
130 } | 128 } |
131 | 129 |
132 protected: | 130 protected: |
133 virtual gfx::Size GetPreferredSize() const override { | 131 gfx::Size GetPreferredSize() const override { |
134 gfx::Size size = views::View::GetPreferredSize(); | 132 gfx::Size size = views::View::GetPreferredSize(); |
135 size.SetToMax(gfx::Size(min_width_, 0)); | 133 size.SetToMax(gfx::Size(min_width_, 0)); |
136 return size; | 134 return size; |
137 } | 135 } |
138 | 136 |
139 private: | 137 private: |
140 views::Label* label_; | 138 views::Label* label_; |
141 int min_width_; | 139 int min_width_; |
142 | 140 |
143 DISALLOW_COPY_AND_ASSIGN(InformationTextArea); | 141 DISALLOW_COPY_AND_ASSIGN(InformationTextArea); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 for (size_t i = 0; i < candidate_views_.size(); ++i) { | 397 for (size_t i = 0; i < candidate_views_.size(); ++i) { |
400 if (sender == candidate_views_[i]) { | 398 if (sender == candidate_views_[i]) { |
401 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); | 399 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); |
402 return; | 400 return; |
403 } | 401 } |
404 } | 402 } |
405 } | 403 } |
406 | 404 |
407 } // namespace ime | 405 } // namespace ime |
408 } // namespace ash | 406 } // namespace ash |
OLD | NEW |