summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 22:10:00 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 22:10:00 +0000
commit811660224acd3f72ee7364668103602089a35f15 (patch)
tree04ed8bdf317c629164a3ed666091e11317ee0a18 /chrome
parent4bb80764b3e2f3540c5bf8e1bb0efd9b0613e82b (diff)
downloadchromium_src-811660224acd3f72ee7364668103602089a35f15.zip
chromium_src-811660224acd3f72ee7364668103602089a35f15.tar.gz
chromium_src-811660224acd3f72ee7364668103602089a35f15.tar.bz2
Revert 38828 - Make clicking on side tabs to select them work.
Use a simple round rect for the visual treatment. Add some rect conversion utils. http://crbug.com/34509 TEST=none Review URL: http://codereview.chromium.org/597012 TBR=ben@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/bookmark_manager_view.cc4
-rw-r--r--chrome/browser/views/detachable_toolbar_view.cc18
-rw-r--r--chrome/browser/views/frame/browser_view_layout.cc2
-rw-r--r--chrome/browser/views/sad_tab_view.cc8
-rw-r--r--chrome/browser/views/tabs/browser_tab_strip_controller.cc8
-rw-r--r--chrome/browser/views/tabs/browser_tab_strip_controller.h2
-rw-r--r--chrome/browser/views/tabs/side_tab.cc127
-rw-r--r--chrome/browser/views/tabs/side_tab.h35
-rw-r--r--chrome/browser/views/tabs/side_tab_strip.cc24
-rw-r--r--chrome/browser/views/tabs/side_tab_strip.h9
10 files changed, 39 insertions, 198 deletions
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc
index b6f4c8a..7e8c8d3 100644
--- a/chrome/browser/views/bookmark_manager_view.cc
+++ b/chrome/browser/views/bookmark_manager_view.cc
@@ -8,7 +8,6 @@
#include "app/gfx/canvas.h"
#include "app/gfx/color_utils.h"
-#include "app/gfx/skia_util.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/keyboard_codes.h"
@@ -33,6 +32,7 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
+#include "skia/ext/skia_utils.h"
#include "third_party/skia/include/core/SkShader.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/label.h"
@@ -350,7 +350,7 @@ void BookmarkManagerView::PaintBackground(gfx::Canvas* canvas) {
canvas->drawColor(kBackgroundColorBottom, SkXfermode::kSrc_Mode);
SkPaint paint;
- paint.setShader(gfx::CreateGradientShader(0, kBackgroundGradientHeight,
+ paint.setShader(skia::CreateGradientShader(0, kBackgroundGradientHeight,
kBackgroundColorTop,
kBackgroundColorBottom))->safeUnref();
canvas->FillRectInt(0, 0, width(), kBackgroundGradientHeight, paint);
diff --git a/chrome/browser/views/detachable_toolbar_view.cc b/chrome/browser/views/detachable_toolbar_view.cc
index a3773e6..924ecb0 100644
--- a/chrome/browser/views/detachable_toolbar_view.cc
+++ b/chrome/browser/views/detachable_toolbar_view.cc
@@ -5,10 +5,10 @@
#include "chrome/browser/views/detachable_toolbar_view.h"
#include "app/gfx/canvas.h"
-#include "app/gfx/skia_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/browser_theme_provider.h"
#include "grit/theme_resources.h"
+#include "skia/ext/skia_utils.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkShader.h"
@@ -98,10 +98,10 @@ void DetachableToolbarView::PaintVerticalDivider(
const SkColor& bottom_color) {
// Draw the upper half of the divider.
SkPaint paint;
- paint.setShader(gfx::CreateGradientShader(vertical_padding + 1,
- height / 2,
- top_color,
- middle_color))->safeUnref();
+ paint.setShader(skia::CreateGradientShader(vertical_padding + 1,
+ height / 2,
+ top_color,
+ middle_color))->safeUnref();
SkRect rc = { SkIntToScalar(x),
SkIntToScalar(vertical_padding + 1),
SkIntToScalar(x + 1),
@@ -110,10 +110,10 @@ void DetachableToolbarView::PaintVerticalDivider(
// Draw the lower half of the divider.
SkPaint paint_down;
- paint_down.setShader(gfx::CreateGradientShader(height / 2,
- height - vertical_padding,
- middle_color,
- bottom_color))->safeUnref();
+ paint_down.setShader(skia::CreateGradientShader(height / 2,
+ height - vertical_padding,
+ middle_color,
+ bottom_color))->safeUnref();
SkRect rc_down = { SkIntToScalar(x),
SkIntToScalar(height / 2),
SkIntToScalar(x + 1),
diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc
index 332d836..2172268 100644
--- a/chrome/browser/views/frame/browser_view_layout.cc
+++ b/chrome/browser/views/frame/browser_view_layout.cc
@@ -283,7 +283,7 @@ int BrowserViewLayout::LayoutTabStrip() {
browser_view_->frame()->GetBoundsForTabStrip(tabstrip_);
if (browser_view_->UsingSideTabs()) {
- vertical_layout_rect_.Inset(layout_bounds.right(), 0, 0, 0);
+ vertical_layout_rect_.Inset(layout_bounds.width(), 0, 0, 0);
} else {
gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
tabstrip_->SetBackgroundOffset(
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index 8b6ebaa..9b9f839 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/views/sad_tab_view.h"
#include "app/gfx/canvas.h"
-#include "app/gfx/skia_util.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/size.h"
@@ -13,6 +12,7 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
+#include "skia/ext/skia_utils.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
static const int kSadTabOffset = -64;
@@ -52,9 +52,9 @@ SadTabView::SadTabView(TabContents* tab_contents)
void SadTabView::Paint(gfx::Canvas* canvas) {
SkPaint paint;
- paint.setShader(gfx::CreateGradientShader(0, height(),
- kBackgroundColor,
- kBackgroundEndColor))->safeUnref();
+ paint.setShader(skia::CreateGradientShader(0, height(),
+ kBackgroundColor,
+ kBackgroundEndColor))->safeUnref();
paint.setStyle(SkPaint::kFill_Style);
canvas->drawRectCoords(0, 0,
SkIntToScalar(width()), SkIntToScalar(height()),
diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/views/tabs/browser_tab_strip_controller.cc
index ddc147c..2b4706e 100644
--- a/chrome/browser/views/tabs/browser_tab_strip_controller.cc
+++ b/chrome/browser/views/tabs/browser_tab_strip_controller.cc
@@ -34,14 +34,6 @@ bool BrowserTabStripController::IsSelected(int index) const {
return model_->selected_index() == index;
}
-void BrowserTabStripController::SelectTab(int index) {
- model_->SelectTabContentsAt(index, true);
-}
-
-void BrowserTabStripController::CloseTab(int index) {
- model_->CloseTabContentsAt(index);
-}
-
////////////////////////////////////////////////////////////////////////////////
// BrowserTabStripController, TabStripModelObserver implementation:
diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.h b/chrome/browser/views/tabs/browser_tab_strip_controller.h
index d2d6a90..4db5fde 100644
--- a/chrome/browser/views/tabs/browser_tab_strip_controller.h
+++ b/chrome/browser/views/tabs/browser_tab_strip_controller.h
@@ -20,8 +20,6 @@ class BrowserTabStripController : public SideTabStripModel,
virtual SkBitmap GetIcon(int index) const;
virtual string16 GetTitle(int index) const;
virtual bool IsSelected(int index) const;
- virtual void SelectTab(int index);
- virtual void CloseTab(int index);
// TabStripModelObserver implementation:
virtual void TabInsertedAt(TabContents* contents, int index,
diff --git a/chrome/browser/views/tabs/side_tab.cc b/chrome/browser/views/tabs/side_tab.cc
index 8907a2e..e435bcb 100644
--- a/chrome/browser/views/tabs/side_tab.cc
+++ b/chrome/browser/views/tabs/side_tab.cc
@@ -5,146 +5,50 @@
#include "chrome/browser/views/tabs/side_tab.h"
#include "app/gfx/canvas.h"
-#include "app/gfx/skia_util.h"
#include "app/resource_bundle.h"
-#include "app/theme_provider.h"
#include "base/string_util.h"
-#include "grit/theme_resources.h"
-#include "views/controls/button/image_button.h"
namespace {
const int kVerticalTabHeight = 27;
-const int kIconSize = 16;
-const int kIconTitleSpacing = 4;
-const int kTitleCloseSpacing = 4;
-const SkScalar kRoundRectRadius = 5;
-const SkColor kTabBackgroundColor = SK_ColorWHITE;
-const SkAlpha kBackgroundTabAlpha = 200;
-static const int kHoverDurationMs = 900;
+const int kTextPadding = 4;
+const int kFavIconHeight = 16;
};
// static
gfx::Font* SideTab::font_ = NULL;
-SkBitmap* SideTab::close_button_n_ = NULL;
-SkBitmap* SideTab::close_button_h_ = NULL;
-SkBitmap* SideTab::close_button_p_ = NULL;
////////////////////////////////////////////////////////////////////////////////
// SideTab, public:
-SideTab::SideTab(SideTabModel* model)
- : model_(model),
- close_button_(NULL) {
+SideTab::SideTab(SideTabModel* model) : model_(model) {
InitClass();
-
- views::ImageButton* close_button = new views::ImageButton(this);
- close_button->SetImage(views::CustomButton::BS_NORMAL, close_button_n_);
- close_button->SetImage(views::CustomButton::BS_HOT, close_button_h_);
- close_button->SetImage(views::CustomButton::BS_PUSHED, close_button_p_);
- close_button_ = close_button;
- AddChildView(close_button_);
-
- hover_animation_.reset(new SlideAnimation(this));
- hover_animation_->SetSlideDuration(kHoverDurationMs);
}
SideTab::~SideTab() {
}
////////////////////////////////////////////////////////////////////////////////
-// SideTab, AnimationDelegate implementation:
-
-void SideTab::AnimationProgressed(const Animation* animation) {
- SchedulePaint();
-}
-
-void SideTab::AnimationCanceled(const Animation* animation) {
- AnimationEnded(animation);
-}
-
-void SideTab::AnimationEnded(const Animation* animation) {
- SchedulePaint();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// SideTab, views::ButtonListener implementation:
-
-void SideTab::ButtonPressed(views::Button* sender, const views::Event& event) {
- DCHECK(sender == close_button_);
- model_->CloseTab(this);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// SideTab, views::View overrides:
void SideTab::Layout() {
- int icon_y;
- int icon_x = icon_y = (height() - kIconSize) / 2;
- icon_bounds_.SetRect(icon_x, icon_y, kIconSize, kIconSize);
-
- gfx::Size ps = close_button_->GetPreferredSize();
- int close_y = (height() - ps.height()) / 2;
- close_button_->SetBounds(width() - ps.width() - close_y, close_y, ps.width(),
- ps.height());
-
- int title_y = (height() - font_->height()) / 2;
- int title_x = icon_bounds_.right() + kIconTitleSpacing;
- title_bounds_.SetRect(title_x, title_y,
- close_button_->x() - kTitleCloseSpacing - title_x,
- font_->height());
+ // TODO(beng):
}
void SideTab::Paint(gfx::Canvas* canvas) {
- SkPaint paint;
- paint.setColor(kTabBackgroundColor);
- paint.setAntiAlias(true);
- SkRect background_rect = gfx::RectToSkRect(GetLocalBounds(false));
- canvas->drawRoundRect(background_rect, kRoundRectRadius, kRoundRectRadius,
- paint);
+ canvas->FillRectInt(model_->IsSelected(this) ? SK_ColorBLUE : SK_ColorRED,
+ 0, 0, width(), height());
+ gfx::Rect text_rect = GetLocalBounds(false);
+ text_rect.Inset(kTextPadding, kTextPadding, kTextPadding, kTextPadding);
- canvas->DrawBitmapInt(model_->GetIcon(this), 0, 0, kIconSize, kIconSize,
- icon_bounds_.x(), icon_bounds_.y(),
- icon_bounds_.width(), icon_bounds_.height(), false);
canvas->DrawStringInt(UTF16ToWideHack(model_->GetTitle(this)), *font_,
- SK_ColorBLACK, title_bounds_.x(), title_bounds_.y(),
- title_bounds_.width(), title_bounds_.height());
-
- if (!model_->IsSelected(this) &&
- GetThemeProvider()->ShouldUseNativeFrame()) {
- // Make sure un-selected tabs are somewhat transparent.
- SkPaint paint;
-
- SkAlpha opacity = kBackgroundTabAlpha;
- if (hover_animation_->IsAnimating())
- opacity = static_cast<SkAlpha>(hover_animation_->GetCurrentValue() * 255);
-
- paint.setColor(SkColorSetARGB(kBackgroundTabAlpha, 255, 255, 255));
- paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
- paint.setStyle(SkPaint::kFill_Style);
- paint.setAntiAlias(true);
- canvas->drawRoundRect(background_rect, kRoundRectRadius, kRoundRectRadius,
- paint);
- }
+ SK_ColorBLACK, text_rect.x(), text_rect.y(),
+ text_rect.width(), text_rect.height());
}
gfx::Size SideTab::GetPreferredSize() {
- return gfx::Size(0, 27);
-}
-
-void SideTab::OnMouseEntered(const views::MouseEvent& event) {
- hover_animation_->SetTweenType(SlideAnimation::EASE_OUT);
- hover_animation_->Show();
-}
-
-void SideTab::OnMouseExited(const views::MouseEvent& event) {
- hover_animation_->SetTweenType(SlideAnimation::EASE_IN);
- hover_animation_->Hide();
-}
-
-bool SideTab::OnMousePressed(const views::MouseEvent& event) {
- if (event.IsOnlyLeftMouseButton())
- model_->SelectTab(this);
- return true;
+ const int kTabHeight = std::max(font_->height() + 2 * kTextPadding,
+ kFavIconHeight + 2 * kTextPadding);
+ return gfx::Size(0, kTabHeight);
}
////////////////////////////////////////////////////////////////////////////////
@@ -156,11 +60,6 @@ void SideTab::InitClass() {
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
-
- close_button_n_ = rb.GetBitmapNamed(IDR_TAB_CLOSE);
- close_button_h_ = rb.GetBitmapNamed(IDR_TAB_CLOSE_H);
- close_button_p_ = rb.GetBitmapNamed(IDR_TAB_CLOSE_P);
-
initialized = true;
}
}
diff --git a/chrome/browser/views/tabs/side_tab.h b/chrome/browser/views/tabs/side_tab.h
index 787cd33..767b649 100644
--- a/chrome/browser/views/tabs/side_tab.h
+++ b/chrome/browser/views/tabs/side_tab.h
@@ -6,9 +6,7 @@
#define CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_H_
#include "app/gfx/font.h"
-#include "app/slide_animation.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "views/controls/button/button.h"
#include "views/view.h"
class SideTab;
@@ -19,36 +17,17 @@ class SideTabModel {
virtual string16 GetTitle(SideTab* tab) const = 0;
virtual SkBitmap GetIcon(SideTab* tab) const = 0;
virtual bool IsSelected(SideTab* tab) const = 0;
-
- // Selects the tab.
- virtual void SelectTab(SideTab* tab) = 0;
-
- // Closes the tab.
- virtual void CloseTab(SideTab* tab) = 0;
};
-class SideTab : public views::View,
- public views::ButtonListener,
- public AnimationDelegate {
+class SideTab : public views::View {
public:
explicit SideTab(SideTabModel* model);
virtual ~SideTab();
- // AnimationDelegate implementation:
- virtual void AnimationProgressed(const Animation* animation);
- virtual void AnimationCanceled(const Animation* animation);
- virtual void AnimationEnded(const Animation* animation);
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
// views::View Overrides:
virtual void Layout();
virtual void Paint(gfx::Canvas* canvas);
virtual gfx::Size GetPreferredSize();
- virtual void OnMouseEntered(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual bool OnMousePressed(const views::MouseEvent& event);
private:
// Loads class-specific resources.
@@ -56,19 +35,7 @@ class SideTab : public views::View,
SideTabModel* model_;
- gfx::Rect icon_bounds_;
- gfx::Rect title_bounds_;
-
- views::Button* close_button_;
-
- // Hover animation.
- scoped_ptr<SlideAnimation> hover_animation_;
-
static gfx::Font* font_;
- static SkBitmap* close_button_n_;
- static SkBitmap* close_button_m_;
- static SkBitmap* close_button_h_;
- static SkBitmap* close_button_p_;
DISALLOW_COPY_AND_ASSIGN(SideTab);
};
diff --git a/chrome/browser/views/tabs/side_tab_strip.cc b/chrome/browser/views/tabs/side_tab_strip.cc
index 06be870..3ea8a3d 100644
--- a/chrome/browser/views/tabs/side_tab_strip.cc
+++ b/chrome/browser/views/tabs/side_tab_strip.cc
@@ -15,7 +15,6 @@
namespace {
const int kVerticalTabSpacing = 2;
const int kTabStripWidth = 127;
-const int kTabStripInset = 3;
}
////////////////////////////////////////////////////////////////////////////////
@@ -80,14 +79,6 @@ bool SideTabStrip::IsSelected(SideTab* tab) const {
return model_->IsSelected(GetIndexOfSideTab(tab));
}
-void SideTabStrip::SelectTab(SideTab* tab) {
- model_->SelectTab(GetIndexOfSideTab(tab));
-}
-
-void SideTabStrip::CloseTab(SideTab* tab) {
- model_->CloseTab(GetIndexOfSideTab(tab));
-}
-
////////////////////////////////////////////////////////////////////////////////
// SideTabStrip, BaseTabStrip implementation:
@@ -99,7 +90,7 @@ void SideTabStrip::SetBackgroundOffset(const gfx::Point& offset) {
}
bool SideTabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
- return GetViewForPoint(point) == this;
+ return true;
}
void SideTabStrip::SetDraggedTabBounds(int tab_index,
@@ -125,19 +116,20 @@ TabStrip* SideTabStrip::AsTabStrip() {
// SideTabStrip, views::View overrides:
void SideTabStrip::Layout() {
- gfx::Rect layout_rect = GetLocalBounds(false);
- layout_rect.Inset(kTabStripInset, kTabStripInset);
- int y = layout_rect.y();
+ int y = 0;
for (int c = GetChildViewCount(), i = 0; i < c; ++i) {
views::View* child = GetChildViewAt(i);
- child->SetBounds(layout_rect.x(), y, layout_rect.width(),
- child->GetPreferredSize().height());
+ child->SetBounds(0, y, width(), child->GetPreferredSize().height());
y = child->bounds().bottom() + kVerticalTabSpacing;
}
}
+void SideTabStrip::Paint(gfx::Canvas* canvas) {
+ // canvas->FillRectInt(SK_ColorGREEN, 0, 0, width(), height());
+}
+
gfx::Size SideTabStrip::GetPreferredSize() {
- return gfx::Size(kTabStripWidth, height());
+ return gfx::Size(kTabStripWidth, 0);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/tabs/side_tab_strip.h b/chrome/browser/views/tabs/side_tab_strip.h
index 61a0bc4..4cde29f 100644
--- a/chrome/browser/views/tabs/side_tab_strip.h
+++ b/chrome/browser/views/tabs/side_tab_strip.h
@@ -17,12 +17,6 @@ class SideTabStripModel {
virtual SkBitmap GetIcon(int index) const = 0;
virtual string16 GetTitle(int index) const = 0;
virtual bool IsSelected(int index) const = 0;
-
- // Select the tab at the specified index in the model.
- virtual void SelectTab(int index) = 0;
-
- // Closes the tab at the specified index in the model.
- virtual void CloseTab(int index) = 0;
};
class SideTabStrip : public BaseTabStrip,
@@ -59,8 +53,6 @@ class SideTabStrip : public BaseTabStrip,
virtual string16 GetTitle(SideTab* tab) const;
virtual SkBitmap GetIcon(SideTab* tab) const;
virtual bool IsSelected(SideTab* tab) const;
- virtual void SelectTab(SideTab* tab);
- virtual void CloseTab(SideTab* tab);
// BaseTabStrip implementation:
virtual int GetPreferredHeight();
@@ -75,6 +67,7 @@ class SideTabStrip : public BaseTabStrip,
// views::View overrides:
virtual void Layout();
+ virtual void Paint(gfx::Canvas* canvas);
virtual gfx::Size GetPreferredSize();
private: