Add ICU message format support
[chromium-blink-merge.git] / ui / aura_extra / image_window_delegate.cc
blob531f653da6339b2c27bc3232a7deaca63fbe42dc
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
3 // found in the LICENSE file.
5 #include "ui/aura_extra/image_window_delegate.h"
7 #include "ui/base/cursor/cursor.h"
8 #include "ui/base/hit_test.h"
9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/paint_recorder.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/image/image_skia.h"
17 namespace aura_extra {
19 ImageWindowDelegate::ImageWindowDelegate()
20 : background_color_(SK_ColorWHITE),
21 size_mismatch_(false) {
24 ImageWindowDelegate::~ImageWindowDelegate() {
27 void ImageWindowDelegate::SetImage(const gfx::Image& image) {
28 image_ = image;
29 if (!window_size_.IsEmpty() && !image_.IsEmpty())
30 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
33 gfx::Size ImageWindowDelegate::GetMinimumSize() const {
34 return gfx::Size();
37 gfx::Size ImageWindowDelegate::GetMaximumSize() const {
38 return gfx::Size();
41 void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
42 const gfx::Rect& new_bounds) {
43 window_size_ = new_bounds.size();
44 if (!image_.IsEmpty())
45 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
48 gfx::NativeCursor ImageWindowDelegate::GetCursor(const gfx::Point& point) {
49 return gfx::kNullCursor;
52 int ImageWindowDelegate::GetNonClientComponent(const gfx::Point& point) const {
53 return HTNOWHERE;
56 bool ImageWindowDelegate::ShouldDescendIntoChildForEventHandling(
57 aura::Window* child,
58 const gfx::Point& location) {
59 return false;
62 bool ImageWindowDelegate::CanFocus() {
63 return false;
66 void ImageWindowDelegate::OnCaptureLost() {
69 void ImageWindowDelegate::OnPaint(const ui::PaintContext& context) {
70 ui::PaintRecorder recorder(context, window_size_);
71 if (background_color_ != SK_ColorTRANSPARENT &&
72 (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) {
73 recorder.canvas()->DrawColor(background_color_);
75 if (!image_.IsEmpty()) {
76 recorder.canvas()->DrawImageInt(image_.AsImageSkia(), offset_.x(),
77 offset_.y());
81 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) {
84 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) {
87 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) {
88 delete this;
91 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
94 bool ImageWindowDelegate::HasHitTestMask() const {
95 return false;
98 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
101 } // namespace aura_extra