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

Unified Diff: chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc

Issue 98703003: Mode Indicator using BubbleDelegateView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated based on the review Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc b/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4ce800a817fccc900da83634160368c4c71e4c91
--- /dev/null
+++ b/chrome/browser/chromeos/input_method/mode_indicator_delegate_view.cc
@@ -0,0 +1,78 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/input_method/mode_indicator_delegate_view.h"
+
+#include "ash/shell.h"
+#include "ash/wm/window_animations.h"
+#include "base/logging.h"
+#include "ui/views/bubble/bubble_delegate.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/fill_layout.h"
+
+namespace chromeos {
+namespace input_method {
+
+namespace {
+// Minimum size of inner contents in pixel.
+const int kMinSize = 43;
Jun Mukai 2013/12/03 01:09:28 Noticed that the bubble is slightly bigger than th
+
+// If the cursor bounds is lower than this margin in pixel, the mode
+// indicator is shown above the cursor instead on bottom.
+const int kSizeMargin = 75;
+
+// After this duration in msec, the mode inicator will be fading out.
+const int kShowingDuration = 500;
+} // namespace
+
+
+ModeIndicatorDelegateView::ModeIndicatorDelegateView(
+ const gfx::Rect& cursor_bounds,
+ const string16& label)
+ : cursor_bounds_(cursor_bounds),
+ label_view_(new views::Label(label)) {
+ set_use_focusless(true);
+ set_accept_events(false);
+ set_shadow(views::BubbleBorder::NO_SHADOW);
+
+ const gfx::Rect screen_bounds =
+ ash::Shell::GetScreen()->GetDisplayMatching(cursor_bounds).work_area();
+ if (screen_bounds.bottom() - cursor_bounds.bottom() > kSizeMargin)
+ set_arrow(views::BubbleBorder::TOP_CENTER);
+ else
+ set_arrow(views::BubbleBorder::BOTTOM_CENTER);
+}
+
+ModeIndicatorDelegateView::~ModeIndicatorDelegateView() {}
+
+void ModeIndicatorDelegateView::FadeOut() {
+ StartFade(false);
+}
+
+void ModeIndicatorDelegateView::ShowAndFadeOut() {
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ GetWidget()->GetNativeView(),
+ views::corewm::ANIMATE_HIDE);
+ GetWidget()->Show();
+ timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kShowingDuration),
+ this,
+ &ModeIndicatorDelegateView::FadeOut);
+}
+
+gfx::Size ModeIndicatorDelegateView::GetPreferredSize() {
+ gfx::Size size = label_view_->GetPreferredSize();
+ size.SetToMax(gfx::Size(kMinSize, kMinSize));
+ return size;
+}
+
+void ModeIndicatorDelegateView::Init() {
+ SetLayoutManager(new views::FillLayout());
+ AddChildView(label_view_);
+
+ SetAnchorRect(cursor_bounds_);
+}
+
+} // namespace input_method
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698