Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: ui/chromeos/ime/candidate_window_view.cc

Issue 2584013003: Fix background opacity/color of IME candidate window. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "ui/chromeos/ime/candidate_view.h" 13 #include "ui/chromeos/ime/candidate_view.h"
14 #include "ui/chromeos/ime/candidate_window_constants.h" 14 #include "ui/chromeos/ime/candidate_window_constants.h"
15 #include "ui/display/display.h" 15 #include "ui/display/display.h"
16 #include "ui/display/screen.h" 16 #include "ui/display/screen.h"
17 #include "ui/gfx/color_palette.h"
17 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
18 #include "ui/native_theme/native_theme.h" 19 #include "ui/native_theme/native_theme.h"
19 #include "ui/views/background.h" 20 #include "ui/views/background.h"
20 #include "ui/views/border.h" 21 #include "ui/views/border.h"
21 #include "ui/views/bubble/bubble_frame_view.h" 22 #include "ui/views/bubble/bubble_frame_view.h"
22 #include "ui/views/controls/label.h" 23 #include "ui/views/controls/label.h"
23 #include "ui/views/layout/box_layout.h" 24 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/layout/fill_layout.h" 25 #include "ui/views/layout/fill_layout.h"
25 #include "ui/wm/core/window_animations.h" 26 #include "ui/wm/core/window_animations.h"
26 27
27 namespace ui { 28 namespace ui {
28 namespace ime { 29 namespace ime {
29 30
30 namespace { 31 namespace {
31 32
32 class CandidateWindowBorder : public views::BubbleBorder { 33 class CandidateWindowBorder : public views::BubbleBorder {
33 public: 34 public:
34 explicit CandidateWindowBorder(gfx::NativeView parent) 35 explicit CandidateWindowBorder(gfx::NativeView parent)
35 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER, 36 : views::BubbleBorder(views::BubbleBorder::TOP_CENTER,
36 views::BubbleBorder::NO_SHADOW, 37 views::BubbleBorder::NO_SHADOW,
37 SK_ColorTRANSPARENT), 38 gfx::kPlaceholderColor),
38 parent_(parent), 39 parent_(parent),
39 offset_(0) { 40 offset_(0) {
40 set_paint_arrow(views::BubbleBorder::PAINT_NONE); 41 set_paint_arrow(views::BubbleBorder::PAINT_NONE);
42 set_use_theme_background_color(true);
41 } 43 }
42 ~CandidateWindowBorder() override {} 44 ~CandidateWindowBorder() override {}
43 45
44 void set_offset(int offset) { offset_ = offset; } 46 void set_offset(int offset) { offset_ = offset; }
45 47
46 private: 48 private:
47 // Overridden from views::BubbleBorder: 49 // Overridden from views::BubbleBorder:
48 gfx::Rect GetBounds(const gfx::Rect& anchor_rect, 50 gfx::Rect GetBounds(const gfx::Rect& anchor_rect,
49 const gfx::Size& content_size) const override { 51 const gfx::Size& content_size) const override {
50 gfx::Rect bounds(content_size); 52 gfx::Rect bounds(content_size);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 150
149 CandidateWindowView::CandidateWindowView(gfx::NativeView parent) 151 CandidateWindowView::CandidateWindowView(gfx::NativeView parent)
150 : selected_candidate_index_in_page_(-1), 152 : selected_candidate_index_in_page_(-1),
151 should_show_at_composition_head_(false), 153 should_show_at_composition_head_(false),
152 should_show_upper_side_(false), 154 should_show_upper_side_(false),
153 was_candidate_window_open_(false) { 155 was_candidate_window_open_(false) {
154 set_can_activate(false); 156 set_can_activate(false);
155 set_parent_window(parent); 157 set_parent_window(parent);
156 set_margins(gfx::Insets()); 158 set_margins(gfx::Insets());
157 159
158 // Set the background and the border of the view.
159 ui::NativeTheme* theme = GetNativeTheme();
160 set_background(
161 views::Background::CreateSolidBackground(theme->GetSystemColor(
162 ui::NativeTheme::kColorId_WindowBackground)));
163 SetBorder(views::Border::CreateSolidBorder( 160 SetBorder(views::Border::CreateSolidBorder(
164 1, theme->GetSystemColor(ui::NativeTheme::kColorId_MenuBorderColor))); 161 1,
162 GetNativeTheme()->theme->GetSystemColor(
163 ui::NativeTheme::kColorId_MenuBorderColor)));
165 164
166 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 165 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
167 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0); 166 auxiliary_text_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0);
168 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth); 167 preedit_ = new InformationTextArea(gfx::ALIGN_LEFT, kMinPreeditAreaWidth);
169 candidate_area_ = new views::View; 168 candidate_area_ = new views::View;
170 auxiliary_text_->SetVisible(false); 169 auxiliary_text_->SetVisible(false);
171 preedit_->SetVisible(false); 170 preedit_->SetVisible(false);
172 candidate_area_->SetVisible(false); 171 candidate_area_->SetVisible(false);
173 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM); 172 preedit_->SetBorderFromPosition(InformationTextArea::BOTTOM);
174 if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) { 173 if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) {
(...skipping 19 matching lines...) Expand all
194 193
195 views::Widget* CandidateWindowView::InitWidget() { 194 views::Widget* CandidateWindowView::InitWidget() {
196 views::Widget* widget = BubbleDialogDelegateView::CreateBubble(this); 195 views::Widget* widget = BubbleDialogDelegateView::CreateBubble(this);
197 196
198 wm::SetWindowVisibilityAnimationType( 197 wm::SetWindowVisibilityAnimationType(
199 widget->GetNativeView(), 198 widget->GetNativeView(),
200 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 199 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
201 200
202 GetBubbleFrameView()->SetBubbleBorder(std::unique_ptr<views::BubbleBorder>( 201 GetBubbleFrameView()->SetBubbleBorder(std::unique_ptr<views::BubbleBorder>(
203 new CandidateWindowBorder(parent_window()))); 202 new CandidateWindowBorder(parent_window())));
203 GetBubbleFrameView()->OnNativeThemeChanged(widget->GetNativeTheme());
204 return widget; 204 return widget;
205 } 205 }
206 206
207 void CandidateWindowView::UpdateVisibility() { 207 void CandidateWindowView::UpdateVisibility() {
208 if (candidate_area_->visible() || auxiliary_text_->visible() || 208 if (candidate_area_->visible() || auxiliary_text_->visible() ||
209 preedit_->visible()) { 209 preedit_->visible()) {
210 SizeToContents(); 210 SizeToContents();
211 } else { 211 } else {
212 GetWidget()->Close(); 212 GetWidget()->Close();
213 } 213 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 for (size_t i = 0; i < candidate_views_.size(); ++i) { 410 for (size_t i = 0; i < candidate_views_.size(); ++i) {
411 if (sender == candidate_views_[i]) { 411 if (sender == candidate_views_[i]) {
412 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); 412 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i));
413 return; 413 return;
414 } 414 }
415 } 415 }
416 } 416 }
417 417
418 } // namespace ime 418 } // namespace ime
419 } // namespace ui 419 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698