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_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 show_animation_.reset(new ui::SlideAnimation(this)); | 139 show_animation_.reset(new ui::SlideAnimation(this)); |
140 if (BookmarkBarView::testing_) { | 140 if (BookmarkBarView::testing_) { |
141 // For some reason during testing the events generated by animating | 141 // For some reason during testing the events generated by animating |
142 // throw off the test. So, don't animate while testing. | 142 // throw off the test. So, don't animate while testing. |
143 show_animation_->Reset(1); | 143 show_animation_->Reset(1); |
144 } else { | 144 } else { |
145 show_animation_->Show(); | 145 show_animation_->Show(); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { | 149 virtual bool GetTooltipText(const gfx::Point& p, |
| 150 std::wstring* tooltip) OVERRIDE { |
150 gfx::Point location(p); | 151 gfx::Point location(p); |
151 ConvertPointToScreen(this, &location); | 152 ConvertPointToScreen(this, &location); |
152 *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle(location, url_, | 153 *tooltip = BookmarkBarView::CreateToolTipForURLAndTitle(location, url_, |
153 text(), profile_); | 154 text(), profile_); |
154 return !tooltip->empty(); | 155 return !tooltip->empty(); |
155 } | 156 } |
156 | 157 |
157 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { | 158 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { |
158 return event_utils::IsPossibleDispositionEvent(e); | 159 return event_utils::IsPossibleDispositionEvent(e); |
159 } | 160 } |
(...skipping 28 matching lines...) Expand all Loading... |
188 show_animation_.reset(new ui::SlideAnimation(this)); | 189 show_animation_.reset(new ui::SlideAnimation(this)); |
189 if (BookmarkBarView::testing_) { | 190 if (BookmarkBarView::testing_) { |
190 // For some reason during testing the events generated by animating | 191 // For some reason during testing the events generated by animating |
191 // throw off the test. So, don't animate while testing. | 192 // throw off the test. So, don't animate while testing. |
192 show_animation_->Reset(1); | 193 show_animation_->Reset(1); |
193 } else { | 194 } else { |
194 show_animation_->Show(); | 195 show_animation_->Show(); |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
| 199 virtual bool GetTooltipText(const gfx::Point& p, |
| 200 std::wstring* tooltip) OVERRIDE { |
| 201 if (text_size_.width() > GetTextBounds().width()) |
| 202 *tooltip = text_; |
| 203 return !tooltip->empty(); |
| 204 } |
| 205 |
198 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { | 206 virtual bool IsTriggerableEvent(const views::MouseEvent& e) OVERRIDE { |
199 // Left clicks should show the menu contents and right clicks should show | 207 // Left clicks should show the menu contents and right clicks should show |
200 // the context menu. They should not trigger the opening of underlying urls. | 208 // the context menu. They should not trigger the opening of underlying urls. |
201 if (e.flags() == ui::EF_LEFT_BUTTON_DOWN || | 209 if (e.flags() == ui::EF_LEFT_BUTTON_DOWN || |
202 e.flags() == ui::EF_RIGHT_BUTTON_DOWN) | 210 e.flags() == ui::EF_RIGHT_BUTTON_DOWN) |
203 return false; | 211 return false; |
204 | 212 |
205 WindowOpenDisposition disposition( | 213 WindowOpenDisposition disposition( |
206 event_utils::DispositionFromEventFlags(e.flags())); | 214 event_utils::DispositionFromEventFlags(e.flags())); |
207 return disposition != CURRENT_TAB; | 215 return disposition != CURRENT_TAB; |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 (1 - size_animation_->GetCurrentValue()))); | 1754 (1 - size_animation_->GetCurrentValue()))); |
1747 } else { | 1755 } else { |
1748 prefsize.set_height( | 1756 prefsize.set_height( |
1749 static_cast<int>( | 1757 static_cast<int>( |
1750 browser_defaults::kBookmarkBarHeight * | 1758 browser_defaults::kBookmarkBarHeight * |
1751 size_animation_->GetCurrentValue())); | 1759 size_animation_->GetCurrentValue())); |
1752 } | 1760 } |
1753 } | 1761 } |
1754 return prefsize; | 1762 return prefsize; |
1755 } | 1763 } |
OLD | NEW |