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/ui/gtk/tabs/tab_strip_gtk.cc

Issue 8771014: GTK: Cleanup of TabStripGtk::ResizeLayoutTabs() now that the layout is fixed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gtk/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 void TabStripGtk::HandleGlobalMouseMoveEvent() { 1391 void TabStripGtk::HandleGlobalMouseMoveEvent() {
1392 if (!IsCursorInTabStripZone()) { 1392 if (!IsCursorInTabStripZone()) {
1393 // Mouse moved outside the tab slop zone, start a timer to do a resize 1393 // Mouse moved outside the tab slop zone, start a timer to do a resize
1394 // layout after a short while... 1394 // layout after a short while...
1395 if (!weak_factory_.HasWeakPtrs()) { 1395 if (!weak_factory_.HasWeakPtrs()) {
1396 MessageLoop::current()->PostDelayedTask( 1396 MessageLoop::current()->PostDelayedTask(
1397 FROM_HERE, 1397 FROM_HERE,
1398 base::Bind(&TabStripGtk::ResizeLayoutTabsWithoutResult, 1398 base::Bind(&TabStripGtk::ResizeLayoutTabs,
1399 weak_factory_.GetWeakPtr()), 1399 weak_factory_.GetWeakPtr()),
1400 kResizeTabsTimeMs); 1400 kResizeTabsTimeMs);
1401 } 1401 }
1402 } else { 1402 } else {
1403 // Mouse moved quickly out of the tab strip and then into it again, so 1403 // Mouse moved quickly out of the tab strip and then into it again, so
1404 // cancel the timer so that the strip doesn't move when the mouse moves 1404 // cancel the timer so that the strip doesn't move when the mouse moves
1405 // back over it. 1405 // back over it.
1406 weak_factory_.InvalidateWeakPtrs(); 1406 weak_factory_.InvalidateWeakPtrs();
1407 } 1407 }
1408 } 1408 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 !GetTabAt(tab_index)->mini()) { 1553 !GetTabAt(tab_index)->mini()) {
1554 return mini_to_non_mini_gap_ + kTabHOffset; 1554 return mini_to_non_mini_gap_ + kTabHOffset;
1555 } 1555 }
1556 return kTabHOffset; 1556 return kTabHOffset;
1557 } 1557 }
1558 1558
1559 int TabStripGtk::tab_start_x() const { 1559 int TabStripGtk::tab_start_x() const {
1560 return 0; 1560 return 0;
1561 } 1561 }
1562 1562
1563 bool TabStripGtk::ResizeLayoutTabs() { 1563 void TabStripGtk::ResizeLayoutTabs() {
1564 weak_factory_.InvalidateWeakPtrs(); 1564 weak_factory_.InvalidateWeakPtrs();
1565 layout_factory_.InvalidateWeakPtrs(); 1565 layout_factory_.InvalidateWeakPtrs();
1566 1566
1567 // It is critically important that this is unhooked here, otherwise we will 1567 // It is critically important that this is unhooked here, otherwise we will
1568 // keep spying on messages forever. 1568 // keep spying on messages forever.
1569 RemoveMessageLoopObserver(); 1569 RemoveMessageLoopObserver();
1570 1570
1571 available_width_for_tabs_ = -1; 1571 available_width_for_tabs_ = -1;
1572 int mini_tab_count = GetMiniTabCount(); 1572 int mini_tab_count = GetMiniTabCount();
1573 if (mini_tab_count == GetTabCount()) { 1573 if (mini_tab_count == GetTabCount()) {
1574 // Only mini tabs, we know the tab widths won't have changed (all mini-tabs 1574 // Only mini tabs, we know the tab widths won't have changed (all mini-tabs
1575 // have the same width), so there is nothing to do. 1575 // have the same width), so there is nothing to do.
1576 return false; 1576 return;
1577 } 1577 }
1578 TabGtk* first_tab = GetTabAt(mini_tab_count); 1578 TabGtk* first_tab = GetTabAt(mini_tab_count);
1579 double unselected, selected; 1579 double unselected, selected;
1580 GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected); 1580 GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected);
1581 int w = Round(first_tab->IsActive() ? selected : unselected); 1581 int w = Round(first_tab->IsActive() ? selected : unselected);
1582 1582
1583 // We only want to run the animation if we're not already at the desired 1583 // We only want to run the animation if we're not already at the desired
1584 // size. 1584 // size.
1585 if (abs(first_tab->width() - w) > 1) { 1585 if (abs(first_tab->width() - w) > 1)
1586 StartResizeLayoutAnimation(); 1586 StartResizeLayoutAnimation();
1587 return true;
1588 }
1589
1590 return false;
1591 }
1592
1593 void TabStripGtk::ResizeLayoutTabsWithoutResult() {
1594 ResizeLayoutTabs();
1595 } 1587 }
1596 1588
1597 bool TabStripGtk::IsCursorInTabStripZone() const { 1589 bool TabStripGtk::IsCursorInTabStripZone() const {
1598 gfx::Point tabstrip_topleft; 1590 gfx::Point tabstrip_topleft;
1599 gtk_util::ConvertWidgetPointToScreen(tabstrip_.get(), &tabstrip_topleft); 1591 gtk_util::ConvertWidgetPointToScreen(tabstrip_.get(), &tabstrip_topleft);
1600 1592
1601 gfx::Rect bds = bounds(); 1593 gfx::Rect bds = bounds();
1602 bds.set_origin(tabstrip_topleft); 1594 bds.set_origin(tabstrip_topleft);
1603 bds.set_height(bds.height() + kTabStripAnimationVSlop); 1595 bds.set_height(bds.height() + kTabStripAnimationVSlop);
1604 1596
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 } 2222 }
2231 2223
2232 void TabStripGtk::SetNewTabButtonBackground() { 2224 void TabStripGtk::SetNewTabButtonBackground() {
2233 SkColor color = theme_service_->GetColor( 2225 SkColor color = theme_service_->GetColor(
2234 ThemeService::COLOR_BUTTON_BACKGROUND); 2226 ThemeService::COLOR_BUTTON_BACKGROUND);
2235 SkBitmap* background = theme_service_->GetBitmapNamed( 2227 SkBitmap* background = theme_service_->GetBitmapNamed(
2236 IDR_THEME_WINDOW_CONTROL_BACKGROUND); 2228 IDR_THEME_WINDOW_CONTROL_BACKGROUND);
2237 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); 2229 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK);
2238 newtab_button_->SetBackground(color, background, mask); 2230 newtab_button_->SetBackground(color, background, mask);
2239 } 2231 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698