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

Side by Side Diff: chrome/browser/ui/gtk/nine_box.cc

Issue 8872004: GTK: More changes from raw widget->allocation to using the accessor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 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
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/gtk/nine_box.h" 5 #include "chrome/browser/ui/gtk/nine_box.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 delete images_[i]; 114 delete images_[i];
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 void NineBox::RenderToWidget(GtkWidget* dst) const { 119 void NineBox::RenderToWidget(GtkWidget* dst) const {
120 RenderToWidgetWithOpacity(dst, 1.0); 120 RenderToWidgetWithOpacity(dst, 1.0);
121 } 121 }
122 122
123 void NineBox::RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const { 123 void NineBox::RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const {
124 int dst_width = dst->allocation.width; 124 GtkAllocation allocation;
125 int dst_height = dst->allocation.height; 125 gtk_widget_get_allocation(dst, &allocation);
126 int dst_width = allocation.width;
127 int dst_height = allocation.height;
126 128
127 // The upper-left and lower-right corners of the center square in the 129 // The upper-left and lower-right corners of the center square in the
128 // rendering of the ninebox. 130 // rendering of the ninebox.
129 int x1 = gdk_pixbuf_get_width(images_[0]->ToGdkPixbuf()); 131 int x1 = gdk_pixbuf_get_width(images_[0]->ToGdkPixbuf());
130 int y1 = gdk_pixbuf_get_height(images_[0]->ToGdkPixbuf()); 132 int y1 = gdk_pixbuf_get_height(images_[0]->ToGdkPixbuf());
131 int x2 = images_[2] ? dst_width - gdk_pixbuf_get_width( 133 int x2 = images_[2] ? dst_width - gdk_pixbuf_get_width(
132 images_[2]->ToGdkPixbuf()) : x1; 134 images_[2]->ToGdkPixbuf()) : x1;
133 int y2 = images_[6] ? dst_height - gdk_pixbuf_get_height( 135 int y2 = images_[6] ? dst_height - gdk_pixbuf_get_height(
134 images_[6]->ToGdkPixbuf()) : y1; 136 images_[6]->ToGdkPixbuf()) : y1;
135 // Paint nothing if there's not enough room. 137 // Paint nothing if there's not enough room.
136 if (x2 < x1 || y2 < y1) 138 if (x2 < x1 || y2 < y1)
137 return; 139 return;
138 140
139 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(dst->window)); 141 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(dst->window));
140 // For widgets that have their own window, the allocation (x,y) coordinates 142 // For widgets that have their own window, the allocation (x,y) coordinates
141 // are GdkWindow relative. For other widgets, the coordinates are relative 143 // are GdkWindow relative. For other widgets, the coordinates are relative
142 // to their container. 144 // to their container.
143 if (GTK_WIDGET_NO_WINDOW(dst)) { 145 if (GTK_WIDGET_NO_WINDOW(dst)) {
144 // Transform our cairo from window to widget coordinates. 146 // Transform our cairo from window to widget coordinates.
145 cairo_translate(cr, dst->allocation.x, dst->allocation.y); 147 cairo_translate(cr, allocation.x, allocation.y);
146 } 148 }
147 149
148 if (base::i18n::IsRTL()) { 150 if (base::i18n::IsRTL()) {
149 cairo_translate(cr, dst_width, 0.0f); 151 cairo_translate(cr, dst_width, 0.0f);
150 cairo_scale(cr, -1.0f, 1.0f); 152 cairo_scale(cr, -1.0f, 1.0f);
151 } 153 }
152 154
153 // Top row, center image is horizontally tiled. 155 // Top row, center image is horizontally tiled.
154 DrawImage(cr, dst, images_[0], 0, 0, opacity); 156 DrawImage(cr, dst, images_[0], 0, 0, opacity);
155 TileImage(cr, dst, images_[1], x1, 0, x2 - x1, y1, opacity); 157 TileImage(cr, dst, images_[1], x1, 0, x2 - x1, y1, opacity);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 cairo_paint(flipped_cr); 219 cairo_paint(flipped_cr);
218 cairo_destroy(flipped_cr); 220 cairo_destroy(flipped_cr);
219 221
220 // Mask the widget. 222 // Mask the widget.
221 gtk_widget_shape_combine_mask(widget, flipped_mask, 0, 0); 223 gtk_widget_shape_combine_mask(widget, flipped_mask, 0, 0);
222 g_object_unref(flipped_mask); 224 g_object_unref(flipped_mask);
223 } 225 }
224 226
225 g_object_unref(mask); 227 g_object_unref(mask);
226 } 228 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698