blob: 61dfd8ecffd722e196a48e88662507bc2a872d6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright (c) 2012 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 ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
#define ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
#include "ui/aura/event_filter.h"
#include "ui/views/bubble/bubble_delegate.h"
namespace aura {
class LocatedEvent;
}
namespace views {
class View;
class Widget;
}
namespace ash {
namespace internal {
// Specialized bubble view for status area tray bubbles.
// Mostly this handles custom anchor location and arrow and border rendering.
class TrayBubbleView : public views::BubbleDelegateView {
public:
class Host : public aura::EventFilter {
public:
Host();
virtual ~Host();
void InitializeHost(views::Widget* widget, views::View* tray_view);
virtual void BubbleViewDestroyed() = 0;
virtual gfx::Rect GetAnchorRect() const = 0;
virtual void OnMouseEnteredView() = 0;
virtual void OnMouseExitedView() = 0;
virtual void OnClickedOutsideView() = 0;
// 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;
virtual ui::GestureStatus PreHandleGestureEvent(
aura::Window* target,
aura::GestureEvent* event) OVERRIDE;
private:
void ProcessLocatedEvent(const aura::LocatedEvent& event);
views::Widget* widget_;
views::View* tray_view_;
DISALLOW_COPY_AND_ASSIGN(Host);
};
TrayBubbleView(views::View* anchor,
views::BubbleBorder::ArrowLocation arrow_location,
Host* host,
bool can_activate,
int bubble_width);
virtual ~TrayBubbleView();
// Creates a bubble border with the specified arrow offset.
void SetBubbleBorder(int arrow_offset);
// Called whenever the bubble anchor location may have moved.
void UpdateAnchor();
// Sets the maximum bubble height and resizes the bubble.
void SetMaxHeight(int height);
// Called when the host is destroyed.
void reset_host() { host_ = NULL; }
// Overridden from views::WidgetDelegate.
virtual bool CanActivate() const OVERRIDE;
// Overridden from views::BubbleDelegateView.
virtual gfx::Rect GetAnchorRect() OVERRIDE;
// Overridden from views::View.
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
protected:
// Overridden from views::BubbleDelegateView.
virtual void Init() OVERRIDE;
virtual gfx::Rect GetBubbleBounds() OVERRIDE;
// Overridden from views::View.
virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) OVERRIDE;
private:
Host* host_;
bool can_activate_;
int max_height_;
int bubble_width_;
DISALLOW_COPY_AND_ASSIGN(TrayBubbleView);
};
} // namespace internal
} // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
|