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

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

Issue 136093007: Widget::ShouldUseNativeFrame is now meaningful on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 11 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
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 a33da5211fe38f5b2a5cd5e5c06a7cf31fd3b5b1..056c6a00672945b290b781ad103686b8d1d84bd8 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -70,9 +70,11 @@ namespace {
static const int kTabStripAnimationVSlop = 40;
// Inactive tabs in a native frame are slightly transparent.
static const int kNativeFrameInactiveTabAlpha = 200;
+#if defined(OS_WIN)
// If there are multiple tabs selected then make non-selected inactive tabs
// even more transparent.
static const int kNativeFrameInactiveTabAlphaMultiSelection = 150;
sky 2014/02/03 21:53:03 Rename this to better match other naming.
Matt Giuca 2014/02/05 23:25:31 Done.
+#endif
// Alpha applied to all elements save the selected tabs.
static const int kInactiveTabAndNewTabButtonAlphaAsh = 230;
@@ -333,7 +335,9 @@ class NewTabButton : public views::ImageButton {
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
private:
- bool ShouldUseNativeFrame() const;
+ // Returns true on Windows if the Glass styling is being used.
+ // This implies that the tab strip overlaps a native window frame.
+ bool UsingWindowsGlass() const;
gfx::ImageSkia GetBackgroundImage(views::CustomButton::ButtonState state,
ui::ScaleFactor scale_factor) const;
gfx::ImageSkia GetImageForState(views::CustomButton::ButtonState state,
@@ -427,16 +431,19 @@ void NewTabButton::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
}
-bool NewTabButton::ShouldUseNativeFrame() const {
+bool NewTabButton::UsingWindowsGlass() const {
+#if defined(OS_WIN)
return GetWidget() &&
GetWidget()->GetTopLevelWidget()->ShouldUseNativeFrame();
+#endif
+return false;
}
gfx::ImageSkia NewTabButton::GetBackgroundImage(
views::CustomButton::ButtonState state,
ui::ScaleFactor scale_factor) const {
int background_id = 0;
- if (ShouldUseNativeFrame()) {
+ if (UsingWindowsGlass()) {
background_id = IDR_THEME_TAB_BACKGROUND_V;
} else if (tab_strip_->controller()->IsIncognito()) {
background_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO;
@@ -452,7 +459,7 @@ gfx::ImageSkia NewTabButton::GetBackgroundImage(
switch (state) {
case views::CustomButton::STATE_NORMAL:
case views::CustomButton::STATE_HOVERED:
- alpha = ShouldUseNativeFrame() ? kNativeFrameInactiveTabAlpha : 255;
+ alpha = UsingWindowsGlass() ? kNativeFrameInactiveTabAlpha : 255;
break;
case views::CustomButton::STATE_PRESSED:
alpha = 145;
@@ -525,7 +532,7 @@ gfx::ImageSkia NewTabButton::GetImageForState(
// Draw the button border with a slight alpha.
const int kNativeFrameOverlayAlpha = 178;
sky 2014/02/03 21:53:03 rename these too.
Matt Giuca 2014/02/05 23:25:31 Done.
const int kOpaqueFrameOverlayAlpha = 230;
- uint8 alpha = ShouldUseNativeFrame() ?
+ uint8 alpha = UsingWindowsGlass() ?
kNativeFrameOverlayAlpha : kOpaqueFrameOverlayAlpha;
canvas.DrawImageInt(*overlay, 0, 0, alpha);
@@ -1332,7 +1339,9 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
if (inactive_tab_alpha < 255)
canvas->Restore();
+#if defined(OS_WIN)
sky 2014/02/03 21:53:03 I would rather move the ifdef to a function with a
Matt Giuca 2014/02/05 23:25:31 Done.
if (GetWidget()->ShouldUseNativeFrame()) {
+ // On Windows, a native frame implies Glass.
// Make sure non-active tabs are somewhat transparent.
SkPaint paint;
// If there are multiple tabs selected, fade non-selected tabs more to make
@@ -1346,6 +1355,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
// The tabstrip area overlaps the toolbar area by 2 px.
canvas->DrawRect(gfx::Rect(0, 0, width(), height() - 2), paint);
}
+#endif
// Now selected but not active. We don't want these dimmed if using native
// frame, so they're painted after initial pass.

Powered by Google App Engine
This is Rietveld 408576698