Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / ash / ime / mode_indicator_view.cc
blob64c9b2430eba7b337b3916ea1dc7f39707dffc7f
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
3 // found in the LICENSE file.
5 #include "ash/ime/mode_indicator_view.h"
7 #include "base/logging.h"
8 #include "ui/views/bubble/bubble_delegate.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/corewm/window_animations.h"
11 #include "ui/views/layout/fill_layout.h"
13 namespace ash {
14 namespace ime {
16 namespace {
17 // Minimum size of inner contents in pixel.
18 // 43 is the designed size including the default margin (6 * 2).
19 const int kMinSize = 31;
21 // After this duration in msec, the mode inicator will be fading out.
22 const int kShowingDuration = 500;
23 } // namespace
26 ModeIndicatorView::ModeIndicatorView(gfx::NativeView parent,
27 const gfx::Rect& cursor_bounds,
28 const base::string16& label)
29 : cursor_bounds_(cursor_bounds),
30 label_view_(new views::Label(label)) {
31 set_use_focusless(true);
32 set_accept_events(false);
33 set_parent_window(parent);
34 set_shadow(views::BubbleBorder::NO_SHADOW);
35 set_arrow(views::BubbleBorder::TOP_CENTER);
38 ModeIndicatorView::~ModeIndicatorView() {}
40 void ModeIndicatorView::FadeOut() {
41 StartFade(false);
44 void ModeIndicatorView::ShowAndFadeOut() {
45 views::corewm::SetWindowVisibilityAnimationTransition(
46 GetWidget()->GetNativeView(),
47 views::corewm::ANIMATE_HIDE);
48 GetWidget()->Show();
49 timer_.Start(FROM_HERE,
50 base::TimeDelta::FromMilliseconds(kShowingDuration),
51 this,
52 &ModeIndicatorView::FadeOut);
55 gfx::Size ModeIndicatorView::GetPreferredSize() {
56 gfx::Size size = label_view_->GetPreferredSize();
57 size.SetToMax(gfx::Size(kMinSize, kMinSize));
58 return size;
61 void ModeIndicatorView::Init() {
62 SetLayoutManager(new views::FillLayout());
63 AddChildView(label_view_);
65 SetAnchorRect(cursor_bounds_);
68 } // namespace ime
69 } // namespace ash