From 08fb74a9f12f59c531cc5d7acdb0afea183dba12 Mon Sep 17 00:00:00 2001 From: "deanm@chromium.org" Date: Fri, 13 Mar 2009 17:50:34 +0000 Subject: Improve the look of the Linux omnibox. - Paint a border around the input widget, which makes it fit better into the toolbar. A bordered widget is also very nice to have for debugging, so I abstracted a small helper for making a bordered bin. - Improve the results popup by painting with some Pango attributes. Sort of looks awful over NX, but I'm hoping it looks better on a real session. BUG=8236 Review URL: http://codereview.chromium.org/46035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11644 0039d316-1c4b-4281-b951-d872f2087c98 --- base/gfx/gtk_util.cc | 15 +++++++++++++++ base/gfx/gtk_util.h | 7 +++++++ 2 files changed, 22 insertions(+) (limited to 'base') diff --git a/base/gfx/gtk_util.cc b/base/gfx/gtk_util.cc index e12bb6e..0808193 100755 --- a/base/gfx/gtk_util.cc +++ b/base/gfx/gtk_util.cc @@ -5,6 +5,7 @@ #include "base/gfx/gtk_util.h" #include +#include #include "base/gfx/rect.h" #include "skia/include/SkBitmap.h" @@ -60,4 +61,18 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) { return pixbuf; } +GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, + int top, int bottom, int left, int right) { + // Use a GtkEventBox to get the background painted. However, we can't just + // use a container border, since it won't paint there. Use an alignment + // inside to get the sizes exactly of how we want the border painted. + GtkWidget* ebox = gtk_event_box_new(); + gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, color); + GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); + gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right); + gtk_container_add(GTK_CONTAINER(alignment), child); + gtk_container_add(GTK_CONTAINER(ebox), alignment); + return ebox; +} + } // namespace gfx diff --git a/base/gfx/gtk_util.h b/base/gfx/gtk_util.h index 40a7855..02b1385 100755 --- a/base/gfx/gtk_util.h +++ b/base/gfx/gtk_util.h @@ -7,8 +7,10 @@ #include +typedef struct _GdkColor GdkColor; typedef struct _GdkPixbuf GdkPixbuf; typedef struct _GdkRegion GdkRegion; +typedef struct _GtkWidget GtkWidget; class SkBitmap; // Define a macro for creating GdkColors from RGB values. This is a macro to @@ -28,6 +30,11 @@ void SubtractRectanglesFromRegion(GdkRegion* region, // operation, all of the pixels must be copied and their order swapped. GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap); +// Create a GtkBin with |child| as its child widget. This bin will paint a +// border of color |color| with the sizes specified in pixels. +GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, + int top, int bottom, int left, int right); + } // namespace gfx #endif // BASE_GFX_GTK_UTIL_H_ -- cgit v1.1