OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/ui/views/bookmarks/bookmark_bar_instructions_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/defaults.h" | 8 #include "chrome/browser/defaults.h" |
9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // We don't want the link to alter tab navigation. | 35 // We don't want the link to alter tab navigation. |
36 import_link_->set_focusable(false); | 36 import_link_->set_focusable(false); |
37 import_link_->set_listener(this); | 37 import_link_->set_listener(this); |
38 AddChildView(import_link_); | 38 AddChildView(import_link_); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { | 42 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { |
43 int ascent = 0, descent = 0, height = 0, width = 0; | 43 int ascent = 0, descent = 0, height = 0, width = 0; |
44 for (int i = 0; i < child_count(); ++i) { | 44 for (int i = 0; i < child_count(); ++i) { |
45 views::View* view = GetChildViewAt(i); | 45 views::View* view = child_at(i); |
46 gfx::Size pref = view->GetPreferredSize(); | 46 gfx::Size pref = view->GetPreferredSize(); |
47 int baseline = view->GetBaseline(); | 47 int baseline = view->GetBaseline(); |
48 if (baseline != -1) { | 48 if (baseline != -1) { |
49 ascent = std::max(ascent, baseline); | 49 ascent = std::max(ascent, baseline); |
50 descent = std::max(descent, pref.height() - baseline); | 50 descent = std::max(descent, pref.height() - baseline); |
51 } else { | 51 } else { |
52 height = std::max(pref.height(), height); | 52 height = std::max(pref.height(), height); |
53 } | 53 } |
54 width += pref.width(); | 54 width += pref.width(); |
55 } | 55 } |
56 width += (child_count() - 1) * kViewPadding; | 56 width += (child_count() - 1) * kViewPadding; |
57 if (ascent != 0) | 57 if (ascent != 0) |
58 height = std::max(ascent + descent, height); | 58 height = std::max(ascent + descent, height); |
59 return gfx::Size(width, height); | 59 return gfx::Size(width, height); |
60 } | 60 } |
61 | 61 |
62 void BookmarkBarInstructionsView::Layout() { | 62 void BookmarkBarInstructionsView::Layout() { |
63 int remaining_width = width(); | 63 int remaining_width = width(); |
64 int x = 0; | 64 int x = 0; |
65 for (int i = 0; i < child_count(); ++i) { | 65 for (int i = 0; i < child_count(); ++i) { |
66 views::View* view = GetChildViewAt(i); | 66 views::View* view = child_at(i); |
67 gfx::Size pref = view->GetPreferredSize(); | 67 gfx::Size pref = view->GetPreferredSize(); |
68 int baseline = view->GetBaseline(); | 68 int baseline = view->GetBaseline(); |
69 int y; | 69 int y; |
70 if (baseline != -1 && baseline_ != -1) | 70 if (baseline != -1 && baseline_ != -1) |
71 y = baseline_ - baseline; | 71 y = baseline_ - baseline; |
72 else | 72 else |
73 y = (height() - pref.height()) / 2; | 73 y = (height() - pref.height()) / 2; |
74 int view_width = std::min(remaining_width, pref.width()); | 74 int view_width = std::min(remaining_width, pref.width()); |
75 view->SetBounds(x, y, view_width, pref.height()); | 75 view->SetBounds(x, y, view_width, pref.height()); |
76 x += view_width + kViewPadding; | 76 x += view_width + kViewPadding; |
(...skipping 27 matching lines...) Expand all Loading... |
104 const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 104 const ui::ThemeProvider* theme_provider = GetThemeProvider(); |
105 if (!theme_provider) | 105 if (!theme_provider) |
106 return; | 106 return; |
107 updated_colors_ = true; | 107 updated_colors_ = true; |
108 SkColor text_color = | 108 SkColor text_color = |
109 theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); | 109 theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); |
110 instructions_->SetColor(text_color); | 110 instructions_->SetColor(text_color); |
111 if (import_link_) | 111 if (import_link_) |
112 import_link_->SetColor(text_color); | 112 import_link_->SetColor(text_color); |
113 } | 113 } |
OLD | NEW |