Index: ui/aura_shell/shell_tooltip_manager.h |
diff --git a/ui/aura_shell/shell_tooltip_manager.h b/ui/aura_shell/shell_tooltip_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..20d7c01624c7f88246b3ba87638481771ba1da9c |
--- /dev/null |
+++ b/ui/aura_shell/shell_tooltip_manager.h |
@@ -0,0 +1,95 @@ |
+// Copyright (c) 2011 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. |
+ |
+#ifndef UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_ |
+#define UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_ |
+#pragma once |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "base/string16.h" |
+#include "base/timer.h" |
+#include "ui/aura/client/tooltip_client.h" |
+#include "ui/aura/event_filter.h" |
+#include "ui/aura/window_observer.h" |
+#include "ui/aura_shell/aura_shell_export.h" |
+#include "ui/base/events.h" |
+#include "ui/gfx/point.h" |
+#include "views/controls/label.h" |
+ |
+namespace aura { |
+class KeyEvent; |
+class MouseEvent; |
+class TouchEvent; |
+class Window; |
+} |
+ |
+namespace gfx { |
+class Canvas; |
+} |
+ |
+namespace views { |
+class Widget; |
+} |
+ |
+namespace aura_shell { |
+ |
+// ShellTooltipManager provides tooltip functionality for aura shell. |
+class AURA_SHELL_EXPORT ShellTooltipManager : public aura::TooltipClient, |
+ public aura::EventFilter, |
+ public aura::WindowObserver { |
+ public: |
+ ShellTooltipManager(); |
+ virtual ~ShellTooltipManager(); |
+ |
+ // Overridden from aura::TooltipClient. |
+ void UpdateTooltip(aura::Window* target); |
+ |
+ // Overridden from aura::EventFilter. |
+ virtual bool PreHandleKeyEvent(aura::Window* target, |
+ aura::KeyEvent* event) OVERRIDE; |
+ virtual bool PreHandleMouseEvent(aura::Window* target, |
+ aura::MouseEvent* event) OVERRIDE; |
+ virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, |
+ aura::TouchEvent* event) OVERRIDE; |
+ |
+ // Overridden from aura::WindowObserver. |
+ virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
+ |
+ private: |
+ void TooltipTimerFired(); |
+ |
+ // Updates the tooltip if required (if there is any change in the tooltip |
+ // text or the aura::Window. |
+ void UpdateIfRequired(); |
+ |
+ // Adjusts the bounds given by the arguments to fit inside the desktop |
+ // and applies the adjusted bounds to the tooltip_label_. |
+ void SetTooltipBounds(gfx::Point mouse_pos, |
+ int tooltip_width, |
+ int tooltip_height); |
+ |
+ scoped_ptr<views::Widget> tooltip_widget_; |
Ben Goodger (Google)
2011/11/30 21:54:19
Instead of tooltip_widget_, I'd create some class
varunjain
2011/11/30 22:42:07
Done.
|
+ aura::Window* tooltip_window_; |
+ string16 tooltip_text_; |
+ |
+ class LabelWithBorder : public views::Label { |
+ public: |
+ void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
+ views::Label::OnPaint(canvas); |
+ views::Label::OnPaintBorder(canvas); |
+ } |
+ }; |
+ |
+ LabelWithBorder tooltip_label_; |
+ |
+ base::RepeatingTimer<ShellTooltipManager> tooltip_timer_; |
+ |
+ gfx::Point curr_mouse_loc_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ShellTooltipManager); |
+}; |
+ |
+} // namespace aura_shell |
+ |
+#endif // UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_ |