Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Unified Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2187363002: arc: Scale notification surface to fit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix floating close button pos on 2560x1700 by using coordinate before scaling Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/arc/notification/arc_custom_notification_view.cc
diff --git a/ui/arc/notification/arc_custom_notification_view.cc b/ui/arc/notification/arc_custom_notification_view.cc
index cd5f6c1359a7cf665ef9924cb7b7d0fa42b97b52..9fe3b059bec68d358c5a623d2f9469e57f868892 100644
--- a/ui/arc/notification/arc_custom_notification_view.cc
+++ b/ui/arc/notification/arc_custom_notification_view.cc
@@ -9,6 +9,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/message_center/message_center_style.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
@@ -80,17 +81,40 @@ void ArcCustomNotificationView::ViewHierarchyChanged(
if (!widget || !surface_ || !details.is_add)
return;
- SetPreferredSize(surface_->GetSize());
+ gfx::Size preferred_size = surface_->GetSize();
+ float scale = 1.0f;
+ if (preferred_size.width() != message_center::kNotificationWidth) {
+ scale = static_cast<float>(message_center::kNotificationWidth) /
+ preferred_size.width();
+ preferred_size.SetSize(message_center::kNotificationWidth,
+ preferred_size.height() * scale);
+ }
+
+ SetPreferredSize(preferred_size);
Attach(surface_->window());
}
void ArcCustomNotificationView::Layout() {
views::NativeViewHost::Layout();
+ if (surface_) {
+ // Scale notification surface if necessary.
+ gfx::Transform transform;
+ const gfx::Size surface_size = surface_->GetSize();
+ const gfx::Size contents_size = GetContentsBounds().size();
+ if (!surface_size.IsEmpty() && !contents_size.IsEmpty() &&
+ surface_size != contents_size) {
reveman 2016/07/28 18:50:53 nit: "surface_size != contents_size" check is not
xiyuan 2016/07/28 19:32:51 Done.
+ transform.Scale(
+ static_cast<float>(contents_size.width()) / surface_size.width(),
+ static_cast<float>(contents_size.height()) / surface_size.height());
+ }
+ surface_->window()->SetTransform(transform);
+ }
+
if (!floating_close_button_widget_ || !surface_ || !GetWidget())
return;
- gfx::Rect surface_local_bounds(surface_->window()->bounds().size());
+ gfx::Rect surface_local_bounds(surface_->GetSize());
gfx::Rect close_button_bounds(floating_close_button_->GetPreferredSize());
close_button_bounds.set_x(surface_local_bounds.right() -
close_button_bounds.width());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698