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

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

Issue 150041: Theme window control buttons.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Theme window control buttons.... Created 11 years, 5 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
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.h ('k') | chrome/test/test_browser_window.h » ('j') | 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) 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 #if defined(OS_WIN)
15 #include "app/win_util.h" 15 #include "app/win_util.h"
16 #endif 16 #endif
17 #include "base/gfx/size.h" 17 #include "base/gfx/size.h"
18 #include "base/stl_util-inl.h" 18 #include "base/stl_util-inl.h"
19 #include "chrome/browser/browser_theme_provider.h"
19 #include "chrome/browser/metrics/user_metrics.h" 20 #include "chrome/browser/metrics/user_metrics.h"
20 #include "chrome/browser/profile.h" 21 #include "chrome/browser/profile.h"
21 #include "chrome/browser/tab_contents/tab_contents.h" 22 #include "chrome/browser/tab_contents/tab_contents.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 23 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "chrome/browser/view_ids.h" 24 #include "chrome/browser/view_ids.h"
24 #include "chrome/browser/views/tabs/dragged_tab_controller.h" 25 #include "chrome/browser/views/tabs/dragged_tab_controller.h"
25 #include "chrome/browser/views/tabs/tab.h" 26 #include "chrome/browser/views/tabs/tab.h"
26 #include "chrome/browser/tab_contents/tab_contents.h" 27 #include "chrome/browser/tab_contents/tab_contents.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
30 #include "views/controls/image_view.h" 31 #include "views/controls/image_view.h"
31 #include "views/painter.h" 32 #include "views/painter.h"
33 #include "views/widget/default_theme_provider.h"
32 #include "views/window/non_client_view.h" 34 #include "views/window/non_client_view.h"
33 #include "views/window/window.h" 35 #include "views/window/window.h"
34 36
35 #undef min 37 #undef min
36 #undef max 38 #undef max
37 39
38 using views::DropTargetEvent; 40 using views::DropTargetEvent;
39 41
40 static const int kDefaultAnimationDurationMs = 100; 42 static const int kDefaultAnimationDurationMs = 100;
41 static const int kResizeLayoutAnimationDurationMs = 166; 43 static const int kResizeLayoutAnimationDurationMs = 166;
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 590 }
589 } 591 }
590 } 592 }
591 593
592 void TabStrip::SetBackgroundOffset(gfx::Point offset) { 594 void TabStrip::SetBackgroundOffset(gfx::Point offset) {
593 int tab_count = GetTabCount(); 595 int tab_count = GetTabCount();
594 for (int i = 0; i < tab_count; ++i) 596 for (int i = 0; i < tab_count; ++i)
595 GetTabAt(i)->SetBackgroundOffset(offset); 597 GetTabAt(i)->SetBackgroundOffset(offset);
596 } 598 }
597 599
600 void TabStrip::InitTabStripButtons() {
601 newtab_button_ = new NewTabButton(this);
602 LoadNewTabButtonImage();
603 newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB));
604 AddChildView(newtab_button_);
605 }
606
598 /////////////////////////////////////////////////////////////////////////////// 607 ///////////////////////////////////////////////////////////////////////////////
599 // TabStrip, views::View overrides: 608 // TabStrip, views::View overrides:
600 609
601 void TabStrip::PaintChildren(gfx::Canvas* canvas) { 610 void TabStrip::PaintChildren(gfx::Canvas* canvas) {
602 // Paint the tabs in reverse order, so they stack to the left. 611 // Paint the tabs in reverse order, so they stack to the left.
603 Tab* selected_tab = NULL; 612 Tab* selected_tab = NULL;
604 for (int i = GetTabCount() - 1; i >= 0; --i) { 613 for (int i = GetTabCount() - 1; i >= 0; --i) {
605 Tab* tab = GetTabAt(i); 614 Tab* tab = GetTabAt(i);
606 // We must ask the _Tab's_ model, not ourselves, because in some situations 615 // We must ask the _Tab's_ model, not ourselves, because in some situations
607 // the model will be different to this object, e.g. when a Tab is being 616 // the model will be different to this object, e.g. when a Tab is being
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 return next_tab; 770 return next_tab;
762 Tab* tab = GetTabAt(i); 771 Tab* tab = GetTabAt(i);
763 if (IsPointInTab(tab, point)) 772 if (IsPointInTab(tab, point))
764 return tab; 773 return tab;
765 } 774 }
766 775
767 // No need to do any floating view stuff, we don't use them in the TabStrip. 776 // No need to do any floating view stuff, we don't use them in the TabStrip.
768 return this; 777 return this;
769 } 778 }
770 779
780 void TabStrip::ThemeChanged() {
781 LoadNewTabButtonImage();
782 }
783
771 /////////////////////////////////////////////////////////////////////////////// 784 ///////////////////////////////////////////////////////////////////////////////
772 // TabStrip, TabStripModelObserver implementation: 785 // TabStrip, TabStripModelObserver implementation:
773 786
774 void TabStrip::TabInsertedAt(TabContents* contents, 787 void TabStrip::TabInsertedAt(TabContents* contents,
775 int index, 788 int index,
776 bool foreground) { 789 bool foreground) {
777 DCHECK(contents); 790 DCHECK(contents);
778 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index)); 791 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index));
779 792
780 if (active_animation_.get()) 793 if (active_animation_.get())
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 break; 1081 break;
1069 } 1082 }
1070 } 1083 }
1071 #endif 1084 #endif
1072 1085
1073 /////////////////////////////////////////////////////////////////////////////// 1086 ///////////////////////////////////////////////////////////////////////////////
1074 // TabStrip, private: 1087 // TabStrip, private:
1075 1088
1076 void TabStrip::Init() { 1089 void TabStrip::Init() {
1077 model_->AddObserver(this); 1090 model_->AddObserver(this);
1078 newtab_button_ = new NewTabButton(this); 1091 newtab_button_size_.SetSize(kNewTabButtonWidth, kNewTabButtonHeight);
1079 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1080 SkBitmap* bitmap;
1081
1082 bitmap = rb.GetBitmapNamed(IDR_NEWTAB_BUTTON);
1083 newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap);
1084 newtab_button_->SetImage(views::CustomButton::BS_PUSHED,
1085 rb.GetBitmapNamed(IDR_NEWTAB_BUTTON_P));
1086 newtab_button_->SetImage(views::CustomButton::BS_HOT,
1087 rb.GetBitmapNamed(IDR_NEWTAB_BUTTON_H));
1088
1089 newtab_button_size_.SetSize(bitmap->width(), bitmap->height());
1090 actual_newtab_button_size_ = newtab_button_size_;
1091
1092 newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB));
1093 AddChildView(newtab_button_);
1094
1095 if (drop_indicator_width == 0) { 1092 if (drop_indicator_width == 0) {
1096 // Direction doesn't matter, both images are the same size. 1093 // Direction doesn't matter, both images are the same size.
1097 SkBitmap* drop_image = GetDropArrowImage(true); 1094 SkBitmap* drop_image = GetDropArrowImage(true);
1098 drop_indicator_width = drop_image->width(); 1095 drop_indicator_width = drop_image->width();
1099 drop_indicator_height = drop_image->height(); 1096 drop_indicator_height = drop_image->height();
1100 } 1097 }
1101 } 1098 }
1102 1099
1100 void TabStrip::LoadNewTabButtonImage() {
1101 ThemeProvider* tp = GetThemeProvider();
1102
1103 // If we don't have a theme provider yet, it means we do not have a
1104 // root view, and are therefore in a test.
1105 if (tp == NULL)
1106 tp = new views::DefaultThemeProvider();
1107
1108 SkBitmap* bitmap = tp->GetBitmapNamed(IDR_NEWTAB_BUTTON);
1109 SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND);
1110 SkBitmap* background = tp->GetBitmapNamed(
1111 IDR_THEME_WINDOW_CONTROL_BACKGROUND);
1112
1113 newtab_button_->SetImage(views::CustomButton::BS_NORMAL, bitmap);
1114 newtab_button_->SetImage(views::CustomButton::BS_PUSHED,
1115 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_P));
1116 newtab_button_->SetImage(views::CustomButton::BS_HOT,
1117 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_H));
1118 newtab_button_->SetBackground(color, background,
1119 tp->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK));
1120 }
1121
1103 Tab* TabStrip::GetTabAt(int index) const { 1122 Tab* TabStrip::GetTabAt(int index) const {
1104 DCHECK(index >= 0 && index < GetTabCount()); 1123 DCHECK(index >= 0 && index < GetTabCount());
1105 return tab_data_.at(index).tab; 1124 return tab_data_.at(index).tab;
1106 } 1125 }
1107 1126
1108 Tab* TabStrip::GetTabAtAdjustForAnimation(int index) const { 1127 Tab* TabStrip::GetTabAtAdjustForAnimation(int index) const {
1109 if (active_animation_.get() && 1128 if (active_animation_.get() &&
1110 active_animation_->type() == TabAnimation::REMOVE && 1129 active_animation_->type() == TabAnimation::REMOVE &&
1111 index >= 1130 index >=
1112 static_cast<RemoveTabAnimation*>(active_animation_.get())->index()) { 1131 static_cast<RemoveTabAnimation*>(active_animation_.get())->index()) {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 &TabStrip::ResizeLayoutTabs), 1596 &TabStrip::ResizeLayoutTabs),
1578 kResizeTabsTimeMs); 1597 kResizeTabsTimeMs);
1579 } 1598 }
1580 } else { 1599 } else {
1581 // Mouse moved quickly out of the tab strip and then into it again, so 1600 // Mouse moved quickly out of the tab strip and then into it again, so
1582 // cancel the timer so that the strip doesn't move when the mouse moves 1601 // cancel the timer so that the strip doesn't move when the mouse moves
1583 // back over it. 1602 // back over it.
1584 resize_layout_factory_.RevokeAll(); 1603 resize_layout_factory_.RevokeAll();
1585 } 1604 }
1586 } 1605 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.h ('k') | chrome/test/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698