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

Side by Side Diff: ui/views/window/frame_background.h

Issue 8772060: Refactor window frame painting into a window background class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final cleanup of PaintRestored Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/window/custom_frame_view.cc ('k') | ui/views/window/frame_background.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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_VIEWS_WINDOW_FRAME_BACKGROUND_H_
6 #define UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/views/views_export.h"
12
13 class SkBitmap;
14 namespace gfx {
15 class Canvas;
16 }
17
18 namespace views {
19
20 class View;
21
22 // FrameBackground handles painting for all the various window frames we
23 // support in Chrome. It intends to consolidate paint code that historically
24 // was copied. One frame to rule them all!
25 class VIEWS_EXPORT FrameBackground {
26 public:
27 FrameBackground();
28 ~FrameBackground();
29
30 // Sets the color to draw under the frame bitmaps.
31 void set_frame_color(SkColor color) { frame_color_ = color; }
32
33 // Sets the theme bitmap for the top of the window. May be NULL.
34 // Memory is owned by the caller.
35 void set_theme_bitmap(SkBitmap* bitmap) { theme_bitmap_ = bitmap; }
36
37 // Sets an image that overlays the top window bitmap. Usually used to add
38 // edge highlighting to provide the illusion of depth. May be NULL.
39 // Memory is owned by the caller.
40 void set_theme_overlay_bitmap(SkBitmap* bitmap) {
41 theme_overlay_bitmap_ = bitmap;
42 }
43
44 // Sets the height of the top area to fill with the default frame color,
45 // which must extend behind the tab strip.
46 void set_top_area_height(int height) { top_area_height_ = height; }
47
48 // Only used if we have an overlay image for the theme.
49 void set_theme_background_y(int y) { theme_background_y_ = y; }
50
51 // Vertical offset for theme image when drawing maximized.
52 void set_maximized_top_offset(int offset) { maximized_top_offset_ = offset; }
53
54 // Sets images used when drawing the sides of the frame.
55 // Caller owns the memory.
56 void SetSideImages(SkBitmap* left,
57 SkBitmap* top,
58 SkBitmap* right,
59 SkBitmap* bottom);
60
61 // Sets images used when drawing the corners of the frame.
62 // Caller owns the memory.
63 void SetCornerImages(SkBitmap* top_left,
64 SkBitmap* top_right,
65 SkBitmap* bottom_left,
66 SkBitmap* bottom_right);
67
68 // Sets attributes to paint top-left and top-right corners for maximized
69 // windows. Use 0 and NULL if you don't want special corners.
70 // TODO(jamescook): This is the remnant of a ChromeOS window hack, and should
71 // be removed.
72 void SetMaximizedCorners(SkBitmap* top_left,
73 SkBitmap* top_right,
74 int top_offset);
75
76 // Paints the border for a standard, non-maximized window. Also paints the
77 // background of the title bar area, since the top frame border and the
78 // title bar background are a contiguous component.
79 void PaintRestored(gfx::Canvas* canvas, View* view) const;
80
81 // Paints the border for a maximized window, which does not include the
82 // window edges.
83 void PaintMaximized(gfx::Canvas* canvas, View* view) const;
84
85 private:
86 // Fills the frame area with the frame color.
87 void PaintFrameColor(gfx::Canvas* canvas, View* view) const;
88
89 SkColor frame_color_;
90 SkBitmap* theme_bitmap_;
91 SkBitmap* theme_overlay_bitmap_;
92 int top_area_height_;
93
94 // Images for the sides of the frame.
95 SkBitmap* left_edge_;
96 SkBitmap* top_edge_;
97 SkBitmap* right_edge_;
98 SkBitmap* bottom_edge_;
99
100 // Images for the corners of the frame.
101 SkBitmap* top_left_corner_;
102 SkBitmap* top_right_corner_;
103 SkBitmap* bottom_left_corner_;
104 SkBitmap* bottom_right_corner_;
105
106 // Attributes for maximized window painting.
107 // TODO(jamescook): Remove all these.
108 SkBitmap* maximized_top_left_;
109 SkBitmap* maximized_top_right_;
110 int maximized_top_offset_;
111 int theme_background_y_;
112
113 DISALLOW_COPY_AND_ASSIGN(FrameBackground);
114 };
115
116 } // namespace views
117
118 #endif // UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_
OLDNEW
« no previous file with comments | « ui/views/window/custom_frame_view.cc ('k') | ui/views/window/frame_background.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698