| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 background_offset_ = offset; | 298 background_offset_ = offset; |
| 299 } | 299 } |
| 300 | 300 |
| 301 protected: | 301 protected: |
| 302 // Overridden from views::View: | 302 // Overridden from views::View: |
| 303 virtual bool HasHitTestMask() const OVERRIDE; | 303 virtual bool HasHitTestMask() const OVERRIDE; |
| 304 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; | 304 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; |
| 305 #if defined(OS_WIN) && !defined(USE_AURA) | 305 #if defined(OS_WIN) && !defined(USE_AURA) |
| 306 void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 306 void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 307 #endif | 307 #endif |
| 308 virtual ui::GestureStatus OnGestureEvent( | 308 virtual ui::EventResult OnGestureEvent( |
| 309 const ui::GestureEvent& event) OVERRIDE; | 309 const ui::GestureEvent& event) OVERRIDE; |
| 310 void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 310 void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 311 | 311 |
| 312 private: | 312 private: |
| 313 bool ShouldUseNativeFrame() const; | 313 bool ShouldUseNativeFrame() const; |
| 314 gfx::ImageSkia GetBackgroundImage(views::CustomButton::ButtonState state, | 314 gfx::ImageSkia GetBackgroundImage(views::CustomButton::ButtonState state, |
| 315 ui::ScaleFactor scale_factor) const; | 315 ui::ScaleFactor scale_factor) const; |
| 316 gfx::ImageSkia GetImageForState(views::CustomButton::ButtonState state, | 316 gfx::ImageSkia GetImageForState(views::CustomButton::ButtonState state, |
| 317 ui::ScaleFactor scale_factor) const; | 317 ui::ScaleFactor scale_factor) const; |
| 318 gfx::ImageSkia GetImage(ui::ScaleFactor scale_factor) const; | 318 gfx::ImageSkia GetImage(ui::ScaleFactor scale_factor) const; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 gfx::Point point(event.x(), event.y()); | 367 gfx::Point point(event.x(), event.y()); |
| 368 views::View::ConvertPointToScreen(this, &point); | 368 views::View::ConvertPointToScreen(this, &point); |
| 369 ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); | 369 ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); |
| 370 SetState(BS_NORMAL); | 370 SetState(BS_NORMAL); |
| 371 return; | 371 return; |
| 372 } | 372 } |
| 373 views::ImageButton::OnMouseReleased(event); | 373 views::ImageButton::OnMouseReleased(event); |
| 374 } | 374 } |
| 375 #endif | 375 #endif |
| 376 | 376 |
| 377 ui::GestureStatus NewTabButton::OnGestureEvent( | 377 ui::EventResult NewTabButton::OnGestureEvent( |
| 378 const ui::GestureEvent& event) { | 378 const ui::GestureEvent& event) { |
| 379 // Consume all gesture events here so that the parent (BaseTab) does not | 379 // Consume all gesture events here so that the parent (BaseTab) does not |
| 380 // start consuming gestures. | 380 // start consuming gestures. |
| 381 views::ImageButton::OnGestureEvent(event); | 381 views::ImageButton::OnGestureEvent(event); |
| 382 return ui::GESTURE_STATUS_CONSUMED; | 382 return ui::ER_CONSUMED; |
| 383 } | 383 } |
| 384 | 384 |
| 385 void NewTabButton::OnPaint(gfx::Canvas* canvas) { | 385 void NewTabButton::OnPaint(gfx::Canvas* canvas) { |
| 386 gfx::ImageSkia image = GetImage(canvas->scale_factor()); | 386 gfx::ImageSkia image = GetImage(canvas->scale_factor()); |
| 387 canvas->DrawImageInt(image, 0, height() - image.height()); | 387 canvas->DrawImageInt(image, 0, height() - image.height()); |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool NewTabButton::ShouldUseNativeFrame() const { | 390 bool NewTabButton::ShouldUseNativeFrame() const { |
| 391 return GetWidget() && | 391 return GetWidget() && |
| 392 GetWidget()->GetTopLevelWidget()->ShouldUseNativeFrame(); | 392 GetWidget()->GetTopLevelWidget()->ShouldUseNativeFrame(); |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { | 1428 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { |
| 1429 UpdateLayoutTypeFromMouseEvent(this, event); | 1429 UpdateLayoutTypeFromMouseEvent(this, event); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { | 1432 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { |
| 1433 SetResetToShrinkOnExit(true); | 1433 SetResetToShrinkOnExit(true); |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 ui::GestureStatus TabStrip::OnGestureEvent( | 1436 ui::EventResult TabStrip::OnGestureEvent( |
| 1437 const ui::GestureEvent& event) { | 1437 const ui::GestureEvent& event) { |
| 1438 SetResetToShrinkOnExit(false); | 1438 SetResetToShrinkOnExit(false); |
| 1439 switch (event.type()) { | 1439 switch (event.type()) { |
| 1440 case ui::ET_GESTURE_END: | 1440 case ui::ET_GESTURE_END: |
| 1441 EndDrag(END_DRAG_COMPLETE); | 1441 EndDrag(END_DRAG_COMPLETE); |
| 1442 if (adjust_layout_) { | 1442 if (adjust_layout_) { |
| 1443 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); | 1443 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); |
| 1444 controller_->LayoutTypeMaybeChanged(); | 1444 controller_->LayoutTypeMaybeChanged(); |
| 1445 } | 1445 } |
| 1446 break; | 1446 break; |
| 1447 | 1447 |
| 1448 case ui::ET_GESTURE_LONG_PRESS: | 1448 case ui::ET_GESTURE_LONG_PRESS: |
| 1449 if (drag_controller_.get()) | 1449 if (drag_controller_.get()) |
| 1450 drag_controller_->SetMoveBehavior(TabDragController::REORDER); | 1450 drag_controller_->SetMoveBehavior(TabDragController::REORDER); |
| 1451 break; | 1451 break; |
| 1452 | 1452 |
| 1453 case ui::ET_GESTURE_SCROLL_UPDATE: | 1453 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 1454 ContinueDrag(this, event.location()); | 1454 ContinueDrag(this, event.location()); |
| 1455 break; | 1455 break; |
| 1456 | 1456 |
| 1457 case ui::ET_GESTURE_BEGIN: | 1457 case ui::ET_GESTURE_BEGIN: |
| 1458 EndDrag(END_DRAG_CANCEL); | 1458 EndDrag(END_DRAG_CANCEL); |
| 1459 break; | 1459 break; |
| 1460 | 1460 |
| 1461 default: | 1461 default: |
| 1462 break; | 1462 break; |
| 1463 } | 1463 } |
| 1464 return ui::GESTURE_STATUS_CONSUMED; | 1464 return ui::ER_CONSUMED; |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 void TabStrip::GetCurrentTabWidths(double* unselected_width, | 1467 void TabStrip::GetCurrentTabWidths(double* unselected_width, |
| 1468 double* selected_width) const { | 1468 double* selected_width) const { |
| 1469 *unselected_width = current_unselected_width_; | 1469 *unselected_width = current_unselected_width_; |
| 1470 *selected_width = current_selected_width_; | 1470 *selected_width = current_selected_width_; |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 /////////////////////////////////////////////////////////////////////////////// | 1473 /////////////////////////////////////////////////////////////////////////////// |
| 1474 // TabStrip, private: | 1474 // TabStrip, private: |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 if (!adjust_layout_) | 2449 if (!adjust_layout_) |
| 2450 return false; | 2450 return false; |
| 2451 | 2451 |
| 2452 #if !defined(OS_CHROMEOS) | 2452 #if !defined(OS_CHROMEOS) |
| 2453 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2453 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
| 2454 return false; | 2454 return false; |
| 2455 #endif | 2455 #endif |
| 2456 | 2456 |
| 2457 return true; | 2457 return true; |
| 2458 } | 2458 } |
| OLD | NEW |