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

Side by Side Diff: chrome/browser/views/tabs/tab_strip.cc

Issue 113537: Makes it so tab_strip can compile on linux. Most differences are due... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/tabs/tab_strip.h" 5 #include "chrome/browser/views/tabs/tab_strip.h"
6 6
7 #include "app/drag_drop_types.h" 7 #include "app/drag_drop_types.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/os_exchange_data.h" 11 #include "app/os_exchange_data.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "app/slide_animation.h" 13 #include "app/slide_animation.h"
14 #if defined(OS_WIN)
14 #include "app/win_util.h" 15 #include "app/win_util.h"
16 #endif
15 #include "base/gfx/size.h" 17 #include "base/gfx/size.h"
16 #include "base/stl_util-inl.h" 18 #include "base/stl_util-inl.h"
17 #include "chrome/browser/metrics/user_metrics.h" 19 #include "chrome/browser/metrics/user_metrics.h"
18 #include "chrome/browser/profile.h" 20 #include "chrome/browser/profile.h"
19 #include "chrome/browser/tab_contents/tab_contents.h" 21 #include "chrome/browser/tab_contents/tab_contents.h"
20 #include "chrome/browser/tabs/tab_strip_model.h" 22 #include "chrome/browser/tabs/tab_strip_model.h"
21 #include "chrome/browser/view_ids.h" 23 #include "chrome/browser/view_ids.h"
22 #include "chrome/browser/views/tabs/dragged_tab_controller.h" 24 #include "chrome/browser/views/tabs/dragged_tab_controller.h"
23 #include "chrome/browser/views/tabs/tab.h" 25 #include "chrome/browser/views/tabs/tab.h"
24 #include "chrome/browser/tab_contents/tab_contents.h" 26 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 virtual ~NewTabButton() {} 70 virtual ~NewTabButton() {}
69 71
70 protected: 72 protected:
71 // Overridden from views::View: 73 // Overridden from views::View:
72 virtual bool HasHitTestMask() const { 74 virtual bool HasHitTestMask() const {
73 return true; 75 return true;
74 } 76 }
75 virtual void GetHitTestMask(gfx::Path* path) const { 77 virtual void GetHitTestMask(gfx::Path* path) const {
76 DCHECK(path); 78 DCHECK(path);
77 79
78 SkScalar h = SkIntToScalar(height());
79 SkScalar w = SkIntToScalar(width()); 80 SkScalar w = SkIntToScalar(width());
80 81
81 // These values are defined by the shape of the new tab bitmap. Should that 82 // These values are defined by the shape of the new tab bitmap. Should that
82 // bitmap ever change, these values will need to be updated. They're so 83 // bitmap ever change, these values will need to be updated. They're so
83 // custom it's not really worth defining constants for. 84 // custom it's not really worth defining constants for.
84 path->moveTo(0, 1); 85 path->moveTo(0, 1);
85 path->lineTo(w - 7, 1); 86 path->lineTo(w - 7, 1);
86 path->lineTo(w - 4, 4); 87 path->lineTo(w - 4, 4);
87 path->lineTo(w, 16); 88 path->lineTo(w, 16);
88 path->lineTo(w - 1, 17); 89 path->lineTo(w - 1, 17);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool layout_on_completion_; 225 bool layout_on_completion_;
225 226
226 const Type type_; 227 const Type type_;
227 228
228 DISALLOW_EVIL_CONSTRUCTORS(TabAnimation); 229 DISALLOW_EVIL_CONSTRUCTORS(TabAnimation);
229 }; 230 };
230 231
231 /////////////////////////////////////////////////////////////////////////////// 232 ///////////////////////////////////////////////////////////////////////////////
232 233
233 // Handles insertion of a Tab at |index|. 234 // Handles insertion of a Tab at |index|.
234 class InsertTabAnimation : public TabStrip::TabAnimation { 235 class TabStrip::InsertTabAnimation : public TabStrip::TabAnimation {
235 public: 236 public:
236 explicit InsertTabAnimation(TabStrip* tabstrip, int index) 237 explicit InsertTabAnimation(TabStrip* tabstrip, int index)
237 : TabAnimation(tabstrip, INSERT), 238 : TabAnimation(tabstrip, INSERT),
238 index_(index) { 239 index_(index) {
239 int tab_count = tabstrip->GetTabCount(); 240 int tab_count = tabstrip->GetTabCount();
240 GenerateStartAndEndWidths(tab_count - 1, tab_count); 241 GenerateStartAndEndWidths(tab_count - 1, tab_count);
241 } 242 }
242 virtual ~InsertTabAnimation() {} 243 virtual ~InsertTabAnimation() {}
243 244
244 protected: 245 protected:
(...skipping 20 matching lines...) Expand all
265 266
266 private: 267 private:
267 int index_; 268 int index_;
268 269
269 DISALLOW_EVIL_CONSTRUCTORS(InsertTabAnimation); 270 DISALLOW_EVIL_CONSTRUCTORS(InsertTabAnimation);
270 }; 271 };
271 272
272 /////////////////////////////////////////////////////////////////////////////// 273 ///////////////////////////////////////////////////////////////////////////////
273 274
274 // Handles removal of a Tab from |index| 275 // Handles removal of a Tab from |index|
275 class RemoveTabAnimation : public TabStrip::TabAnimation { 276 class TabStrip::RemoveTabAnimation : public TabStrip::TabAnimation {
276 public: 277 public:
277 RemoveTabAnimation(TabStrip* tabstrip, int index, TabContents* contents) 278 RemoveTabAnimation(TabStrip* tabstrip, int index, TabContents* contents)
278 : TabAnimation(tabstrip, REMOVE), 279 : TabAnimation(tabstrip, REMOVE),
279 index_(index) { 280 index_(index) {
280 int tab_count = tabstrip->GetTabCount(); 281 int tab_count = tabstrip->GetTabCount();
281 GenerateStartAndEndWidths(tab_count, tab_count - 1); 282 GenerateStartAndEndWidths(tab_count, tab_count - 1);
282 } 283 }
283 284
284 // Returns the index of the tab being removed. 285 // Returns the index of the tab being removed.
285 int index() const { return index_; } 286 int index() const { return index_; }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // a mouse moved event at the current mouse position. This tickles the Tab 330 // a mouse moved event at the current mouse position. This tickles the Tab
330 // the mouse is currently over to show the "hot" state of the close button. 331 // the mouse is currently over to show the "hot" state of the close button.
331 void HighlightCloseButton() { 332 void HighlightCloseButton() {
332 if (tabstrip_->available_width_for_tabs_ == -1 || 333 if (tabstrip_->available_width_for_tabs_ == -1 ||
333 tabstrip_->IsDragSessionActive()) { 334 tabstrip_->IsDragSessionActive()) {
334 // This function is not required (and indeed may crash!) for removes 335 // This function is not required (and indeed may crash!) for removes
335 // spawned by non-mouse closes and drag-detaches. 336 // spawned by non-mouse closes and drag-detaches.
336 return; 337 return;
337 } 338 }
338 339
340 #if defined(OS_WIN)
339 POINT pt; 341 POINT pt;
340 GetCursorPos(&pt); 342 GetCursorPos(&pt);
341 views::Widget* widget = tabstrip_->GetWidget(); 343 views::Widget* widget = tabstrip_->GetWidget();
342 RECT wr; 344 RECT wr;
343 GetWindowRect(widget->GetNativeView(), &wr); 345 GetWindowRect(widget->GetNativeView(), &wr);
344 pt.x -= wr.left; 346 pt.x -= wr.left;
345 pt.y -= wr.top; 347 pt.y -= wr.top;
346 348
347 // Return to message loop - otherwise we may disrupt some operation that's 349 // Return to message loop - otherwise we may disrupt some operation that's
348 // in progress. 350 // in progress.
349 PostMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0, 351 PostMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0,
350 MAKELPARAM(pt.x, pt.y)); 352 MAKELPARAM(pt.x, pt.y));
353 #else
354 NOTIMPLEMENTED();
355 #endif
351 } 356 }
352 357
353 int index_; 358 int index_;
354 359
355 DISALLOW_EVIL_CONSTRUCTORS(RemoveTabAnimation); 360 DISALLOW_EVIL_CONSTRUCTORS(RemoveTabAnimation);
356 }; 361 };
357 362
358 /////////////////////////////////////////////////////////////////////////////// 363 ///////////////////////////////////////////////////////////////////////////////
359 364
360 // Handles the movement of a Tab from one position to another. 365 // Handles the movement of a Tab from one position to another.
361 class MoveTabAnimation : public TabStrip::TabAnimation { 366 class TabStrip::MoveTabAnimation : public TabStrip::TabAnimation {
362 public: 367 public:
363 MoveTabAnimation(TabStrip* tabstrip, int tab_a_index, int tab_b_index) 368 MoveTabAnimation(TabStrip* tabstrip, int tab_a_index, int tab_b_index)
364 : TabAnimation(tabstrip, MOVE), 369 : TabAnimation(tabstrip, MOVE),
365 start_tab_a_bounds_(tabstrip_->GetIdealBounds(tab_b_index)), 370 start_tab_a_bounds_(tabstrip_->GetIdealBounds(tab_b_index)),
366 start_tab_b_bounds_(tabstrip_->GetIdealBounds(tab_a_index)) { 371 start_tab_b_bounds_(tabstrip_->GetIdealBounds(tab_a_index)) {
367 tab_a_ = tabstrip_->GetTabAt(tab_a_index); 372 tab_a_ = tabstrip_->GetTabAt(tab_a_index);
368 tab_b_ = tabstrip_->GetTabAt(tab_b_index); 373 tab_b_ = tabstrip_->GetTabAt(tab_b_index);
369 374
370 // Since we don't do a full TabStrip re-layout, we need to force a full 375 // Since we don't do a full TabStrip re-layout, we need to force a full
371 // layout upon completion since we're not guaranteed to be in a good state 376 // layout upon completion since we're not guaranteed to be in a good state
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 gfx::Rect start_tab_a_bounds_; 411 gfx::Rect start_tab_a_bounds_;
407 gfx::Rect start_tab_b_bounds_; 412 gfx::Rect start_tab_b_bounds_;
408 413
409 DISALLOW_EVIL_CONSTRUCTORS(MoveTabAnimation); 414 DISALLOW_EVIL_CONSTRUCTORS(MoveTabAnimation);
410 }; 415 };
411 416
412 /////////////////////////////////////////////////////////////////////////////// 417 ///////////////////////////////////////////////////////////////////////////////
413 418
414 // Handles the animated resize layout of the entire TabStrip from one width 419 // Handles the animated resize layout of the entire TabStrip from one width
415 // to another. 420 // to another.
416 class ResizeLayoutAnimation : public TabStrip::TabAnimation { 421 class TabStrip::ResizeLayoutAnimation : public TabStrip::TabAnimation {
417 public: 422 public:
418 explicit ResizeLayoutAnimation(TabStrip* tabstrip) 423 explicit ResizeLayoutAnimation(TabStrip* tabstrip)
419 : TabAnimation(tabstrip, RESIZE) { 424 : TabAnimation(tabstrip, RESIZE) {
420 int tab_count = tabstrip->GetTabCount(); 425 int tab_count = tabstrip->GetTabCount();
421 GenerateStartAndEndWidths(tab_count, tab_count); 426 GenerateStartAndEndWidths(tab_count, tab_count);
422 InitStartState(); 427 InitStartState();
423 } 428 }
424 virtual ~ResizeLayoutAnimation() { 429 virtual ~ResizeLayoutAnimation() {
425 } 430 }
426 431
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // crash in the case where the user closes the window after closing a tab 494 // crash in the case where the user closes the window after closing a tab
490 // but before moving the mouse. 495 // but before moving the mouse.
491 RemoveMessageLoopObserver(); 496 RemoveMessageLoopObserver();
492 } 497 }
493 498
494 int TabStrip::GetPreferredHeight() { 499 int TabStrip::GetPreferredHeight() {
495 return GetPreferredSize().height(); 500 return GetPreferredSize().height();
496 } 501 }
497 502
498 bool TabStrip::CanProcessInputEvents() const { 503 bool TabStrip::CanProcessInputEvents() const {
499 return IsAnimating() == NULL; 504 return !IsAnimating();
500 } 505 }
501 506
502 bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) { 507 bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) {
503 views::View* v = GetViewForPoint(point); 508 views::View* v = GetViewForPoint(point);
504 509
505 // If there is no control at this location, claim the hit was in the title 510 // If there is no control at this location, claim the hit was in the title
506 // bar to get a move action. 511 // bar to get a move action.
507 if (v == this) 512 if (v == this)
508 return true; 513 return true;
509 514
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 } 813 }
809 } 814 }
810 815
811 // We only add the tab to the child list if it's not already - an invisible 816 // We only add the tab to the child list if it's not already - an invisible
812 // tab maintained by the DraggedTabController will already be parented. 817 // tab maintained by the DraggedTabController will already be parented.
813 if (!tab->GetParent()) 818 if (!tab->GetParent())
814 AddChildView(tab); 819 AddChildView(tab);
815 820
816 // Don't animate the first tab, it looks weird, and don't animate anything 821 // Don't animate the first tab, it looks weird, and don't animate anything
817 // if the containing window isn't visible yet. 822 // if the containing window isn't visible yet.
818 if (GetTabCount() > 1 && GetWidget() && 823 if (GetTabCount() > 1 && GetWindow() && GetWindow()->IsVisible()) {
819 IsWindowVisible(GetWidget()->GetNativeView())) {
820 StartInsertTabAnimation(index); 824 StartInsertTabAnimation(index);
821 } else { 825 } else {
822 Layout(); 826 Layout();
823 } 827 }
824 } 828 }
825 829
826 void TabStrip::TabDetachedAt(TabContents* contents, int index) { 830 void TabStrip::TabDetachedAt(TabContents* contents, int index) {
827 if (CanUpdateDisplay()) { 831 if (CanUpdateDisplay()) {
828 GenerateIdealBounds(); 832 GenerateIdealBounds();
829 StartRemoveTabAnimation(index, contents); 833 StartRemoveTabAnimation(index, contents);
(...skipping 16 matching lines...) Expand all
846 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) { 850 if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) {
847 Layout(); 851 Layout();
848 } else { 852 } else {
849 SchedulePaint(); 853 SchedulePaint();
850 } 854 }
851 } 855 }
852 } 856 }
853 857
854 void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) { 858 void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) {
855 Tab* tab = GetTabAt(from_index); 859 Tab* tab = GetTabAt(from_index);
856 Tab* other_tab = GetTabAt(to_index);
857 tab_data_.erase(tab_data_.begin() + from_index); 860 tab_data_.erase(tab_data_.begin() + from_index);
858 TabData data = {tab, gfx::Rect()}; 861 TabData data = {tab, gfx::Rect()};
859 tab_data_.insert(tab_data_.begin() + to_index, data); 862 tab_data_.insert(tab_data_.begin() + to_index, data);
860 GenerateIdealBounds(); 863 GenerateIdealBounds();
861 StartMoveTabAnimation(from_index, to_index); 864 StartMoveTabAnimation(from_index, to_index);
862 } 865 }
863 866
864 void TabStrip::TabChangedAt(TabContents* contents, int index, 867 void TabStrip::TabChangedAt(TabContents* contents, int index,
865 bool loading_only) { 868 bool loading_only) {
866 // Index is in terms of the model. Need to make sure we adjust that index in 869 // Index is in terms of the model. Need to make sure we adjust that index in
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 void TabStrip::ButtonPressed(views::Button* sender) { 1002 void TabStrip::ButtonPressed(views::Button* sender) {
1000 if (sender == newtab_button_) { 1003 if (sender == newtab_button_) {
1001 UserMetrics::RecordAction(L"NewTab_Button", model_->profile()); 1004 UserMetrics::RecordAction(L"NewTab_Button", model_->profile());
1002 model_->delegate()->AddBlankTab(true); 1005 model_->delegate()->AddBlankTab(true);
1003 } 1006 }
1004 } 1007 }
1005 1008
1006 /////////////////////////////////////////////////////////////////////////////// 1009 ///////////////////////////////////////////////////////////////////////////////
1007 // TabStrip, MessageLoop::Observer implementation: 1010 // TabStrip, MessageLoop::Observer implementation:
1008 1011
1012 #if defined(OS_WIN)
1009 void TabStrip::WillProcessMessage(const MSG& msg) { 1013 void TabStrip::WillProcessMessage(const MSG& msg) {
1010 } 1014 }
1011 1015
1012 void TabStrip::DidProcessMessage(const MSG& msg) { 1016 void TabStrip::DidProcessMessage(const MSG& msg) {
1013 // We spy on three different Windows messages here to see if the mouse has 1017 // We spy on three different Windows messages here to see if the mouse has
1014 // moved out of the bounds of the tabstrip, which we use as our cue to kick 1018 // moved out of the bounds of the tabstrip, which we use as our cue to kick
1015 // of the resize animation. The messages are: 1019 // of the resize animation. The messages are:
1016 // 1020 //
1017 // WM_MOUSEMOVE: 1021 // WM_MOUSEMOVE:
1018 // For when the mouse moves from the tabstrip over into the rest of the 1022 // For when the mouse moves from the tabstrip over into the rest of the
(...skipping 30 matching lines...) Expand all
1049 } 1053 }
1050 } else { 1054 } else {
1051 // Mouse moved quickly out of the tab strip and then into it again, so 1055 // Mouse moved quickly out of the tab strip and then into it again, so
1052 // cancel the timer so that the strip doesn't move when the mouse moves 1056 // cancel the timer so that the strip doesn't move when the mouse moves
1053 // back over it. 1057 // back over it.
1054 resize_layout_factory_.RevokeAll(); 1058 resize_layout_factory_.RevokeAll();
1055 } 1059 }
1056 break; 1060 break;
1057 } 1061 }
1058 } 1062 }
1063 #else
1064 void TabStrip::WillProcessEvent(GdkEvent* event) {
1065 NOTIMPLEMENTED();
1066 }
1067 #endif
1059 1068
1060 /////////////////////////////////////////////////////////////////////////////// 1069 ///////////////////////////////////////////////////////////////////////////////
1061 // TabStrip, private: 1070 // TabStrip, private:
1062 1071
1063 void TabStrip::Init() { 1072 void TabStrip::Init() {
1064 model_->AddObserver(this); 1073 model_->AddObserver(this);
1065 newtab_button_ = new NewTabButton(this); 1074 newtab_button_ = new NewTabButton(this);
1066 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1075 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1067 SkBitmap* bitmap; 1076 SkBitmap* bitmap;
1068 1077
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 StartResizeLayoutAnimation(); 1205 StartResizeLayoutAnimation();
1197 } 1206 }
1198 1207
1199 bool TabStrip::IsCursorInTabStripZone() { 1208 bool TabStrip::IsCursorInTabStripZone() {
1200 gfx::Rect bounds = GetLocalBounds(true); 1209 gfx::Rect bounds = GetLocalBounds(true);
1201 gfx::Point tabstrip_topleft(bounds.origin()); 1210 gfx::Point tabstrip_topleft(bounds.origin());
1202 View::ConvertPointToScreen(this, &tabstrip_topleft); 1211 View::ConvertPointToScreen(this, &tabstrip_topleft);
1203 bounds.set_origin(tabstrip_topleft); 1212 bounds.set_origin(tabstrip_topleft);
1204 bounds.set_height(bounds.height() + kTabStripAnimationVSlop); 1213 bounds.set_height(bounds.height() + kTabStripAnimationVSlop);
1205 1214
1206 CPoint cursor_point; 1215 #if defined(OS_WIN)
1207 GetCursorPos(&cursor_point); 1216 CPoint cursor_point_c;
1217 GetCursorPos(&cursor_point_c);
1218 gfx::Point cursor_point(cursor_point_c);
1219 #else
1220 // TODO: make sure this is right with multiple monitors.
1221 gint x, y;
1222 gdk_display_get_pointer(NULL, NULL, &x, &y, NULL);
1223 gfx::Point cursor_point(x, y);
1224 #endif
1208 1225
1209 return bounds.Contains(cursor_point.x, cursor_point.y); 1226 return bounds.Contains(cursor_point.x(), cursor_point.y());
1210 } 1227 }
1211 1228
1212 void TabStrip::AddMessageLoopObserver() { 1229 void TabStrip::AddMessageLoopObserver() {
1213 if (!added_as_message_loop_observer_) { 1230 if (!added_as_message_loop_observer_) {
1214 MessageLoopForUI::current()->AddObserver(this); 1231 MessageLoopForUI::current()->AddObserver(this);
1215 added_as_message_loop_observer_ = true; 1232 added_as_message_loop_observer_ = true;
1216 } 1233 }
1217 } 1234 }
1218 1235
1219 void TabStrip::RemoveMessageLoopObserver() { 1236 void TabStrip::RemoveMessageLoopObserver() {
(...skipping 23 matching lines...) Expand all
1243 center_x = MirroredXCoordinateInsideView(center_x); 1260 center_x = MirroredXCoordinateInsideView(center_x);
1244 1261
1245 // Determine the screen bounds. 1262 // Determine the screen bounds.
1246 gfx::Point drop_loc(center_x - drop_indicator_width / 2, 1263 gfx::Point drop_loc(center_x - drop_indicator_width / 2,
1247 -drop_indicator_height); 1264 -drop_indicator_height);
1248 ConvertPointToScreen(this, &drop_loc); 1265 ConvertPointToScreen(this, &drop_loc);
1249 gfx::Rect drop_bounds(drop_loc.x(), drop_loc.y(), drop_indicator_width, 1266 gfx::Rect drop_bounds(drop_loc.x(), drop_loc.y(), drop_indicator_width,
1250 drop_indicator_height); 1267 drop_indicator_height);
1251 1268
1252 // If the rect doesn't fit on the monitor, push the arrow to the bottom. 1269 // If the rect doesn't fit on the monitor, push the arrow to the bottom.
1270 #if defined(OS_WIN)
1253 gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(drop_bounds); 1271 gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(drop_bounds);
1254 *is_beneath = (monitor_bounds.IsEmpty() || 1272 *is_beneath = (monitor_bounds.IsEmpty() ||
1255 !monitor_bounds.Contains(drop_bounds)); 1273 !monitor_bounds.Contains(drop_bounds));
1274 #else
1275 *is_beneath = false;
1276 NOTIMPLEMENTED();
1277 #endif
1256 if (*is_beneath) 1278 if (*is_beneath)
1257 drop_bounds.Offset(0, drop_bounds.height() + height()); 1279 drop_bounds.Offset(0, drop_bounds.height() + height());
1258 1280
1259 return drop_bounds; 1281 return drop_bounds;
1260 } 1282 }
1261 1283
1262 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) { 1284 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) {
1263 // If the UI layout is right-to-left, we need to mirror the mouse 1285 // If the UI layout is right-to-left, we need to mirror the mouse
1264 // coordinates since we calculate the drop index based on the 1286 // coordinates since we calculate the drop index based on the
1265 // original (and therefore non-mirrored) positions of the tabs. 1287 // original (and therefore non-mirrored) positions of the tabs.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 if (is_beneath == drop_info_->point_down) { 1328 if (is_beneath == drop_info_->point_down) {
1307 drop_info_->point_down = !is_beneath; 1329 drop_info_->point_down = !is_beneath;
1308 drop_info_->arrow_view->SetImage( 1330 drop_info_->arrow_view->SetImage(
1309 GetDropArrowImage(drop_info_->point_down)); 1331 GetDropArrowImage(drop_info_->point_down));
1310 } 1332 }
1311 } 1333 }
1312 1334
1313 // Reposition the window. Need to show it too as the window is initially 1335 // Reposition the window. Need to show it too as the window is initially
1314 // hidden. 1336 // hidden.
1315 1337
1338 #if defined(OS_WIN)
1316 drop_info_->arrow_window->SetWindowPos( 1339 drop_info_->arrow_window->SetWindowPos(
1317 HWND_TOPMOST, drop_bounds.x(), drop_bounds.y(), drop_bounds.width(), 1340 HWND_TOPMOST, drop_bounds.x(), drop_bounds.y(), drop_bounds.width(),
1318 drop_bounds.height(), SWP_NOACTIVATE | SWP_SHOWWINDOW); 1341 drop_bounds.height(), SWP_NOACTIVATE | SWP_SHOWWINDOW);
1342 #else
1343 NOTIMPLEMENTED();
1344 #endif
1319 } 1345 }
1320 1346
1321 int TabStrip::GetDropEffect(const views::DropTargetEvent& event) { 1347 int TabStrip::GetDropEffect(const views::DropTargetEvent& event) {
1322 const int source_ops = event.GetSourceOperations(); 1348 const int source_ops = event.GetSourceOperations();
1323 if (source_ops & DragDropTypes::DRAG_COPY) 1349 if (source_ops & DragDropTypes::DRAG_COPY)
1324 return DragDropTypes::DRAG_COPY; 1350 return DragDropTypes::DRAG_COPY;
1325 if (source_ops & DragDropTypes::DRAG_LINK) 1351 if (source_ops & DragDropTypes::DRAG_LINK)
1326 return DragDropTypes::DRAG_LINK; 1352 return DragDropTypes::DRAG_LINK;
1327 return DragDropTypes::DRAG_MOVE; 1353 return DragDropTypes::DRAG_MOVE;
1328 } 1354 }
1329 1355
1330 // static 1356 // static
1331 SkBitmap* TabStrip::GetDropArrowImage(bool is_down) { 1357 SkBitmap* TabStrip::GetDropArrowImage(bool is_down) {
1332 return ResourceBundle::GetSharedInstance().GetBitmapNamed( 1358 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
1333 is_down ? IDR_TAB_DROP_DOWN : IDR_TAB_DROP_UP); 1359 is_down ? IDR_TAB_DROP_DOWN : IDR_TAB_DROP_UP);
1334 } 1360 }
1335 1361
1336 // TabStrip::DropInfo ---------------------------------------------------------- 1362 // TabStrip::DropInfo ----------------------------------------------------------
1337 1363
1338 TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down) 1364 TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
1339 : drop_index(drop_index), 1365 : drop_index(drop_index),
1340 drop_before(drop_before), 1366 drop_before(drop_before),
1341 point_down(point_down) { 1367 point_down(point_down) {
1368 #if defined(OS_WIN)
1342 arrow_window = new views::WidgetWin; 1369 arrow_window = new views::WidgetWin;
1343 arrow_window->set_window_style(WS_POPUP); 1370 arrow_window->set_window_style(WS_POPUP);
1344 arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE | 1371 arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE |
1345 WS_EX_LAYERED | WS_EX_TRANSPARENT); 1372 WS_EX_LAYERED | WS_EX_TRANSPARENT);
1346 1373
1347 arrow_view = new views::ImageView; 1374 arrow_view = new views::ImageView;
1348 arrow_view->SetImage(GetDropArrowImage(point_down)); 1375 arrow_view->SetImage(GetDropArrowImage(point_down));
1349 1376
1350 arrow_window->Init( 1377 arrow_window->Init(
1351 NULL, 1378 NULL,
1352 gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height), 1379 gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height),
1353 true); 1380 true);
1354 arrow_window->SetContentsView(arrow_view); 1381 arrow_window->SetContentsView(arrow_view);
1382 #else
1383 NOTIMPLEMENTED();
1384 #endif
1355 } 1385 }
1356 1386
1357 TabStrip::DropInfo::~DropInfo() { 1387 TabStrip::DropInfo::~DropInfo() {
1358 // Close eventually deletes the window, which deletes arrow_view too. 1388 // Close eventually deletes the window, which deletes arrow_view too.
1389 #if defined(OS_WIN)
1359 arrow_window->Close(); 1390 arrow_window->Close();
1391 #endif
1360 } 1392 }
1361 1393
1362 /////////////////////////////////////////////////////////////////////////////// 1394 ///////////////////////////////////////////////////////////////////////////////
1363 1395
1364 // Called from: 1396 // Called from:
1365 // - BasicLayout 1397 // - BasicLayout
1366 // - Tab insertion/removal 1398 // - Tab insertion/removal
1367 // - Tab reorder 1399 // - Tab reorder
1368 void TabStrip::GenerateIdealBounds() { 1400 void TabStrip::GenerateIdealBounds() {
1369 int tab_count = GetTabCount(); 1401 int tab_count = GetTabCount();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 // If the TabContents being detached was removed as a result of a drag 1548 // If the TabContents being detached was removed as a result of a drag
1517 // gesture from its corresponding Tab, we don't want to remove the Tab from 1549 // gesture from its corresponding Tab, we don't want to remove the Tab from
1518 // the child list, because if we do so it'll stop receiving events and the 1550 // the child list, because if we do so it'll stop receiving events and the
1519 // drag will stall. So we only remove if a drag isn't active, or the Tab 1551 // drag will stall. So we only remove if a drag isn't active, or the Tab
1520 // was for some other TabContents. 1552 // was for some other TabContents.
1521 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { 1553 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) {
1522 removed->GetParent()->RemoveChildView(removed); 1554 removed->GetParent()->RemoveChildView(removed);
1523 delete removed; 1555 delete removed;
1524 } 1556 }
1525 } 1557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698