Commit 1a507e13 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[UI] Align dropdown position with the combobox so their borders align

Before this CL, the code was mistakenly adding internal padding to
the menu position. But both the combobox and the dropdown draw their
borders similarly and hence they should use the same bounds.

Screenshots:
Before: https://screenshot.googleplex.com/DrCgx0mp5Th.png
After: https://screenshot.googleplex.com/0EEH40BOw1p.png

Bug: 1044038
Change-Id: I275b3ae320d44e93357364a64a9f37a607445d74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261273
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781519}
parent 041ebe60
...@@ -609,21 +609,15 @@ void Combobox::PaintIconAndText(gfx::Canvas* canvas) { ...@@ -609,21 +609,15 @@ void Combobox::PaintIconAndText(gfx::Canvas* canvas) {
} }
void Combobox::ShowDropDownMenu(ui::MenuSourceType source_type) { void Combobox::ShowDropDownMenu(ui::MenuSourceType source_type) {
// Menu border widths.
constexpr int kMenuBorderWidthLeft = 1;
constexpr int kMenuBorderWidthTop = 1; constexpr int kMenuBorderWidthTop = 1;
constexpr int kMenuBorderWidthRight = 1; // Menu's requested position's width should be the same as local bounds so the
// border of the menu lines up with the border of the combobox. The y
// coordinate however should be shifted to the bottom with the border with not
// to overlap with the combobox border.
gfx::Rect lb = GetLocalBounds(); gfx::Rect lb = GetLocalBounds();
gfx::Point menu_position(lb.origin()); gfx::Point menu_position(lb.origin());
// Inset the menu's requested position so the border of the menu lines up
// with the border of the combobox.
menu_position.set_x(menu_position.x() + kMenuBorderWidthLeft);
menu_position.set_y(menu_position.y() + kMenuBorderWidthTop); menu_position.set_y(menu_position.y() + kMenuBorderWidthTop);
lb.set_width(lb.width() - (kMenuBorderWidthLeft + kMenuBorderWidthRight));
View::ConvertPointToScreen(this, &menu_position); View::ConvertPointToScreen(this, &menu_position);
gfx::Rect bounds(menu_position, lb.size()); gfx::Rect bounds(menu_position, lb.size());
......
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