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