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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 protected: | 300 protected: |
301 // Overridden from views::View: | 301 // Overridden from views::View: |
302 virtual bool HasHitTestMask() const OVERRIDE; | 302 virtual bool HasHitTestMask() const OVERRIDE; |
303 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; | 303 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; |
304 #if defined(OS_WIN) && !defined(USE_AURA) | 304 #if defined(OS_WIN) && !defined(USE_AURA) |
305 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 305 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
306 #endif | 306 #endif |
307 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 307 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
308 | 308 |
309 // Overridden from ui::EventHandler: | 309 // Overridden from ui::EventHandler: |
310 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 310 virtual void OnGestureEvent(ui::GestureEvent* event) 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; |
319 | 319 |
320 // Tab strip that contains this button. | 320 // Tab strip that contains this button. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 views::ImageButton::OnMouseReleased(event); | 374 views::ImageButton::OnMouseReleased(event); |
375 } | 375 } |
376 #endif | 376 #endif |
377 | 377 |
378 void NewTabButton::OnPaint(gfx::Canvas* canvas) { | 378 void NewTabButton::OnPaint(gfx::Canvas* canvas) { |
379 gfx::ImageSkia image = GetImage(canvas->scale_factor()); | 379 gfx::ImageSkia image = GetImage(canvas->scale_factor()); |
380 canvas->DrawImageInt(image, 0, height() - image.height()); | 380 canvas->DrawImageInt(image, 0, height() - image.height()); |
381 } | 381 } |
382 | 382 |
383 ui::EventResult NewTabButton::OnGestureEvent(ui::GestureEvent* event) { | 383 void NewTabButton::OnGestureEvent(ui::GestureEvent* event) { |
384 // Consume all gesture events here so that the parent (Tab) does not | 384 // Consume all gesture events here so that the parent (Tab) does not |
385 // start consuming gestures. | 385 // start consuming gestures. |
386 views::ImageButton::OnGestureEvent(event); | 386 views::ImageButton::OnGestureEvent(event); |
387 return ui::ER_CONSUMED; | 387 event->SetHandled(); |
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(); |
393 } | 393 } |
394 | 394 |
395 gfx::ImageSkia NewTabButton::GetBackgroundImage( | 395 gfx::ImageSkia NewTabButton::GetBackgroundImage( |
396 views::CustomButton::ButtonState state, | 396 views::CustomButton::ButtonState state, |
397 ui::ScaleFactor scale_factor) const { | 397 ui::ScaleFactor scale_factor) const { |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 } | 1456 } |
1457 | 1457 |
1458 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { | 1458 void TabStrip::OnMouseMoved(const ui::MouseEvent& event) { |
1459 UpdateLayoutTypeFromMouseEvent(this, event); | 1459 UpdateLayoutTypeFromMouseEvent(this, event); |
1460 } | 1460 } |
1461 | 1461 |
1462 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { | 1462 void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { |
1463 SetResetToShrinkOnExit(true); | 1463 SetResetToShrinkOnExit(true); |
1464 } | 1464 } |
1465 | 1465 |
1466 ui::EventResult TabStrip::OnGestureEvent(ui::GestureEvent* event) { | 1466 void TabStrip::OnGestureEvent(ui::GestureEvent* event) { |
1467 SetResetToShrinkOnExit(false); | 1467 SetResetToShrinkOnExit(false); |
1468 switch (event->type()) { | 1468 switch (event->type()) { |
1469 case ui::ET_GESTURE_END: | 1469 case ui::ET_GESTURE_END: |
1470 EndDrag(END_DRAG_COMPLETE); | 1470 EndDrag(END_DRAG_COMPLETE); |
1471 if (adjust_layout_) { | 1471 if (adjust_layout_) { |
1472 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); | 1472 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); |
1473 controller_->LayoutTypeMaybeChanged(); | 1473 controller_->LayoutTypeMaybeChanged(); |
1474 } | 1474 } |
1475 break; | 1475 break; |
1476 | 1476 |
1477 case ui::ET_GESTURE_LONG_PRESS: | 1477 case ui::ET_GESTURE_LONG_PRESS: |
1478 if (drag_controller_.get()) | 1478 if (drag_controller_.get()) |
1479 drag_controller_->SetMoveBehavior(TabDragController::REORDER); | 1479 drag_controller_->SetMoveBehavior(TabDragController::REORDER); |
1480 break; | 1480 break; |
1481 | 1481 |
1482 case ui::ET_GESTURE_SCROLL_UPDATE: | 1482 case ui::ET_GESTURE_SCROLL_UPDATE: |
1483 ContinueDrag(this, event->location()); | 1483 ContinueDrag(this, event->location()); |
1484 break; | 1484 break; |
1485 | 1485 |
1486 case ui::ET_GESTURE_BEGIN: | 1486 case ui::ET_GESTURE_BEGIN: |
1487 EndDrag(END_DRAG_CANCEL); | 1487 EndDrag(END_DRAG_CANCEL); |
1488 break; | 1488 break; |
1489 | 1489 |
1490 default: | 1490 default: |
1491 break; | 1491 break; |
1492 } | 1492 } |
1493 return ui::ER_CONSUMED; | 1493 event->SetHandled(); |
1494 } | 1494 } |
1495 | 1495 |
1496 void TabStrip::GetCurrentTabWidths(double* unselected_width, | 1496 void TabStrip::GetCurrentTabWidths(double* unselected_width, |
1497 double* selected_width) const { | 1497 double* selected_width) const { |
1498 *unselected_width = current_unselected_width_; | 1498 *unselected_width = current_unselected_width_; |
1499 *selected_width = current_selected_width_; | 1499 *selected_width = current_selected_width_; |
1500 } | 1500 } |
1501 | 1501 |
1502 /////////////////////////////////////////////////////////////////////////////// | 1502 /////////////////////////////////////////////////////////////////////////////// |
1503 // TabStrip, private: | 1503 // TabStrip, private: |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 if (!adjust_layout_) | 2571 if (!adjust_layout_) |
2572 return false; | 2572 return false; |
2573 | 2573 |
2574 #if !defined(OS_CHROMEOS) | 2574 #if !defined(OS_CHROMEOS) |
2575 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2575 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
2576 return false; | 2576 return false; |
2577 #endif | 2577 #endif |
2578 | 2578 |
2579 return true; | 2579 return true; |
2580 } | 2580 } |
OLD | NEW |