OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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_GTK_TABS_DRAGGED_TAB_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TABS_DRAGGED_TAB_GTK_H_ |
| 7 |
| 8 #include <gtk/gtk.h> |
| 9 |
| 10 #include "app/slide_animation.h" |
| 11 #include "base/gfx/point.h" |
| 12 #include "base/gfx/rect.h" |
| 13 #include "base/gfx/size.h" |
| 14 #include "base/scoped_ptr.h" |
| 15 #include "base/task.h" |
| 16 #include "chrome/common/owned_widget_gtk.h" |
| 17 |
| 18 class ChromeCanvas; |
| 19 class TabContents; |
| 20 class TabRendererGtk; |
| 21 |
| 22 class DraggedTabGtk : public AnimationDelegate { |
| 23 public: |
| 24 DraggedTabGtk(TabContents* datasource, |
| 25 const gfx::Point& mouse_tab_offset, |
| 26 const gfx::Size& contents_size); |
| 27 virtual ~DraggedTabGtk(); |
| 28 |
| 29 // Moves the DraggedTabView to the appropriate location given the mouse |
| 30 // pointer at |screen_point|. |
| 31 void MoveTo(const gfx::Point& screen_point); |
| 32 |
| 33 // Notifies the DraggedTabView that it has become attached to a TabStrip. |
| 34 void Attach(int selected_width); |
| 35 |
| 36 // Notifies the DraggedTabView that it should update itself. |
| 37 void Update(); |
| 38 |
| 39 // Animates the DraggedTabView to the specified bounds, then calls back to |
| 40 // |callback|. |
| 41 typedef Callback0::Type AnimateToBoundsCallback; |
| 42 void AnimateToBounds(const gfx::Rect& bounds, |
| 43 AnimateToBoundsCallback* callback); |
| 44 |
| 45 // Returns the size of the DraggedTabView. Used when attaching to a TabStrip |
| 46 // to determine where to place the Tab in the attached TabStrip. |
| 47 gfx::Size attached_tab_size() const { return attached_tab_size_; } |
| 48 |
| 49 private: |
| 50 // Overridden from AnimationDelegate: |
| 51 virtual void AnimationProgressed(const Animation* animation); |
| 52 virtual void AnimationEnded(const Animation* animation); |
| 53 virtual void AnimationCanceled(const Animation* animation); |
| 54 |
| 55 // Gets the preferred size of the dragged tab. |
| 56 virtual gfx::Size GetPreferredSize(); |
| 57 |
| 58 // Resizes the container to fit the content for the current attachment mode. |
| 59 void ResizeContainer(); |
| 60 |
| 61 // Utility for scaling a size by the current scaling factor. |
| 62 int ScaleValue(int value); |
| 63 |
| 64 // Sets the color map of the container window to allow the window to be |
| 65 // transparent. |
| 66 void SetContainerColorMap(); |
| 67 |
| 68 // expose-event handler that redraws the dragged tab. |
| 69 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, |
| 70 DraggedTabGtk* dragged_tab); |
| 71 |
| 72 // The window that contains the dragged tab or tab contents. |
| 73 OwnedWidgetGtk container_; |
| 74 |
| 75 // The renderer that paints the dragged tab. |
| 76 scoped_ptr<TabRendererGtk> renderer_; |
| 77 |
| 78 // True if the view is currently attached to a TabStrip. Controls rendering |
| 79 // and sizing modes. |
| 80 bool attached_; |
| 81 |
| 82 // The unscaled offset of the mouse from the top left of the dragged Tab. |
| 83 // This is used to maintain an appropriate offset for the mouse pointer when |
| 84 // dragging scaled and unscaled representations, and also to calculate the |
| 85 // position of detached windows. |
| 86 gfx::Point mouse_tab_offset_; |
| 87 |
| 88 // The desired width of the TabRenderer when the DraggedTabView is attached |
| 89 // to a TabStrip. |
| 90 gfx::Size attached_tab_size_; |
| 91 |
| 92 // The dimensions of the TabContents being dragged. |
| 93 gfx::Size contents_size_; |
| 94 |
| 95 // The animation used to slide the attached view to its final location. |
| 96 SlideAnimation close_animation_; |
| 97 |
| 98 // A callback notified when the animation is complete. |
| 99 scoped_ptr<Callback0::Type> animation_callback_; |
| 100 |
| 101 // The start and end bounds of the animation sequence. |
| 102 gfx::Rect animation_start_bounds_; |
| 103 gfx::Rect animation_end_bounds_; |
| 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(DraggedTabGtk); |
| 106 }; |
| 107 |
| 108 #endif // CHROME_BROWSER_GTK_TABS_DRAGGED_TAB_GTK_H_ |
OLD | NEW |