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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_VIEW_H_
10 #include "build/build_config.h"
11 #include "ui/gfx/point.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/gfx/size.h"
14 #include "ui/views/view.h"
16 class NativeViewPhotobooth
;
18 class DraggedTabView
: public views::View
{
20 // Creates a new DraggedTabView using |renderers| as the Views. DraggedTabView
21 // takes ownership of the views in |renderers| and |photobooth|.
22 DraggedTabView(const std::vector
<views::View
*>& renderers
,
23 const std::vector
<gfx::Rect
>& renderer_bounds
,
24 const gfx::Point
& mouse_tab_offset
,
25 const gfx::Size
& contents_size
,
26 NativeViewPhotobooth
* photobooth
);
27 virtual ~DraggedTabView();
29 // Moves the DraggedTabView to the appropriate location given the mouse
30 // pointer at |screen_point|.
31 void MoveTo(const gfx::Point
& screen_point
);
33 // Sets the offset of the mouse from the upper left corner of the tab.
34 void set_mouse_tab_offset(const gfx::Point
& offset
) {
35 mouse_tab_offset_
= offset
;
38 // Notifies the DraggedTabView that it should update itself.
42 // Overridden from views::View:
43 virtual void OnPaint(gfx::Canvas
* canvas
) OVERRIDE
;
44 virtual void Layout() OVERRIDE
;
45 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
47 // Paint the view, when it's not attached to any TabStrip.
48 void PaintDetachedView(gfx::Canvas
* canvas
);
50 // Paint the view, when "Show window contents while dragging" is disabled.
51 void PaintFocusRect(gfx::Canvas
* canvas
);
53 // Returns the preferred size of the container.
54 gfx::Size
PreferredContainerSize();
56 // Utility for scaling a size by the current scaling factor.
57 int ScaleValue(int value
);
59 // The window that contains the DraggedTabView.
60 scoped_ptr
<views::Widget
> container_
;
62 // The renderer that paints the Tab shape.
63 std::vector
<views::View
*> renderers_
;
65 // Bounds of the renderers.
66 std::vector
<gfx::Rect
> renderer_bounds_
;
68 // True if "Show window contents while dragging" is enabled.
69 bool show_contents_on_drag_
;
71 // The unscaled offset of the mouse from the top left of the dragged Tab.
72 // This is used to maintain an appropriate offset for the mouse pointer when
73 // dragging scaled and unscaled representations, and also to calculate the
74 // position of detached windows.
75 gfx::Point mouse_tab_offset_
;
77 // The size of the tab renderer.
80 // A handle to the DIB containing the current screenshot of the WebContents
82 scoped_ptr
<NativeViewPhotobooth
> photobooth_
;
84 // Size of the WebContents being dragged.
85 gfx::Size contents_size_
;
87 DISALLOW_COPY_AND_ASSIGN(DraggedTabView
);
90 #endif // CHROME_BROWSER_UI_VIEWS_TABS_DRAGGED_TAB_VIEW_H_