summaryrefslogtreecommitdiffstats
path: root/views/controls/image_view.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 18:13:50 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 18:13:50 +0000
commitcb1e496b84e8f9d702a4f78da65f7a3a5ec18594 (patch)
treeb974c4bb3673c1a3c587544f19a4caa7af8d2394 /views/controls/image_view.cc
parenta1c3c861aea9a429785f40324c93a0d27f12b8a6 (diff)
downloadchromium_src-cb1e496b84e8f9d702a4f78da65f7a3a5ec18594.zip
chromium_src-cb1e496b84e8f9d702a4f78da65f7a3a5ec18594.tar.gz
chromium_src-cb1e496b84e8f9d702a4f78da65f7a3a5ec18594.tar.bz2
Makes it possible for Widget's on GTK to have a transparent
background. Additionally implements always on top and makes ImageView support borders. BUG=none TEST=none Review URL: http://codereview.chromium.org/119269 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/image_view.cc')
-rw-r--r--views/controls/image_view.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/views/controls/image_view.cc b/views/controls/image_view.cc
index 10d87b1..d8108b04 100644
--- a/views/controls/image_view.cc
+++ b/views/controls/image_view.cc
@@ -5,6 +5,7 @@
#include "views/controls/image_view.h"
#include "app/gfx/canvas.h"
+#include "app/gfx/insets.h"
#include "base/logging.h"
namespace views {
@@ -53,12 +54,15 @@ void ImageView::ResetImageSize() {
}
gfx::Size ImageView::GetPreferredSize() {
+ gfx::Insets insets = GetInsets();
if (image_size_set_) {
gfx::Size image_size;
GetImageSize(&image_size);
+ image_size.Enlarge(insets.width(), insets.height());
return image_size;
}
- return gfx::Size(image_.width(), image_.height());
+ return gfx::Size(image_.width() + insets.width(),
+ image_.height() + insets.height());
}
void ImageView::ComputeImageOrigin(int image_width, int image_height,
@@ -75,12 +79,14 @@ void ImageView::ComputeImageOrigin(int image_width, int image_height,
actual_horiz_alignment = TRAILING;
}
+ gfx::Insets insets = GetInsets();
+
switch(actual_horiz_alignment) {
case LEADING:
- *x = 0;
+ *x = insets.left();
break;
case TRAILING:
- *x = width() - image_width;
+ *x = width() - insets.right() - image_width;
break;
case CENTER:
*x = (width() - image_width) / 2;
@@ -91,10 +97,10 @@ void ImageView::ComputeImageOrigin(int image_width, int image_height,
switch (vert_alignment_) {
case LEADING:
- *y = 0;
+ *y = insets.top();
break;
case TRAILING:
- *y = height() - image_height;
+ *y = height() - insets.bottom() - image_height;
break;
case CENTER:
*y = (height() - image_height) / 2;