Commit 955be75d authored by mirandac@chromium.org's avatar mirandac@chromium.org

Change status bubble so that it expands to accommodate URL's that are abridged...

Change status bubble so that it expands to accommodate URL's that are abridged in the standard width.

BUG= http://crbug.com/1455
TEST= Mouse over a link which is abridged in the status bubble.  Hover for 2 seconds.  Link should expand to show as much as possible without extending out of the view in which it is contained.

Review URL: http://codereview.chromium.org/146043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19829 0039d316-1c4b-4281-b951-d872f2087c98
parent 13805a61
...@@ -25,6 +25,7 @@ class StatusBubbleMac : public StatusBubble { ...@@ -25,6 +25,7 @@ class StatusBubbleMac : public StatusBubble {
virtual void Hide(); virtual void Hide();
virtual void MouseMoved(); virtual void MouseMoved();
virtual void UpdateDownloadShelfVisibility(bool visible); virtual void UpdateDownloadShelfVisibility(bool visible);
virtual void SetBubbleWidth(int width);
private: private:
friend class StatusBubbleMacTest; friend class StatusBubbleMacTest;
......
...@@ -192,6 +192,10 @@ void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) { ...@@ -192,6 +192,10 @@ void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void StatusBubbleMac::SetBubbleWidth(int width) {
NOTIMPLEMENTED();
}
void StatusBubbleMac::Create() { void StatusBubbleMac::Create() {
if (window_) if (window_)
return; return;
......
...@@ -36,6 +36,10 @@ class StatusBubbleGtk : public StatusBubble { ...@@ -36,6 +36,10 @@ class StatusBubbleGtk : public StatusBubble {
// the download shelf, when it is visible. // the download shelf, when it is visible.
virtual void UpdateDownloadShelfVisibility(bool visible) { } virtual void UpdateDownloadShelfVisibility(bool visible) { }
virtual void SetBubbleWidth(int width) { }
void SetStatus(const std::string& status_utf8);
// Top of the widget hierarchy for a StatusBubble. This top level widget is // Top of the widget hierarchy for a StatusBubble. This top level widget is
// guarenteed to have its gtk_widget_name set to "status-bubble" for // guarenteed to have its gtk_widget_name set to "status-bubble" for
// identification. // identification.
......
...@@ -44,6 +44,9 @@ class StatusBubble { ...@@ -44,6 +44,9 @@ class StatusBubble {
// This is used by to ensure that the status bubble does not obscure // This is used by to ensure that the status bubble does not obscure
// the download shelf, when it is visible. // the download shelf, when it is visible.
virtual void UpdateDownloadShelfVisibility(bool visible) = 0; virtual void UpdateDownloadShelfVisibility(bool visible) = 0;
// Allow StatusView animation to set width of StatusBubble.
virtual void SetBubbleWidth(int width) = 0;
}; };
#endif // #ifndef CHROME_BROWSER_STATUS_BUBBLE_H_ #endif // #ifndef CHROME_BROWSER_STATUS_BUBBLE_H_
This diff is collapsed.
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include "base/gfx/rect.h" #include "base/gfx/rect.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "base/task.h"
#include "chrome/browser/status_bubble.h" #include "chrome/browser/status_bubble.h"
#include "googleurl/src/gurl.h"
class GURL; class GURL;
namespace views { namespace views {
...@@ -26,6 +28,9 @@ class StatusBubbleViews : public StatusBubble { ...@@ -26,6 +28,9 @@ class StatusBubbleViews : public StatusBubble {
// The combined vertical padding above and below the text. // The combined vertical padding above and below the text.
static const int kTotalVerticalPadding = 7; static const int kTotalVerticalPadding = 7;
// On hover, expand status bubble to accommodate long URL after this delay.
static const int kExpandHoverDelay = 2000;
explicit StatusBubbleViews(views::Widget* frame); explicit StatusBubbleViews(views::Widget* frame);
~StatusBubbleViews(); ~StatusBubbleViews();
...@@ -40,6 +45,9 @@ class StatusBubbleViews : public StatusBubble { ...@@ -40,6 +45,9 @@ class StatusBubbleViews : public StatusBubble {
// Set the bounds of the bubble relative to the browser window. // Set the bounds of the bubble relative to the browser window.
void SetBounds(int x, int y, int w, int h); void SetBounds(int x, int y, int w, int h);
// Set bubble to new width; for animation of expansion.
void SetBubbleWidth(int width);
// Overridden from StatusBubble: // Overridden from StatusBubble:
virtual void SetStatus(const std::wstring& status); virtual void SetStatus(const std::wstring& status);
virtual void SetURL(const GURL& url, const std::wstring& languages); virtual void SetURL(const GURL& url, const std::wstring& languages);
...@@ -49,6 +57,7 @@ class StatusBubbleViews : public StatusBubble { ...@@ -49,6 +57,7 @@ class StatusBubbleViews : public StatusBubble {
private: private:
class StatusView; class StatusView;
class StatusViewExpander;
// Initializes the popup and view. // Initializes the popup and view.
void Init(); void Init();
...@@ -57,12 +66,34 @@ class StatusBubbleViews : public StatusBubble { ...@@ -57,12 +66,34 @@ class StatusBubbleViews : public StatusBubble {
// users to see links in the region normally occupied by the status bubble. // users to see links in the region normally occupied by the status bubble.
void AvoidMouse(); void AvoidMouse();
// Expand bubble size to accommodate an abridged URL.
void ExpandBubble();
// Cancel all the expansions waiting in the timer.
void CancelExpandTimer();
// Get the standard width for a status bubble in the current frame size.
int GetStandardStatusBubbleWidth();
// Get the maximum possible width for a status bubble in the current
// frame size.
int GetMaxStatusBubbleWidth();
// The status text we want to display when there are no URLs to display. // The status text we want to display when there are no URLs to display.
std::wstring status_text_; std::wstring status_text_;
// The url we want to display when there is no status text to display. // The url we want to display when there is no status text to display.
// This string may be elided if the URL is too long to fit in status bubble.
std::wstring url_text_; std::wstring url_text_;
// The original url. We need to keep this around to we can re-elide it to
// dynamically fit the bubble if we need to expand it to show a url that
// has been cut off.
GURL url_;
// Keep this around so we can elide the original url when we expand it.
std::wstring languages_;
// Position relative to the parent window. // Position relative to the parent window.
gfx::Point position_; gfx::Point position_;
gfx::Size size_; gfx::Size size_;
...@@ -77,10 +108,17 @@ class StatusBubbleViews : public StatusBubble { ...@@ -77,10 +108,17 @@ class StatusBubbleViews : public StatusBubble {
views::Widget* frame_; views::Widget* frame_;
StatusView* view_; StatusView* view_;
StatusViewExpander* expand_view_;
// If the download shelf is visible, do not obscure it. // If the download shelf is visible, do not obscure it.
bool download_shelf_is_visible_; bool download_shelf_is_visible_;
// Is the bubble expanded? If so, change size immediately.
bool is_expanded_;
// Times expansion of status bubble when URL is too long for standard width.
ScopedRunnableMethodFactory<StatusBubbleViews> expand_timer_factory_;
DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment