Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/gtk/slide_animator_gtk.cc

Issue 507022: Fix issue 11258: Linux: gracefully handle small browser window... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/infobar_gtk.cc ('k') | chrome/browser/gtk/tab_contents_container_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/gtk/slide_animator_gtk.h" 5 #include "chrome/browser/gtk/slide_animator_gtk.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "app/slide_animation.h" 8 #include "app/slide_animation.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 #include "chrome/browser/gtk/gtk_expanded_container.h"
12
11 namespace { 13 namespace {
12 14
13 void OnFixedSizeAllocate(GtkWidget* fixed, 15 void OnChildSizeRequest(GtkWidget* expanded,
14 GtkAllocation* allocation, 16 GtkWidget* child,
15 GtkWidget* child) { 17 GtkRequisition* requisition,
16 // The size of the GtkFixed has changed. We want |child_| to match widths, 18 gpointer control_child_size) {
17 // but the height should not change. 19 // If |control_child_size| is true, then we want |child_| to match the width
18 gtk_widget_set_size_request(child, allocation->width, -1); 20 // of the |widget_|, but the height of |child_| should not change.
21 if (!GPOINTER_TO_INT(control_child_size)) {
22 requisition->width = -1;
23 }
24 requisition->height = -1;
19 } 25 }
20 26
21 } // namespace 27 } // namespace
22 28
23 SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child, 29 SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child,
24 Direction direction, 30 Direction direction,
25 int duration, 31 int duration,
26 bool linear, 32 bool linear,
27 bool control_child_size, 33 bool control_child_size,
28 Delegate* delegate) 34 Delegate* delegate)
29 : child_(child), 35 : child_(child),
30 direction_(direction), 36 direction_(direction),
31 delegate_(delegate) { 37 delegate_(delegate) {
32 widget_.Own(gtk_fixed_new()); 38 widget_.Own(gtk_expanded_container_new());
33 gtk_fixed_put(GTK_FIXED(widget_.get()), child, 0, 0); 39 gtk_container_add(GTK_CONTAINER(widget_.get()), child);
34 gtk_widget_set_size_request(widget_.get(), -1, 0); 40 gtk_widget_set_size_request(widget_.get(), -1, 0);
35 if (control_child_size) { 41
36 // If the child requests it, we will manually set the size request for 42 // If the child requests it, we will manually set the size request for
37 // |child_| every time the GtkFixed changes sizes. This is mainly useful 43 // |child_| every time the |widget_| changes sizes. This is mainly useful
38 // for bars, where we want the child to expand to fill all available space. 44 // for bars, where we want the child to expand to fill all available space.
39 g_signal_connect(widget_.get(), "size-allocate", 45 g_signal_connect(widget_.get(), "child-size-request",
40 G_CALLBACK(OnFixedSizeAllocate), child_); 46 G_CALLBACK(OnChildSizeRequest),
41 } 47 GINT_TO_POINTER(control_child_size));
42 48
43 // We connect to this signal to set an initial position for our child widget. 49 // We connect to this signal to set an initial position for our child widget.
44 // The reason we connect to this signal rather than setting the initial 50 // The reason we connect to this signal rather than setting the initial
45 // position here is that the widget is currently unallocated and may not 51 // position here is that the widget is currently unallocated and may not
46 // even have a size request. 52 // even have a size request.
47 g_signal_connect(child, "size-allocate", 53 g_signal_connect(child, "size-allocate",
48 G_CALLBACK(OnChildSizeAllocate), this); 54 G_CALLBACK(OnChildSizeAllocate), this);
49 55
50 child_needs_move_ = (direction == DOWN); 56 child_needs_move_ = (direction == DOWN);
51 57
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return animation_->IsAnimating(); 105 return animation_->IsAnimating();
100 } 106 }
101 107
102 void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) { 108 void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) {
103 GtkRequisition req; 109 GtkRequisition req;
104 gtk_widget_size_request(child_, &req); 110 gtk_widget_size_request(child_, &req);
105 111
106 int showing_height = static_cast<int>(req.height * 112 int showing_height = static_cast<int>(req.height *
107 animation_->GetCurrentValue()); 113 animation_->GetCurrentValue());
108 if (direction_ == DOWN) { 114 if (direction_ == DOWN) {
109 gtk_fixed_move(GTK_FIXED(widget_.get()), child_, 0, 115 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()),
110 showing_height - req.height); 116 child_, 0, showing_height - req.height);
111 child_needs_move_ = false; 117 child_needs_move_ = false;
112 } 118 }
113 gtk_widget_set_size_request(widget_.get(), -1, showing_height); 119 gtk_widget_set_size_request(widget_.get(), -1, showing_height);
114 } 120 }
115 121
116 void SlideAnimatorGtk::AnimationEnded(const Animation* animation) { 122 void SlideAnimatorGtk::AnimationEnded(const Animation* animation) {
117 if (!animation_->IsShowing()) { 123 if (!animation_->IsShowing()) {
118 gtk_widget_hide(widget_.get()); 124 gtk_widget_hide(widget_.get());
119 if (delegate_) 125 if (delegate_)
120 delegate_->Closed(); 126 delegate_->Closed();
121 } 127 }
122 } 128 }
123 129
124 // static 130 // static
125 void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child, 131 void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child,
126 GtkAllocation* allocation, 132 GtkAllocation* allocation,
127 SlideAnimatorGtk* slider) { 133 SlideAnimatorGtk* slider) {
128 if (slider->child_needs_move_) { 134 if (slider->child_needs_move_) {
129 gtk_fixed_move(GTK_FIXED(slider->widget()), child, 0, -allocation->height); 135 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(slider->widget()),
136 child, 0, -allocation->height);
130 slider->child_needs_move_ = false; 137 slider->child_needs_move_ = false;
131 } 138 }
132 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/infobar_gtk.cc ('k') | chrome/browser/gtk/tab_contents_container_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698