summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 23:42:23 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 23:42:23 +0000
commit6479c267dd32aab3f043aa2d3b2f808505c031ef (patch)
treeb4c1f5aa25fb119ed28338626e947a7f296a02e3
parentb44f5db5391f9865d5950fe88f77dd80e7661ab2 (diff)
downloadchromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.zip
chromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.tar.gz
chromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.tar.bz2
Removes WidgetWin dependency from StatusBubbleViews so that it can compile on Linux.
Requires: - making SetOpacity a cross platform method on Widget, replacing SetLayeredAlpha. - moving Window::SetBounds to Widget - replacing usage of MoveWindow in StatusBubbleViews with call to new SetBounds method. BUG=none TEST=make sure transparency still works for floating widgets like - status bubble, full screen exit bubble, dragged tabs Review URL: http://codereview.chromium.org/113846 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16948 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/external_tab_container.cc29
-rw-r--r--chrome/browser/external_tab_container.h8
-rw-r--r--chrome/browser/views/browser_bubble_win.cc2
-rw-r--r--chrome/browser/views/download_started_animation_win.cc6
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.cc2
-rw-r--r--chrome/browser/views/html_dialog_view.cc3
-rw-r--r--chrome/browser/views/status_bubble_views.cc145
-rw-r--r--chrome/browser/views/status_bubble_views.h13
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc4
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--views/widget/widget.h21
-rw-r--r--views/widget/widget_gtk.cc93
-rw-r--r--views/widget/widget_gtk.h12
-rw-r--r--views/widget/widget_win.cc102
-rw-r--r--views/widget/widget_win.h29
-rw-r--r--views/window/window.h10
-rw-r--r--views/window/window_win.cc6
-rw-r--r--views/window/window_win.h3
20 files changed, 283 insertions, 213 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index a32ed53..608b34e 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -323,6 +323,31 @@ void ExternalTabContainer::GetBounds(gfx::Rect* out,
*out = gfx::Rect(crect);
}
+void ExternalTabContainer::SetBounds(const gfx::Rect& bounds) {
+ SetBounds(bounds, NULL);
+}
+
+void ExternalTabContainer::SetBounds(const gfx::Rect& bounds,
+ gfx::NativeView other_window) {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Close() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::CloseNow() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Show() {
+ NOTIMPLEMENTED();
+}
+
+void ExternalTabContainer::Hide() {
+ NOTIMPLEMENTED();
+}
+
gfx::NativeView ExternalTabContainer::GetNativeView() const {
return m_hWnd;
}
@@ -334,6 +359,10 @@ void ExternalTabContainer::PaintNow(const gfx::Rect& update_rect) {
RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_NOERASE);
}
+void ExternalTabContainer::SetOpacity(unsigned char opacity) {
+ NOTIMPLEMENTED();
+}
+
views::RootView* ExternalTabContainer::GetRootView() {
return const_cast<views::RootView*>(&root_view_);
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index ee111e7..536dd52 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -110,8 +110,16 @@ class ExternalTabContainer : public TabContentsDelegate,
// views::Widget
/////////////////////////////////////////////////////////////////////////////
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void SetBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window);
+ virtual void Close();
+ virtual void CloseNow();
+ virtual void Show();
+ virtual void Hide();
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
+ virtual void SetOpacity(unsigned char opacity);
virtual views::RootView* GetRootView();
virtual Widget* GetRootWidget() const { return NULL; }
virtual bool IsVisible() const;
diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc
index 1adb229..47924ec 100644
--- a/chrome/browser/views/browser_bubble_win.cc
+++ b/chrome/browser/views/browser_bubble_win.cc
@@ -16,7 +16,7 @@ void BrowserBubble::InitPopup() {
pop->set_window_ex_style(WS_EX_LAYERED |
WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
- pop->SetLayeredAlpha(0xFF);
+ pop->SetOpacity(0xFF);
pop->Init(native_view, bounds_, false);
pop->SetContentsView(view_);
popup_.reset(pop);
diff --git a/chrome/browser/views/download_started_animation_win.cc b/chrome/browser/views/download_started_animation_win.cc
index 799d2ec..4de387e 100644
--- a/chrome/browser/views/download_started_animation_win.cc
+++ b/chrome/browser/views/download_started_animation_win.cc
@@ -105,7 +105,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin(
popup_->set_window_style(WS_POPUP);
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TRANSPARENT);
- popup_->SetLayeredAlpha(0x00);
+ popup_->SetOpacity(0x00);
popup_->Init(tab_contents_->GetNativeView(), rc, false);
popup_->SetContentsView(this);
Reposition();
@@ -157,8 +157,8 @@ void DownloadStartedAnimationWin::AnimateToState(double state) {
double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0,
static_cast<double>(1.0));
- popup_->SetLayeredAlpha(
- static_cast<BYTE>(opacity * 255.0));
+ popup_->SetOpacity(
+ static_cast<SkColor>(opacity * 255.0));
SchedulePaint(); // Reposition() calls MoveWindow() which never picks up
// alpha changes, so we need to force a paint.
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 5235fcd..677653a 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -569,7 +569,7 @@ void BrowserView::Show() {
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {
- frame_->GetWindow()->SetBounds(bounds);
+ GetWidget()->SetBounds(bounds);
}
void BrowserView::Close() {
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index 1623779..3b5e60c 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/views/fullscreen_exit_bubble.cc
@@ -144,7 +144,7 @@ FullscreenExitBubble::FullscreenExitBubble(
popup_->set_window_style(WS_POPUP);
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
- popup_->SetLayeredAlpha(static_cast<int>(0xff * kOpacity));
+ popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
popup_->Init(frame->GetNativeView(), GetPopupRect(false), false);
popup_->SetContentsView(view_);
popup_->Show(); // This does not activate the popup.
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 4be7870..afb23ad 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
#include "views/window/window.h"
namespace browser {
@@ -157,7 +158,7 @@ void HtmlDialogView::CloseContents(TabContents* source) {
void HtmlDialogView::MoveContents(TabContents* source, const gfx::Rect& pos) {
// The contained web page wishes to resize itself. We let it do this because
// if it's a dialog we know about, we trust it not to be mean to the user.
- window()->SetBounds(pos);
+ GetWidget()->SetBounds(pos);
}
bool HtmlDialogView::IsPopup(TabContents* source) {
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 59b78ef..9c8748a 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -9,7 +9,9 @@
#include "app/gfx/canvas.h"
#include "app/gfx/text_elider.h"
#include "app/l10n_util.h"
+#if defined(OS_WIN)
#include "app/l10n_util_win.h"
+#endif
#include "app/animation.h"
#include "app/resource_bundle.h"
#include "base/string_util.h"
@@ -22,7 +24,10 @@
#include "third_party/skia/include/core/SkRect.h"
#include "views/controls/label.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
+#if defined(OS_WIN)
#include "views/widget/widget_win.h"
+#endif
// The color of the background bubble.
static const SkColor kBubbleColor = SkColorSetRGB(222, 234, 248);
@@ -69,13 +74,13 @@ class StatusBubbleViews::StatusView : public views::Label,
public Animation,
public AnimationDelegate {
public:
- StatusView(StatusBubble* status_bubble, views::WidgetWin* popup)
+ StatusView(StatusBubble* status_bubble, views::Widget* popup)
: Animation(kFramerate, this),
- status_bubble_(status_bubble),
- popup_(popup),
stage_(BUBBLE_HIDDEN),
style_(STYLE_STANDARD),
timer_factory_(this),
+ status_bubble_(status_bubble),
+ popup_(popup),
opacity_start_(0),
opacity_end_(0) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -83,7 +88,7 @@ class StatusBubbleViews::StatusView : public views::Label,
SetFont(font);
}
- ~StatusView() {
+ virtual ~StatusView() {
Stop();
CancelTimer();
}
@@ -155,8 +160,8 @@ class StatusBubbleViews::StatusView : public views::Label,
// Manager, owns us.
StatusBubble* status_bubble_;
- // Handle to the HWND that contains us.
- views::WidgetWin* popup_;
+ // Handle to the widget that contains us.
+ views::Widget* popup_;
// The currently-displayed text.
std::wstring text_;
@@ -219,9 +224,8 @@ void StatusBubbleViews::StatusView::OnTimer() {
}
void StatusBubbleViews::StatusView::CancelTimer() {
- if (!timer_factory_.empty()) {
+ if (!timer_factory_.empty())
timer_factory_.RevokeAll();
- }
}
void StatusBubbleViews::StatusView::RestartTimer(int delay) {
@@ -298,7 +302,7 @@ double StatusBubbleViews::StatusView::GetCurrentOpacity() {
}
void StatusBubbleViews::StatusView::SetOpacity(double opacity) {
- popup_->SetLayeredAlpha(static_cast<BYTE>(opacity * 255));
+ popup_->SetOpacity(static_cast<unsigned char>(opacity * 255));
SchedulePaint();
}
@@ -331,8 +335,8 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setColor(kBubbleColor);
- RECT parent_rect;
- ::GetWindowRect(popup_->GetNativeView(), &parent_rect);
+ gfx::Rect popup_bounds;
+ popup_->GetBounds(&popup_bounds, true);
// Figure out how to round the bubble's four corners.
SkScalar rad[8];
@@ -392,8 +396,8 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
}
// Draw the bubble's shadow.
- int width = parent_rect.right - parent_rect.left;
- int height = parent_rect.bottom - parent_rect.top;
+ int width = popup_bounds.width();
+ int height = popup_bounds.height();
SkRect rect;
rect.set(0, 0,
SkIntToScalar(width),
@@ -449,42 +453,40 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
const int StatusBubbleViews::kShadowThickness = 1;
StatusBubbleViews::StatusBubbleViews(views::Widget* frame)
- : popup_(NULL),
- frame_(frame),
- view_(NULL),
+ : offset_(0),
+ popup_(NULL),
opacity_(0),
- position_(0, 0),
- size_(0, 0),
- offset_(0) {
+ frame_(frame),
+ view_(NULL) {
}
StatusBubbleViews::~StatusBubbleViews() {
if (popup_.get())
popup_->CloseNow();
-
- position_ = NULL;
- size_ = NULL;
}
void StatusBubbleViews::Init() {
if (!popup_.get()) {
- popup_.reset(new views::WidgetWin());
- popup_->set_delete_on_destroy(false);
+#if defined(OS_WIN)
+ views::WidgetWin* popup = new views::WidgetWin;
+ popup->set_delete_on_destroy(false);
if (!view_)
- view_ = new StatusView(this, popup_.get());
-
- gfx::Rect rc(0, 0, 0, 0);
-
- popup_->set_window_style(WS_POPUP);
- popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
- WS_EX_TRANSPARENT |
- l10n_util::GetExtendedTooltipStyles());
- popup_->SetLayeredAlpha(0x00);
- popup_->Init(frame_->GetNativeView(), rc, false);
- popup_->SetContentsView(view_);
+ view_ = new StatusView(this, popup);
+
+ popup->set_window_style(WS_POPUP);
+ popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
+ WS_EX_TRANSPARENT |
+ l10n_util::GetExtendedTooltipStyles());
+ popup->SetOpacity(0x00);
+ popup->Init(frame_->GetNativeView(), gfx::Rect(), false);
+ popup->SetContentsView(view_);
Reposition();
- popup_->Show();
+ popup->Show();
+ popup_.reset(popup);
+#else
+ NOTIMPLEMENTED();
+#endif
}
}
@@ -516,9 +518,9 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) {
}
// Set Elided Text corresponding to the GURL object.
- RECT parent_rect;
- ::GetWindowRect(popup_->GetNativeView(), &parent_rect);
- int text_width = static_cast<int>(parent_rect.right - parent_rect.left -
+ gfx::Rect popup_bounds;
+ popup_->GetBounds(&popup_bounds, true);
+ int text_width = static_cast<int>(popup_bounds.width() -
(kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
url_text_ = gfx::ElideUrl(url, view_->Label::GetFont(), text_width,
languages);
@@ -555,8 +557,14 @@ void StatusBubbleViews::AvoidMouse() {
// Our status bubble is located in screen coordinates, so we should get
// those rather than attempting to reverse decode the web contents
// coordinates.
- CPoint cursor_location;
- GetCursorPos(&cursor_location);
+ gfx::Point cursor_location;
+#if defined(OS_WIN)
+ POINT tmp = { 0, 0 };
+ GetCursorPos(&tmp);
+ cursor_location = tmp;
+#else
+ NOTIMPLEMENTED();
+#endif
// Get the position of the frame.
gfx::Point top_left;
@@ -564,32 +572,32 @@ void StatusBubbleViews::AvoidMouse() {
views::View::ConvertPointToScreen(root, &top_left);
// Get the cursor position relative to the popup.
- cursor_location.x -= (top_left.x() + position_.x);
- cursor_location.y -= (top_left.y() + position_.y);
+ cursor_location.set_x(cursor_location.x() - (top_left.x() + position_.x()));
+ cursor_location.set_y(cursor_location.y() - (top_left.y() + position_.y()));
// If the mouse is in a position where we think it would move the
// status bubble, figure out where and how the bubble should be moved.
- if (cursor_location.y > -kMousePadding &&
- cursor_location.x < size_.cx + kMousePadding) {
- int offset = kMousePadding + cursor_location.y;
+ if (cursor_location.y() > -kMousePadding &&
+ cursor_location.x() < size_.width() + kMousePadding) {
+ int offset = kMousePadding + cursor_location.y();
// Make the movement non-linear.
offset = offset * offset / kMousePadding;
// When the mouse is entering from the right, we want the offset to be
// scaled by how horizontally far away the cursor is from the bubble.
- if (cursor_location.x > size_.cx) {
+ if (cursor_location.x() > size_.width()) {
offset = static_cast<int>(static_cast<float>(offset) * (
static_cast<float>(kMousePadding -
- (cursor_location.x - size_.cx)) /
+ (cursor_location.x() - size_.width())) /
static_cast<float>(kMousePadding)));
}
// Cap the offset and change the visual presentation of the bubble
// depending on where it ends up (so that rounded corners square off
// and mate to the edges of the tab content).
- if (offset >= size_.cy - kShadowThickness * 2) {
- offset = size_.cy - kShadowThickness * 2;
+ if (offset >= size_.height() - kShadowThickness * 2) {
+ offset = size_.height() - kShadowThickness * 2;
view_->SetStyle(StatusView::STYLE_BOTTOM);
} else if (offset > kBubbleCornerRadius / 2 - kShadowThickness) {
view_->SetStyle(StatusView::STYLE_FLOATING);
@@ -598,12 +606,17 @@ void StatusBubbleViews::AvoidMouse() {
}
// Check if the bubble sticks out from the monitor.
+#if defined(OS_WIN)
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(MonitorFromWindow(frame_->GetNativeView(),
MONITOR_DEFAULTTONEAREST), &monitor_info);
gfx::Rect monitor_rect(monitor_info.rcWork);
- const int bubble_bottom_y = top_left.y() + position_.y + size_.cy;
+#else
+ gfx::Rect monitor_rect;
+ NOTIMPLEMENTED();
+#endif
+ const int bubble_bottom_y = top_left.y() + position_.y() + size_.height();
if (bubble_bottom_y + offset > monitor_rect.height()) {
// The offset is still too large. Move the bubble to the right and reset
@@ -613,26 +626,23 @@ void StatusBubbleViews::AvoidMouse() {
int root_width = root->GetLocalBounds(true).width(); // border included.
// Substract border width + bubble width.
- int right_position_x = root_width - (position_.x + size_.cx);
- popup_->MoveWindow(top_left.x() + right_position_x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ int right_position_x = root_width - (position_.x() + size_.width());
+ popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x,
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
} else {
offset_ = offset;
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y + offset_,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y() + offset_,
+ size_.width(), size_.height()));
}
} else if (offset_ != 0 ||
view_->GetStyle() == StatusView::STYLE_STANDARD_RIGHT) {
offset_ = 0;
view_->SetStyle(StatusView::STYLE_STANDARD);
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
}
}
@@ -641,10 +651,9 @@ void StatusBubbleViews::Reposition() {
gfx::Point top_left;
views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
- popup_->MoveWindow(top_left.x() + position_.x,
- top_left.y() + position_.y,
- size_.cx,
- size_.cy);
+ popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
+ top_left.y() + position_.y(),
+ size_.width(), size_.height()));
}
}
diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h
index cdda382..5a94bb2 100644
--- a/chrome/browser/views/status_bubble_views.h
+++ b/chrome/browser/views/status_bubble_views.h
@@ -6,11 +6,14 @@
#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_VIEWS_H_
#include "base/gfx/rect.h"
+#include "base/logging.h"
+#include "base/scoped_ptr.h"
#include "chrome/browser/status_bubble.h"
-#include "views/widget/widget.h"
-#include "views/widget/widget_win.h"
class GURL;
+namespace views {
+class Widget;
+}
// StatusBubble displays a bubble of text that fades in, hovers over the
// browser chrome and fades away when not needed. It is primarily designed
@@ -53,15 +56,15 @@ class StatusBubbleViews : public StatusBubble {
std::wstring url_text_;
// Position relative to the parent window.
- CPoint position_;
- CSize size_;
+ gfx::Point position_;
+ gfx::Size size_;
// How vertically offset the bubble is from its root position_.
int offset_;
// We use a HWND for the popup so that it may float above any HWNDs in our
// UI (the location bar, for example).
- scoped_ptr<views::WidgetWin> popup_;
+ scoped_ptr<views::Widget> popup_;
double opacity_;
views::Widget* frame_;
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index b3ac3bf..06ca3ad 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -169,7 +169,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate {
popup->set_window_style(WS_POPUP);
popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
WS_EX_TOPMOST);
- popup->SetLayeredAlpha(0x00);
+ popup->SetOpacity(0x00);
popup->Init(NULL, info.GetPopupRect(), false);
popup->SetContentsView(new DockView(info.type()));
if (info.in_enable_area())
@@ -237,7 +237,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate {
virtual void UpdateLayeredAlpha() {
#if defined(OS_WIN)
double scale = in_enable_area_ ? 1 : .5;
- static_cast<views::WidgetWin*>(popup_)->SetLayeredAlpha(
+ static_cast<views::WidgetWin*>(popup_)->SetOpacity(
static_cast<BYTE>(animation_.GetCurrentValue() * scale * 255.0));
popup_->GetRootView()->SchedulePaint();
#else
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index c805db1..77fd7c7 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -104,7 +104,7 @@ void DraggedTabView::Attach(int selected_width) {
photobooth_ = NULL;
attached_tab_size_.set_width(selected_width);
#if defined(OS_WIN)
- container_->SetLayeredAlpha(kOpaqueAlpha);
+ container_->SetOpacity(kOpaqueAlpha);
#else
NOTIMPLEMENTED();
#endif
@@ -116,7 +116,7 @@ void DraggedTabView::Detach(NativeViewPhotobooth* photobooth) {
attached_ = false;
photobooth_ = photobooth;
#if defined(OS_WIN)
- container_->SetLayeredAlpha(kTransparentAlpha);
+ container_->SetOpacity(kTransparentAlpha);
#else
NOTIMPLEMENTED();
#endif
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 8545723..51c2645 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1690,6 +1690,8 @@
['include', '^browser/views/info_bubble.h'],
['include', '^browser/views/location_bar_view.cc'],
['include', '^browser/views/location_bar_view.h'],
+ ['include', '^browser/views/status_bubble_views.cc'],
+ ['include', '^browser/views/status_bubble_views.h'],
['include', '^browser/views/tab_contents/native_tab_contents_container_gtk.cc'],
['include', '^browser/views/tab_contents/native_tab_contents_container_gtk.h'],
['include', '^browser/views/tabs/dragged_tab_view.cc'],
diff --git a/views/widget/widget.h b/views/widget/widget.h
index b2c3551..efa16c5 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -46,12 +46,33 @@ class Widget {
// including_frame is ignored.
virtual void GetBounds(gfx::Rect* out, bool including_frame) const = 0;
+ // Sizes and/or places the widget to the specified bounds, size or position.
+ virtual void SetBounds(const gfx::Rect& bounds) = 0;
+
+ // Hides the widget then closes it after a return to the message loop.
+ virtual void Close() = 0;
+
+ // Closes the widget immediately. Compare to |Close|. This will destroy the
+ // window handle associated with this Widget, so should not be called from
+ // any code that expects it to be valid beyond this call.
+ virtual void CloseNow() = 0;
+
+ // Shows or hides the widget, without changing activation state.
+ virtual void Show() = 0;
+ virtual void Hide() = 0;
+
// Returns the gfx::NativeView associated with this Widget.
virtual gfx::NativeView GetNativeView() const = 0;
// Forces a paint of a specified rectangle immediately.
virtual void PaintNow(const gfx::Rect& update_rect) = 0;
+ // Sets the opacity of the widget. This may allow widgets behind the widget
+ // in the Z-order to become visible, depending on the capabilities of the
+ // underlying windowing system. Note that the caller must then schedule a
+ // repaint to allow this change to take effect.
+ virtual void SetOpacity(unsigned char opacity) = 0;
+
// Returns the RootView contained by this Widget.
virtual RootView* GetRootView() = 0;
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index fe347a5..64558ed 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -51,6 +51,9 @@ static int GetFlagsForEventButton(const GdkEventButton& event) {
return flags;
}
+////////////////////////////////////////////////////////////////////////////////
+// WidgetGtk, public:
+
WidgetGtk::WidgetGtk(Type type)
: is_window_(false),
type_(type),
@@ -189,6 +192,44 @@ void WidgetGtk::SetContentsView(View* view) {
OnSizeAllocate(widget_, &(widget_->allocation));
}
+////////////////////////////////////////////////////////////////////////////////
+// WidgetGtk, Widget implementation:
+
+void WidgetGtk::GetBounds(gfx::Rect* out, bool including_frame) const {
+ DCHECK(widget_);
+
+ int x = 0, y = 0, w, h;
+ if (GTK_IS_WINDOW(widget_)) {
+ gtk_window_get_position(GTK_WINDOW(widget_), &x, &y);
+ gtk_window_get_size(GTK_WINDOW(widget_), &w, &h);
+ } else {
+ // TODO: make sure this is right. Docs indicate gtk_window_get_position
+ // returns a value useful to the window manager, which may not be the same
+ // as the actual location on the screen.
+ GetWidgetPositionOnScreen(widget_, &x, &y);
+ w = widget_->allocation.width;
+ h = widget_->allocation.height;
+ }
+
+ if (including_frame) {
+ // TODO: Docs indicate it isn't possible to get at this value. We may need
+ // to turn off all decorations so that the frame is always of a 0x0 size.
+ NOTIMPLEMENTED();
+ }
+
+ return out->SetRect(x, y, w, h);
+}
+
+void WidgetGtk::SetBounds(const gfx::Rect& bounds) {
+ if (type_ == TYPE_CHILD) {
+ WidgetGtk* parent_widget = GetViewForNative(gtk_widget_get_parent(widget_));
+ parent_widget->PositionChild(widget_, bounds.x(), bounds.y(),
+ bounds.width(), bounds.height());
+ } else {
+ NOTIMPLEMENTED();
+ }
+}
+
void WidgetGtk::Close() {
if (!widget_)
return; // No need to do anything.
@@ -218,41 +259,6 @@ void WidgetGtk::Hide() {
gtk_widget_hide(widget_);
}
-void WidgetGtk::SetBounds(const gfx::Rect& bounds) {
- if (type_ == TYPE_CHILD) {
- WidgetGtk* parent_widget = GetViewForNative(gtk_widget_get_parent(widget_));
- parent_widget->PositionChild(widget_, bounds.x(), bounds.y(),
- bounds.width(), bounds.height());
- } else {
- NOTIMPLEMENTED();
- }
-}
-
-void WidgetGtk::GetBounds(gfx::Rect* out, bool including_frame) const {
- DCHECK(widget_);
-
- int x = 0, y = 0, w, h;
- if (GTK_IS_WINDOW(widget_)) {
- gtk_window_get_position(GTK_WINDOW(widget_), &x, &y);
- gtk_window_get_size(GTK_WINDOW(widget_), &w, &h);
- } else {
- // TODO: make sure this is right. Docs indicate gtk_window_get_position
- // returns a value useful to the window manager, which may not be the same
- // as the actual location on the screen.
- GetWidgetPositionOnScreen(widget_, &x, &y);
- w = widget_->allocation.width;
- h = widget_->allocation.height;
- }
-
- if (including_frame) {
- // TODO: Docs indicate it isn't possible to get at this value. We may need
- // to turn off all decorations so that the frame is always of a 0x0 size.
- NOTIMPLEMENTED();
- }
-
- return out->SetRect(x, y, w, h);
-}
-
gfx::NativeView WidgetGtk::GetNativeView() const {
return widget_;
}
@@ -262,6 +268,11 @@ void WidgetGtk::PaintNow(const gfx::Rect& update_rect) {
update_rect.width(), update_rect.height());
}
+void WidgetGtk::SetOpacity(unsigned char opacity) {
+ // TODO(port): implement this feature.
+ NOTIMPLEMENTED();
+}
+
RootView* WidgetGtk::GetRootView() {
if (!root_view_.get()) {
// First time the root view is being asked for, create it now.
@@ -304,14 +315,20 @@ Window* WidgetGtk::GetWindow() {
return GetWindowImpl(widget_);
}
+const Window* WidgetGtk::GetWindow() const {
+ return GetWindowImpl(widget_);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WidgetGtk, MessageLoopForUI::Observer implementation:
+
void WidgetGtk::DidProcessEvent(GdkEvent* event) {
if (root_view_->NeedsPainting(true))
PaintNow(root_view_->GetScheduledPaintRect());
}
-const Window* WidgetGtk::GetWindow() const {
- return GetWindowImpl(widget_);
-}
+////////////////////////////////////////////////////////////////////////////////
+// TODO(beng): organize into sections:
void WidgetGtk::CreateGtkWidget() {
if (type_ == TYPE_CHILD) {
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index 73d8b7f..7cbc87e 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -59,18 +59,16 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer {
virtual void SetContentsView(View* view);
+ // Overridden from Widget:
+ virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
+ virtual void SetBounds(const gfx::Rect& bounds);
virtual void Close();
- void CloseNow();
+ virtual void CloseNow();
virtual void Show();
virtual void Hide();
-
- // Sets the bounds of the widget.
- virtual void SetBounds(const gfx::Rect& bounds);
-
- // Overridden from Widget:
- virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
+ virtual void SetOpacity(unsigned char opacity);
virtual RootView* GetRootView();
virtual Widget* GetRootWidget() const;
virtual bool IsVisible() const;
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index fdb6252..039ab36 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -253,6 +253,54 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
crect.Width(), crect.Height());
}
+void WidgetWin::SetBounds(const gfx::Rect& bounds) {
+ SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
+ SWP_NOACTIVATE);
+}
+
+void WidgetWin::Close() {
+ if (!IsWindow())
+ return; // No need to do anything.
+
+ // Let's hide ourselves right away.
+ Hide();
+ if (close_widget_factory_.empty()) {
+ // And we delay the close so that if we are called from an ATL callback,
+ // we don't destroy the window before the callback returned (as the caller
+ // may delete ourselves on destroy and the ATL callback would still
+ // dereference us when the callback returns).
+ MessageLoop::current()->PostTask(FROM_HERE,
+ close_widget_factory_.NewRunnableMethod(
+ &WidgetWin::CloseNow));
+ }
+}
+
+void WidgetWin::CloseNow() {
+ // We may already have been destroyed if the selection resulted in a tab
+ // switch which will have reactivated the browser window and closed us, so
+ // we need to check to see if we're still a window before trying to destroy
+ // ourself.
+ if (IsWindow())
+ DestroyWindow();
+}
+
+void WidgetWin::Show() {
+ if (IsWindow())
+ ShowWindow(SW_SHOWNOACTIVATE);
+}
+
+void WidgetWin::Hide() {
+ if (IsWindow()) {
+ // NOTE: Be careful not to activate any windows here (for example, calling
+ // ShowWindow(SW_HIDE) will automatically activate another window). This
+ // code can be called while a window is being deactivated, and activating
+ // another window will screw up the activation that is already in progress.
+ SetWindowPos(NULL, 0, 0, 0, 0,
+ SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ }
+}
+
gfx::NativeView WidgetWin::GetNativeView() const {
return hwnd_;
}
@@ -316,6 +364,10 @@ void WidgetWin::PaintNow(const gfx::Rect& update_rect) {
}
}
+void WidgetWin::SetOpacity(unsigned char opacity) {
+ layered_alpha_ = static_cast<BYTE>(opacity);
+}
+
RootView* WidgetWin::GetRootView() {
if (!root_view_.get()) {
// First time the root view is being asked for, create it now.
@@ -359,13 +411,6 @@ const Window* WidgetWin::GetWindow() const {
return GetWindowImpl(hwnd_);
}
-void WidgetWin::SetLayeredAlpha(BYTE layered_alpha) {
- layered_alpha_ = layered_alpha;
-
-// if (hwnd_)
-// UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC());
-}
-
void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
if (use_layered_buffer_ == use_layered_buffer)
return;
@@ -407,49 +452,6 @@ RootView* WidgetWin::FindRootView(HWND hwnd) {
return root_view;
}
-void WidgetWin::Close() {
- if (!IsWindow())
- return; // No need to do anything.
-
- // Let's hide ourselves right away.
- Hide();
- if (close_widget_factory_.empty()) {
- // And we delay the close so that if we are called from an ATL callback,
- // we don't destroy the window before the callback returned (as the caller
- // may delete ourselves on destroy and the ATL callback would still
- // dereference us when the callback returns).
- MessageLoop::current()->PostTask(FROM_HERE,
- close_widget_factory_.NewRunnableMethod(
- &WidgetWin::CloseNow));
- }
-}
-
-void WidgetWin::Hide() {
- if (IsWindow()) {
- // NOTE: Be careful not to activate any windows here (for example, calling
- // ShowWindow(SW_HIDE) will automatically activate another window). This
- // code can be called while a window is being deactivated, and activating
- // another window will screw up the activation that is already in progress.
- SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
- }
-}
-
-void WidgetWin::Show() {
- if (IsWindow())
- ShowWindow(SW_SHOWNOACTIVATE);
-}
-
-void WidgetWin::CloseNow() {
- // We may already have been destroyed if the selection resulted in a tab
- // switch which will have reactivated the browser window and closed us, so
- // we need to check to see if we're still a window before trying to destroy
- // ourself.
- if (IsWindow())
- DestroyWindow();
-}
-
///////////////////////////////////////////////////////////////////////////////
// MessageLoop::Observer
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 3a120db..ebf6bfa 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -111,10 +111,6 @@ class WidgetWin : public Widget,
delete_on_destroy_ = delete_on_destroy;
}
- // Sets the initial opacity of a layered window, or updates the window's
- // opacity if it is on the screen.
- void SetLayeredAlpha(BYTE layered_alpha);
-
// See description of use_layered_buffer_ for details.
void SetUseLayeredBuffer(bool use_layered_buffer);
@@ -126,23 +122,6 @@ class WidgetWin : public Widget,
// Returns the RootView associated with the specified HWND (if any).
static RootView* FindRootView(HWND hwnd);
- // Closes the window asynchronously by scheduling a task for it. The window
- // is destroyed as a result.
- // This invokes Hide to hide the window, and schedules a task that
- // invokes CloseNow.
- virtual void Close();
-
- // Hides the window. This does NOT delete the window, it just hides it.
- virtual void Hide();
-
- // Shows the window without changing size/position/activation state.
- virtual void Show();
-
- // Closes the window synchronously. Note that this should not be called from
- // an ATL message callback as it deletes the WidgetWin and ATL will
- // dereference it after the callback is processed.
- void CloseNow();
-
// All classes registered by WidgetWin start with this name.
static const wchar_t* const kBaseClassName;
@@ -234,8 +213,14 @@ class WidgetWin : public Widget,
// Overridden from Widget:
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
+ virtual void SetBounds(const gfx::Rect& bounds);
+ virtual void Close();
+ virtual void CloseNow();
+ virtual void Show();
+ virtual void Hide();
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
+ virtual void SetOpacity(unsigned char opacity);
virtual RootView* GetRootView();
virtual Widget* GetRootWidget() const;
virtual bool IsVisible() const;
@@ -514,6 +499,8 @@ class WidgetWin : public Widget,
// is true.
virtual bool ReleaseCaptureOnMouseReleased() { return true; }
+ // Creates the RootView to be used within this Widget. Can be overridden to
+ // create specialized RootView implementations.
virtual RootView* CreateRootView();
// Returns true if this WidgetWin is opaque.
diff --git a/views/window/window.h b/views/window/window.h
index bb618ed..b5a1f56 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -50,12 +50,10 @@ class Window {
// Retrieves the restored bounds for the window.
virtual gfx::Rect GetNormalBounds() const = 0;
- // Sizes and/or places the window to the specified bounds, size or position.
- virtual void SetBounds(const gfx::Rect& bounds) = 0;
-
- // As above, except the window is inserted after |other_window| in the window
- // Z-order. If this window is not yet visible, other_window's monitor is used
- // as the constraining rectangle, rather than this window's monitor.
+ // Sets the Window's bounds. The window is inserted after |other_window| in
+ // the window Z-order. If this window is not yet visible, other_window's
+ // monitor is used as the constraining rectangle, rather than this window's
+ // monitor.
virtual void SetBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) = 0;
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 2ba4797..3e52871 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -127,10 +127,6 @@ gfx::Rect WindowWin::GetNormalBounds() const {
return gfx::Rect(wp.rcNormalPosition);
}
-void WindowWin::SetBounds(const gfx::Rect& bounds) {
- SetBounds(bounds, NULL);
-}
-
void WindowWin::SetBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) {
win_util::SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
@@ -1213,7 +1209,7 @@ void WindowWin::SetInitialBounds(const gfx::Rect& create_bounds) {
SizeWindowToDefault();
} else {
// Use the supplied initial bounds.
- SetBounds(create_bounds);
+ SetBounds(create_bounds, NULL);
}
}
}
diff --git a/views/window/window_win.h b/views/window/window_win.h
index ddc2f21..5be2319 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -50,10 +50,9 @@ class WindowWin : public WidgetWin,
focus_on_creation_ = focus_on_creation;
}
- // Window overrides:
+ // Overridden from Window:
virtual gfx::Rect GetBounds() const;
virtual gfx::Rect GetNormalBounds() const;
- virtual void SetBounds(const gfx::Rect& bounds);
virtual void SetBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window);
virtual void Show();