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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.h

Issue 291093005: Removes --enable-stacked-tab-strip flag (Stacked Tabs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes --enable-stacked-tab-strip flag (removed stale header) Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "chrome/browser/ui/tabs/tab_strip_layout_type.h"
14 #include "chrome/browser/ui/views/tabs/tab.h" 13 #include "chrome/browser/ui/views/tabs/tab.h"
15 #include "chrome/browser/ui/views/tabs/tab_controller.h" 14 #include "chrome/browser/ui/views/tabs/tab_controller.h"
16 #include "ui/gfx/animation/animation_container.h" 15 #include "ui/gfx/animation/animation_container.h"
17 #include "ui/gfx/point.h" 16 #include "ui/gfx/point.h"
18 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
19 #include "ui/views/animation/bounds_animator.h" 18 #include "ui/views/animation/bounds_animator.h"
20 #include "ui/views/controls/button/image_button.h" 19 #include "ui/views/controls/button/image_button.h"
21 #include "ui/views/mouse_watcher.h" 20 #include "ui/views/mouse_watcher.h"
22 #include "ui/views/view.h" 21 #include "ui/views/view.h"
23 #include "ui/views/view_model.h" 22 #include "ui/views/view_model.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 public: 56 public:
58 static const char kViewClassName[]; 57 static const char kViewClassName[];
59 58
60 explicit TabStrip(TabStripController* controller); 59 explicit TabStrip(TabStripController* controller);
61 virtual ~TabStrip(); 60 virtual ~TabStrip();
62 61
63 // Add and remove observers to changes within this TabStrip. 62 // Add and remove observers to changes within this TabStrip.
64 void AddObserver(TabStripObserver* observer); 63 void AddObserver(TabStripObserver* observer);
65 void RemoveObserver(TabStripObserver* observer); 64 void RemoveObserver(TabStripObserver* observer);
66 65
67 // Sets the layout type. If |adjust_layout| is true the layout type changes 66 // If |adjust_layout| is true the stacked layout changes based on whether the
68 // based on whether the user uses a mouse or touch device with the tabstrip. 67 // user uses a mouse or a touch device with the tabstrip.
69 // If |adjust_layout| is false the layout is fixed to |layout_type|. 68 void set_adjust_layout(bool adjust_layout) { adjust_layout_ = adjust_layout; }
70 void SetLayoutType(TabStripLayoutType layout_type, bool adjust_layout); 69
71 TabStripLayoutType layout_type() const { return layout_type_; } 70 // |stacked_layout_| defines what should happen when the tabs won't fit at
71 // their ideal size. When |stacked_layout_| is true the tabs are always sized
72 // to their ideal size and stacked on top of each other so that only a certain
73 // set of tabs are visible. This is used when the user uses a touch device.
74 // When |stacked_layout_| is false the tabs shrink to accommodate the
75 // available space. This is the default.
76 bool stacked_layout() const { return stacked_layout_; }
77
78 // Sets |stacked_layout_| and animates if necessary.
79 void SetStackedLayout(bool stacked_layout);
72 80
73 // Returns the bounds of the new tab button. 81 // Returns the bounds of the new tab button.
74 gfx::Rect GetNewTabButtonBounds(); 82 gfx::Rect GetNewTabButtonBounds();
75 83
76 // Returns true if the new tab button should be sized to the top of the tab 84 // Returns true if the new tab button should be sized to the top of the tab
77 // strip. 85 // strip.
78 bool SizeTabButtonToTopOfTabStrip(); 86 bool SizeTabButtonToTopOfTabStrip();
79 87
80 // Starts highlighting the tab at the specified index. 88 // Starts highlighting the tab at the specified index.
81 void StartHighlight(int model_index); 89 void StartHighlight(int model_index);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 416
409 // Releases ownership of the current TabDragController. 417 // Releases ownership of the current TabDragController.
410 TabDragController* ReleaseDragController(); 418 TabDragController* ReleaseDragController();
411 419
412 // Paints all the tabs in |tabs_closing_map_[index]|. 420 // Paints all the tabs in |tabs_closing_map_[index]|.
413 void PaintClosingTabs(gfx::Canvas* canvas, 421 void PaintClosingTabs(gfx::Canvas* canvas,
414 int index, 422 int index,
415 const views::CullSet& cull_set); 423 const views::CullSet& cull_set);
416 424
417 // Invoked when a mouse event occurs over |source|. Potentially switches the 425 // Invoked when a mouse event occurs over |source|. Potentially switches the
418 // layout type. 426 // |stacked_layout_|.
419 void UpdateLayoutTypeFromMouseEvent(views::View* source, 427 void UpdateStackedLayoutFromMouseEvent(views::View* source,
420 const ui::MouseEvent& event); 428 const ui::MouseEvent& event);
421 429
422 // -- Tab Resize Layout ----------------------------------------------------- 430 // -- Tab Resize Layout -----------------------------------------------------
423 431
424 // Returns the exact (unrounded) current width of each tab. 432 // Returns the exact (unrounded) current width of each tab.
425 void GetCurrentTabWidths(double* unselected_width, 433 void GetCurrentTabWidths(double* unselected_width,
426 double* selected_width) const; 434 double* selected_width) const;
427 435
428 // Returns the exact (unrounded) desired width of each tab, based on the 436 // Returns the exact (unrounded) desired width of each tab, based on the
429 // desired strip width and number of tabs. If 437 // desired strip width and number of tabs. If
430 // |width_of_tabs_for_mouse_close_| is nonnegative we use that value in 438 // |width_of_tabs_for_mouse_close_| is nonnegative we use that value in
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // Returns the x-coordinates of the tabs. 540 // Returns the x-coordinates of the tabs.
533 std::vector<int> GetTabXCoordinates(); 541 std::vector<int> GetTabXCoordinates();
534 542
535 // Creates/Destroys |touch_layout_| as necessary. 543 // Creates/Destroys |touch_layout_| as necessary.
536 void SwapLayoutIfNecessary(); 544 void SwapLayoutIfNecessary();
537 545
538 // Returns true if |touch_layout_| is needed. 546 // Returns true if |touch_layout_| is needed.
539 bool NeedsTouchLayout() const; 547 bool NeedsTouchLayout() const;
540 548
541 // Sets the value of |reset_to_shrink_on_exit_|. If true |mouse_watcher_| is 549 // Sets the value of |reset_to_shrink_on_exit_|. If true |mouse_watcher_| is
542 // used to track when the mouse truly exits the tabstrip and the layout type 550 // used to track when the mouse truly exits the tabstrip and the stacked
543 // is reset. 551 // layout is reset.
544 void SetResetToShrinkOnExit(bool value); 552 void SetResetToShrinkOnExit(bool value);
545 553
546 // Should the layout dynamically adjust?
547 bool GetAdjustLayout() const;
548
549 // -- Member Variables ------------------------------------------------------ 554 // -- Member Variables ------------------------------------------------------
550 555
551 // There is a one-to-one mapping between each of the tabs in the 556 // There is a one-to-one mapping between each of the tabs in the
552 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab 557 // TabStripController (TabStripModel) and |tabs_|. Because we animate tab
553 // removal there exists a period of time where a tab is displayed but not in 558 // removal there exists a period of time where a tab is displayed but not in
554 // the model. When this occurs the tab is removed from |tabs_| and placed in 559 // the model. When this occurs the tab is removed from |tabs_| and placed in
555 // |tabs_closing_map_|. When the animation completes the tab is removed from 560 // |tabs_closing_map_|. When the animation completes the tab is removed from
556 // |tabs_closing_map_|. The painting code ensures both sets of tabs are 561 // |tabs_closing_map_|. The painting code ensures both sets of tabs are
557 // painted, and the event handling code ensures only tabs in |tabs_| are used. 562 // painted, and the event handling code ensures only tabs in |tabs_| are used.
558 views::ViewModel tabs_; 563 views::ViewModel tabs_;
(...skipping 30 matching lines...) Expand all
589 // Valid for the lifetime of a drag over us. 594 // Valid for the lifetime of a drag over us.
590 scoped_ptr<DropInfo> drop_info_; 595 scoped_ptr<DropInfo> drop_info_;
591 596
592 // To ensure all tabs pulse at the same time they share the same animation 597 // To ensure all tabs pulse at the same time they share the same animation
593 // container. This is that animation container. 598 // container. This is that animation container.
594 scoped_refptr<gfx::AnimationContainer> animation_container_; 599 scoped_refptr<gfx::AnimationContainer> animation_container_;
595 600
596 // MouseWatcher is used for two things: 601 // MouseWatcher is used for two things:
597 // . When a tab is closed to reset the layout. 602 // . When a tab is closed to reset the layout.
598 // . When a mouse is used and the layout dynamically adjusts and is currently 603 // . When a mouse is used and the layout dynamically adjusts and is currently
599 // TAB_STRIP_LAYOUT_STACKED. 604 // stacked (|stacked_layout_| is true).
600 scoped_ptr<views::MouseWatcher> mouse_watcher_; 605 scoped_ptr<views::MouseWatcher> mouse_watcher_;
601 606
602 // The controller for a drag initiated from a Tab. Valid for the lifetime of 607 // The controller for a drag initiated from a Tab. Valid for the lifetime of
603 // the drag session. 608 // the drag session.
604 scoped_ptr<TabDragController> drag_controller_; 609 scoped_ptr<TabDragController> drag_controller_;
605 610
606 views::BoundsAnimator bounds_animator_; 611 views::BoundsAnimator bounds_animator_;
607 612
608 // Size we last layed out at. 613 // Size we last layed out at.
609 gfx::Size last_layout_size_; 614 gfx::Size last_layout_size_;
610 615
611 TabStripLayoutType layout_type_; 616 // See description above stacked_layout().
617 bool stacked_layout_;
612 618
613 // See description above SetLayoutType(). 619 // Should the layout dynamically adjust?
614 bool adjust_layout_; 620 bool adjust_layout_;
615 621
616 // Only used while in touch mode. 622 // Only used while in touch mode.
617 scoped_ptr<StackedTabStripLayout> touch_layout_; 623 scoped_ptr<StackedTabStripLayout> touch_layout_;
618 624
619 // If true the layout type is set to TAB_STRIP_LAYOUT_SHRINK when the mouse 625 // If true the |stacked_layout_| is set to false when the mouse exits the
620 // exits the tabstrip (as determined using MouseWatcher). 626 // tabstrip (as determined using MouseWatcher).
621 bool reset_to_shrink_on_exit_; 627 bool reset_to_shrink_on_exit_;
622 628
623 // Location of the mouse at the time of the last move. 629 // Location of the mouse at the time of the last move.
624 gfx::Point last_mouse_move_location_; 630 gfx::Point last_mouse_move_location_;
625 631
626 // Time of the last mouse move event. 632 // Time of the last mouse move event.
627 base::TimeTicks last_mouse_move_time_; 633 base::TimeTicks last_mouse_move_time_;
628 634
629 // Number of mouse moves. 635 // Number of mouse moves.
630 int mouse_move_count_; 636 int mouse_move_count_;
631 637
632 // Timer used when a tab is closed and we need to relayout. Only used when a 638 // Timer used when a tab is closed and we need to relayout. Only used when a
633 // tab close comes from a touch device. 639 // tab close comes from a touch device.
634 base::OneShotTimer<TabStrip> resize_layout_timer_; 640 base::OneShotTimer<TabStrip> resize_layout_timer_;
635 641
636 // True if tabs are painted as rectangular light-bars. 642 // True if tabs are painted as rectangular light-bars.
637 bool immersive_style_; 643 bool immersive_style_;
638 644
639 // Our observers. 645 // Our observers.
640 typedef ObserverList<TabStripObserver> TabStripObservers; 646 typedef ObserverList<TabStripObserver> TabStripObservers;
641 TabStripObservers observers_; 647 TabStripObservers observers_;
642 648
643 DISALLOW_COPY_AND_ASSIGN(TabStrip); 649 DISALLOW_COPY_AND_ASSIGN(TabStrip);
644 }; 650 };
645 651
646 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_ 652 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_STRIP_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc ('k') | chrome/browser/ui/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698