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

Side by Side Diff: ui/aura_shell/shell_tooltip_manager.h

Issue 8747022: Aura: Tooltips (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed usage of window delegate. Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
6 #define UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
7 #pragma once
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h"
11 #include "base/timer.h"
12 #include "ui/aura/client/tooltip_client.h"
13 #include "ui/aura/event_filter.h"
14 #include "ui/aura/window_observer.h"
15 #include "ui/aura_shell/aura_shell_export.h"
16 #include "ui/base/events.h"
17 #include "ui/gfx/point.h"
18 #include "views/controls/label.h"
19
20 namespace aura {
21 class KeyEvent;
22 class MouseEvent;
23 class TouchEvent;
24 class Window;
25 }
26
27 namespace gfx {
28 class Canvas;
29 }
30
31 namespace views {
32 class Widget;
33 }
34
35 namespace aura_shell {
36
37 // ShellTooltipManager provides tooltip functionality for aura shell.
38 class AURA_SHELL_EXPORT ShellTooltipManager : public aura::TooltipClient,
39 public aura::EventFilter,
40 public aura::WindowObserver {
41 public:
42 ShellTooltipManager();
43 virtual ~ShellTooltipManager();
44
45 // Overridden from aura::TooltipClient.
46 void UpdateTooltip(aura::Window* target);
47
48 // Overridden from aura::EventFilter.
49 virtual bool PreHandleKeyEvent(aura::Window* target,
50 aura::KeyEvent* event) OVERRIDE;
51 virtual bool PreHandleMouseEvent(aura::Window* target,
52 aura::MouseEvent* event) OVERRIDE;
53 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
54 aura::TouchEvent* event) OVERRIDE;
55
56 // Overridden from aura::WindowObserver.
57 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
58
59 private:
60 void TooltipTimerFired();
61
62 // Updates the tooltip if required (if there is any change in the tooltip
63 // text or the aura::Window.
64 void UpdateIfRequired();
65
66 // Adjusts the bounds given by the arguments to fit inside the desktop
67 // and applies the adjusted bounds to the tooltip_label_.
68 void SetTooltipBounds(gfx::Point mouse_pos,
69 int tooltip_width,
70 int tooltip_height);
71
72 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.
73 aura::Window* tooltip_window_;
74 string16 tooltip_text_;
75
76 class LabelWithBorder : public views::Label {
77 public:
78 void OnPaint(gfx::Canvas* canvas) OVERRIDE {
79 views::Label::OnPaint(canvas);
80 views::Label::OnPaintBorder(canvas);
81 }
82 };
83
84 LabelWithBorder tooltip_label_;
85
86 base::RepeatingTimer<ShellTooltipManager> tooltip_timer_;
87
88 gfx::Point curr_mouse_loc_;
89
90 DISALLOW_COPY_AND_ASSIGN(ShellTooltipManager);
91 };
92
93 } // namespace aura_shell
94
95 #endif // UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698