OLD | NEW |
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 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 | 1407 |
1408 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { | 1408 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { |
1409 UpdateLayoutTypeFromMouseEvent(this, event); | 1409 UpdateLayoutTypeFromMouseEvent(this, event); |
1410 } | 1410 } |
1411 | 1411 |
1412 ui::GestureStatus TabStrip::OnGestureEvent( | 1412 ui::GestureStatus TabStrip::OnGestureEvent( |
1413 const ui::GestureEvent& event) { | 1413 const ui::GestureEvent& event) { |
1414 switch (event.type()) { | 1414 switch (event.type()) { |
1415 case ui::ET_GESTURE_END: | 1415 case ui::ET_GESTURE_END: |
1416 EndDrag(false); | 1416 EndDrag(false); |
1417 if (adjust_layout_ && ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { | 1417 if (adjust_layout_) { |
1418 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); | 1418 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); |
1419 controller_->LayoutTypeMaybeChanged(); | 1419 controller_->LayoutTypeMaybeChanged(); |
1420 } | 1420 } |
1421 break; | 1421 break; |
1422 | 1422 |
1423 case ui::ET_GESTURE_LONG_PRESS: | 1423 case ui::ET_GESTURE_LONG_PRESS: |
1424 if (drag_controller_.get()) | 1424 if (drag_controller_.get()) |
1425 drag_controller_->SetMoveBehavior(TabDragController::REORDER); | 1425 drag_controller_->SetMoveBehavior(TabDragController::REORDER); |
1426 break; | 1426 break; |
1427 | 1427 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 | 1792 |
1793 const std::vector<BaseTab*>& tabs = tabs_closing_map_[index]; | 1793 const std::vector<BaseTab*>& tabs = tabs_closing_map_[index]; |
1794 for (std::vector<BaseTab*>::const_reverse_iterator i(tabs.rbegin()); | 1794 for (std::vector<BaseTab*>::const_reverse_iterator i(tabs.rbegin()); |
1795 i != tabs.rend(); ++i) { | 1795 i != tabs.rend(); ++i) { |
1796 (*i)->Paint(canvas); | 1796 (*i)->Paint(canvas); |
1797 } | 1797 } |
1798 } | 1798 } |
1799 | 1799 |
1800 void TabStrip::UpdateLayoutTypeFromMouseEvent(views::View* source, | 1800 void TabStrip::UpdateLayoutTypeFromMouseEvent(views::View* source, |
1801 const ui::MouseEvent& event) { | 1801 const ui::MouseEvent& event) { |
1802 if (!adjust_layout_ || ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 1802 if (!adjust_layout_) |
1803 return; | 1803 return; |
1804 | 1804 |
| 1805 #if !defined(OS_CHROMEOS) |
| 1806 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
| 1807 return; |
| 1808 #endif |
| 1809 |
1805 // The following code attempts to switch to TAB_STRIP_LAYOUT_SHRINK when the | 1810 // The following code attempts to switch to TAB_STRIP_LAYOUT_SHRINK when the |
1806 // mouse is used, and TAB_STRIP_LAYOUT_STACKED when a touch device is | 1811 // mouse is used, and TAB_STRIP_LAYOUT_STACKED when a touch device is |
1807 // used. This is made problematic by windows generating mouse move events that | 1812 // used. This is made problematic by windows generating mouse move events that |
1808 // do not clearly indicate the move is the result of a touch device. This | 1813 // do not clearly indicate the move is the result of a touch device. This |
1809 // assumes a real mouse is used if |kMouseMoveCountBeforeConsiderReal| mouse | 1814 // assumes a real mouse is used if |kMouseMoveCountBeforeConsiderReal| mouse |
1810 // move events are received within the time window |kMouseMoveTimeMS|. | 1815 // move events are received within the time window |kMouseMoveTimeMS|. |
1811 // At the time we get a mouse press we know whether its from a touch device | 1816 // At the time we get a mouse press we know whether its from a touch device |
1812 // or not, but we don't layout then else everything shifts. Instead we wait | 1817 // or not, but we don't layout then else everything shifts. Instead we wait |
1813 // for the release. | 1818 // for the release. |
1814 // | 1819 // |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 | 2366 |
2362 int mini_tab_count = GetMiniTabCount(); | 2367 int mini_tab_count = GetMiniTabCount(); |
2363 int normal_count = tab_count() - mini_tab_count; | 2368 int normal_count = tab_count() - mini_tab_count; |
2364 if (normal_count <= 1 || normal_count == mini_tab_count) | 2369 if (normal_count <= 1 || normal_count == mini_tab_count) |
2365 return false; | 2370 return false; |
2366 int x = GetStartXForNormalTabs(); | 2371 int x = GetStartXForNormalTabs(); |
2367 int available_width = width() - x - new_tab_button_width(); | 2372 int available_width = width() - x - new_tab_button_width(); |
2368 return (Tab::GetTouchWidth() * normal_count + | 2373 return (Tab::GetTouchWidth() * normal_count + |
2369 tab_h_offset() * (normal_count - 1)) > available_width; | 2374 tab_h_offset() * (normal_count - 1)) > available_width; |
2370 } | 2375 } |
OLD | NEW |