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

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

Issue 115438: Linux: Just enough toolbar theming to make everything look normal again.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months 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/nine_box.h ('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) 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/nine_box.h" 5 #include "chrome/browser/gtk/nine_box.h"
6 6
7 #include "app/gfx/gtk_util.h"
7 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "app/theme_provider.h"
8 #include "base/gfx/gtk_util.h" 10 #include "base/gfx/gtk_util.h"
9 #include "base/gfx/point.h" 11 #include "base/gfx/point.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 13
12 namespace { 14 namespace {
13 15
14 // Draw pixbuf |src| into |dst| at position (x, y). 16 // Draw pixbuf |src| into |dst| at position (x, y).
15 void DrawPixbuf(cairo_t* cr, GdkPixbuf* src, int x, int y) { 17 void DrawPixbuf(cairo_t* cr, GdkPixbuf* src, int x, int y) {
16 gdk_cairo_set_source_pixbuf(cr, src, x, y); 18 gdk_cairo_set_source_pixbuf(cr, src, x, y);
17 cairo_paint(cr); 19 cairo_paint(cr);
18 } 20 }
19 21
20 // Tile pixbuf |src| across |cr| at |x|, |y| for |width| and |height|. 22 // Tile pixbuf |src| across |cr| at |x|, |y| for |width| and |height|.
21 void TileImage(cairo_t* cr, GdkPixbuf* src, 23 void TileImage(cairo_t* cr, GdkPixbuf* src,
22 int x, int y, int width, int height) { 24 int x, int y, int width, int height) {
23 gdk_cairo_set_source_pixbuf(cr, src, x, y); 25 gdk_cairo_set_source_pixbuf(cr, src, x, y);
24 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); 26 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
25 cairo_rectangle(cr, x, y, width, height); 27 cairo_rectangle(cr, x, y, width, height);
26 cairo_fill(cr); 28 cairo_fill(cr);
27 } 29 }
28 30
31 GdkPixbuf* GetPixbufNamed(ThemeProvider* theme_provider, int name) {
32 return gfx::GdkPixbufFromSkBitmap(theme_provider->GetBitmapNamed(name));
33 }
34
29 } // namespace 35 } // namespace
30 36
31 NineBox::NineBox(int top_left, int top, int top_right, int left, int center, 37 NineBox::NineBox(int top_left, int top, int top_right, int left, int center,
32 int right, int bottom_left, int bottom, int bottom_right) { 38 int right, int bottom_left, int bottom, int bottom_right) {
33 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 39 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
34 images_[0] = top_left ? rb.GetPixbufNamed(top_left) : NULL; 40 images_[0] = top_left ? rb.GetPixbufNamed(top_left) : NULL;
35 images_[1] = top ? rb.GetPixbufNamed(top) : NULL; 41 images_[1] = top ? rb.GetPixbufNamed(top) : NULL;
36 images_[2] = top_right ? rb.GetPixbufNamed(top_right) : NULL; 42 images_[2] = top_right ? rb.GetPixbufNamed(top_right) : NULL;
37 images_[3] = left ? rb.GetPixbufNamed(left) : NULL; 43 images_[3] = left ? rb.GetPixbufNamed(left) : NULL;
38 images_[4] = center ? rb.GetPixbufNamed(center) : NULL; 44 images_[4] = center ? rb.GetPixbufNamed(center) : NULL;
39 images_[5] = right ? rb.GetPixbufNamed(right) : NULL; 45 images_[5] = right ? rb.GetPixbufNamed(right) : NULL;
40 images_[6] = bottom_left ? rb.GetPixbufNamed(bottom_left) : NULL; 46 images_[6] = bottom_left ? rb.GetPixbufNamed(bottom_left) : NULL;
41 images_[7] = bottom ? rb.GetPixbufNamed(bottom) : NULL; 47 images_[7] = bottom ? rb.GetPixbufNamed(bottom) : NULL;
42 images_[8] = bottom_right ? rb.GetPixbufNamed(bottom_right) : NULL; 48 images_[8] = bottom_right ? rb.GetPixbufNamed(bottom_right) : NULL;
43 } 49 }
44 50
51 NineBox::NineBox(ThemeProvider* theme_provider,
52 int top_left, int top, int top_right, int left, int center,
53 int right, int bottom_left, int bottom, int bottom_right) {
54 images_[0] = top_left ?
55 GetPixbufNamed(theme_provider, top_left) : NULL;
56 images_[1] = top ?
57 GetPixbufNamed(theme_provider, top) : NULL;
58 images_[2] = top_right ?
59 GetPixbufNamed(theme_provider, top_right) : NULL;
60 images_[3] = left ?
61 GetPixbufNamed(theme_provider, left) : NULL;
62 images_[4] = center ?
63 GetPixbufNamed(theme_provider, center) : NULL;
64 images_[5] = right ?
65 GetPixbufNamed(theme_provider, right) : NULL;
66 images_[6] = bottom_left ?
67 GetPixbufNamed(theme_provider, bottom_left) : NULL;
68 images_[7] = bottom ?
69 GetPixbufNamed(theme_provider, bottom) : NULL;
70 images_[8] = bottom_right ?
71 GetPixbufNamed(theme_provider, bottom_right) : NULL;
72 }
73
45 NineBox::~NineBox() { 74 NineBox::~NineBox() {
46 } 75 }
47 76
48 void NineBox::RenderToWidget(GtkWidget* dst) const { 77 void NineBox::RenderToWidget(GtkWidget* dst) const {
49 int dst_width = dst->allocation.width; 78 int dst_width = dst->allocation.width;
50 int dst_height = dst->allocation.height; 79 int dst_height = dst->allocation.height;
51 80
52 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(dst->window)); 81 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(dst->window));
53 // For widgets that have their own window, the allocation (x,y) coordinates 82 // For widgets that have their own window, the allocation (x,y) coordinates
54 // are GdkWindow relative. For other widgets, the coordinates are relative 83 // are GdkWindow relative. For other widgets, the coordinates are relative
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 cairo_t* cr = gdk_cairo_create(mask); 169 cairo_t* cr = gdk_cairo_create(mask);
141 cairo_rectangle(cr, x1, 0, x2 - x1, widget->allocation.height); 170 cairo_rectangle(cr, x1, 0, x2 - x1, widget->allocation.height);
142 cairo_fill(cr); 171 cairo_fill(cr);
143 172
144 // Mask the widget's window's shape. 173 // Mask the widget's window's shape.
145 gtk_widget_shape_combine_mask(widget, mask, 0, 0); 174 gtk_widget_shape_combine_mask(widget, mask, 0, 0);
146 175
147 g_object_unref(mask); 176 g_object_unref(mask);
148 cairo_destroy(cr); 177 cairo_destroy(cr);
149 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/nine_box.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698