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_view.h" | 5 #include "ash/ime/candidate_view.h" |
6 | 6 |
7 #include "ash/ime/candidate_window_constants.h" | 7 #include "ash/ime/candidate_window_constants.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "ui/base/ime/candidate_window.h" | 9 #include "ui/base/ime/candidate_window.h" |
10 #include "ui/gfx/color_utils.h" | 10 #include "ui/gfx/color_utils.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // the vertical candidate window. | 23 // the vertical candidate window. |
24 class VerticalCandidateLabel : public views::Label { | 24 class VerticalCandidateLabel : public views::Label { |
25 public: | 25 public: |
26 VerticalCandidateLabel() {} | 26 VerticalCandidateLabel() {} |
27 | 27 |
28 private: | 28 private: |
29 virtual ~VerticalCandidateLabel() {} | 29 virtual ~VerticalCandidateLabel() {} |
30 | 30 |
31 // Returns the preferred size, but guarantees that the width has at | 31 // Returns the preferred size, but guarantees that the width has at |
32 // least kMinCandidateLabelWidth pixels. | 32 // least kMinCandidateLabelWidth pixels. |
33 virtual gfx::Size GetPreferredSize() OVERRIDE { | 33 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
34 gfx::Size size = Label::GetPreferredSize(); | 34 gfx::Size size = Label::GetPreferredSize(); |
35 size.SetToMax(gfx::Size(kMinCandidateLabelWidth, 0)); | 35 size.SetToMax(gfx::Size(kMinCandidateLabelWidth, 0)); |
36 size.SetToMin(gfx::Size(kMaxCandidateLabelWidth, size.height())); | 36 size.SetToMin(gfx::Size(kMaxCandidateLabelWidth, size.height())); |
37 return size; | 37 return size; |
38 } | 38 } |
39 | 39 |
40 DISALLOW_COPY_AND_ASSIGN(VerticalCandidateLabel); | 40 DISALLOW_COPY_AND_ASSIGN(VerticalCandidateLabel); |
41 }; | 41 }; |
42 | 42 |
43 // Creates the shortcut label, and returns it (never returns NULL). | 43 // Creates the shortcut label, and returns it (never returns NULL). |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 infolist_icon_->SetBounds( | 265 infolist_icon_->SetBounds( |
266 right - kInfolistIndicatorIconWidth - kInfolistIndicatorIconPadding, | 266 right - kInfolistIndicatorIconWidth - kInfolistIndicatorIconPadding, |
267 kInfolistIndicatorIconPadding, | 267 kInfolistIndicatorIconPadding, |
268 kInfolistIndicatorIconWidth, | 268 kInfolistIndicatorIconWidth, |
269 height() - kInfolistIndicatorIconPadding * 2); | 269 height() - kInfolistIndicatorIconPadding * 2); |
270 right -= kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2; | 270 right -= kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2; |
271 } | 271 } |
272 annotation_label_->SetBounds(x, 0, right - x, height()); | 272 annotation_label_->SetBounds(x, 0, right - x, height()); |
273 } | 273 } |
274 | 274 |
275 gfx::Size CandidateView::GetPreferredSize() { | 275 gfx::Size CandidateView::GetPreferredSize() const { |
276 const int padding_width = | 276 const int padding_width = |
277 orientation_ == ui::CandidateWindow::VERTICAL ? 4 : 6; | 277 orientation_ == ui::CandidateWindow::VERTICAL ? 4 : 6; |
278 gfx::Size size; | 278 gfx::Size size; |
279 if (shortcut_label_->visible()) { | 279 if (shortcut_label_->visible()) { |
280 size = shortcut_label_->GetPreferredSize(); | 280 size = shortcut_label_->GetPreferredSize(); |
281 size.SetToMax(gfx::Size(shortcut_width_, 0)); | 281 size.SetToMax(gfx::Size(shortcut_width_, 0)); |
282 size.Enlarge(padding_width, 0); | 282 size.Enlarge(padding_width, 0); |
283 } | 283 } |
284 gfx::Size candidate_size = candidate_label_->GetPreferredSize(); | 284 gfx::Size candidate_size = candidate_label_->GetPreferredSize(); |
285 candidate_size.SetToMax(gfx::Size(candidate_width_, 0)); | 285 candidate_size.SetToMax(gfx::Size(candidate_width_, 0)); |
286 size.Enlarge(candidate_size.width() + padding_width, 0); | 286 size.Enlarge(candidate_size.width() + padding_width, 0); |
287 size.SetToMax(candidate_size); | 287 size.SetToMax(candidate_size); |
288 if (annotation_label_->visible()) { | 288 if (annotation_label_->visible()) { |
289 gfx::Size annotation_size = annotation_label_->GetPreferredSize(); | 289 gfx::Size annotation_size = annotation_label_->GetPreferredSize(); |
290 size.Enlarge(annotation_size.width() + padding_width, 0); | 290 size.Enlarge(annotation_size.width() + padding_width, 0); |
291 size.SetToMax(annotation_size); | 291 size.SetToMax(annotation_size); |
292 } | 292 } |
293 | 293 |
294 // Reserves the margin for infolist_icon even if it's not visible. | 294 // Reserves the margin for infolist_icon even if it's not visible. |
295 size.Enlarge( | 295 size.Enlarge( |
296 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); | 296 kInfolistIndicatorIconWidth + kInfolistIndicatorIconPadding * 2, 0); |
297 return size; | 297 return size; |
298 } | 298 } |
299 | 299 |
300 } // namespace ime | 300 } // namespace ime |
301 } // namespace ash | 301 } // namespace ash |
OLD | NEW |