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

Side by Side Diff: chrome/browser/chromeos/frame/normal_browser_frame_view.cc

Issue 3137019: Fix numerous alignment problems, both horizontal and vertical, in drawing the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/chromeos/frame/normal_browser_frame_view.h" 5 #include "chrome/browser/chromeos/frame/normal_browser_frame_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.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 "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 gfx::Rect NormalBrowserFrameView::GetBoundsForTabStrip( 84 gfx::Rect NormalBrowserFrameView::GetBoundsForTabStrip(
85 BaseTabStrip* tabstrip) const { 85 BaseTabStrip* tabstrip) const {
86 int border_thickness = FrameBorderThickness(); 86 int border_thickness = FrameBorderThickness();
87 if (browser_view_->UseVerticalTabs()) { 87 if (browser_view_->UseVerticalTabs()) {
88 // BrowserViewLayout adjusts the height/width based on the status area and 88 // BrowserViewLayout adjusts the height/width based on the status area and
89 // otr icon. 89 // otr icon.
90 gfx::Size ps = tabstrip->GetPreferredSize(); 90 gfx::Size ps = tabstrip->GetPreferredSize();
91 return gfx::Rect(border_thickness, NonClientTopBorderHeight(), 91 return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
92 ps.width(), browser_view_->height()); 92 ps.width(), browser_view_->height());
93 } 93 }
94 return gfx::Rect(border_thickness, NonClientTopBorderHeight(), 94 return gfx::Rect(border_thickness, GetHorizontalTabStripVerticalOffset(false),
95 std::max(0, width() - (2 * border_thickness)), 95 std::max(0, width() - (2 * border_thickness)),
96 tabstrip->GetPreferredHeight()); 96 tabstrip->GetPreferredHeight());
97 } 97 }
98 98
99 int NormalBrowserFrameView::GetHorizontalTabStripVerticalOffset(
100 bool restored) const {
101 return NonClientTopBorderHeight();
102 }
103
99 void NormalBrowserFrameView::UpdateThrobber(bool running) { 104 void NormalBrowserFrameView::UpdateThrobber(bool running) {
100 // No window icon. 105 // No window icon.
101 } 106 }
102 107
103 gfx::Size NormalBrowserFrameView::GetMinimumSize() { 108 gfx::Size NormalBrowserFrameView::GetMinimumSize() {
104 gfx::Size min_size(browser_view_->GetMinimumSize()); 109 gfx::Size min_size(browser_view_->GetMinimumSize());
105 int border_thickness = FrameBorderThickness(); 110 int border_thickness = FrameBorderThickness();
106 min_size.Enlarge(2 * border_thickness, 111 min_size.Enlarge(2 * border_thickness,
107 NonClientTopBorderHeight() + border_thickness); 112 NonClientTopBorderHeight() + border_thickness);
108 113
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return std::max(0, FrameBorderThickness() - 254 return std::max(0, FrameBorderThickness() -
250 (browser_view_->IsTabStripVisible() ? kTabstripTopShadowThickness : 0)); 255 (browser_view_->IsTabStripVisible() ? kTabstripTopShadowThickness : 0));
251 } 256 }
252 257
253 void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 258 void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
254 ThemeProvider* tp = GetThemeProvider(); 259 ThemeProvider* tp = GetThemeProvider();
255 views::Window* window = frame_->GetWindow(); 260 views::Window* window = frame_->GetWindow();
256 261
257 // Window frame mode and color 262 // Window frame mode and color
258 SkBitmap* theme_frame; 263 SkBitmap* theme_frame;
259 int y = 0; 264 // HACK: This is to properly align the frame background with the tab
265 // background. This was added because when this code was copied from the
266 // opaque frame code, that code didn't correctly handle maximized mode theme
267 // alignment. That bug has since been fixed in a more general but more
268 // complex way in the opaque frame. Since this file is eventually going to
269 // die (see crbug.com/52674), I'm just leaving this here rather than replacing
270 // it with the complex fix.
271 int y = -kCustomFrameBackgroundVerticalOffset - 1;
260 // Never theme app and popup windows. 272 // Never theme app and popup windows.
261 if (!browser_view_->IsBrowserTypeNormal()) { 273 if (!browser_view_->IsBrowserTypeNormal()) {
262 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 274 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
263 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? 275 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ?
264 IDR_FRAME : IDR_FRAME_INACTIVE); 276 IDR_FRAME : IDR_FRAME_INACTIVE);
277 y = 0; // These are never themed.
265 } else if (!browser_view_->IsOffTheRecord()) { 278 } else if (!browser_view_->IsOffTheRecord()) {
266 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? 279 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
267 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); 280 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE);
268 // TODO(oshima): gtk based CHROMEOS is using non custom frame
269 // mode which does this adjustment. This should be removed
270 // once it's fully migrated to views. -1 is due to the layout
271 // difference between views and gtk and will be removed.
272 // See http://crbug.com/28580.
273 y = -kCustomFrameBackgroundVerticalOffset - 1;
274 } else { 281 } else {
275 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? 282 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
276 IDR_THEME_FRAME_INCOGNITO: IDR_THEME_FRAME_INCOGNITO_INACTIVE); 283 IDR_THEME_FRAME_INCOGNITO: IDR_THEME_FRAME_INCOGNITO_INACTIVE);
277 y = -kCustomFrameBackgroundVerticalOffset - 1;
278 } 284 }
279 // Draw the theme frame. 285 // Draw the theme frame. It must be aligned with the tabstrip as if we were
286 // in restored mode. Note that the top of the tabstrip is
287 // kTabstripTopShadowThickness px off the top of the screen.
280 canvas->TileImageInt(*theme_frame, 0, y, width(), theme_frame->height()); 288 canvas->TileImageInt(*theme_frame, 0, y, width(), theme_frame->height());
281 289
282 // Draw the theme frame overlay 290 // Draw the theme frame overlay
283 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && 291 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
284 browser_view_->IsBrowserTypeNormal()) { 292 browser_view_->IsBrowserTypeNormal()) {
285 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ? 293 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
286 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); 294 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
287 canvas->DrawBitmapInt(*theme_overlay, 0, 0); 295 canvas->DrawBitmapInt(*theme_overlay, 0, y);
288 } 296 }
289 297
290 if (!browser_view_->IsToolbarVisible()) { 298 if (!browser_view_->IsToolbarVisible()) {
291 // There's no toolbar to edge the frame border, so we need to draw a bottom 299 // There's no toolbar to edge the frame border, so we need to draw a bottom
292 // edge. The graphic we use for this has a built in client edge, so we clip 300 // edge. The graphic we use for this has a built in client edge, so we clip
293 // it off the bottom. 301 // it off the bottom.
294 SkBitmap* top_center = 302 SkBitmap* top_center =
295 tp->GetBitmapNamed(IDR_APP_TOP_CENTER); 303 tp->GetBitmapNamed(IDR_APP_TOP_CENTER);
296 int edge_height = top_center->height() - kClientEdgeThickness; 304 int edge_height = top_center->height() - kClientEdgeThickness;
297 canvas->TileImageInt(*top_center, 0, 305 canvas->TileImageInt(*top_center, 0,
(...skipping 23 matching lines...) Expand all
321 int bottom_y = toolbar_bounds.y() + split_point; 329 int bottom_y = toolbar_bounds.y() + split_point;
322 SkBitmap* toolbar_left = 330 SkBitmap* toolbar_left =
323 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); 331 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
324 int bottom_edge_height = 332 int bottom_edge_height =
325 std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point; 333 std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point;
326 334
327 SkColor theme_toolbar_color = 335 SkColor theme_toolbar_color =
328 tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); 336 tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
329 canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y, 337 canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y,
330 toolbar_bounds.width(), bottom_edge_height); 338 toolbar_bounds.width(), bottom_edge_height);
331 toolbar_bounds.Inset(-kClientEdgeThickness, 0);
332 339
333 int strip_height = browser_view_->GetTabStripHeight(); 340 int strip_height = browser_view_->GetTabStripHeight();
334 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); 341 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
335 342
336 canvas->TileImageInt(*theme_toolbar, toolbar_bounds.x(), 343 canvas->TileImageInt(*theme_toolbar, toolbar_bounds.x(),
337 strip_height - kFrameShadowThickness, toolbar_bounds.x(), 344 strip_height - kFrameShadowThickness, toolbar_bounds.x(), bottom_y,
338 bottom_y, toolbar_bounds.width(), theme_toolbar->height()); 345 toolbar_bounds.width(), theme_toolbar->height());
339 346
340 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, 347 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
341 toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(), 348 toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(),
342 toolbar_left->width(), split_point, false); 349 toolbar_left->width(), split_point, false);
343 canvas->DrawBitmapInt(*toolbar_left, 0, 350 canvas->DrawBitmapInt(*toolbar_left, 0,
344 toolbar_left->height() - bottom_edge_height, toolbar_left->width(), 351 toolbar_left->height() - bottom_edge_height, toolbar_left->width(),
345 bottom_edge_height, toolbar_bounds.x() - toolbar_left->width(), bottom_y, 352 bottom_edge_height, toolbar_bounds.x() - toolbar_left->width(), bottom_y,
346 toolbar_left->width(), bottom_edge_height, false); 353 toolbar_left->width(), bottom_edge_height, false);
347 354
348 SkBitmap* toolbar_center = 355 SkBitmap* toolbar_center =
(...skipping 10 matching lines...) Expand all
359 bottom_edge_height, toolbar_bounds.right(), bottom_y, 366 bottom_edge_height, toolbar_bounds.right(), bottom_y,
360 toolbar_right->width(), bottom_edge_height, false); 367 toolbar_right->width(), bottom_edge_height, false);
361 368
362 // Draw the content/toolbar separator. 369 // Draw the content/toolbar separator.
363 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 370 canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
364 toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness, 371 toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness,
365 toolbar_bounds.width(), kClientEdgeThickness); 372 toolbar_bounds.width(), kClientEdgeThickness);
366 } 373 }
367 374
368 } // namespace chromeos 375 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/frame/normal_browser_frame_view.h ('k') | chrome/browser/views/detachable_toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698