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

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 10407110: Adds clipping to the tabs when stacked. This is necessary so we don't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_strip.cc
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 7d2a87ea28b558751b48b6e36b6700d34bd91e17..36620d4a38a24ba380d289f5a06f654ea1ebd06a 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -186,6 +186,44 @@ int newtab_button_asset_height() {
return value;
}
+// Amount to adjust the clip by when the tab is stacked before the active index.
+int stacked_tab_left_clip() {
+ static int value = -1;
+ if (value == -1) {
+ switch (ui::GetDisplayLayout()) {
+ case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
+ value = 20;
+ break;
+ case ui::LAYOUT_TOUCH:
+ value = 26;
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+ return value;
+}
+
+// Amount to adjust the clip by when the tab is stacked after the active index.
+int stacked_tab_right_clip() {
+ static int value = -1;
+ if (value == -1) {
+ switch (ui::GetDisplayLayout()) {
+ case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
+ value = 20;
+ break;
+ case ui::LAYOUT_TOUCH:
+ value = 26;
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+ return value;
+}
+
// Animation delegate used when a dragged tab is released. When done sets the
// dragging state to false.
class ResetDraggingStateDelegate
@@ -955,6 +993,36 @@ void TabStrip::ClickActiveTab(const BaseTab* tab) const {
controller()->ClickActiveTab(index);
}
+bool TabStrip::ShouldPaintTab(const BaseTab* tab, gfx::Rect* clip) {
+ // Only touch layout needs to restrict the clip.
+ if (!touch_layout_.get())
+ return true;
+
+ int index = GetModelIndexOfBaseTab(tab);
+ if (index == -1)
+ return true; // Tab is closing, paint it all.
+
+ if (index < touch_layout_->active_index()) {
+ if (tab_at(index)->x() == tab_at(index + 1)->x())
+ return false;
+
+ clip->SetRect(0, 0, tab_at(index + 1)->x() - tab_at(index)->x() +
+ stacked_tab_left_clip(),
+ tab_at(index)->height());
+ } else if (index > touch_layout_->active_index() && index > 0) {
+ const gfx::Rect& tab_bounds(tab_at(index)->bounds());
+ const gfx::Rect& previous_tab_bounds(tab_at(index - 1)->bounds());
+ if (tab_bounds.x() == previous_tab_bounds.x())
+ return false;
+ if (previous_tab_bounds.right() + tab_h_offset() != tab_bounds.x()) {
+ int x = previous_tab_bounds.right() - tab_bounds.x() -
+ stacked_tab_right_clip();
+ clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
+ }
+ }
+ return true;
+}
+
void TabStrip::MouseMovedOutOfHost() {
ResizeLayoutTabs();
}
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698