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

Side by Side Diff: ui/aura_extra/image_window_delegate.h

Issue 880703002: Move ImageWindowDelegate to ui/aura_extra (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to ui/aura_extra Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_IMAGE_WINDOW_DELEGATE_H_ 5 #ifndef UI_AURA_EXTRA_IMAGE_WINDOW_DELEGATE_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_IMAGE_WINDOW_DELEGATE_H_ 6 #define UI_AURA_EXTRA_IMAGE_WINDOW_DELEGATE_H_
7 7
8 #include "content/common/content_export.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/aura/window_delegate.h" 9 #include "ui/aura/window_delegate.h"
10 #include "ui/aura_extra/aura_extra_export.h"
10 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/gfx/geometry/vector2d.h"
11 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
12 14
13 namespace content { 15 namespace aura_extra {
14 16
15 // An ImageWindowDelegate paints an image for a Window. The delegate destroys 17 // An ImageWindowDelegate paints an image for a Window, possibly also filling
16 // itself when the Window is destroyed. The delegate does not consume any event. 18 // the window with a specified backround color. By default the delegate destroys
17 class CONTENT_EXPORT ImageWindowDelegate : public aura::WindowDelegate { 19 // itself when the Window is destroyed. Use |SetSelfDestroy| to override. The
20 // delegate does not consume any event.
21 class AURA_EXTRA_EXPORT ImageWindowDelegate : public aura::WindowDelegate {
18 public: 22 public:
19 ImageWindowDelegate(); 23 ImageWindowDelegate();
20 24
25 void SetBackgroundColor(SkColor color);
sadrul 2015/01/28 18:26:56 set_background_color
mohsen 2015/01/28 21:10:29 Done.
21 void SetImage(const gfx::Image& image); 26 void SetImage(const gfx::Image& image);
27 void SetImageOffset(gfx::Vector2d offset);
sadrul 2015/01/28 18:26:56 set_image_offset
mohsen 2015/01/28 21:10:29 Done.
28
29 // Controls whether the delegate destroys itself when its window is destroyed.
30 void SetSelfDestroy(bool self_destroy);
sadrul 2015/01/28 18:26:56 set_self_destroy()
mohsen 2015/01/28 21:10:29 Done.
31
22 bool has_image() const { return !image_.IsEmpty(); } 32 bool has_image() const { return !image_.IsEmpty(); }
23 33
24 protected: 34 protected:
25 ~ImageWindowDelegate() override; 35 ~ImageWindowDelegate() override;
26 36
27 // Overridden from aura::WindowDelegate: 37 // Overridden from aura::WindowDelegate:
28 gfx::Size GetMinimumSize() const override; 38 gfx::Size GetMinimumSize() const override;
29 gfx::Size GetMaximumSize() const override; 39 gfx::Size GetMaximumSize() const override;
30 void OnBoundsChanged(const gfx::Rect& old_bounds, 40 void OnBoundsChanged(const gfx::Rect& old_bounds,
31 const gfx::Rect& new_bounds) override; 41 const gfx::Rect& new_bounds) override;
32 gfx::NativeCursor GetCursor(const gfx::Point& point) override; 42 gfx::NativeCursor GetCursor(const gfx::Point& point) override;
33 int GetNonClientComponent(const gfx::Point& point) const override; 43 int GetNonClientComponent(const gfx::Point& point) const override;
34 bool ShouldDescendIntoChildForEventHandling( 44 bool ShouldDescendIntoChildForEventHandling(
35 aura::Window* child, 45 aura::Window* child,
36 const gfx::Point& location) override; 46 const gfx::Point& location) override;
37 bool CanFocus() override; 47 bool CanFocus() override;
38 void OnCaptureLost() override; 48 void OnCaptureLost() override;
39 void OnPaint(gfx::Canvas* canvas) override; 49 void OnPaint(gfx::Canvas* canvas) override;
40 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 50 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
41 void OnWindowDestroying(aura::Window* window) override; 51 void OnWindowDestroying(aura::Window* window) override;
42 void OnWindowDestroyed(aura::Window* window) override; 52 void OnWindowDestroyed(aura::Window* window) override;
43 void OnWindowTargetVisibilityChanged(bool visible) override; 53 void OnWindowTargetVisibilityChanged(bool visible) override;
44 bool HasHitTestMask() const override; 54 bool HasHitTestMask() const override;
45 void GetHitTestMask(gfx::Path* mask) const override; 55 void GetHitTestMask(gfx::Path* mask) const override;
46 56
47 protected: 57 protected:
58 SkColor background_color_;
48 gfx::Image image_; 59 gfx::Image image_;
60 gfx::Vector2d offset_;
61 bool self_destroy_;
62
49 gfx::Size window_size_; 63 gfx::Size window_size_;
50 64
51 // Keeps track of whether the window size matches the image size or not. If 65 // Keeps track of whether the window size matches the image size or not. If
52 // the image size is smaller than the window size, then the delegate paints a 66 // the image size is smaller than the window size, then the delegate paints a
53 // white background for the missing regions. 67 // white background for the missing regions.
54 bool size_mismatch_; 68 bool size_mismatch_;
55 69
56 DISALLOW_COPY_AND_ASSIGN(ImageWindowDelegate); 70 DISALLOW_COPY_AND_ASSIGN(ImageWindowDelegate);
57 }; 71 };
58 72
59 } // namespace content 73 } // namespace aura_extra
60 74
61 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_IMAGE_WINDOW_DELEGATE_H_ 75 #endif // UI_AURA_EXTRA_IMAGE_WINDOW_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698