Commit ea51f2c7 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Profile picker] Make the window fit well on the screen

This CL makes sure that the profile picker window fits on the current
screen. Moreover, it forces the window to be somewhat smaller then the
current screen so that it still looks like a dialog window.

Bug: 773501
Change-Id: If5fef1920387c6fd421c3b7257426e6bacd6fdad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362887
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Commit-Queue: David Roger <droger@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799091}
parent 524d8a1f
......@@ -32,6 +32,7 @@ namespace {
ProfilePickerView* g_profile_picker_view = nullptr;
constexpr int kWindowWidth = 1024;
constexpr int kWindowHeight = 758;
constexpr float kMaxRatioOfWorkArea = 0.9;
} // namespace
// static
......@@ -117,7 +118,14 @@ void ProfilePickerView::Init(Profile* system_profile) {
}
gfx::Size ProfilePickerView::CalculatePreferredSize() const {
return gfx::Size(kWindowWidth, kWindowHeight);
gfx::Size preferred_size = gfx::Size(kWindowWidth, kWindowHeight);
gfx::Size work_area_size = GetWidget()->GetWorkAreaBoundsInScreen().size();
// Keep the window smaller then |work_area_size| so that it feels more like a
// dialog then like the actual Chrome window.
gfx::Size max_dialog_size = ScaleToFlooredSize(
work_area_size, kMaxRatioOfWorkArea, kMaxRatioOfWorkArea);
preferred_size.SetToMin(max_dialog_size);
return preferred_size;
}
void ProfilePickerView::WindowClosing() {
......
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