Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/ui/views/tabs/base_tab_strip.cc

Issue 6750007: Scrolling Tabs (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressing Scott's review comments Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tabs/base_tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/base_tab_strip.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/title_prefix_matcher.h" 8 #include "chrome/browser/ui/title_prefix_matcher.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" 10 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return false; 371 return false;
372 bool started_drag = drag_controller_->started_drag(); 372 bool started_drag = drag_controller_->started_drag();
373 drag_controller_->EndDrag(canceled); 373 drag_controller_->EndDrag(canceled);
374 return started_drag; 374 return started_drag;
375 } 375 }
376 376
377 BaseTab* BaseTabStrip::GetTabAt(BaseTab* tab, 377 BaseTab* BaseTabStrip::GetTabAt(BaseTab* tab,
378 const gfx::Point& tab_in_tab_coordinates) { 378 const gfx::Point& tab_in_tab_coordinates) {
379 gfx::Point local_point = tab_in_tab_coordinates; 379 gfx::Point local_point = tab_in_tab_coordinates;
380 ConvertPointToView(tab, this, &local_point); 380 ConvertPointToView(tab, this, &local_point);
381 views::View* view = GetEventHandlerForPoint(local_point); 381 return GetTabAtLocal(local_point);
382 if (!view)
383 return NULL; // No tab contains the point.
384
385 // Walk up the view hierarchy until we find a tab, or the TabStrip.
386 while (view && view != this && view->GetID() != VIEW_ID_TAB)
387 view = view->parent();
388
389 return view && view->GetID() == VIEW_ID_TAB ?
390 static_cast<BaseTab*>(view) : NULL;
391 } 382 }
392 383
393 void BaseTabStrip::Layout() { 384 void BaseTabStrip::Layout() {
394 // Only do a layout if our size changed. 385 // Only do a layout if our size changed.
395 if (last_layout_size_ == size()) 386 if (last_layout_size_ == size())
396 return; 387 return;
397 DoLayout(); 388 DoLayout();
398 } 389 }
399 390
400 bool BaseTabStrip::OnMouseDragged(const views::MouseEvent& event) { 391 bool BaseTabStrip::OnMouseDragged(const views::MouseEvent& event) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 StopAnimating(false); 555 StopAnimating(false);
565 556
566 GenerateIdealBounds(); 557 GenerateIdealBounds();
567 558
568 for (int i = 0; i < tab_count(); ++i) 559 for (int i = 0; i < tab_count(); ++i)
569 tab_data_[i].tab->SetBoundsRect(tab_data_[i].ideal_bounds); 560 tab_data_[i].tab->SetBoundsRect(tab_data_[i].ideal_bounds);
570 561
571 SchedulePaint(); 562 SchedulePaint();
572 } 563 }
573 564
565 BaseTab* BaseTabStrip::GetTabAtLocal(
566 const gfx::Point& local_point) {
567 views::View* view = GetEventHandlerForPoint(local_point);
568 if (!view)
569 return NULL; // No tab contains the point.
570
571 // Walk up the view hierarchy until we find a tab, or the TabStrip.
572 while (view && view != this && view->GetID() != VIEW_ID_TAB)
573 view = view->parent();
574
575 return view && view->GetID() == VIEW_ID_TAB ?
576 static_cast<BaseTab*>(view) : NULL;
577 }
578
574 void BaseTabStrip::StoppedDraggingTab(BaseTab* tab, bool* is_first_tab) { 579 void BaseTabStrip::StoppedDraggingTab(BaseTab* tab, bool* is_first_tab) {
575 int tab_data_index = TabIndexOfTab(tab); 580 int tab_data_index = TabIndexOfTab(tab);
576 if (tab_data_index == -1) { 581 if (tab_data_index == -1) {
577 // The tab was removed before the drag completed. Don't do anything. 582 // The tab was removed before the drag completed. Don't do anything.
578 return; 583 return;
579 } 584 }
580 585
581 if (*is_first_tab) { 586 if (*is_first_tab) {
582 *is_first_tab = false; 587 *is_first_tab = false;
583 PrepareForAnimation(); 588 PrepareForAnimation();
584 589
585 // Animate the view back to its correct position. 590 // Animate the view back to its correct position.
586 GenerateIdealBounds(); 591 GenerateIdealBounds();
587 AnimateToIdealBounds(); 592 AnimateToIdealBounds();
588 } 593 }
589 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab))); 594 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab)));
590 // Install a delegate to reset the dragging state when done. We have to leave 595 // Install a delegate to reset the dragging state when done. We have to leave
591 // dragging true for the tab otherwise it'll draw beneath the new tab button. 596 // dragging true for the tab otherwise it'll draw beneath the new tab button.
592 bounds_animator_.SetAnimationDelegate( 597 bounds_animator_.SetAnimationDelegate(
593 tab, new ResetDraggingStateDelegate(tab), true); 598 tab, new ResetDraggingStateDelegate(tab), true);
594 } 599 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698