diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 01:13:54 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 01:13:54 +0000 |
commit | 396c0398493d17b7e23f8720481dcfae6d9d3cc7 (patch) | |
tree | 66af9d0aaf75250b8ce68b12234c133a0f051441 | |
parent | 10eaf87fb4e1f7677001d16c1296b7305143f633 (diff) | |
download | chromium_src-396c0398493d17b7e23f8720481dcfae6d9d3cc7.zip chromium_src-396c0398493d17b7e23f8720481dcfae6d9d3cc7.tar.gz chromium_src-396c0398493d17b7e23f8720481dcfae6d9d3cc7.tar.bz2 |
More miscellaneous cleanup bits to try and move info_bubble.* closer to my locally rewritten versions, so that the diff will be readable.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/196131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26312 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/first_run_bubble.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 96 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.h | 18 |
3 files changed, 51 insertions, 67 deletions
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc index a29b9ff..af628cb 100644 --- a/chrome/browser/views/first_run_bubble.cc +++ b/chrome/browser/views/first_run_bubble.cc @@ -357,10 +357,8 @@ FirstRunBubble* FirstRunBubble::Show(Profile* profile, view = new FirstRunOEMBubbleView(window, profile); else view = new FirstRunBubbleView(window, profile); - window->SetDelegate(window); window->set_view(view); - window->Init(parent, position_relative_to, view); - window->ShowWindow(SW_SHOW); + window->Init(parent, position_relative_to, view, window); window->GetFocusManager()->AddFocusChangeListener(view); view->BubbleShown(); return window; diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 5b4586c..e390050 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -20,69 +20,64 @@ using views::View; +namespace { + // All sizes are in pixels. // Size of the border, along each edge. -static const int kBorderSize = 1; +const int kBorderSize = 1; // Size of the arrow. -static const int kArrowSize = 5; +const int kArrowSize = 5; // Number of pixels to the start of the arrow from the edge of the window. -static const int kArrowXOffset = 13; +const int kArrowXOffset = 13; // Number of pixels between the tip of the arrow and the region we're // pointing to. -static const int kArrowToContentPadding = -4; +const int kArrowToContentPadding = -4; // Background color of the bubble. #if defined(OS_WIN) -static const SkColor kBackgroundColor = - color_utils::GetSysSkColor(COLOR_WINDOW); +const SkColor kBackgroundColor = color_utils::GetSysSkColor(COLOR_WINDOW); #else // TODO(beng): source from theme provider. -static const SkColor kBackgroundColor = SK_ColorWHITE; +const SkColor kBackgroundColor = SK_ColorWHITE; #endif // Color of the border and arrow. -static const SkColor kBorderColor1 = SkColorSetRGB(99, 99, 99); +const SkColor kBorderColor1 = SkColorSetRGB(99, 99, 99); // Border shadow color. -static const SkColor kBorderColor2 = SkColorSetRGB(160, 160, 160); +const SkColor kBorderColor2 = SkColorSetRGB(160, 160, 160); // Intended dimensions of the bubble's corner images. If you update these, // make sure that the OnSize code works. -static const int kInfoBubbleCornerWidth = 3; -static const int kInfoBubbleCornerHeight = 3; +const int kInfoBubbleCornerWidth = 3; +const int kInfoBubbleCornerHeight = 3; // Bubble corner images. -static const SkBitmap* kInfoBubbleCornerTopLeft = NULL; -static const SkBitmap* kInfoBubbleCornerTopRight = NULL; -static const SkBitmap* kInfoBubbleCornerBottomLeft = NULL; -static const SkBitmap* kInfoBubbleCornerBottomRight = NULL; +const SkBitmap* kInfoBubbleCornerTopLeft = NULL; +const SkBitmap* kInfoBubbleCornerTopRight = NULL; +const SkBitmap* kInfoBubbleCornerBottomLeft = NULL; +const SkBitmap* kInfoBubbleCornerBottomRight = NULL; // Margins around the content. -static const int kInfoBubbleViewTopMargin = 6; -static const int kInfoBubbleViewBottomMargin = 9; -static const int kInfoBubbleViewLeftMargin = 6; -static const int kInfoBubbleViewRightMargin = 6; +const int kInfoBubbleViewTopMargin = 6; +const int kInfoBubbleViewBottomMargin = 9; +const int kInfoBubbleViewLeftMargin = 6; +const int kInfoBubbleViewRightMargin = 6; + +} // namespace // InfoBubble ----------------------------------------------------------------- // static InfoBubble* InfoBubble::Show(views::Window* parent, const gfx::Rect& position_relative_to, - views::View* content, + views::View* contents, InfoBubbleDelegate* delegate) { InfoBubble* window = new InfoBubble(); - window->Init(parent, position_relative_to, content); - // Set the delegate before we show, on the off chance the delegate is needed - // during showing. - window->delegate_ = delegate; -#if defined(OS_WIN) - window->ShowWindow(SW_SHOW); -#else - static_cast<WidgetGtk*>(window)->Show(); -#endif + window->Init(parent, position_relative_to, contents, delegate); return window; } @@ -103,10 +98,13 @@ InfoBubble::InfoBubble() void InfoBubble::Init(views::Window* parent, const gfx::Rect& position_relative_to, - views::View* content) { + views::View* contents, + InfoBubbleDelegate* delegate) { parent_ = parent; parent_->DisableInactiveRendering(); + delegate_ = delegate; + if (kInfoBubbleCornerTopLeft == NULL) { kInfoBubbleCornerTopLeft = ResourceBundle::GetSharedInstance() .GetBitmapNamed(IDR_INFO_BUBBLE_CORNER_TOP_LEFT); @@ -119,12 +117,12 @@ void InfoBubble::Init(views::Window* parent, } #if defined(OS_WIN) set_window_style(WS_POPUP | WS_CLIPCHILDREN); - set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW); + set_window_ex_style(WS_EX_TOOLWINDOW); set_initial_class_style( (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? 0 : CS_DROPSHADOW); #endif - content_view_ = CreateContentView(content); + content_view_ = CreateContentView(contents); #if defined(OS_WIN) WidgetWin::Init(parent->GetNativeWindow(), gfx::Rect()); @@ -137,34 +135,24 @@ void InfoBubble::Init(views::Window* parent, // and if they differ reset the bounds. gfx::Rect parented_bounds = content_view_->CalculateWindowBoundsAndAjust(position_relative_to); - - // TODO(beng): This should be done in a cleaner and cross-platform way. -#if defined(OS_WIN) - SetWindowPos(NULL, parented_bounds.x(), parented_bounds.y(), - parented_bounds.width(), parented_bounds.height(), - SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER); - // Invoke ChangeSize, otherwise layered window isn't updated correctly. - ChangeSize(0, CSize(parented_bounds.width(), parented_bounds.height())); -#else SetBounds(parented_bounds); -#endif #if defined(OS_WIN) // Register the Escape accelerator for closing. - GetFocusManager()->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false, - false, false), - this); - // Set initial alpha value of the layered window. - SetLayeredWindowAttributes(GetNativeView(), - RGB(0xFF, 0xFF, 0xFF), - 255, - LWA_ALPHA); + GetFocusManager()->RegisterAccelerator( + views::Accelerator(VK_ESCAPE, false, false, false), this); #endif - NotificationService::current()->Notify( - NotificationType::INFO_BUBBLE_CREATED, - Source<InfoBubble>(this), - NotificationService::NoDetails()); + NotificationService::current()->Notify(NotificationType::INFO_BUBBLE_CREATED, + Source<InfoBubble>(this), + NotificationService::NoDetails()); + + // Show the window. +#if defined(OS_WIN) + ShowWindow(SW_SHOW); +#else + static_cast<WidgetGtk*>(window)->Show(); +#endif } InfoBubble::ContentView* InfoBubble::CreateContentView(View* content) { diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h index 933c31a..fe3231c 100644 --- a/chrome/browser/views/info_bubble.h +++ b/chrome/browser/views/info_bubble.h @@ -63,14 +63,13 @@ class InfoBubble : public views::WidgetGtk { // when the Escape key is pressed (the default behavior). static InfoBubble* Show(views::Window* parent, const gfx::Rect& position_relative_to, - views::View* content, + views::View* contents, InfoBubbleDelegate* delegate); // Overridden from WidgetWin: virtual void Close(); protected: - protected: // InfoBubble::CreateContentView() creates one of these. ContentView houses // the supplied content as its only child view, renders the arrow/border of // the bubble and sizes the content. @@ -146,18 +145,12 @@ class InfoBubble : public views::WidgetGtk { // Creates the InfoBubble. void Init(views::Window* parent, const gfx::Rect& position_relative_to, - views::View* contents); - - // Sets the delegate for that InfoBubble. - void SetDelegate(InfoBubbleDelegate* delegate) { delegate_ = delegate; } + views::View* contents, + InfoBubbleDelegate* delegate); // Creates and return a new ContentView containing content. virtual ContentView* CreateContentView(views::View* content); - // Closes the window notifying the delegate. |closed_by_escape| is true if - // the close is the result of pressing escape. - void Close(bool closed_by_escape); - #if defined(OS_WIN) // Overridden from WidgetWin: virtual void OnActivate(UINT action, BOOL minimized, HWND window); @@ -167,6 +160,11 @@ class InfoBubble : public views::WidgetGtk { virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation); #endif + private: + // Closes the window notifying the delegate. |closed_by_escape| is true if + // the close is the result of pressing escape. + void Close(bool closed_by_escape); + // Overridden from WidgetWin/WidgetGtk: virtual bool AcceleratorPressed(const views::Accelerator& accelerator); |