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

Side by Side Diff: ui/base/cocoa/three_part_image.h

Issue 918533005: Mac: Optimize TabView drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split ThreePartImage 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
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef UI_BASE_COCOA_THREE_PART_IMAGE_H
6 #define UI_BASE_COCOA_THREE_PART_IMAGE_H
7
8 #import <Cocoa/Cocoa.h>
9
10 #include "base/mac/scoped_nsobject.h"
11 #include "ui/base/ui_base_export.h"
12
13 namespace ui {
14
15 // 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.
16 // The middle image is optional.
17 // Vertical orientation is not currently supported.
18 class UI_BASE_EXPORT ThreePartImage {
19 public:
20 ThreePartImage(int left_id, int middle_id, int right_id);
21 ~ThreePartImage();
22
23 // Returns the image rects if drawn in |bounds|.
24 NSRect GetLeftRect(NSRect bounds) const;
25 NSRect GetMiddleRect(NSRect bounds) const;
26 NSRect GetRightRect(NSRect bounds) const;
27
28 // Draws the three part image inside |rect|.
29 void DrawInRect(NSRect rect, NSCompositingOperation op, CGFloat alpha) const;
30
31 // Returns YES if |point| is in a non-transparent part of the images.
32 // Returns YES if |point| is inside the middle rect and there is no middle
33 // image.
34 BOOL HitTest(NSPoint point, NSRect bounds) const;
35
36 private:
37 // Returns YES if |point| is in a non-transparent part of |image|.
38 BOOL HitTestImage(NSPoint point, NSImage* image, NSRect imageRect) const;
39
40 base::scoped_nsobject<NSImage> leftImage_;
41 base::scoped_nsobject<NSImage> middleImage_;
42 base::scoped_nsobject<NSImage> rightImage_;
43 NSSize leftSize_;
44 NSSize rightSize_;
45
46 DISALLOW_COPY_AND_ASSIGN(ThreePartImage);
47 };
48
49 } // namespace ui
50
51 #endif // UI_BASE_COCOA_THREE_PART_IMAGE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698