Index: ui/base/cocoa/three_part_image.h |
diff --git a/ui/base/cocoa/three_part_image.h b/ui/base/cocoa/three_part_image.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6969ada2ee9fa5dfa8376f3e6edcd857b67e74c8 |
--- /dev/null |
+++ b/ui/base/cocoa/three_part_image.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_BASE_COCOA_THREE_PART_IMAGE_H |
+#define UI_BASE_COCOA_THREE_PART_IMAGE_H |
+ |
+#import <Cocoa/Cocoa.h> |
+ |
+#include "base/mac/scoped_nsobject.h" |
+#include "ui/base/ui_base_export.h" |
+ |
+namespace ui { |
+ |
+// A wrapper around NSDrawThreePartImage that caches the images. |
Robert Sesek
2015/02/12 21:56:37
This should mention that the ids are for ResourceB
Andre
2015/02/12 22:10:37
Done.
|
+// The middle image is optional. |
+// Vertical orientation is not currently supported. |
+class UI_BASE_EXPORT ThreePartImage { |
+ public: |
+ ThreePartImage(int left_id, int middle_id, int right_id); |
+ ~ThreePartImage(); |
+ |
+ // Returns the image rects if drawn in |bounds|. |
+ NSRect GetLeftRect(NSRect bounds) const; |
+ NSRect GetMiddleRect(NSRect bounds) const; |
+ NSRect GetRightRect(NSRect bounds) const; |
+ |
+ // Draws the three part image inside |rect|. |
+ void DrawInRect(NSRect rect, NSCompositingOperation op, CGFloat alpha) const; |
+ |
+ // Returns YES if |point| is in a non-transparent part of the images. |
+ // Returns YES if |point| is inside the middle rect and there is no middle |
+ // image. |
+ BOOL HitTest(NSPoint point, NSRect bounds) const; |
+ |
+ private: |
+ // Returns YES if |point| is in a non-transparent part of |image|. |
+ BOOL HitTestImage(NSPoint point, NSImage* image, NSRect imageRect) const; |
+ |
+ base::scoped_nsobject<NSImage> leftImage_; |
+ base::scoped_nsobject<NSImage> middleImage_; |
+ base::scoped_nsobject<NSImage> rightImage_; |
+ NSSize leftSize_; |
+ NSSize rightSize_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ThreePartImage); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_BASE_COCOA_THREE_PART_IMAGE_H |