Commit 82cbf537 authored by estade@chromium.org's avatar estade@chromium.org

Fix arrow position in action-style comboboxes on Linux in GTK theme mode.

BUG=386487

Review URL: https://codereview.chromium.org/344103002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278685 0039d316-1c4b-4281-b951-d872f2087c98
parent 645947ef
...@@ -218,14 +218,6 @@ void PaintArrowButton( ...@@ -218,14 +218,6 @@ void PaintArrowButton(
x, 0, arrow_button_images[0]->width(), height); x, 0, arrow_button_images[0]->width(), height);
} }
// Returns the size of the disclosure arrow.
gfx::Size ArrowSize(const ui::NativeTheme* native_theme) {
ui::NativeTheme::ExtraParams ignored;
return native_theme->GetPartSize(ui::NativeTheme::kComboboxArrow,
ui::NativeTheme::kNormal,
ignored);
}
} // namespace } // namespace
// static // static
...@@ -361,7 +353,7 @@ void Combobox::Layout() { ...@@ -361,7 +353,7 @@ void Combobox::Layout() {
} }
case STYLE_ACTION: { case STYLE_ACTION: {
arrow_button_width = GetDisclosureArrowLeftPadding() + arrow_button_width = GetDisclosureArrowLeftPadding() +
ArrowSize(GetNativeTheme()).width() + ArrowSize().width() +
GetDisclosureArrowRightPadding(); GetDisclosureArrowRightPadding();
text_button_width = width() - arrow_button_width; text_button_width = width() - arrow_button_width;
break; break;
...@@ -419,7 +411,7 @@ gfx::Size Combobox::GetPreferredSize() const { ...@@ -419,7 +411,7 @@ gfx::Size Combobox::GetPreferredSize() const {
gfx::Insets insets = GetInsets(); gfx::Insets insets = GetInsets();
int total_width = std::max(kMinComboboxWidth, content_size_.width()) + int total_width = std::max(kMinComboboxWidth, content_size_.width()) +
insets.width() + GetDisclosureArrowLeftPadding() + insets.width() + GetDisclosureArrowLeftPadding() +
ArrowSize(GetNativeTheme()).width() + GetDisclosureArrowRightPadding(); ArrowSize().width() + GetDisclosureArrowRightPadding();
return gfx::Size(total_width, content_size_.height() + insets.height()); return gfx::Size(total_width, content_size_.height() + insets.height());
} }
...@@ -663,7 +655,7 @@ void Combobox::PaintText(gfx::Canvas* canvas) { ...@@ -663,7 +655,7 @@ void Combobox::PaintText(gfx::Canvas* canvas) {
selected_index_ = 0; selected_index_ = 0;
base::string16 text = model()->GetItemAt(selected_index_); base::string16 text = model()->GetItemAt(selected_index_);
gfx::Size arrow_size = ArrowSize(GetNativeTheme()); gfx::Size arrow_size = ArrowSize();
int disclosure_arrow_offset = width() - arrow_size.width() - int disclosure_arrow_offset = width() - arrow_size.width() -
GetDisclosureArrowLeftPadding() - GetDisclosureArrowRightPadding(); GetDisclosureArrowLeftPadding() - GetDisclosureArrowRightPadding();
...@@ -850,4 +842,22 @@ int Combobox::GetDisclosureArrowRightPadding() const { ...@@ -850,4 +842,22 @@ int Combobox::GetDisclosureArrowRightPadding() const {
return 0; return 0;
} }
gfx::Size Combobox::ArrowSize() const {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// TODO(estade): hack alert! This should always use GetNativeTheme(). For now
// STYLE_ACTION isn't properly themed so we have to override the NativeTheme
// behavior. See crbug.com/384071
const ui::NativeTheme* native_theme_for_arrow = style_ == STYLE_ACTION ?
ui::NativeTheme::instance() :
GetNativeTheme();
#else
const ui::NativeTheme* native_theme_for_arrow = GetNativeTheme();
#endif
ui::NativeTheme::ExtraParams ignored;
return native_theme_for_arrow->GetPartSize(ui::NativeTheme::kComboboxArrow,
ui::NativeTheme::kNormal,
ignored);
}
} // namespace views } // namespace views
...@@ -159,6 +159,9 @@ class VIEWS_EXPORT Combobox : public MenuDelegate, ...@@ -159,6 +159,9 @@ class VIEWS_EXPORT Combobox : public MenuDelegate,
int GetDisclosureArrowLeftPadding() const; int GetDisclosureArrowLeftPadding() const;
int GetDisclosureArrowRightPadding() const; int GetDisclosureArrowRightPadding() const;
// Returns the size of the disclosure arrow.
gfx::Size ArrowSize() const;
// Handles the clicking event. // Handles the clicking event.
void HandleClickEvent(); void HandleClickEvent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment