summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/gfx/insets.h18
-rw-r--r--views/controls/button/native_button_gtk.cc3
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc41
3 files changed, 40 insertions, 22 deletions
diff --git a/app/gfx/insets.h b/app/gfx/insets.h
index 6b8e9b1..f5806ac 100644
--- a/app/gfx/insets.h
+++ b/app/gfx/insets.h
@@ -5,6 +5,12 @@
#ifndef APP_GFX_INSETS_H_
#define APP_GFX_INSETS_H_
+#include "build/build_config.h"
+
+#if defined(OS_LINUX)
+#include <gtk/gtkstyle.h>
+#endif
+
namespace gfx {
//
@@ -16,7 +22,17 @@ class Insets {
public:
Insets() : top_(0), left_(0), bottom_(0), right_(0) {}
Insets(int top, int left, int bottom, int right)
- : top_(top), left_(left), bottom_(bottom), right_(right) { }
+ : top_(top),
+ left_(left),
+ bottom_(bottom),
+ right_(right) {}
+#if defined(OS_LINUX)
+ explicit Insets(const GtkBorder& border)
+ : top_(border.top),
+ left_(border.left),
+ bottom_(border.bottom),
+ right_(border.right) {}
+#endif
~Insets() {}
diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc
index e663db6..317e6bd 100644
--- a/views/controls/button/native_button_gtk.cc
+++ b/views/controls/button/native_button_gtk.cc
@@ -88,8 +88,7 @@ gfx::Size NativeButtonGtk::GetPreferredSize() {
if (preferred_size_.IsEmpty()) {
GtkRequisition size_request = { 0, 0 };
gtk_widget_size_request(native_view(), &size_request);
- preferred_size_.SetSize(size_request.width,
- std::max(size_request.height, 29));
+ preferred_size_.SetSize(size_request.width, size_request.height);
}
return preferred_size_;
}
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index 9728a1d..026a6b7 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -6,6 +6,7 @@
#include "views/controls/textfield/native_textfield_gtk.h"
+#include "app/gfx/insets.h"
#include "app/gfx/gtk_util.h"
#include "base/string_util.h"
#include "skia/ext/skia_utils_gtk.h"
@@ -139,23 +140,29 @@ gfx::Insets NativeTextfieldGtk::CalculateInsets() {
GtkWidget* widget = native_view();
GtkEntry* entry = GTK_ENTRY(widget);
- const GtkBorder* inner_border = gtk_entry_get_inner_border(entry);
- int left = 0, right = 0, top = 0, bottom = 0;
- if (!inner_border)
- gtk_widget_style_get(widget, "inner-border", &inner_border, NULL);
+ gfx::Insets insets;
+ const GtkBorder* inner_border = gtk_entry_get_inner_border(entry);
if (inner_border) {
- left += inner_border->left;
- right += inner_border->right;
- top += inner_border->top;
- bottom += inner_border->bottom;
+ insets += gfx::Insets(*inner_border);
+ } else {
+ // No explicit border set, try the style.
+ GtkBorder* style_border;
+ gtk_widget_style_get(widget, "inner-border", &style_border, NULL);
+ if (style_border) {
+ insets += gfx::Insets(*style_border);
+ gtk_border_free(style_border);
+ } else {
+ // If border is null, Gtk uses 2 on all sides.
+ insets += gfx::Insets(2, 2, 2, 2);
+ }
}
if (entry->has_frame) {
- left += widget->style->xthickness;
- right += widget->style->xthickness;
- top += widget->style->ythickness;
- bottom += widget->style->ythickness;
+ insets += gfx::Insets(widget->style->ythickness,
+ widget->style->xthickness,
+ widget->style->ythickness,
+ widget->style->xthickness);
}
gboolean interior_focus;
@@ -164,14 +171,10 @@ gfx::Insets NativeTextfieldGtk::CalculateInsets() {
"focus-line-width", &focus_width,
"interior-focus", &interior_focus,
NULL);
- if (!interior_focus) {
- left += focus_width;
- right += focus_width;
- top += focus_width;
- bottom += focus_width;
- }
+ if (!interior_focus)
+ insets += gfx::Insets(focus_width, focus_width, focus_width, focus_width);
- return gfx::Insets(top, left, bottom, right);
+ return insets;
}
void NativeTextfieldGtk::SetHorizontalMargins(int left, int right) {