summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 23:28:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-17 23:28:02 +0000
commit85b893f08d534d5146d94de1863a4e0ac0cbf75c (patch)
tree7bb5c85d3873d706a8d9fab0e71e6bd3a89ade64 /chrome/browser/gtk
parente9696d5781422146bfd90766ab9307dc614c587a (diff)
downloadchromium_src-85b893f08d534d5146d94de1863a4e0ac0cbf75c.zip
chromium_src-85b893f08d534d5146d94de1863a4e0ac0cbf75c.tar.gz
chromium_src-85b893f08d534d5146d94de1863a4e0ac0cbf75c.tar.bz2
Two tweaks to the linux tab strip code:
. Adds a 3 pixel gap between pinned and non-pinned tabs. . Fixes bug when rapdily dragging pinned tabs that could result in unpinning all tabs to right of pinned tab being dragged. BUG=none TEST=none Review URL: http://codereview.chromium.org/155725 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc16
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h2
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc11
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.h3
4 files changed, 24 insertions, 8 deletions
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 691bb95..4625902 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -266,7 +266,7 @@ void DraggedTabControllerGtk::MoveTab(const gfx::Point& screen_point) {
if (attached_tabstrip_) {
TabStripModel* attached_model = attached_tabstrip_->model();
int from_index = attached_model->GetIndexOfTabContents(dragged_contents_);
- AdjustDragPointForPinnedTabs(screen_point, from_index, &dragged_tab_point);
+ AdjustDragPointForPinnedTabs(screen_point, &from_index, &dragged_tab_point);
// Determine the horizontal move threshold. This is dependent on the width
// of tabs. The smaller the tabs compared to the standard size, the smaller
@@ -353,7 +353,7 @@ void DraggedTabControllerGtk::StartPinTimerIfNecessary(
void DraggedTabControllerGtk::AdjustDragPointForPinnedTabs(
const gfx::Point& screen_point,
- int from_index,
+ int* from_index,
gfx::Point* dragged_tab_point) {
TabStripModel* attached_model = attached_tabstrip_->model();
int pinned_count = attached_model->IndexOfFirstNonPinnedTab();
@@ -368,7 +368,7 @@ void DraggedTabControllerGtk::AdjustDragPointForPinnedTabs(
if (local_point.x() <= pinned_threshold) {
// The mouse was moved below the threshold that triggers the tab to be
// pinned.
- MakeDraggedTabPinned(from_index);
+ MakeDraggedTabPinned(*from_index);
// The dragged tab point was calculated using the old mouse_offset, which
// we just reset. Recalculate it.
@@ -386,7 +386,12 @@ void DraggedTabControllerGtk::AdjustDragPointForPinnedTabs(
// The mouse has moved past the point that triggers the tab to be unpinned.
// Update the dragged tab and model accordingly.
dragged_tab_->set_pinned(false);
- attached_model->SetTabPinned(from_index, false);
+ attached_model->SetTabPinned(*from_index, false);
+
+ // Changing the tabs pinned state may have forced it to move (as can happen
+ // if the user rapidly drags a pinned tab past other pinned tabs). Update
+ // the from_index.
+ *from_index = attached_model->GetIndexOfTabContents(dragged_contents_);
dragged_tab_->Resize(dragged_tab_->tab_width());
}
@@ -574,7 +579,8 @@ int DraggedTabControllerGtk::GetPinnedThreshold() {
}
gfx::Rect last_pinned_bounds =
attached_tabstrip_->GetIdealBounds(pinned_count - 1);
- return last_pinned_bounds.x() + TabGtk::GetPinnedWidth() / 2;
+ return last_pinned_bounds.x() + TabStripGtk::pinned_to_non_pinned_gap_ +
+ TabGtk::GetPinnedWidth() / 2;
}
gfx::Rect DraggedTabControllerGtk::GetDraggedTabTabStripBounds(
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
index 704fe35..5b1b66b 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h
@@ -128,7 +128,7 @@ class DraggedTabControllerGtk : public NotificationObserver,
// pinned threshold, the dragged tab is not allowed to go before the first
// non-pinned tab and the dragged tab (and model) are marked as non-pinned.
void AdjustDragPointForPinnedTabs(const gfx::Point& screen_point,
- int from_index,
+ int* from_index,
gfx::Point* dragged_tab_point);
// Returns the compatible TabStrip that is under the specified point (screen
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index c931ab0..191d027 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -55,8 +55,8 @@ const int kTabStripAnimationVSlop = 40;
const int kHorizontalMoveThreshold = 16; // pixels
-// The horizontal offset from one tab to the next,
-// which results in overlapping tabs.
+// The horizontal offset from one tab to the next, which results in overlapping
+// tabs.
const int kTabHOffset = -16;
// A linux specific menu item for toggling window decorations.
@@ -654,6 +654,9 @@ class PinAndMoveAnimation : public TabStripGtk::TabAnimation {
////////////////////////////////////////////////////////////////////////////////
// TabStripGtk, public:
+// static
+const int TabStripGtk::pinned_to_non_pinned_gap_ = 3;
+
TabStripGtk::TabStripGtk(TabStripModel* model)
: current_unselected_width_(TabGtk::GetStandardSize().width()),
current_selected_width_(TabGtk::GetStandardSize().width()),
@@ -1341,6 +1344,10 @@ void TabStripGtk::GetDesiredTabWidths(int tab_count,
}
int TabStripGtk::GetTabHOffset(int tab_index) {
+ if (tab_index < GetTabCount() && GetTabAt(tab_index - 1)->is_pinned() &&
+ !GetTabAt(tab_index)->is_pinned()) {
+ return pinned_to_non_pinned_gap_ + kTabHOffset;
+ }
return kTabHOffset;
}
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h
index 94328ba..e4ae4ac 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h
@@ -132,6 +132,9 @@ class TabStripGtk : public TabStripModelObserver,
const NotificationSource& source,
const NotificationDetails& details);
+ // Horizontal gap between pinned and non-pinned tabs.
+ static const int pinned_to_non_pinned_gap_;
+
private:
friend class DraggedTabControllerGtk;
friend class InsertTabAnimation;