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