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

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

Issue 40139: Put the dropdown menu button on the linux download shelf.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
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 "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // This function paints one row at a time. 43 // This function paints one row at a time.
44 // To make indexing sane, |images| points at the current row of images, 44 // To make indexing sane, |images| points at the current row of images,
45 // so images[0] always refers to the left-most image of the current row. 45 // so images[0] always refers to the left-most image of the current row.
46 GdkPixbuf** images = &images_[0]; 46 GdkPixbuf** images = &images_[0];
47 47
48 // The upper-left and lower-right corners of the center square in the 48 // The upper-left and lower-right corners of the center square in the
49 // rendering of the ninebox. 49 // rendering of the ninebox.
50 const int x1 = gdk_pixbuf_get_width(images[0]); 50 const int x1 = gdk_pixbuf_get_width(images[0]);
51 const int y1 = gdk_pixbuf_get_height(images[0]); 51 const int y1 = gdk_pixbuf_get_height(images[0]);
52 const int x2 = gdk_pixbuf_get_width(dst) - gdk_pixbuf_get_width(images[8]); 52 const int x2 = images[2] ?
53 const int y2 = gdk_pixbuf_get_height(dst) - gdk_pixbuf_get_height(images[8]); 53 gdk_pixbuf_get_width(dst) - gdk_pixbuf_get_width(images[2]) : x1;
54 const int y2 = images[6] ?
55 gdk_pixbuf_get_height(dst) - gdk_pixbuf_get_height(images[6]) : y1;
54 DCHECK(x2 >= x1); 56 DCHECK(x2 >= x1);
55 DCHECK(y2 >= y1); 57 DCHECK(y2 >= y1);
56 58
57 DrawPixbuf(images[0], dst, 0, 0); 59 if (images[0])
58 RenderTopCenterStrip(dst, x1, x2); 60 DrawPixbuf(images[0], dst, 0, 0);
59 DrawPixbuf(images[2], dst, x2, 0); 61 if (images[1])
62 RenderTopCenterStrip(dst, x1, x2);
63 if (images[2])
64 DrawPixbuf(images[2], dst, x2, 0);
60 65
61 // Center row. Needs vertical tiling. 66 // Center row. Needs vertical tiling.
62 images = &images_[1 * 3]; 67 images = &images_[1 * 3];
63 TileImage(images[0], dst, 68 if (images[0]) {
64 0, y1, 69 TileImage(images[0], dst,
65 0, y2); 70 0, y1,
71 0, y2);
72 }
66 if (images[1]) { 73 if (images[1]) {
67 const int delta_y = gdk_pixbuf_get_height(images[1]); 74 const int delta_y = gdk_pixbuf_get_height(images[1]);
68 for (int y = y1; y < y2; y += delta_y) { 75 for (int y = y1; y < y2; y += delta_y) {
69 TileImage(images[1], dst, 76 TileImage(images[1], dst,
70 x1, y, 77 x1, y,
71 x2, y); 78 x2, y);
72 } 79 }
73 } 80 }
74 TileImage(images[2], dst, 81 if (images[2]) {
75 x2, y1, 82 TileImage(images[2], dst,
76 x2, y2); 83 x2, y1,
84 x2, y2);
85 }
77 86
78 // Bottom row. 87 // Bottom row.
79 images = &images_[2 * 3]; 88 images = &images_[2 * 3];
80 DrawPixbuf(images[0], dst, 0, y2); 89 if (images[0])
81 TileImage(images[1], dst, 90 DrawPixbuf(images[0], dst, 0, y2);
82 x1, y2, 91 if (images[1]) {
83 x2, y2); 92 TileImage(images[1], dst,
84 DrawPixbuf(images[2], dst, x2, y2); 93 x1, y2,
94 x2, y2);
95 }
96 if (images[2])
97 DrawPixbuf(images[2], dst, x2, y2);
85 } 98 }
86 99
87 void NineBox::RenderTopCenterStrip(GdkPixbuf* dst, int x1, int x2) { 100 void NineBox::RenderTopCenterStrip(GdkPixbuf* dst, int x1, int x2) {
88 TileImage(images_[1], dst, 101 TileImage(images_[1], dst,
89 x1, 0, 102 x1, 0,
90 x2, 0); 103 x2, 0);
91 } 104 }
92 105
93 void NineBox::TileImage(GdkPixbuf* src, GdkPixbuf* dst, 106 void NineBox::TileImage(GdkPixbuf* src, GdkPixbuf* dst,
94 int x1, int y1, int x2, int y2) { 107 int x1, int y1, int x2, int y2) {
(...skipping 11 matching lines...) Expand all
106 dy = src_height; 119 dy = src_height;
107 DCHECK(dx == 0 || dy == 0); 120 DCHECK(dx == 0 || dy == 0);
108 121
109 for (int x = x1, y = y1; x < x2 || y < y2; x += dx, y += dy) { 122 for (int x = x1, y = y1; x < x2 || y < y2; x += dx, y += dy) {
110 gdk_pixbuf_copy_area(src, 0, 0, 123 gdk_pixbuf_copy_area(src, 0, 0,
111 dx ? std::min(src_width, dst_width - x) : src_width, 124 dx ? std::min(src_width, dst_width - x) : src_width,
112 dy ? std::min(src_height, dst_height - y) : src_height, 125 dy ? std::min(src_height, dst_height - y) : src_height,
113 dst, x, y); 126 dst, x, y);
114 } 127 }
115 } 128 }
OLDNEW
« chrome/browser/gtk/download_shelf_gtk.cc ('K') | « chrome/browser/gtk/nine_box.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698