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

Side by Side Diff: ui/gfx/scoped_canvas.h

Issue 1904753002: MenuButton: support Mac look & feel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cache arrow images Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 UI_GFX_SCOPED_CANVAS_H_ 5 #ifndef UI_GFX_SCOPED_CANVAS_H_
6 #define UI_GFX_SCOPED_CANVAS_H_ 6 #define UI_GFX_SCOPED_CANVAS_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 12
13 class Rect;
14
13 // Saves the drawing state, and restores the state when going out of scope. 15 // Saves the drawing state, and restores the state when going out of scope.
14 class ScopedCanvas { 16 class ScopedCanvas {
15 public: 17 public:
16 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) { 18 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) {
17 if (canvas_) 19 if (canvas_)
18 canvas_->Save(); 20 canvas_->Save();
19 } 21 }
20 ~ScopedCanvas() { 22 ~ScopedCanvas() {
21 if (canvas_) 23 if (canvas_)
22 canvas_->Restore(); 24 canvas_->Restore();
23 } 25 }
24 26
25 private: 27 private:
26 gfx::Canvas* canvas_; 28 gfx::Canvas* canvas_;
27 29
28 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas); 30 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas);
29 }; 31 };
30 32
33 // Saves the drawing state, and applies an RTL transform for the supplied rect
34 // if the UI is in RTL layout. The resulting transform is such that anything
35 // drawn inside the supplied rect will be flipped horizontally.
36 class ScopedRTLFlipCanvas {
tapted 2016/04/26 05:05:57 ooh this needs to be GFX_EXPORT (+include gfx_expo
Elly Fong-Jones 2016/04/26 17:41:25 I made this and ScopedCanvas both GFX_EXPORT. I'm
tapted 2016/04/27 03:25:11 The inlined methods wouldn't have required it, but
37 public:
38 ScopedRTLFlipCanvas(gfx::Canvas* canvas, const gfx::Rect& rect);
39 ~ScopedRTLFlipCanvas() {}
40
41 private:
42 ScopedCanvas canvas_;
43
44 DISALLOW_COPY_AND_ASSIGN(ScopedRTLFlipCanvas);
45 };
46
31 } // namespace gfx 47 } // namespace gfx
32 48
33 #endif // UI_GFX_SCOPED_CANVAS_H_ 49 #endif // UI_GFX_SCOPED_CANVAS_H_
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/scoped_canvas.cc » ('j') | ui/views/controls/button/menu_button.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698