OLD | NEW |
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/views/tabs/tab.h" | 5 #include "chrome/browser/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "app/multi_animation.h" | 9 #include "app/multi_animation.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 void Tab::Layout() { | 229 void Tab::Layout() { |
230 gfx::Rect lb = GetLocalBounds(false); | 230 gfx::Rect lb = GetLocalBounds(false); |
231 if (lb.IsEmpty()) | 231 if (lb.IsEmpty()) |
232 return; | 232 return; |
233 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); | 233 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
234 | 234 |
235 // The height of the content of the Tab is the largest of the favicon, | 235 // The height of the content of the Tab is the largest of the favicon, |
236 // the title text and the close button graphic. | 236 // the title text and the close button graphic. |
237 int content_height = std::max(kFavIconSize, font_height()); | 237 int content_height = std::max(kFavIconSize, font_height()); |
238 content_height = std::max(content_height, close_button_height()); | 238 gfx::Size close_button_size(close_button()->GetPreferredSize()); |
| 239 content_height = std::max(content_height, close_button_size.height()); |
239 | 240 |
240 // Size the Favicon. | 241 // Size the Favicon. |
241 showing_icon_ = ShouldShowIcon(); | 242 showing_icon_ = ShouldShowIcon(); |
242 if (showing_icon_) { | 243 if (showing_icon_) { |
243 // Use the size of the favicon as apps use a bigger favicon size. | 244 // Use the size of the favicon as apps use a bigger favicon size. |
244 int favicon_size = | 245 int favicon_size = |
245 !data().favicon.empty() ? data().favicon.width() : kFavIconSize; | 246 !data().favicon.empty() ? data().favicon.width() : kFavIconSize; |
246 int favicon_top = kTopPadding + content_height / 2 - favicon_size / 2; | 247 int favicon_top = kTopPadding + content_height / 2 - favicon_size / 2; |
247 int favicon_left = lb.x(); | 248 int favicon_left = lb.x(); |
248 if (favicon_size != kFavIconSize) { | 249 if (favicon_size != kFavIconSize) { |
(...skipping 16 matching lines...) Expand all Loading... |
265 favicon_bounds_.set_x(x); | 266 favicon_bounds_.set_x(x); |
266 } | 267 } |
267 } | 268 } |
268 } else { | 269 } else { |
269 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); | 270 favicon_bounds_.SetRect(lb.x(), lb.y(), 0, 0); |
270 } | 271 } |
271 | 272 |
272 // Size the Close button. | 273 // Size the Close button. |
273 showing_close_button_ = ShouldShowCloseBox(); | 274 showing_close_button_ = ShouldShowCloseBox(); |
274 if (showing_close_button_) { | 275 if (showing_close_button_) { |
275 int close_button_top = | 276 int close_button_top = kTopPadding + kCloseButtonVertFuzz + |
276 kTopPadding + kCloseButtonVertFuzz + | 277 (content_height - close_button_size.height()) / 2; |
277 (content_height - close_button_height()) / 2; | |
278 // If the ratio of the close button size to tab width exceeds the maximum. | 278 // If the ratio of the close button size to tab width exceeds the maximum. |
279 close_button()->SetBounds(lb.width() + kCloseButtonHorzFuzz, | 279 close_button()->SetBounds(lb.width() + kCloseButtonHorzFuzz, |
280 close_button_top, close_button_width(), | 280 close_button_top, close_button_size.width(), |
281 close_button_height()); | 281 close_button_size.height()); |
282 close_button()->SetVisible(true); | 282 close_button()->SetVisible(true); |
283 } else { | 283 } else { |
284 close_button()->SetBounds(0, 0, 0, 0); | 284 close_button()->SetBounds(0, 0, 0, 0); |
285 close_button()->SetVisible(false); | 285 close_button()->SetVisible(false); |
286 } | 286 } |
287 | 287 |
288 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing; | 288 int title_left = favicon_bounds_.right() + kFavIconTitleSpacing; |
289 int title_top = kTopPadding + (content_height - font_height()) / 2; | 289 int title_top = kTopPadding + (content_height - font_height()) / 2; |
290 // Size the Title text to fill the remaining space. | 290 // Size the Title text to fill the remaining space. |
291 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { | 291 if (!data().mini || width() >= kMiniTabRendererAsNormalTabWidth) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 tab_active.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 604 tab_active.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
605 tab_active.l_width = tab_active.image_l->width(); | 605 tab_active.l_width = tab_active.image_l->width(); |
606 tab_active.r_width = tab_active.image_r->width(); | 606 tab_active.r_width = tab_active.image_r->width(); |
607 | 607 |
608 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 608 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
609 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 609 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
610 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 610 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
611 tab_inactive.l_width = tab_inactive.image_l->width(); | 611 tab_inactive.l_width = tab_inactive.image_l->width(); |
612 tab_inactive.r_width = tab_inactive.image_r->width(); | 612 tab_inactive.r_width = tab_inactive.image_r->width(); |
613 } | 613 } |
OLD | NEW |