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

Side by Side Diff: chrome/browser/views/frame/glass_browser_frame_view.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/views/frame/glass_browser_frame_view.h" 5 #include "chrome/browser/views/frame/glass_browser_frame_view.h"
6 6
7 #include "app/gfx/chrome_canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "app/theme_provider.h" 9 #include "app/theme_provider.h"
10 #include "chrome/browser/browser_theme_provider.h" 10 #include "chrome/browser/browser_theme_provider.h"
11 #include "chrome/browser/views/frame/browser_view.h" 11 #include "chrome/browser/views/frame/browser_view.h"
12 #include "chrome/browser/views/tabs/tab_strip.h" 12 #include "chrome/browser/views/tabs/tab_strip.h"
13 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "views/window/client_view.h" 14 #include "views/window/client_view.h"
15 #include "views/window/window_resources.h" 15 #include "views/window/window_resources.h"
16 16
17 // static 17 // static
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 NonClientBorderThickness(), border_thickness, 169 NonClientBorderThickness(), border_thickness,
170 kResizeAreaCornerSize - border_thickness, 170 kResizeAreaCornerSize - border_thickness,
171 frame_->GetDelegate()->CanResize()); 171 frame_->GetDelegate()->CanResize());
172 // Fall back to the caption if no other component matches. 172 // Fall back to the caption if no other component matches.
173 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 173 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
174 } 174 }
175 175
176 /////////////////////////////////////////////////////////////////////////////// 176 ///////////////////////////////////////////////////////////////////////////////
177 // GlassBrowserFrameView, views::View overrides: 177 // GlassBrowserFrameView, views::View overrides:
178 178
179 void GlassBrowserFrameView::Paint(ChromeCanvas* canvas) { 179 void GlassBrowserFrameView::Paint(gfx::Canvas* canvas) {
180 if (!browser_view_->IsTabStripVisible()) 180 if (!browser_view_->IsTabStripVisible())
181 return; // Nothing is visible, so don't bother to paint. 181 return; // Nothing is visible, so don't bother to paint.
182 182
183 PaintDistributorLogo(canvas); 183 PaintDistributorLogo(canvas);
184 PaintToolbarBackground(canvas); 184 PaintToolbarBackground(canvas);
185 PaintOTRAvatar(canvas); 185 PaintOTRAvatar(canvas);
186 if (!frame_->IsMaximized()) 186 if (!frame_->IsMaximized())
187 PaintRestoredClientEdge(canvas); 187 PaintRestoredClientEdge(canvas);
188 } 188 }
189 189
(...skipping 19 matching lines...) Expand all
209 int GlassBrowserFrameView::NonClientTopBorderHeight() const { 209 int GlassBrowserFrameView::NonClientTopBorderHeight() const {
210 if (frame_->IsFullscreen()) 210 if (frame_->IsFullscreen())
211 return 0; 211 return 0;
212 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass 212 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass
213 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border 213 // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border
214 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). 214 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()).
215 return GetSystemMetrics(SM_CXSIZEFRAME) + 215 return GetSystemMetrics(SM_CXSIZEFRAME) +
216 (browser_view_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); 216 (browser_view_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness);
217 } 217 }
218 218
219 void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) { 219 void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) {
220 // The distributor logo is only painted when the frame is not maximized and 220 // The distributor logo is only painted when the frame is not maximized and
221 // when we actually have a logo. 221 // when we actually have a logo.
222 if (!frame_->IsMaximized() && distributor_logo_ && 222 if (!frame_->IsMaximized() && distributor_logo_ &&
223 browser_view_->ShouldShowDistributorLogo()) { 223 browser_view_->ShouldShowDistributorLogo()) {
224 // NOTE: We don't mirror the logo placement here because the outer frame 224 // NOTE: We don't mirror the logo placement here because the outer frame
225 // itself isn't mirrored in RTL. This is a bug; if it is fixed, this should 225 // itself isn't mirrored in RTL. This is a bug; if it is fixed, this should
226 // be mirrored as in opaque_non_client_view.cc. 226 // be mirrored as in opaque_non_client_view.cc.
227 canvas->DrawBitmapInt(*distributor_logo_, logo_bounds_.x(), 227 canvas->DrawBitmapInt(*distributor_logo_, logo_bounds_.x(),
228 logo_bounds_.y()); 228 logo_bounds_.y());
229 } 229 }
230 } 230 }
231 231
232 void GlassBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) { 232 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
233 ThemeProvider* tp = GetThemeProvider(); 233 ThemeProvider* tp = GetThemeProvider();
234 234
235 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); 235 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
236 gfx::Point toolbar_origin(toolbar_bounds.origin()); 236 gfx::Point toolbar_origin(toolbar_bounds.origin());
237 View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin); 237 View::ConvertPointToView(frame_->GetClientView(), this, &toolbar_origin);
238 toolbar_bounds.set_origin(toolbar_origin); 238 toolbar_bounds.set_origin(toolbar_origin);
239 239
240 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); 240 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
241 241
242 // Draw the toolbar background, setting src_y of the paint to the tab 242 // Draw the toolbar background, setting src_y of the paint to the tab
(...skipping 11 matching lines...) Expand all
254 254
255 SkBitmap* toolbar_center = 255 SkBitmap* toolbar_center =
256 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); 256 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
257 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(), 257 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(),
258 toolbar_bounds.width(), toolbar_center->height()); 258 toolbar_bounds.width(), toolbar_center->height());
259 259
260 canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER), 260 canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
261 toolbar_bounds.right(), toolbar_bounds.y()); 261 toolbar_bounds.right(), toolbar_bounds.y());
262 } 262 }
263 263
264 void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) { 264 void GlassBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
265 if (!browser_view_->ShouldShowOffTheRecordAvatar()) 265 if (!browser_view_->ShouldShowOffTheRecordAvatar())
266 return; 266 return;
267 267
268 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); 268 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
269 canvas->DrawBitmapInt(otr_avatar_icon, 0, 269 canvas->DrawBitmapInt(otr_avatar_icon, 0,
270 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, 270 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2,
271 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), 271 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(),
272 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), 272 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(),
273 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); 273 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false);
274 } 274 }
275 275
276 void GlassBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { 276 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
277 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 277 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
278 278
279 // The client edges start below the toolbar upper corner images regardless 279 // The client edges start below the toolbar upper corner images regardless
280 // of how tall the toolbar itself is. 280 // of how tall the toolbar itself is.
281 int client_area_top = 281 int client_area_top =
282 frame_->GetClientView()->y() + browser_view_->GetToolbarBounds().y() + 282 frame_->GetClientView()->y() + browser_view_->GetToolbarBounds().y() +
283 rb.GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); 283 rb.GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
284 284
285 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 285 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
286 int client_area_bottom = 286 int client_area_bottom =
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 static bool initialized = false; 413 static bool initialized = false;
414 if (!initialized) { 414 if (!initialized) {
415 #if defined(GOOGLE_CHROME_BUILD) 415 #if defined(GOOGLE_CHROME_BUILD)
416 distributor_logo_ = ResourceBundle::GetSharedInstance(). 416 distributor_logo_ = ResourceBundle::GetSharedInstance().
417 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); 417 GetBitmapNamed(IDR_DISTRIBUTOR_LOGO);
418 #endif 418 #endif
419 419
420 initialized = true; 420 initialized = true;
421 } 421 }
422 } 422 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/glass_browser_frame_view.h ('k') | chrome/browser/views/frame/opaque_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698