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

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

Issue 8779001: GTK: Make NineBox use CairoCachedSurfaces via gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase for merge 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 | « no previous file | chrome/browser/ui/gtk/nine_box.cc » ('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) 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 #ifndef CHROME_BROWSER_UI_GTK_NINE_BOX_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_NINE_BOX_H_
6 #define CHROME_BROWSER_UI_GTK_NINE_BOX_H_ 6 #define CHROME_BROWSER_UI_GTK_NINE_BOX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 namespace gfx {
12 class Image;
13 }
14
11 // A NineBox manages a set of source images representing a 3x3 grid, where 15 // A NineBox manages a set of source images representing a 3x3 grid, where
12 // non-corner images can be tiled to make a larger image. It's used to 16 // non-corner images can be tiled to make a larger image. It's used to
13 // use bitmaps for constructing image-based resizable widgets like buttons. 17 // use bitmaps for constructing image-based resizable widgets like buttons.
14 // 18 //
15 // If you want just a vertical image that stretches in height but is fixed 19 // If you want just a vertical image that stretches in height but is fixed
16 // in width, only pass in images for the left column (leave others NULL). 20 // in width, only pass in images for the left column (leave others NULL).
17 // Similarly, for a horizontal image that stretches in width but is fixed in 21 // Similarly, for a horizontal image that stretches in width but is fixed in
18 // height, only pass in images for the top row. 22 // height, only pass in images for the top row.
19 //
20 // TODO(port): add support for caching server-side pixmaps of prerendered
21 // nineboxes.
22 class NineBox { 23 class NineBox {
23 public: 24 public:
24 // Construct a NineBox with nine images. Images are specified using resource 25 // Construct a NineBox with nine images. Images are specified using resource
25 // ids that will be passed to the resource bundle. Use 0 for no image. 26 // ids that will be passed to the resource bundle. Use 0 for no image.
26 NineBox(int top_left, int top, int top_right, int left, int center, int right, 27 NineBox(int top_left, int top, int top_right, int left, int center, int right,
27 int bottom_left, int bottom, int bottom_right); 28 int bottom_left, int bottom, int bottom_right);
28 29
29 // Construct a NineBox from a single image and insets indicating the sizes 30 // Construct a NineBox from a single image and insets indicating the sizes
30 // of the edges and corners. 31 // of the edges and corners.
31 NineBox(int image, int top_margin, int bottom_margin, int left_margin, 32 NineBox(int image, int top_margin, int bottom_margin, int left_margin,
32 int right_margin); 33 int right_margin);
33 ~NineBox(); 34 ~NineBox();
34 35
35 // Render the NineBox to |dst|. 36 // Render the NineBox to |dst|.
36 // The images will be tiled to fit into the widget. 37 // The images will be tiled to fit into the widget.
37 void RenderToWidget(GtkWidget* dst) const; 38 void RenderToWidget(GtkWidget* dst) const;
38 39
39 // As above, but rendered partially transparent. 40 // As above, but rendered partially transparent.
40 void RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const; 41 void RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const;
41 42
42 // Render the top row of images to |dst| between |x1| and |x1| + |width|.
43 // This is split from RenderToWidget so the toolbar can use it.
44 void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const;
45
46 // Set the shape of |widget| to match that of the ninebox. Note that |widget| 43 // Set the shape of |widget| to match that of the ninebox. Note that |widget|
47 // must have its own window and be allocated. Also, currently only the top 44 // must have its own window and be allocated. Also, currently only the top
48 // three images are used. 45 // three images are used.
49 // TODO(estade): extend this function to use all 9 images (if it's ever 46 // TODO(estade): extend this function to use all 9 images (if it's ever
50 // needed). 47 // needed).
51 void ContourWidget(GtkWidget* widget) const; 48 void ContourWidget(GtkWidget* widget) const;
52 49
53 private: 50 private:
54 GdkPixbuf* images_[9]; 51 gfx::Image* images_[9];
55 bool unref_pixbufs_on_destroy_; 52 bool unref_images_on_destroy_;
56 }; 53 };
57 54
58 #endif // CHROME_BROWSER_UI_GTK_NINE_BOX_H_ 55 #endif // CHROME_BROWSER_UI_GTK_NINE_BOX_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/nine_box.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698