| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "chrome/browser/ui/cocoa/panels/panel_cocoa.h" | 9 #import "chrome/browser/ui/cocoa/panels/panel_cocoa.h" |
| 10 #import "chrome/browser/ui/cocoa/panels/panel_utils_cocoa.h" | 10 #import "chrome/browser/ui/cocoa/panels/panel_utils_cocoa.h" |
| 11 #include "chrome/browser/ui/panels/panel.h" | 11 #include "chrome/browser/ui/panels/panel.h" |
| 12 #include "chrome/browser/ui/panels/panel_manager.h" | 12 #include "chrome/browser/ui/panels/panel_manager.h" |
| 13 #include "chrome/browser/ui/panels/stacked_panel_collection.h" | 13 #include "chrome/browser/ui/panels/stacked_panel_collection.h" |
| 14 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" | |
| 15 #include "ui/base/cocoa/window_size_constants.h" | 14 #include "ui/base/cocoa/window_size_constants.h" |
| 16 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
| 19 #include "ui/gfx/image/image_skia_rep.h" | 18 #include "ui/gfx/image/image_skia_rep.h" |
| 20 #include "ui/gfx/vector2d.h" | 19 #include "ui/gfx/vector2d.h" |
| 20 #include "ui/snapshot/snapshot.h" |
| 21 | 21 |
| 22 // The delegate class to receive the notification from NSViewAnimation. | 22 // The delegate class to receive the notification from NSViewAnimation. |
| 23 @interface BatchBoundsAnimationDelegate : NSObject<NSAnimationDelegate> { | 23 @interface BatchBoundsAnimationDelegate : NSObject<NSAnimationDelegate> { |
| 24 @private | 24 @private |
| 25 PanelStackWindowCocoa* window_; // Weak pointer. | 25 PanelStackWindowCocoa* window_; // Weak pointer. |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Called when NSViewAnimation finishes the animation. | 28 // Called when NSViewAnimation finishes the animation. |
| 29 - (void)animationDidEnd:(NSAnimation*)animation; | 29 - (void)animationDidEnd:(NSAnimation*)animation; |
| 30 @end | 30 @end |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Provide the custom miniwindow image since there is nothing painted for | 293 // Provide the custom miniwindow image since there is nothing painted for |
| 294 // the background stack window. | 294 // the background stack window. |
| 295 gfx::Size stack_window_size = GetStackWindowBounds().size(); | 295 gfx::Size stack_window_size = GetStackWindowBounds().size(); |
| 296 gfx::Canvas canvas(stack_window_size, 1.0f, true); | 296 gfx::Canvas canvas(stack_window_size, 1.0f, true); |
| 297 int y = 0; | 297 int y = 0; |
| 298 Panels::const_iterator iter = panels_.begin(); | 298 Panels::const_iterator iter = panels_.begin(); |
| 299 for (; iter != panels_.end(); ++iter) { | 299 for (; iter != panels_.end(); ++iter) { |
| 300 Panel* panel = *iter; | 300 Panel* panel = *iter; |
| 301 gfx::Rect snapshot_bounds = gfx::Rect(panel->GetBounds().size()); | 301 gfx::Rect snapshot_bounds = gfx::Rect(panel->GetBounds().size()); |
| 302 std::vector<unsigned char> png; | 302 std::vector<unsigned char> png; |
| 303 if (!chrome::GrabWindowSnapshotForUser(panel->GetNativeWindow(), | 303 if (!ui::GrabWindowSnapshot(panel->GetNativeWindow(), |
| 304 &png, | 304 &png, |
| 305 snapshot_bounds)) { | 305 snapshot_bounds)) |
| 306 break; | 306 break; |
| 307 } | |
| 308 gfx::Image snapshot_image = gfx::Image::CreateFrom1xPNGBytes( | 307 gfx::Image snapshot_image = gfx::Image::CreateFrom1xPNGBytes( |
| 309 &(png[0]), png.size()); | 308 &(png[0]), png.size()); |
| 310 canvas.DrawImageInt(snapshot_image.AsImageSkia(), 0, y); | 309 canvas.DrawImageInt(snapshot_image.AsImageSkia(), 0, y); |
| 311 y += snapshot_bounds.height(); | 310 y += snapshot_bounds.height(); |
| 312 } | 311 } |
| 313 if (iter == panels_.end()) { | 312 if (iter == panels_.end()) { |
| 314 gfx::Image image(gfx::ImageSkia(canvas.ExtractImageRep())); | 313 gfx::Image image(gfx::ImageSkia(canvas.ExtractImageRep())); |
| 315 [window_ setMiniwindowImage:image.AsNSImage()]; | 314 [window_ setMiniwindowImage:image.AsNSImage()]; |
| 316 } | 315 } |
| 317 | 316 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater | 371 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater |
| 373 styleMask:NSBorderlessWindowMask | 372 styleMask:NSBorderlessWindowMask |
| 374 backing:NSBackingStoreBuffered | 373 backing:NSBackingStoreBuffered |
| 375 defer:NO]); | 374 defer:NO]); |
| 376 [window_ setBackgroundColor:[NSColor clearColor]]; | 375 [window_ setBackgroundColor:[NSColor clearColor]]; |
| 377 [window_ setHasShadow:YES]; | 376 [window_ setHasShadow:YES]; |
| 378 [window_ setLevel:NSNormalWindowLevel]; | 377 [window_ setLevel:NSNormalWindowLevel]; |
| 379 [window_ orderFront:nil]; | 378 [window_ orderFront:nil]; |
| 380 [window_ setTitle:base::SysUTF16ToNSString(delegate_->GetTitle())]; | 379 [window_ setTitle:base::SysUTF16ToNSString(delegate_->GetTitle())]; |
| 381 } | 380 } |
| OLD | NEW |