OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/bookmark_bar_view.h" | 5 #include "chrome/browser/views/bookmark_bar_view.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/base_drag_source.h" | 9 #include "base/base_drag_source.h" |
10 #include "base/gfx/skia_utils.h" | 10 #include "base/gfx/skia_utils.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 if (BookmarkBarView::testing_) { | 235 if (BookmarkBarView::testing_) { |
236 // For some reason during testing the events generated by animating | 236 // For some reason during testing the events generated by animating |
237 // throw off the test. So, don't animate while testing. | 237 // throw off the test. So, don't animate while testing. |
238 show_animation_->Reset(1); | 238 show_animation_->Reset(1); |
239 } else { | 239 } else { |
240 show_animation_->Show(); | 240 show_animation_->Show(); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 bool GetTooltipText(int x, int y, std::wstring* tooltip) { | 244 bool GetTooltipText(int x, int y, std::wstring* tooltip) { |
245 CPoint location(x, y); | 245 gfx::Point location(x, y); |
246 ConvertPointToScreen(this, &location); | 246 ConvertPointToScreen(this, &location); |
247 *tooltip = CreateToolTipForURLAndTitle( | 247 *tooltip = CreateToolTipForURLAndTitle( |
248 gfx::Point(location.x, location.y), url_, GetText(), | 248 gfx::Point(location.x(), location.y()), url_, GetText(), |
249 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 249 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
250 return !tooltip->empty(); | 250 return !tooltip->empty(); |
251 } | 251 } |
252 | 252 |
253 virtual bool IsTriggerableEvent(const ChromeViews::MouseEvent& e) { | 253 virtual bool IsTriggerableEvent(const ChromeViews::MouseEvent& e) { |
254 return event_utils::IsPossibleDispositionEvent(e); | 254 return event_utils::IsPossibleDispositionEvent(e); |
255 } | 255 } |
256 | 256 |
257 virtual void Paint(ChromeCanvas *canvas) { | 257 virtual void Paint(ChromeCanvas *canvas) { |
258 ChromeViews::TextButton::Paint(canvas); | 258 ChromeViews::TextButton::Paint(canvas); |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 node = model_->GetBookmarkBarNode()->GetChild(button_index); | 1396 node = model_->GetBookmarkBarNode()->GetChild(button_index); |
1397 | 1397 |
1398 // When the UI layout is RTL, the bookmarks are laid out from right to left | 1398 // When the UI layout is RTL, the bookmarks are laid out from right to left |
1399 // and therefore when we display the menu we want it to be aligned with the | 1399 // and therefore when we display the menu we want it to be aligned with the |
1400 // bottom right corner of the bookmark item. | 1400 // bottom right corner of the bookmark item. |
1401 if (UILayoutIsRightToLeft()) | 1401 if (UILayoutIsRightToLeft()) |
1402 anchor_point = MenuItemView::TOPRIGHT; | 1402 anchor_point = MenuItemView::TOPRIGHT; |
1403 else | 1403 else |
1404 anchor_point = MenuItemView::TOPLEFT; | 1404 anchor_point = MenuItemView::TOPLEFT; |
1405 } | 1405 } |
1406 CPoint screen_loc(x, 0); | 1406 gfx::Point screen_loc(x, 0); |
1407 View::ConvertPointToScreen(this, &screen_loc); | 1407 View::ConvertPointToScreen(this, &screen_loc); |
1408 menu_runner_.reset(new MenuRunner(this, node, start_index)); | 1408 menu_runner_.reset(new MenuRunner(this, node, start_index)); |
1409 HWND parent_hwnd = GetViewContainer()->GetHWND(); | 1409 HWND parent_hwnd = GetViewContainer()->GetHWND(); |
1410 menu_runner_->RunMenuAt(parent_hwnd, | 1410 menu_runner_->RunMenuAt(parent_hwnd, |
1411 gfx::Rect(screen_loc.x, screen_loc.y, | 1411 gfx::Rect(screen_loc.x(), screen_loc.y(), |
1412 view->width(), bar_height), | 1412 view->width(), bar_height), |
1413 anchor_point, | 1413 anchor_point, |
1414 false); | 1414 false); |
1415 } | 1415 } |
1416 | 1416 |
1417 void BookmarkBarView::ButtonPressed(ChromeViews::BaseButton* sender) { | 1417 void BookmarkBarView::ButtonPressed(ChromeViews::BaseButton* sender) { |
1418 BookmarkNode* node; | 1418 BookmarkNode* node; |
1419 if (sender->GetTag() == kOtherFolderButtonTag) { | 1419 if (sender->GetTag() == kOtherFolderButtonTag) { |
1420 node = model_->other_node(); | 1420 node = model_->other_node(); |
1421 } else { | 1421 } else { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 } | 1579 } |
1580 if (index == -1) | 1580 if (index == -1) |
1581 return; | 1581 return; |
1582 view_to_position_menu_from = GetBookmarkButton(index); | 1582 view_to_position_menu_from = GetBookmarkButton(index); |
1583 if (UILayoutIsRightToLeft()) | 1583 if (UILayoutIsRightToLeft()) |
1584 anchor = MenuItemView::TOPRIGHT; | 1584 anchor = MenuItemView::TOPRIGHT; |
1585 } | 1585 } |
1586 | 1586 |
1587 drop_info_->is_menu_showing = true; | 1587 drop_info_->is_menu_showing = true; |
1588 drop_menu_runner_.reset(new MenuRunner(this, node, start_index)); | 1588 drop_menu_runner_.reset(new MenuRunner(this, node, start_index)); |
1589 CPoint screen_loc(0, 0); | 1589 gfx::Point screen_loc; |
1590 View::ConvertPointToScreen(view_to_position_menu_from, &screen_loc); | 1590 View::ConvertPointToScreen(view_to_position_menu_from, &screen_loc); |
1591 drop_menu_runner_->RunMenuAt( | 1591 drop_menu_runner_->RunMenuAt( |
1592 GetViewContainer()->GetHWND(), | 1592 GetViewContainer()->GetHWND(), |
1593 gfx::Rect(screen_loc.x, screen_loc.y, | 1593 gfx::Rect(screen_loc.x(), screen_loc.y(), |
1594 view_to_position_menu_from->width(), | 1594 view_to_position_menu_from->width(), |
1595 view_to_position_menu_from->height()), | 1595 view_to_position_menu_from->height()), |
1596 anchor, true); | 1596 anchor, true); |
1597 } | 1597 } |
1598 | 1598 |
1599 void BookmarkBarView::StopShowFolderDropMenuTimer() { | 1599 void BookmarkBarView::StopShowFolderDropMenuTimer() { |
1600 if (show_folder_drop_menu_task_) | 1600 if (show_folder_drop_menu_task_) |
1601 show_folder_drop_menu_task_->Cancel(); | 1601 show_folder_drop_menu_task_->Cancel(); |
1602 } | 1602 } |
1603 | 1603 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 } | 1856 } |
1857 | 1857 |
1858 void BookmarkBarView::StopThrobbing(bool immediate) { | 1858 void BookmarkBarView::StopThrobbing(bool immediate) { |
1859 if (!throbbing_view_) | 1859 if (!throbbing_view_) |
1860 return; | 1860 return; |
1861 | 1861 |
1862 // If not immediate, cycle through 2 more complete cycles. | 1862 // If not immediate, cycle through 2 more complete cycles. |
1863 throbbing_view_->StartThrobbing(immediate ? 0 : 4); | 1863 throbbing_view_->StartThrobbing(immediate ? 0 : 4); |
1864 throbbing_view_ = NULL; | 1864 throbbing_view_ = NULL; |
1865 } | 1865 } |
OLD | NEW |