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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "ui/views/widget/widget.h" | 51 #include "ui/views/widget/widget.h" |
52 #include "ui/views/window/non_client_view.h" | 52 #include "ui/views/window/non_client_view.h" |
53 | 53 |
54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
55 #include "base/win/metro.h" | 55 #include "base/win/metro.h" |
56 #include "ui/base/win/hwnd_util.h" | 56 #include "ui/base/win/hwnd_util.h" |
57 #include "ui/views/widget/monitor_win.h" | 57 #include "ui/views/widget/monitor_win.h" |
58 #endif | 58 #endif |
59 | 59 |
60 using content::UserMetricsAction; | 60 using content::UserMetricsAction; |
61 using views::DropTargetEvent; | 61 using ui::DropTargetEvent; |
62 | 62 |
63 namespace { | 63 namespace { |
64 | 64 |
65 static const int kTabStripAnimationVSlop = 40; | 65 static const int kTabStripAnimationVSlop = 40; |
66 // Inactive tabs in a native frame are slightly transparent. | 66 // Inactive tabs in a native frame are slightly transparent. |
67 static const int kNativeFrameInactiveTabAlpha = 200; | 67 static const int kNativeFrameInactiveTabAlpha = 200; |
68 // If there are multiple tabs selected then make non-selected inactive tabs | 68 // If there are multiple tabs selected then make non-selected inactive tabs |
69 // even more transparent. | 69 // even more transparent. |
70 static const int kNativeFrameInactiveTabAlphaMultiSelection = 150; | 70 static const int kNativeFrameInactiveTabAlphaMultiSelection = 150; |
71 | 71 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 290 } |
291 | 291 |
292 protected: | 292 protected: |
293 // Overridden from views::View: | 293 // Overridden from views::View: |
294 virtual bool HasHitTestMask() const OVERRIDE; | 294 virtual bool HasHitTestMask() const OVERRIDE; |
295 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; | 295 virtual void GetHitTestMask(gfx::Path* path) const OVERRIDE; |
296 #if defined(OS_WIN) && !defined(USE_AURA) | 296 #if defined(OS_WIN) && !defined(USE_AURA) |
297 void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 297 void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
298 #endif | 298 #endif |
299 virtual ui::GestureStatus OnGestureEvent( | 299 virtual ui::GestureStatus OnGestureEvent( |
300 const views::GestureEvent& event) OVERRIDE; | 300 const ui::GestureEvent& event) OVERRIDE; |
301 void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 301 void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
302 | 302 |
303 private: | 303 private: |
304 bool ShouldUseNativeFrame() const; | 304 bool ShouldUseNativeFrame() const; |
305 gfx::ImageSkia GetBackgroundImage(views::CustomButton::ButtonState state, | 305 gfx::ImageSkia GetBackgroundImage(views::CustomButton::ButtonState state, |
306 ui::ScaleFactor scale_factor) const; | 306 ui::ScaleFactor scale_factor) const; |
307 gfx::ImageSkia GetImageForState(views::CustomButton::ButtonState state, | 307 gfx::ImageSkia GetImageForState(views::CustomButton::ButtonState state, |
308 ui::ScaleFactor scale_factor) const; | 308 ui::ScaleFactor scale_factor) const; |
309 gfx::ImageSkia GetImage(ui::ScaleFactor scale_factor) const; | 309 gfx::ImageSkia GetImage(ui::ScaleFactor scale_factor) const; |
310 | 310 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 views::View::ConvertPointToScreen(this, &point); | 359 views::View::ConvertPointToScreen(this, &point); |
360 ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); | 360 ui::ShowSystemMenu(GetWidget()->GetNativeView(), point.x(), point.y()); |
361 SetState(BS_NORMAL); | 361 SetState(BS_NORMAL); |
362 return; | 362 return; |
363 } | 363 } |
364 views::ImageButton::OnMouseReleased(event); | 364 views::ImageButton::OnMouseReleased(event); |
365 } | 365 } |
366 #endif | 366 #endif |
367 | 367 |
368 ui::GestureStatus NewTabButton::OnGestureEvent( | 368 ui::GestureStatus NewTabButton::OnGestureEvent( |
369 const views::GestureEvent& event) { | 369 const ui::GestureEvent& event) { |
370 // Consume all gesture events here so that the parent (BaseTab) does not | 370 // Consume all gesture events here so that the parent (BaseTab) does not |
371 // start consuming gestures. | 371 // start consuming gestures. |
372 views::ImageButton::OnGestureEvent(event); | 372 views::ImageButton::OnGestureEvent(event); |
373 return ui::GESTURE_STATUS_CONSUMED; | 373 return ui::GESTURE_STATUS_CONSUMED; |
374 } | 374 } |
375 | 375 |
376 void NewTabButton::OnPaint(gfx::Canvas* canvas) { | 376 void NewTabButton::OnPaint(gfx::Canvas* canvas) { |
377 gfx::ImageSkia image = GetImage(canvas->scale_factor()); | 377 gfx::ImageSkia image = GetImage(canvas->scale_factor()); |
378 canvas->DrawImageInt(image, 0, height() - image.height()); | 378 canvas->DrawImageInt(image, 0, height() - image.height()); |
379 } | 379 } |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 void TabStrip::OnMouseCaptureLost() { | 1404 void TabStrip::OnMouseCaptureLost() { |
1405 EndDrag(true); | 1405 EndDrag(true); |
1406 } | 1406 } |
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 views::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_ && ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { |
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: |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 GetDropArrowImage(drop_info_->point_down)); | 2104 GetDropArrowImage(drop_info_->point_down)); |
2105 } | 2105 } |
2106 } | 2106 } |
2107 | 2107 |
2108 // Reposition the window. Need to show it too as the window is initially | 2108 // Reposition the window. Need to show it too as the window is initially |
2109 // hidden. | 2109 // hidden. |
2110 drop_info_->arrow_window->SetBounds(drop_bounds); | 2110 drop_info_->arrow_window->SetBounds(drop_bounds); |
2111 drop_info_->arrow_window->Show(); | 2111 drop_info_->arrow_window->Show(); |
2112 } | 2112 } |
2113 | 2113 |
2114 int TabStrip::GetDropEffect(const views::DropTargetEvent& event) { | 2114 int TabStrip::GetDropEffect(const ui::DropTargetEvent& event) { |
2115 const int source_ops = event.source_operations(); | 2115 const int source_ops = event.source_operations(); |
2116 if (source_ops & ui::DragDropTypes::DRAG_COPY) | 2116 if (source_ops & ui::DragDropTypes::DRAG_COPY) |
2117 return ui::DragDropTypes::DRAG_COPY; | 2117 return ui::DragDropTypes::DRAG_COPY; |
2118 if (source_ops & ui::DragDropTypes::DRAG_LINK) | 2118 if (source_ops & ui::DragDropTypes::DRAG_LINK) |
2119 return ui::DragDropTypes::DRAG_LINK; | 2119 return ui::DragDropTypes::DRAG_LINK; |
2120 return ui::DragDropTypes::DRAG_MOVE; | 2120 return ui::DragDropTypes::DRAG_MOVE; |
2121 } | 2121 } |
2122 | 2122 |
2123 // static | 2123 // static |
2124 gfx::ImageSkia* TabStrip::GetDropArrowImage(bool is_down) { | 2124 gfx::ImageSkia* TabStrip::GetDropArrowImage(bool is_down) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 | 2361 |
2362 int mini_tab_count = GetMiniTabCount(); | 2362 int mini_tab_count = GetMiniTabCount(); |
2363 int normal_count = tab_count() - mini_tab_count; | 2363 int normal_count = tab_count() - mini_tab_count; |
2364 if (normal_count <= 1 || normal_count == mini_tab_count) | 2364 if (normal_count <= 1 || normal_count == mini_tab_count) |
2365 return false; | 2365 return false; |
2366 int x = GetStartXForNormalTabs(); | 2366 int x = GetStartXForNormalTabs(); |
2367 int available_width = width() - x - new_tab_button_width(); | 2367 int available_width = width() - x - new_tab_button_width(); |
2368 return (Tab::GetTouchWidth() * normal_count + | 2368 return (Tab::GetTouchWidth() * normal_count + |
2369 tab_h_offset() * (normal_count - 1)) > available_width; | 2369 tab_h_offset() * (normal_count - 1)) > available_width; |
2370 } | 2370 } |
OLD | NEW |