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

Side by Side Diff: ash/frame/header_painter.h

Issue 189463013: [Refactor] Move code for painting the window header for browser windows out of ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/frame/frame_border_hit_test_controller.cc ('k') | ash/frame/header_painter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ASH_FRAME_HEADER_PAINTER_H_ 5 #ifndef ASH_FRAME_HEADER_PAINTER_H_
6 #define ASH_FRAME_HEADER_PAINTER_H_ 6 #define ASH_FRAME_HEADER_PAINTER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" // OVERRIDE
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/animation/animation_delegate.h"
14 #include "ui/gfx/geometry/rect.h"
15 9
16 namespace gfx { 10 namespace gfx {
17 class Canvas; 11 class Canvas;
18 class FontList;
19 class ImageSkia;
20 class Point;
21 class Size;
22 class SlideAnimation;
23 }
24 namespace views {
25 class View;
26 class Widget;
27 } 12 }
28 13
29 namespace ash { 14 namespace ash {
30 class FrameCaptionButtonContainerView;
31 15
32 // Helper class for painting the window header. 16 // Helper class for painting the window header.
33 class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { 17 class ASH_EXPORT HeaderPainter {
34 public: 18 public:
35 enum Mode { 19 enum Mode {
36 MODE_ACTIVE, 20 MODE_ACTIVE,
37 MODE_INACTIVE 21 MODE_INACTIVE
38 }; 22 };
39 23
40 // TODO(pkotwicz): Move code related to "browser" windows out of ash. 24 virtual ~HeaderPainter() {
41 enum Style { 25 }
42 // Header style used for browser windows.
43 STYLE_BROWSER,
44
45 // Header style used for apps and miscellaneous windows (e.g. task manager).
46 STYLE_OTHER
47 };
48
49 HeaderPainter();
50 virtual ~HeaderPainter();
51
52 // None of the parameters are owned.
53 void Init(Style style,
54 views::Widget* frame,
55 views::View* header_view,
56 views::View* window_icon,
57 FrameCaptionButtonContainerView* caption_button_container);
58
59 // Returns the bounds of the client view for a window with |header_height|
60 // and |window_bounds|. The return value and |window_bounds| are in the
61 // views::NonClientView's coordinates.
62 static gfx::Rect GetBoundsForClientView(int header_height,
63 const gfx::Rect& window_bounds);
64
65 // Returns the bounds of the window given |header_height| and |client_bounds|.
66 // The return value and |client_bounds| are in the views::NonClientView's
67 // coordinates.
68 static gfx::Rect GetWindowBoundsForClientBounds(
69 int header_height,
70 const gfx::Rect& client_bounds);
71
72 // Determines the window HT* code at |point|. Returns HTNOWHERE if |point| is
73 // not within the top |header_height_| of |header_view_|. |point| is in the
74 // coordinates of |header_view_|'s widget. The client view must be hittested
75 // before calling this method because a browser's tabs are in the top
76 // |header_height_| of |header_view_|.
77 int NonClientHitTest(const gfx::Point& point) const;
78 26
79 // Returns the header's minimum width. 27 // Returns the header's minimum width.
80 int GetMinimumHeaderWidth() const; 28 virtual int GetMinimumHeaderWidth() const = 0;
81
82 // Returns the inset from the right edge.
83 int GetRightInset() const;
84
85 // Returns the amount that the theme background should be inset.
86 int GetThemeBackgroundXInset() const;
87 29
88 // Paints the header. 30 // Paints the header.
89 // |theme_frame_overlay_id| is 0 if no overlay image should be used. 31 virtual void PaintHeader(gfx::Canvas* canvas, Mode mode) = 0;
90 // |mode| indicates whether the window should be painted as active.
91 void PaintHeader(gfx::Canvas* canvas,
92 Mode mode,
93 int theme_frame_id,
94 int theme_frame_overlay_id);
95 32
96 // Paints the header/content separator line for non-browser windows. 33 // Performs layout for the header.
97 void PaintHeaderContentSeparator(gfx::Canvas* canvas, Mode mode); 34 virtual void LayoutHeader() = 0;
98 35
99 // Returns size of the header/content separator line for non-browser windows 36 // Gets / sets how much of the header is painted. This allows the tabstrip to
100 // in pixels. 37 // affect the header height. This height does not affect LayoutHeader().
101 int HeaderContentSeparatorSize() const; 38 virtual int GetHeaderHeightForPainting() const = 0;
102 39 virtual void SetHeaderHeightForPainting(int height_for_painting) = 0;
103 // Paint the title bar, primarily the title string.
104 void PaintTitleBar(gfx::Canvas* canvas, const gfx::FontList& title_font_list);
105
106 // Performs layout for the header based on |frame_|'s show state.
107 void LayoutHeader();
108
109 // Sets the height of the header. The height of the header affects painting,
110 // and non client hit tests. It does not affect layout.
111 void set_header_height(int header_height) {
112 header_height_ = header_height;
113 }
114
115 // Returns the header height.
116 int header_height() const {
117 return header_height_;
118 }
119 40
120 // Schedule a re-paint of the entire title. 41 // Schedule a re-paint of the entire title.
121 void SchedulePaintForTitle(const gfx::FontList& title_font_list); 42 virtual void SchedulePaintForTitle() = 0;
122
123 // Called when the browser theme changes.
124 void OnThemeChanged();
125
126 // Overridden from gfx::AnimationDelegate
127 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
128
129 private:
130 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment);
131
132 // Paints highlight around the edge of the header for restored browser
133 // windows.
134 void PaintHighlightForRestoredBrowserWindow(gfx::Canvas* canvas);
135
136 // Paints highlight around the edge of the header for inactive restored
137 // non-browser windows.
138 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas);
139
140 // Updates the images used for the minimize, restore and close buttons.
141 void UpdateCaptionButtonImages();
142
143 // Returns the header bounds in the coordinates of |header_view_|. The header
144 // is assumed to be positioned at the top left corner of |header_view_| and to
145 // have the same width as |header_view_|.
146 gfx::Rect GetHeaderLocalBounds() const;
147
148 // Returns the offset between window left edge and title string.
149 int GetTitleOffsetX() const;
150
151 // Returns the vertical center of the caption button container in window
152 // coordinates.
153 int GetCaptionButtonContainerCenterY() const;
154
155 // Returns the radius of the header's top corners.
156 int GetHeaderCornerRadius() const;
157
158 // Get the bounds for the title. The provided |title_font_list| is used to
159 // determine the correct dimensions.
160 gfx::Rect GetTitleBounds(const gfx::FontList& title_font_list);
161
162 Style style_;
163
164 // Not owned
165 views::Widget* frame_;
166 views::View* header_view_;
167 views::View* window_icon_; // May be NULL.
168 FrameCaptionButtonContainerView* caption_button_container_;
169
170 // The height of the header.
171 int header_height_;
172
173 // Image ids and opacity last used for painting header.
174 int previous_theme_frame_id_;
175 int previous_theme_frame_overlay_id_;
176
177 // Image ids and opacity we are crossfading from.
178 int crossfade_theme_frame_id_;
179 int crossfade_theme_frame_overlay_id_;
180
181 scoped_ptr<gfx::SlideAnimation> crossfade_animation_;
182
183 DISALLOW_COPY_AND_ASSIGN(HeaderPainter);
184 }; 43 };
185 44
186 } // namespace ash 45 } // namespace ash
187 46
188 #endif // ASH_FRAME_HEADER_PAINTER_H_ 47 #endif // ASH_FRAME_HEADER_PAINTER_H_
OLDNEW
« no previous file with comments | « ash/frame/frame_border_hit_test_controller.cc ('k') | ash/frame/header_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698