| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
| 6 #define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ | 6 #define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/task.h" |
| 10 #include "chrome/browser/status_bubble.h" | 11 #include "chrome/browser/status_bubble.h" |
| 12 #include "googleurl/src/gurl.h" |
| 11 #include "gfx/rect.h" | 13 #include "gfx/rect.h" |
| 12 | 14 |
| 13 class GURL; | 15 class GURL; |
| 14 namespace gfx { | 16 namespace gfx { |
| 15 class Point; | 17 class Point; |
| 16 } | 18 } |
| 17 namespace views { | 19 namespace views { |
| 18 class Widget; | 20 class Widget; |
| 19 } | 21 } |
| 20 | 22 |
| 21 // StatusBubble displays a bubble of text that fades in, hovers over the | 23 // StatusBubble displays a bubble of text that fades in, hovers over the |
| 22 // browser chrome and fades away when not needed. It is primarily designed | 24 // browser chrome and fades away when not needed. It is primarily designed |
| 23 // to allow users to see where hovered links point to. | 25 // to allow users to see where hovered links point to. |
| 24 class StatusBubbleViews : public StatusBubble { | 26 class StatusBubbleViews : public StatusBubble { |
| 25 public: | 27 public: |
| 26 // How wide the bubble's shadow is. | 28 // How wide the bubble's shadow is. |
| 27 static const int kShadowThickness; | 29 static const int kShadowThickness; |
| 28 | 30 |
| 29 // The combined vertical padding above and below the text. | 31 // The combined vertical padding above and below the text. |
| 30 static const int kTotalVerticalPadding = 7; | 32 static const int kTotalVerticalPadding = 7; |
| 31 | 33 |
| 34 // On hover, expand status bubble to fit long URL after this delay. |
| 35 static const int kExpandHoverDelay = 1600; |
| 36 |
| 32 explicit StatusBubbleViews(views::Widget* frame); | 37 explicit StatusBubbleViews(views::Widget* frame); |
| 33 ~StatusBubbleViews(); | 38 ~StatusBubbleViews(); |
| 34 | 39 |
| 35 // Reposition the bubble - as we are using a WS_POPUP for the bubble, | 40 // Reposition the bubble - as we are using a WS_POPUP for the bubble, |
| 36 // we have to manually position it when the browser window moves. | 41 // we have to manually position it when the browser window moves. |
| 37 void Reposition(); | 42 void Reposition(); |
| 38 | 43 |
| 39 // The bubble only has a preferred height: the sum of the height of | 44 // The bubble only has a preferred height: the sum of the height of |
| 40 // the font and kTotalVerticalPadding. | 45 // the font and kTotalVerticalPadding. |
| 41 gfx::Size GetPreferredSize(); | 46 gfx::Size GetPreferredSize(); |
| 42 | 47 |
| 43 // Set the bounds of the bubble relative to the browser window. | 48 // Set the bounds of the bubble relative to the browser window. |
| 44 void SetBounds(int x, int y, int w, int h); | 49 void SetBounds(int x, int y, int w, int h); |
| 45 | 50 |
| 51 // Set bubble to new width. |
| 52 void SetBubbleWidth(int width); |
| 53 |
| 46 // Overridden from StatusBubble: | 54 // Overridden from StatusBubble: |
| 47 virtual void SetStatus(const std::wstring& status); | 55 virtual void SetStatus(const std::wstring& status); |
| 48 virtual void SetURL(const GURL& url, const std::wstring& languages); | 56 virtual void SetURL(const GURL& url, const std::wstring& languages); |
| 49 virtual void Hide(); | 57 virtual void Hide(); |
| 50 virtual void MouseMoved(const gfx::Point& location, bool left_content); | 58 virtual void MouseMoved(const gfx::Point& location, bool left_content); |
| 51 virtual void UpdateDownloadShelfVisibility(bool visible); | 59 virtual void UpdateDownloadShelfVisibility(bool visible); |
| 52 | 60 |
| 53 private: | 61 private: |
| 54 class StatusView; | 62 class StatusView; |
| 63 class StatusViewExpander; |
| 55 | 64 |
| 56 // Initializes the popup and view. | 65 // Initializes the popup and view. |
| 57 void Init(); | 66 void Init(); |
| 58 | 67 |
| 59 // Attempt to move the status bubble out of the way of the cursor, allowing | 68 // Attempt to move the status bubble out of the way of the cursor, allowing |
| 60 // users to see links in the region normally occupied by the status bubble. | 69 // users to see links in the region normally occupied by the status bubble. |
| 61 void AvoidMouse(const gfx::Point& location); | 70 void AvoidMouse(const gfx::Point& location); |
| 62 | 71 |
| 63 // Returns true if the frame_ is visible and not minimized. | 72 // Returns true if the frame_ is visible and not minimized. |
| 64 bool IsFrameVisible(); | 73 bool IsFrameVisible(); |
| 65 | 74 |
| 75 // Expand bubble size to accommodate a long URL. |
| 76 void ExpandBubble(); |
| 77 |
| 78 // Cancel all waiting expansion animations in the timer. |
| 79 void CancelExpandTimer(); |
| 80 |
| 81 // Get the standard width for a status bubble in the current frame size. |
| 82 int GetStandardStatusBubbleWidth(); |
| 83 |
| 84 // Get the maximum possible width for a status bubble in the current frame |
| 85 // size. |
| 86 int GetMaxStatusBubbleWidth(); |
| 87 |
| 66 // The status text we want to display when there are no URLs to display. | 88 // The status text we want to display when there are no URLs to display. |
| 67 std::wstring status_text_; | 89 std::wstring status_text_; |
| 68 | 90 |
| 69 // The url we want to display when there is no status text to display. | 91 // The url we want to display when there is no status text to display. |
| 70 std::wstring url_text_; | 92 std::wstring url_text_; |
| 71 | 93 |
| 94 // The original, non-elided URL. |
| 95 GURL url_; |
| 96 |
| 97 // Used to elide the original URL again when we expand it. |
| 98 std::wstring languages_; |
| 99 |
| 72 // Position relative to the parent window. | 100 // Position relative to the parent window. |
| 73 gfx::Point position_; | 101 gfx::Point position_; |
| 74 gfx::Size size_; | 102 gfx::Size size_; |
| 75 | 103 |
| 76 // How vertically offset the bubble is from its root position_. | 104 // How vertically offset the bubble is from its root position_. |
| 77 int offset_; | 105 int offset_; |
| 78 | 106 |
| 79 // We use a HWND for the popup so that it may float above any HWNDs in our | 107 // We use a HWND for the popup so that it may float above any HWNDs in our |
| 80 // UI (the location bar, for example). | 108 // UI (the location bar, for example). |
| 81 scoped_ptr<views::Widget> popup_; | 109 scoped_ptr<views::Widget> popup_; |
| 82 double opacity_; | 110 double opacity_; |
| 83 | 111 |
| 84 views::Widget* frame_; | 112 views::Widget* frame_; |
| 85 StatusView* view_; | 113 StatusView* view_; |
| 86 | 114 |
| 115 // Manages the expansion of a status bubble to fit a long URL. |
| 116 scoped_ptr<StatusViewExpander> expand_view_; |
| 117 |
| 87 // If the download shelf is visible, do not obscure it. | 118 // If the download shelf is visible, do not obscure it. |
| 88 bool download_shelf_is_visible_; | 119 bool download_shelf_is_visible_; |
| 89 | 120 |
| 121 // If the bubble has already been expanded, and encounters a new URL, |
| 122 // change size immediately, with no hover. |
| 123 bool is_expanded_; |
| 124 |
| 125 // Times expansion of status bubble when URL is too long for standard width. |
| 126 ScopedRunnableMethodFactory<StatusBubbleViews> expand_timer_factory_; |
| 127 |
| 90 DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); | 128 DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); |
| 91 }; | 129 }; |
| 92 | 130 |
| 93 #endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ | 131 #endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
| OLD | NEW |