Commit 2634272e authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Refactor coordinate system of OpaqueBrowserFrameViewLayout::trailing_button_start_

This CL is a refactor and has no behavioural changes.

OpaqueBrowserFrameView::trailing_button_start_ is an x coordinate
relative to the right edge of the window title bar.

This CL replaces trailing_button_start_ with available_space_trailing_x_
where
available_space_trailing_x_ == host->width() - trailing_button_start_.

available_space_trailing_x_ represents the same x position as
trailing_button_start_ except it's relative to the left edge of the
titlebar (0).

The name "button_start" has been replaced with "available_space_*_x"
as it's used for more than just button elements and now represents
a typical x co-ordinate.

This refactor is intended to support
https://chromium-review.googlesource.com/c/chromium/src/+/1156117
by making HostedAppButtonContainer::LayoutInContainer() less cumbersome
to use in OpaqueBrowserFrameViewLayout.

Bug: 854479
Change-Id: Iff1c29139cd4c8c66286db85fce85b99c94c5261
Reviewed-on: https://chromium-review.googlesource.com/1158313
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580045}
parent c5b03f66
......@@ -47,17 +47,18 @@ void DesktopLinuxBrowserFrameViewLayout::LayoutNewStyleAvatar(
new_avatar_button_->GetPreferredSize(),
delegate_->GetTopAreaHeight() - TitlebarTopThickness(), &button_size,
&button_spacing);
int extra_offset = has_trailing_buttons()
? nav_button_provider_->GetInterNavButtonSpacing()
: 0;
const int extra_offset =
has_trailing_buttons() ? nav_button_provider_->GetInterNavButtonSpacing()
: 0;
int total_width = button_size.width() + button_spacing.right() + extra_offset;
const int total_width =
button_size.width() + button_spacing.right() + extra_offset;
int button_x = host->width() - trailing_button_start_ - total_width;
int button_y = button_spacing.top() + TitlebarTopThickness();
const int button_x = available_space_trailing_x_ - total_width;
const int button_y = button_spacing.top() + TitlebarTopThickness();
minimum_size_for_buttons_ += total_width;
trailing_button_start_ += total_width;
available_space_trailing_x_ -= total_width;
new_avatar_button_->SetBounds(button_x, button_y, button_size.width(),
button_size.height());
......
......@@ -49,9 +49,8 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
const std::vector<views::FrameButton>& leading_buttons,
const std::vector<views::FrameButton>& trailing_buttons);
gfx::Rect GetBoundsForTabStrip(
const gfx::Size& tabstrip_preferred_size,
int available_width) const;
gfx::Rect GetBoundsForTabStrip(const gfx::Size& tabstrip_preferred_size,
int total_width) const;
gfx::Size GetMinimumSize(int available_width) const;
......@@ -165,10 +164,10 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
views::View* new_avatar_button_;
// How far from the leading/trailing edge of the view the next window control
// should be placed.
int leading_button_start_;
int trailing_button_start_;
// The leading and trailing x positions of the empty space available for
// laying out titlebar elements.
int available_space_leading_x_;
int available_space_trailing_x_;
// The size of the window buttons, and the avatar menu item (if any). This
// does not count labels or other elements that should be counted in a
......
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