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 24 matching lines...) Expand all Loading... |
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 virtual ~CandidateWindowBorder() {} |
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 virtual 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 virtual gfx::Insets GetInsets() const override { |
66 return gfx::Insets(); | 66 return gfx::Insets(); |
67 } | 67 } |
68 | 68 |
69 gfx::NativeView parent_; | 69 gfx::NativeView parent_; |
70 int offset_; | 70 int offset_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(CandidateWindowBorder); | 72 DISALLOW_COPY_AND_ASSIGN(CandidateWindowBorder); |
73 }; | 73 }; |
74 | 74 |
75 // Computes the page index. For instance, if the page size is 9, and the | 75 // Computes the page index. For instance, if the page size is 9, and the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 SetBorder(views::Border::CreateSolidSidedBorder( | 123 SetBorder(views::Border::CreateSolidSidedBorder( |
124 (position == TOP) ? 1 : 0, | 124 (position == TOP) ? 1 : 0, |
125 0, | 125 0, |
126 (position == BOTTOM) ? 1 : 0, | 126 (position == BOTTOM) ? 1 : 0, |
127 0, | 127 0, |
128 GetNativeTheme()->GetSystemColor( | 128 GetNativeTheme()->GetSystemColor( |
129 ui::NativeTheme::kColorId_MenuBorderColor))); | 129 ui::NativeTheme::kColorId_MenuBorderColor))); |
130 } | 130 } |
131 | 131 |
132 protected: | 132 protected: |
133 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 133 virtual gfx::Size GetPreferredSize() const override { |
134 gfx::Size size = views::View::GetPreferredSize(); | 134 gfx::Size size = views::View::GetPreferredSize(); |
135 size.SetToMax(gfx::Size(min_width_, 0)); | 135 size.SetToMax(gfx::Size(min_width_, 0)); |
136 return size; | 136 return size; |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 views::Label* label_; | 140 views::Label* label_; |
141 int min_width_; | 141 int min_width_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(InformationTextArea); | 143 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) { | 399 for (size_t i = 0; i < candidate_views_.size(); ++i) { |
400 if (sender == candidate_views_[i]) { | 400 if (sender == candidate_views_[i]) { |
401 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); | 401 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); |
402 return; | 402 return; |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 } // namespace ime | 407 } // namespace ime |
408 } // namespace ash | 408 } // namespace ash |
OLD | NEW |