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 CHROME_BROWSER_UI_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_
6#define CHROME_BROWSER_UI_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_
7#pragma once
8
9#include "chrome/browser/ui/views/bubble/border_contents.h"
10#include "chrome/browser/ui/views/bubble/bubble.h"
11
12// This is a specialization of BorderContents, used to draw a border around
13// an Bubble that has its contents pinned to a specific location. See
14// base class for details.
15class PinnedContentsBorderContents : public BorderContents {
16 public:
17  explicit PinnedContentsBorderContents(const gfx::Point& bubble_anchor)
18      : bubble_anchor_(bubble_anchor) {}
19
20  // BorderContents overrides:
21  virtual void SizeAndGetBounds(
22      const gfx::Rect& position_relative_to,  // In screen coordinates
23      BubbleBorder::ArrowLocation arrow_location,
24      bool allow_bubble_offscreen,
25      const gfx::Size& contents_size,
26      gfx::Rect* contents_bounds,             // Returned in window coordinates
27      gfx::Rect* window_bounds);              // Returned in screen coordinates
28
29 private:
30  // The location of the pinned contents (in screen coordinates).
31  const gfx::Point bubble_anchor_;
32
33  DISALLOW_COPY_AND_ASSIGN(PinnedContentsBorderContents);
34};
35
36// A specialization of the Bubble. Used to draw an Bubble which, in
37// addition to having an arrow pointing to where the user clicked, also shifts
38// the bubble horizontally to fix it to a specific location. See base class
39// for details.
40class PinnedContentsInfoBubble : public Bubble {
41 public:
42  // Shows the Bubble (see base class function for details).
43  // |bubble_anchor| specifies how far horizontally to shift the bubble in
44  // order to anchor its contents. Once the Bubble has been anchored its
45  // arrow may be pointing to a slightly different |y| location than specified
46  // in |position_relative_to|.
47  static PinnedContentsInfoBubble* Show(
48      views::Widget* parent,
49      const gfx::Rect& position_relative_to,
50      BubbleBorder::ArrowLocation arrow_location,
51      const gfx::Point& bubble_anchor_,
52      views::View* contents,
53      BubbleDelegate* delegate);
54
55  // Bubble overrides:
56  virtual BorderContents* CreateBorderContents();
57
58 private:
59  explicit PinnedContentsInfoBubble(const gfx::Point& bubble_anchor)
60      : bubble_anchor_(bubble_anchor) {}
61  virtual ~PinnedContentsInfoBubble() {}
62
63  // The location of the pinned contents (in screen coordinates).
64  const gfx::Point bubble_anchor_;
65
66  DISALLOW_COPY_AND_ASSIGN(PinnedContentsInfoBubble);
67};
68
69#endif  // CHROME_BROWSER_UI_VIEWS_PINNED_CONTENTS_INFO_BUBBLE_H_
70