summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 21:52:48 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 21:52:48 +0000
commit0a2aeb81a06170cf4d99392b683736c46212f9ef (patch)
tree1c491dcbe56474ad5bbbd6da0cd47c75eca414d3 /chrome/browser/gtk
parent26ee7556422eb077a813c9a15a03867779bb8188 (diff)
downloadchromium_src-0a2aeb81a06170cf4d99392b683736c46212f9ef.zip
chromium_src-0a2aeb81a06170cf4d99392b683736c46212f9ef.tar.gz
chromium_src-0a2aeb81a06170cf4d99392b683736c46212f9ef.tar.bz2
Linux: Take download shelf and infobar close animations into account during render view sizing.
http://crbug.com/11080 Review URL: http://codereview.chromium.org/113322 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc7
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h1
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc4
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.h1
-rw-r--r--chrome/browser/gtk/infobar_container_gtk.cc43
-rw-r--r--chrome/browser/gtk/infobar_container_gtk.h6
-rw-r--r--chrome/browser/gtk/infobar_gtk.cc4
-rw-r--r--chrome/browser/gtk/infobar_gtk.h3
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.cc9
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.h6
10 files changed, 65 insertions, 19 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index bf441a5..49fc667 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -593,6 +593,13 @@ void BrowserWindowGtk::UserChangedTheme() {
NOTIMPLEMENTED();
}
+int BrowserWindowGtk::GetExtraRenderViewHeight() const {
+ // The download shelf is controlled by its TabContents, so we don't have to
+ // worry about it here.
+ // TODO(estade): take the bookmark bar into account as well.
+ return infobar_container_->TotalHeightOfClosingBars();
+}
+
void BrowserWindowGtk::ConfirmBrowserCloseWithPendingDownloads() {
NOTIMPLEMENTED();
browser_->InProgressDownloadResponse(false);
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index f292cdf..c54a120 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -79,6 +79,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
void* parent_window);
virtual void UserChangedTheme();
+ virtual int GetExtraRenderViewHeight() const;
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
index 3eb794c..f594a7f 100644
--- a/chrome/browser/gtk/download_shelf_gtk.cc
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -138,6 +138,10 @@ bool DownloadShelfGtk::IsShowing() const {
return slide_widget_->IsShowing();
}
+bool DownloadShelfGtk::IsClosing() const {
+ return slide_widget_->IsClosing();
+}
+
void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) {
DCHECK(download_item);
std::vector<DownloadItemGtk*>::iterator i =
diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h
index e2819a0..bc41647 100644
--- a/chrome/browser/gtk/download_shelf_gtk.h
+++ b/chrome/browser/gtk/download_shelf_gtk.h
@@ -28,6 +28,7 @@ class DownloadShelfGtk : public DownloadShelf {
// DownloadShelf implementation.
virtual void AddDownload(BaseDownloadItemModel* download_model);
virtual bool IsShowing() const;
+ virtual bool IsClosing() const;
private:
// Remove |download_item| from the download shelf and delete it.
diff --git a/chrome/browser/gtk/infobar_container_gtk.cc b/chrome/browser/gtk/infobar_container_gtk.cc
index 3623497..a44ef65 100644
--- a/chrome/browser/gtk/infobar_container_gtk.cc
+++ b/chrome/browser/gtk/infobar_container_gtk.cc
@@ -15,28 +15,33 @@
namespace {
-// Used by RemoveInfoBar to pass data to AnimateClosingForDelegate.
-struct RemoveInfoBarData {
- GtkWidget* container;
- InfoBarDelegate* delegate;
-};
-
+// If |infobar_widget| matches |info_bar_delegate|, then close the infobar.
void AnimateClosingForDelegate(GtkWidget* infobar_widget,
- gpointer remove_info_bar_data) {
+ gpointer info_bar_delegate) {
+ InfoBarDelegate* delegate =
+ static_cast<InfoBarDelegate*>(info_bar_delegate);
InfoBar* infobar = reinterpret_cast<InfoBar*>(
g_object_get_data(G_OBJECT(infobar_widget), "info-bar"));
- RemoveInfoBarData* data =
- reinterpret_cast<RemoveInfoBarData*>(remove_info_bar_data);
if (!infobar) {
NOTREACHED();
return;
}
- if (data->delegate == infobar->delegate())
+ if (delegate == infobar->delegate())
infobar->AnimateClose();
}
+// Get the height of the widget and add it to |userdata|, but only if it is in
+// the process of closing.
+void SumClosingBarHeight(GtkWidget* widget, gpointer userdata) {
+ int* height_sum = static_cast<int*>(userdata);
+ InfoBar* infobar = reinterpret_cast<InfoBar*>(
+ g_object_get_data(G_OBJECT(widget), "info-bar"));
+ if (infobar->IsClosing())
+ *height_sum += widget->allocation.height;
+}
+
} // namespace
// InfoBarContainerGtk, public: ------------------------------------------------
@@ -45,7 +50,7 @@ InfoBarContainerGtk::InfoBarContainerGtk(BrowserWindow* browser_window)
: browser_window_(browser_window),
tab_contents_(NULL),
container_(gtk_vbox_new(FALSE, 0)) {
- gtk_widget_show(container_.get());
+ gtk_widget_show(widget());
}
InfoBarContainerGtk::~InfoBarContainerGtk() {
@@ -65,7 +70,7 @@ void InfoBarContainerGtk::ChangeTabContents(TabContents* contents) {
Source<TabContents>(tab_contents_));
}
- gtk_util::RemoveAllChildren(container_.get());
+ gtk_util::RemoveAllChildren(widget());
tab_contents_ = contents;
if (tab_contents_) {
@@ -83,6 +88,12 @@ void InfoBarContainerGtk::RemoveDelegate(InfoBarDelegate* delegate) {
tab_contents_->RemoveInfoBar(delegate);
}
+int InfoBarContainerGtk::TotalHeightOfClosingBars() const {
+ int sum = 0;
+ gtk_container_foreach(GTK_CONTAINER(widget()), SumClosingBarHeight, &sum);
+ return sum;
+}
+
// InfoBarContainerGtk, NotificationObserver implementation: -------------------
void InfoBarContainerGtk::Observe(NotificationType type,
@@ -109,7 +120,7 @@ void InfoBarContainerGtk::UpdateInfoBars() {
void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) {
InfoBar* infobar = delegate->CreateInfoBar();
infobar->set_container(this);
- gtk_box_pack_end(GTK_BOX(container_.get()), infobar->widget(),
+ gtk_box_pack_end(GTK_BOX(widget()), infobar->widget(),
FALSE, FALSE, 0);
if (animate)
infobar->AnimateOpen();
@@ -118,8 +129,6 @@ void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) {
}
void InfoBarContainerGtk::RemoveInfoBar(InfoBarDelegate* delegate) {
- RemoveInfoBarData remove_info_bar_data = { container_.get(), delegate };
-
- gtk_container_foreach(GTK_CONTAINER(container_.get()),
- AnimateClosingForDelegate, &remove_info_bar_data);
+ gtk_container_foreach(GTK_CONTAINER(widget()),
+ AnimateClosingForDelegate, delegate);
}
diff --git a/chrome/browser/gtk/infobar_container_gtk.h b/chrome/browser/gtk/infobar_container_gtk.h
index 60bd8d0..58e0c52 100644
--- a/chrome/browser/gtk/infobar_container_gtk.h
+++ b/chrome/browser/gtk/infobar_container_gtk.h
@@ -21,7 +21,7 @@ class InfoBarContainerGtk : public NotificationObserver {
virtual ~InfoBarContainerGtk();
// Get the native widget.
- GtkWidget* widget() { return container_.get(); }
+ GtkWidget* widget() const { return container_.get(); }
// Changes the TabContents for which this container is showing InfoBars. Can
// be NULL, in which case we will simply detach ourselves from the old tab
@@ -33,6 +33,10 @@ class InfoBarContainerGtk : public NotificationObserver {
// the InfoBar's close button handler.
void RemoveDelegate(InfoBarDelegate* delegate);
+ // Returns the total pixel height of all infobars in this container that
+ // are currently closing.
+ int TotalHeightOfClosingBars() const;
+
private:
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc
index e129fa9..60fa01d 100644
--- a/chrome/browser/gtk/infobar_gtk.cc
+++ b/chrome/browser/gtk/infobar_gtk.cc
@@ -105,6 +105,10 @@ void InfoBar::Close() {
delete this;
}
+bool InfoBar::IsClosing() {
+ return slide_widget_->IsClosing();
+}
+
void InfoBar::RemoveInfoBar() const {
container_->RemoveDelegate(delegate_);
}
diff --git a/chrome/browser/gtk/infobar_gtk.h b/chrome/browser/gtk/infobar_gtk.h
index c39fceb..e3d5b1b 100644
--- a/chrome/browser/gtk/infobar_gtk.h
+++ b/chrome/browser/gtk/infobar_gtk.h
@@ -43,6 +43,9 @@ class InfoBar : public SlideAnimatorGtk::Delegate {
// is called.
void Close();
+ // Returns true if the infobar is showing the close animation.
+ bool IsClosing();
+
// SlideAnimatorGtk::Delegate implementation.
virtual void Closed();
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc
index 3cf004c..1f76457 100644
--- a/chrome/browser/gtk/slide_animator_gtk.cc
+++ b/chrome/browser/gtk/slide_animator_gtk.cc
@@ -32,7 +32,8 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child,
: child_(child),
direction_(direction),
delegate_(delegate),
- fixed_needs_resize_(false) {
+ fixed_needs_resize_(false),
+ is_closing_(false) {
widget_.Own(gtk_fixed_new());
gtk_fixed_put(GTK_FIXED(widget_.get()), child, 0, 0);
gtk_widget_set_size_request(widget_.get(), -1, 0);
@@ -64,6 +65,7 @@ SlideAnimatorGtk::~SlideAnimatorGtk() {
}
void SlideAnimatorGtk::Open() {
+ is_closing_ = false;
gtk_widget_show_all(widget_.get());
animation_->Show();
}
@@ -84,6 +86,7 @@ void SlideAnimatorGtk::OpenWithoutAnimation() {
}
void SlideAnimatorGtk::Close() {
+ is_closing_ = true;
animation_->Hide();
}
@@ -98,6 +101,10 @@ bool SlideAnimatorGtk::IsShowing() {
return animation_->IsShowing();
}
+bool SlideAnimatorGtk::IsClosing() {
+ return animation_->IsAnimating() && is_closing_;
+}
+
void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) {
int showing_height = child_->allocation.height *
animation_->GetCurrentValue();
diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h
index 7d9fcb6..3acc4f5 100644
--- a/chrome/browser/gtk/slide_animator_gtk.h
+++ b/chrome/browser/gtk/slide_animator_gtk.h
@@ -67,6 +67,9 @@ class SlideAnimatorGtk : public AnimationDelegate {
// Returns whether the widget is visible.
bool IsShowing();
+ // Returns whether the widget is currently showing the close animation.
+ bool IsClosing();
+
// AnimationDelegate implementation.
void AnimationProgressed(const Animation* animation);
void AnimationEnded(const Animation* animation);
@@ -100,6 +103,9 @@ class SlideAnimatorGtk : public AnimationDelegate {
// child widget has been allocated, at which point we will move it, and then
// set this variable to false to indicate it should not be moved again.
bool child_needs_move_;
+
+ // Is true IFF Close() was called more recently than Open().
+ bool is_closing_;
};
#endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_