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

Side by Side Diff: views/bubble/bubble_frame_view.cc

Issue 8227003: Views Bubble API adjustments and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add close_on_esc setting and fade-in functionality. Created 9 years, 2 months 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
« no previous file with comments | « views/bubble/bubble_frame_view.h ('k') | views/bubble/bubble_frame_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/bubble/bubble_frame_view.h" 5 #include "views/bubble/bubble_frame_view.h"
6 6
7 #include "grit/ui_resources.h"
8 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
9 #include "ui/gfx/path.h"
10 #include "views/bubble/bubble_border.h" 8 #include "views/bubble/bubble_border.h"
11 #include "views/widget/widget_delegate.h" 9 #include "views/widget/widget.h"
12 #include "views/window/client_view.h" 10 #include "views/window/client_view.h"
13 11
14 namespace views { 12 namespace views {
15 13
16 BubbleFrameView::BubbleFrameView(Widget* frame, 14 BubbleFrameView::BubbleFrameView(BubbleBorder::ArrowLocation location,
17 const gfx::Rect& bounds, 15 const gfx::Size& client_size,
18 SkColor color, 16 SkColor color) {
19 BubbleBorder::ArrowLocation location) 17 BubbleBorder* bubble_border = new BubbleBorder(location);
20 : frame_(frame), 18 bubble_border->set_background_color(color);
21 frame_bounds_(bounds), 19 set_border(bubble_border);
22 bubble_border_(new BubbleBorder(location)), 20 set_background(new BubbleBackground(bubble_border));
23 bubble_background_(new BubbleBackground(bubble_border_)) { 21 // Calculate the frame size from the client size.
24 SetBoundsRect(bounds); 22 gfx::Rect bounds(gfx::Point(), client_size);
25 bubble_border_->set_background_color(color); 23 SetBoundsRect(GetWindowBoundsForClientBounds(bounds));
26 set_border(bubble_border_);
27 set_background(bubble_background_);
28 } 24 }
29 25
30 BubbleFrameView::~BubbleFrameView() {} 26 BubbleFrameView::~BubbleFrameView() {}
31 27
32 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 28 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
33 gfx::Insets insets; 29 gfx::Rect client_bounds(gfx::Point(), size());
34 bubble_border_->GetInsets(&insets); 30 client_bounds.Inset(GetInsets());
35 return gfx::Rect(insets.left(), insets.top(), 31 return client_bounds;
36 frame_bounds_.width() - insets.left() - insets.right(),
37 frame_bounds_.height() - insets.top() - insets.bottom());
38 } 32 }
39 33
40 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( 34 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds(
41 const gfx::Rect& client_bounds) const { 35 const gfx::Rect& client_bounds) const {
42 return bubble_border_->GetBounds(client_bounds, client_bounds.size()); 36 // The |client_bounds| origin is the bubble arrow anchor point.
43 } 37 gfx::Rect position_relative_to(client_bounds.origin(), gfx::Size());
44 38 // The |client_bounds| size is the bubble client view size.
45 void BubbleFrameView::EnableClose(bool enable) { 39 return static_cast<const BubbleBorder*>(border())->GetBounds(
46 } 40 position_relative_to, client_bounds.size());
47
48 void BubbleFrameView::ResetWindowControls() {
49 }
50
51 void BubbleFrameView::UpdateWindowIcon() {
52 } 41 }
53 42
54 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { 43 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
55 border()->Paint(*this, canvas); 44 border()->Paint(*this, canvas);
56 bubble_background_->Paint(canvas, this); 45 background()->Paint(canvas, this);
57 } 46 }
58 47
59 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { 48 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
60 return frame_->client_view()->NonClientHitTest(point); 49 return GetWidget()->client_view()->NonClientHitTest(point);
61 }
62
63 void BubbleFrameView::GetWindowMask(const gfx::Size& size,
64 gfx::Path* window_mask) {
65 } 50 }
66 51
67 gfx::Size BubbleFrameView::GetPreferredSize() { 52 gfx::Size BubbleFrameView::GetPreferredSize() {
68 gfx::Size pref = frame_->client_view()->GetPreferredSize(); 53 Widget* widget = GetWidget();
69 gfx::Rect bounds(0, 0, pref.width(), pref.height()); 54 gfx::Rect rect(gfx::Point(), widget->client_view()->GetPreferredSize());
70 return frame_->non_client_view()->GetWindowBoundsForClientBounds( 55 return widget->non_client_view()->GetWindowBoundsForClientBounds(rect).size();
71 bounds).size();
72 } 56 }
57
73 } // namespace views 58 } // namespace views
OLDNEW
« no previous file with comments | « views/bubble/bubble_frame_view.h ('k') | views/bubble/bubble_frame_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698