| 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 "ui/chromeos/ime/candidate_window_view.h" | 5 #include "ui/chromeos/ime/candidate_window_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "ui/chromeos/ime/candidate_view.h" | 14 #include "ui/chromeos/ime/candidate_view.h" |
| 15 #include "ui/chromeos/ime/candidate_window_constants.h" | 15 #include "ui/chromeos/ime/candidate_window_constants.h" |
| 16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
| 18 #include "ui/gfx/color_palette.h" |
| 18 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
| 19 #include "ui/native_theme/native_theme.h" | 20 #include "ui/native_theme/native_theme.h" |
| 20 #include "ui/views/background.h" | 21 #include "ui/views/background.h" |
| 21 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| 22 #include "ui/views/bubble/bubble_frame_view.h" | 23 #include "ui/views/bubble/bubble_frame_view.h" |
| 23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 24 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
| 25 #include "ui/views/layout/fill_layout.h" | 26 #include "ui/views/layout/fill_layout.h" |
| 26 #include "ui/wm/core/window_animations.h" | 27 #include "ui/wm/core/window_animations.h" |
| 27 | 28 |
| 28 namespace ui { | 29 namespace ui { |
| 29 namespace ime { | 30 namespace ime { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 class CandidateWindowBorder : public views::BubbleBorder { | 34 class CandidateWindowBorder : public views::BubbleBorder { |
| 34 public: | 35 public: |
| 35 explicit CandidateWindowBorder(gfx::NativeView parent) | 36 explicit CandidateWindowBorder(gfx::NativeView parent) |
| 36 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER, | 37 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER, |
| 37 views::BubbleBorder::NO_SHADOW, | 38 views::BubbleBorder::NO_SHADOW, |
| 38 SK_ColorTRANSPARENT), | 39 gfx::kPlaceholderColor), |
| 39 parent_(parent), | 40 parent_(parent), |
| 40 offset_(0) { | 41 offset_(0) { |
| 41 set_paint_arrow(views::BubbleBorder::PAINT_NONE); | 42 set_paint_arrow(views::BubbleBorder::PAINT_NONE); |
| 43 set_use_theme_background_color(true); |
| 42 } | 44 } |
| 43 ~CandidateWindowBorder() override {} | 45 ~CandidateWindowBorder() override {} |
| 44 | 46 |
| 45 void set_offset(int offset) { offset_ = offset; } | 47 void set_offset(int offset) { offset_ = offset; } |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 // Overridden from views::BubbleBorder: | 50 // Overridden from views::BubbleBorder: |
| 49 gfx::Rect GetBounds(const gfx::Rect& anchor_rect, | 51 gfx::Rect GetBounds(const gfx::Rect& anchor_rect, |
| 50 const gfx::Size& content_size) const override { | 52 const gfx::Size& content_size) const override { |
| 51 gfx::Rect bounds(content_size); | 53 gfx::Rect bounds(content_size); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 148 |
| 147 CandidateWindowView::CandidateWindowView(gfx::NativeView parent) | 149 CandidateWindowView::CandidateWindowView(gfx::NativeView parent) |
| 148 : selected_candidate_index_in_page_(-1), | 150 : selected_candidate_index_in_page_(-1), |
| 149 should_show_at_composition_head_(false), | 151 should_show_at_composition_head_(false), |
| 150 should_show_upper_side_(false), | 152 should_show_upper_side_(false), |
| 151 was_candidate_window_open_(false) { | 153 was_candidate_window_open_(false) { |
| 152 set_can_activate(false); | 154 set_can_activate(false); |
| 153 set_parent_window(parent); | 155 set_parent_window(parent); |
| 154 set_margins(gfx::Insets()); | 156 set_margins(gfx::Insets()); |
| 155 | 157 |
| 156 // Set the background and the border of the view. | |
| 157 ui::NativeTheme* theme = GetNativeTheme(); | |
| 158 set_background( | |
| 159 views::Background::CreateSolidBackground(theme->GetSystemColor( | |
| 160 ui::NativeTheme::kColorId_WindowBackground))); | |
| 161 SetBorder(views::CreateSolidBorder( | 158 SetBorder(views::CreateSolidBorder( |
| 162 1, theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBorderColor))); | 159 1, GetNativeTheme()->GetSystemColor( |
| 160 ui::NativeTheme::kColorId_MenuBorderColor))); |
| 163 | 161 |
| 164 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 162 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 165 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0); | 163 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0); |
| 166 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth); | 164 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth); |
| 167 candidate_area_ = new views::View; | 165 candidate_area_ = new views::View; |
| 168 auxiliary_text_->SetVisible(false); | 166 auxiliary_text_->SetVisible(false); |
| 169 preedit_->SetVisible(false); | 167 preedit_->SetVisible(false); |
| 170 candidate_area_->SetVisible(false); | 168 candidate_area_->SetVisible(false); |
| 171 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM); | 169 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM); |
| 172 if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) { | 170 if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 192 | 190 |
| 193 views::Widget* CandidateWindowView::InitWidget() { | 191 views::Widget* CandidateWindowView::InitWidget() { |
| 194 views::Widget* widget = BubbleDialogDelegateView::CreateBubble(this); | 192 views::Widget* widget = BubbleDialogDelegateView::CreateBubble(this); |
| 195 | 193 |
| 196 wm::SetWindowVisibilityAnimationType( | 194 wm::SetWindowVisibilityAnimationType( |
| 197 widget->GetNativeView(), | 195 widget->GetNativeView(), |
| 198 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 196 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| 199 | 197 |
| 200 GetBubbleFrameView()->SetBubbleBorder(std::unique_ptr<views::BubbleBorder>( | 198 GetBubbleFrameView()->SetBubbleBorder(std::unique_ptr<views::BubbleBorder>( |
| 201 new CandidateWindowBorder(parent_window()))); | 199 new CandidateWindowBorder(parent_window()))); |
| 200 GetBubbleFrameView()->OnNativeThemeChanged(widget->GetNativeTheme()); |
| 202 return widget; | 201 return widget; |
| 203 } | 202 } |
| 204 | 203 |
| 205 void CandidateWindowView::UpdateVisibility() { | 204 void CandidateWindowView::UpdateVisibility() { |
| 206 if (candidate_area_->visible() || auxiliary_text_->visible() || | 205 if (candidate_area_->visible() || auxiliary_text_->visible() || |
| 207 preedit_->visible()) { | 206 preedit_->visible()) { |
| 208 SizeToContents(); | 207 SizeToContents(); |
| 209 } else { | 208 } else { |
| 210 GetWidget()->Close(); | 209 GetWidget()->Close(); |
| 211 } | 210 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 if (sender == candidate_views_[i].get()) { | 408 if (sender == candidate_views_[i].get()) { |
| 410 for (Observer& observer : observers_) | 409 for (Observer& observer : observers_) |
| 411 observer.OnCandidateCommitted(i); | 410 observer.OnCandidateCommitted(i); |
| 412 return; | 411 return; |
| 413 } | 412 } |
| 414 } | 413 } |
| 415 } | 414 } |
| 416 | 415 |
| 417 } // namespace ime | 416 } // namespace ime |
| 418 } // namespace ui | 417 } // namespace ui |
| OLD | NEW |