diff options
-rw-r--r-- | ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc | 7 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button.cc | 68 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button.h | 28 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view.cc | 95 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view.h | 28 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc | 7 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_maximize_button_unittest.cc | 7 | ||||
-rw-r--r-- | ash/wm/custom_frame_view_ash.cc | 17 | ||||
-rw-r--r-- | ash/wm/custom_frame_view_ash_unittest.cc | 3 | ||||
-rw-r--r-- | ash/wm/header_painter.cc | 315 | ||||
-rw-r--r-- | ash/wm/header_painter.h | 26 | ||||
-rw-r--r-- | ash/wm/panels/panel_frame_view.cc | 15 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/foreground/js/media/video_player.js | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc | 81 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h | 23 |
15 files changed, 421 insertions, 301 deletions
diff --git a/ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc b/ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc index 8069482..0694ea7 100644 --- a/ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc +++ b/ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc @@ -67,9 +67,10 @@ class TestWidgetDelegate : public views::WidgetDelegateView { for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) { caption_button_container_->SetButtonImages( static_cast<CaptionButtonIcon>(icon), - IDR_AURA_WINDOW_CLOSE, - IDR_AURA_WINDOW_CLOSE_H, - IDR_AURA_WINDOW_CLOSE_P); + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); } AddChildView(caption_button_container_); diff --git a/ash/wm/caption_buttons/frame_caption_button.cc b/ash/wm/caption_buttons/frame_caption_button.cc index 2f468f8..cce6cc7 100644 --- a/ash/wm/caption_buttons/frame_caption_button.cc +++ b/ash/wm/caption_buttons/frame_caption_button.cc @@ -28,10 +28,12 @@ FrameCaptionButton::FrameCaptionButton(views::ButtonListener* listener, CaptionButtonIcon icon) : CustomButton(listener), icon_(icon), + paint_as_active_(false), last_paint_scale_(1.0f), - normal_image_id_(-1), - hovered_image_id_(-1), - pressed_image_id_(-1), + icon_image_id_(-1), + inactive_icon_image_id_(-1), + hovered_background_image_id_(-1), + pressed_background_image_id_(-1), swap_images_animation_(new gfx::SlideAnimation(this)) { swap_images_animation_->Reset(1); EnableCanvasFlippingForRTLUI(true); @@ -42,16 +44,18 @@ FrameCaptionButton::~FrameCaptionButton() { void FrameCaptionButton::SetImages(CaptionButtonIcon icon, Animate animate, - int normal_image_id, - int hovered_image_id, - int pressed_image_id) { + int icon_image_id, + int inactive_icon_image_id, + int hovered_background_image_id, + int pressed_background_image_id) { // The early return is dependant on |animate| because callers use SetImages() // with ANIMATE_NO to progress the crossfade animation to the end. if (icon == icon_ && (animate == ANIMATE_YES || !swap_images_animation_->is_animating()) && - normal_image_id == normal_image_id_ && - hovered_image_id == hovered_image_id_ && - pressed_image_id == pressed_image_id_) { + icon_image_id == icon_image_id_ && + inactive_icon_image_id == inactive_icon_image_id_ && + hovered_background_image_id == hovered_background_image_id_ && + pressed_background_image_id == pressed_background_image_id_) { return; } @@ -62,14 +66,18 @@ void FrameCaptionButton::SetImages(CaptionButtonIcon icon, } icon_ = icon; - normal_image_id_ = normal_image_id; - hovered_image_id_ = hovered_image_id; - pressed_image_id_ = pressed_image_id; + icon_image_id_ = icon_image_id; + inactive_icon_image_id_ = inactive_icon_image_id; + hovered_background_image_id_ = hovered_background_image_id; + pressed_background_image_id_ = pressed_background_image_id; ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - normal_image_ = *rb.GetImageSkiaNamed(normal_image_id); - hovered_image_ = *rb.GetImageSkiaNamed(hovered_image_id); - pressed_image_ = *rb.GetImageSkiaNamed(pressed_image_id); + icon_image_ = *rb.GetImageSkiaNamed(icon_image_id); + inactive_icon_image_ = *rb.GetImageSkiaNamed(inactive_icon_image_id); + hovered_background_image_ = *rb.GetImageSkiaNamed( + hovered_background_image_id); + pressed_background_image_ = *rb.GetImageSkiaNamed( + pressed_background_image_id); if (animate == ANIMATE_YES) { swap_images_animation_->Reset(0); @@ -87,7 +95,8 @@ bool FrameCaptionButton::IsAnimatingImageSwap() const { } gfx::Size FrameCaptionButton::GetPreferredSize() { - return normal_image_.isNull() ? gfx::Size() : normal_image_.size(); + return hovered_background_image_.isNull() ? + gfx::Size() : hovered_background_image_.size(); } const char* FrameCaptionButton::GetClassName() const { @@ -153,20 +162,19 @@ void FrameCaptionButton::StateChanged() { void FrameCaptionButton::PaintWithAnimationEndState( gfx::Canvas* canvas, int opacity) { - gfx::ImageSkia img; - if (state() == STATE_HOVERED) { - img = hovered_image_; - } else if (state() == STATE_PRESSED) { - img = pressed_image_; - } else { - img = normal_image_; - } - - if (!img.isNull()) { - SkPaint paint; - paint.setAlpha(opacity); - canvas->DrawImageInt(img, 0, 0, paint); - } + SkPaint paint; + paint.setAlpha(opacity); + if (state() == STATE_HOVERED) + canvas->DrawImageInt(hovered_background_image_, 0, 0, paint); + else if (state() == STATE_PRESSED) + canvas->DrawImageInt(pressed_background_image_, 0, 0, paint); + + gfx::ImageSkia icon_image = paint_as_active_ ? + icon_image_ : inactive_icon_image_; + canvas->DrawImageInt(icon_image, + (width() - icon_image.width()) / 2, + (height() - icon_image.height()) / 2, + paint); } } // namespace ash diff --git a/ash/wm/caption_buttons/frame_caption_button.h b/ash/wm/caption_buttons/frame_caption_button.h index ee0f835..8ab8539 100644 --- a/ash/wm/caption_buttons/frame_caption_button.h +++ b/ash/wm/caption_buttons/frame_caption_button.h @@ -37,9 +37,10 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton { // animation is progressed to the end. void SetImages(CaptionButtonIcon icon, Animate animate, - int normal_image_id, - int hovered_image_id, - int pressed_image_id); + int icon_image_id, + int inactive_icon_image_id, + int hovered_background_image_id, + int pressed_background_image_id); // Returns true if the button is crossfading to new visuals set in // SetImages(). @@ -50,6 +51,10 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton { virtual const char* GetClassName() const OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + void set_paint_as_active(bool paint_as_active) { + paint_as_active_ = paint_as_active; + } + CaptionButtonIcon icon() const { return icon_; } @@ -67,16 +72,21 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton { // The button's current icon. CaptionButtonIcon icon_; + // Whether the button should be painted as active. + bool paint_as_active_; + // The scale at which the button was previously painted. float last_paint_scale_; // The images and image ids used to paint the button. - int normal_image_id_; - int hovered_image_id_; - int pressed_image_id_; - gfx::ImageSkia normal_image_; - gfx::ImageSkia hovered_image_; - gfx::ImageSkia pressed_image_; + int icon_image_id_; + int inactive_icon_image_id_; + int hovered_background_image_id_; + int pressed_background_image_id_; + gfx::ImageSkia icon_image_; + gfx::ImageSkia inactive_icon_image_; + gfx::ImageSkia hovered_background_image_; + gfx::ImageSkia pressed_background_image_; // The image to crossfade from. gfx::ImageSkia crossfade_image_; diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.cc b/ash/wm/caption_buttons/frame_caption_button_container_view.cc index 787bead..7a4215f 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.cc @@ -12,11 +12,9 @@ #include "ash/wm/caption_buttons/alternate_frame_size_button.h" #include "ash/wm/caption_buttons/frame_caption_button.h" #include "ash/wm/caption_buttons/frame_maximize_button.h" -#include "grit/ash_resources.h" #include "grit/ui_strings.h" // Accessibility names #include "ui/base/hit_test.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/gfx/canvas.h" #include "ui/gfx/insets.h" @@ -28,9 +26,6 @@ namespace ash { namespace { -// The distance between buttons. -const int kDistanceBetweenButtons = -1; - // Converts |point| from |src| to |dst| and hittests against |dst|. bool ConvertPointToViewAndHitTest(const views::View* src, const views::View* dst, @@ -79,9 +74,6 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( close_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); AddChildView(close_button_); - - button_separator_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_AURA_WINDOW_BUTTON_SEPARATOR).AsImageSkia(); } FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() { @@ -93,13 +85,16 @@ FrameCaptionButtonContainerView::GetOldStyleSizeButton() { NULL : static_cast<FrameMaximizeButton*>(size_button_); } -void FrameCaptionButtonContainerView::SetButtonImages(CaptionButtonIcon icon, - int normal_image_id, - int hovered_image_id, - int pressed_image_id) { - button_icon_id_map_[icon] = ButtonIconIds(normal_image_id, - hovered_image_id, - pressed_image_id); +void FrameCaptionButtonContainerView::SetButtonImages( + CaptionButtonIcon icon, + int icon_image_id, + int inactive_icon_image_id, + int hovered_background_image_id, + int pressed_background_image_id) { + button_icon_id_map_[icon] = ButtonIconIds(icon_image_id, + inactive_icon_image_id, + hovered_background_image_id, + pressed_background_image_id); FrameCaptionButton* buttons[] = { minimize_button_, size_button_, close_button_ }; @@ -107,13 +102,20 @@ void FrameCaptionButtonContainerView::SetButtonImages(CaptionButtonIcon icon, if (buttons[i]->icon() == icon) { buttons[i]->SetImages(icon, FrameCaptionButton::ANIMATE_NO, - normal_image_id, - hovered_image_id, - pressed_image_id); + icon_image_id, + inactive_icon_image_id, + hovered_background_image_id, + pressed_background_image_id); } } } +void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) { + minimize_button_->set_paint_as_active(paint_as_active); + size_button_->set_paint_as_active(paint_as_active); + close_button_->set_paint_as_active(paint_as_active); +} + void FrameCaptionButtonContainerView::ResetWindowControls() { SetButtonsToNormal(ANIMATE_NO); } @@ -135,16 +137,10 @@ int FrameCaptionButtonContainerView::NonClientHitTest( gfx::Size FrameCaptionButtonContainerView::GetPreferredSize() { int width = 0; - bool first_visible = true; for (int i = 0; i < child_count(); ++i) { views::View* child = child_at(i); - if (!child->visible()) - continue; - - width += child_at(i)->GetPreferredSize().width(); - if (!first_visible) - width += kDistanceBetweenButtons; - first_visible = false; + if (child->visible()) + width += child_at(i)->GetPreferredSize().width(); } return gfx::Size(width, close_button_->GetPreferredSize().height()); } @@ -158,7 +154,7 @@ void FrameCaptionButtonContainerView::Layout() { gfx::Size size = child->GetPreferredSize(); child->SetBounds(x, 0, size.width(), size.height()); - x += size.width() + kDistanceBetweenButtons; + x += size.width(); } } @@ -166,22 +162,6 @@ const char* FrameCaptionButtonContainerView::GetClassName() const { return kViewClassName; } -void FrameCaptionButtonContainerView::OnPaint(gfx::Canvas* canvas) { - views::View::OnPaint(canvas); - - // The alternate button style does not paint the button separator. - if (!switches::UseAlternateFrameCaptionButtonStyle()) { - // We should have at most two visible buttons. The button separator is - // always painted underneath the close button regardless of whether a - // button other than the close button is visible. - gfx::Rect divider(close_button_->bounds().origin(), - button_separator_.size()); - canvas->DrawImageInt(button_separator_, - GetMirroredXForRect(divider), - divider.y()); - } -} - void FrameCaptionButtonContainerView::SetButtonIcon(FrameCaptionButton* button, CaptionButtonIcon icon, Animate animate) { @@ -200,9 +180,10 @@ void FrameCaptionButtonContainerView::SetButtonIcon(FrameCaptionButton* button, if (it != button_icon_id_map_.end()) { button->SetImages(icon, fcb_animate, - it->second.normal_image_id, - it->second.hovered_image_id, - it->second.pressed_image_id); + it->second.icon_image_id, + it->second.inactive_icon_image_id, + it->second.hovered_background_image_id, + it->second.pressed_background_image_id); } } @@ -312,17 +293,21 @@ void FrameCaptionButtonContainerView::SetHoveredAndPressedButtons( } FrameCaptionButtonContainerView::ButtonIconIds::ButtonIconIds() - : normal_image_id(-1), - hovered_image_id(-1), - pressed_image_id(-1) { + : icon_image_id(-1), + inactive_icon_image_id(-1), + hovered_background_image_id(-1), + pressed_background_image_id(-1) { } -FrameCaptionButtonContainerView::ButtonIconIds::ButtonIconIds(int normal_id, - int hovered_id, - int pressed_id) - : normal_image_id(normal_id), - hovered_image_id(hovered_id), - pressed_image_id(pressed_id) { +FrameCaptionButtonContainerView::ButtonIconIds::ButtonIconIds( + int icon_id, + int inactive_icon_id, + int hovered_background_id, + int pressed_background_id) + : icon_image_id(icon_id), + inactive_icon_image_id(inactive_icon_id), + hovered_background_image_id(hovered_background_id), + pressed_background_image_id(pressed_background_id) { } FrameCaptionButtonContainerView::ButtonIconIds::~ButtonIconIds() { diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.h b/ash/wm/caption_buttons/frame_caption_button_container_view.h index 39497e8..29399f8 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.h +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.h @@ -7,7 +7,6 @@ #include "ash/ash_export.h" #include "ash/wm/caption_buttons/alternate_frame_size_button_delegate.h" -#include "ui/gfx/image/image_skia.h" #include "ui/views/controls/button/button.h" #include "ui/views/view.h" @@ -75,9 +74,14 @@ class ASH_EXPORT FrameCaptionButtonContainerView // FrameCaptionButtonContainerView will keep track of the images to use for // |icon| even if none of the buttons currently use |icon|. void SetButtonImages(CaptionButtonIcon icon, - int normal_image_id, - int hovered_image_id, - int pressed_image_id); + int icon_image_id, + int inactive_icon_image_id, + int hovered_background_image_id, + int pressed_background_image_id); + + // Sets whether the buttons should be painted as active. Does not schedule + // a repaint. + void SetPaintAsActive(bool paint_as_active); // Tell the window controls to reset themselves to the normal state. void ResetWindowControls(); @@ -91,19 +95,22 @@ class ASH_EXPORT FrameCaptionButtonContainerView virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; virtual const char* GetClassName() const OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; private: friend class FrameCaptionButtonContainerViewTest; struct ButtonIconIds { ButtonIconIds(); - ButtonIconIds(int normal_id, int hovered_id, int pressed_id); + ButtonIconIds(int icon_id, + int inactive_icon_id, + int hovered_background_id, + int pressed_background_id); ~ButtonIconIds(); - int normal_image_id; - int hovered_image_id; - int pressed_image_id; + int icon_image_id; + int inactive_icon_image_id; + int hovered_background_image_id; + int pressed_background_image_id; }; // Sets |button|'s icon to |icon|. If |animate| is ANIMATE_YES, the button @@ -133,9 +140,6 @@ class ASH_EXPORT FrameCaptionButtonContainerView // The widget that the buttons act on. views::Widget* frame_; - // The close button separator. - gfx::ImageSkia button_separator_; - // The buttons. In the normal button style, at most one of |minimize_button_| // and |size_button_| is visible. FrameCaptionButton* minimize_button_; diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc b/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc index 927f556..aa3f4c8 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc @@ -69,9 +69,10 @@ class FrameCaptionButtonContainerViewTest : public ash::test::AshTestBase { for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) { container->SetButtonImages( static_cast<CaptionButtonIcon>(icon), - IDR_AURA_WINDOW_CLOSE, - IDR_AURA_WINDOW_CLOSE_H, - IDR_AURA_WINDOW_CLOSE_P); + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); } } diff --git a/ash/wm/caption_buttons/frame_maximize_button_unittest.cc b/ash/wm/caption_buttons/frame_maximize_button_unittest.cc index dbe8ff2..4fbc2f5 100644 --- a/ash/wm/caption_buttons/frame_maximize_button_unittest.cc +++ b/ash/wm/caption_buttons/frame_maximize_button_unittest.cc @@ -99,9 +99,10 @@ class TestWidgetDelegate : public views::WidgetDelegateView { for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) { caption_button_container_->SetButtonImages( static_cast<CaptionButtonIcon>(icon), - IDR_AURA_WINDOW_CLOSE, - IDR_AURA_WINDOW_CLOSE_H, - IDR_AURA_WINDOW_CLOSE_P); + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); } AddChildView(caption_button_container_); diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc index 994ad5c..f0a91b4 100644 --- a/ash/wm/custom_frame_view_ash.cc +++ b/ash/wm/custom_frame_view_ash.cc @@ -263,20 +263,25 @@ void CustomFrameViewAsh::HeaderView::Layout() { } void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) { + bool paint_as_active = + frame_->non_client_view()->frame_view()->ShouldPaintAsActive(); + caption_button_container_->SetPaintAsActive(paint_as_active); + int theme_image_id = 0; - if (frame_->IsMaximized() || frame_->IsFullscreen()) - theme_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; - else if (frame_->non_client_view()->frame_view()->ShouldPaintAsActive()) - theme_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_ACTIVE; + if (paint_as_active) + theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; else - theme_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INACTIVE; + theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; + HeaderPainter::Mode header_mode = paint_as_active ? + HeaderPainter::MODE_ACTIVE : HeaderPainter::MODE_INACTIVE; header_painter_->PaintHeader( canvas, + header_mode, theme_image_id, 0); header_painter_->PaintTitleBar(canvas, GetTitleFontList()); - header_painter_->PaintHeaderContentSeparator(canvas); + header_painter_->PaintHeaderContentSeparator(canvas, header_mode); } void CustomFrameViewAsh::HeaderView::OnImmersiveRevealStarted() { diff --git a/ash/wm/custom_frame_view_ash_unittest.cc b/ash/wm/custom_frame_view_ash_unittest.cc index 8fa65aa..97d37f1 100644 --- a/ash/wm/custom_frame_view_ash_unittest.cc +++ b/ash/wm/custom_frame_view_ash_unittest.cc @@ -61,7 +61,7 @@ TEST_F(CustomFrameViewAshTest, HeaderHeight) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); gfx::ImageSkia* close_button = - rb.GetImageSkiaNamed(IDR_AURA_WINDOW_MAXIMIZED_CLOSE); + rb.GetImageSkiaNamed(IDR_AURA_WINDOW_CONTROL_BACKGROUND_H); // |kSeparatorSize| should match |kHeaderContentSeparatorSize| in // header_painter.cc @@ -75,7 +75,6 @@ TEST_F(CustomFrameViewAshTest, HeaderHeight) { delegate->custom_frame_view()->GetHeaderView()->height()); widget->Maximize(); - close_button = rb.GetImageSkiaNamed(IDR_AURA_WINDOW_MAXIMIZED_CLOSE2); EXPECT_EQ(close_button->height() + kSeparatorSize, delegate->custom_frame_view()->GetHeaderView()->height()); } diff --git a/ash/wm/header_painter.cc b/ash/wm/header_painter.cc index 3f4d17e..f6fdfaf 100644 --- a/ash/wm/header_painter.cc +++ b/ash/wm/header_painter.cc @@ -43,10 +43,16 @@ const int kTitleNoIconOffsetX = 8; const SkColor kNonMaximizedWindowTitleTextColor = SkColorSetRGB(40, 40, 40); // Color for the maximized window title text. const SkColor kMaximizedWindowTitleTextColor = SK_ColorWHITE; -// Size of header/content separator line below the header image. +// Size of header/content separator line below the header image for non-browser +// windows. const int kHeaderContentSeparatorSize = 1; -// Color of header bottom edge line. -const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(128, 128, 128); +// Color of the active window header/content separator line for non-browser +// windows. +const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(180, 180, 182); +// Color of the inactive window header/content separator line for non-browser +// windows. +const SkColor kHeaderContentSeparatorInactiveColor = + SkColorSetRGB(150, 150, 152); // In the pre-Ash era the web content area had a frame along the left edge, so // user-generated theme images for the new tab page assume they are shifted // right relative to the header. Now that we have removed the left edge frame @@ -139,11 +145,6 @@ HeaderPainter::HeaderPainter() window_icon_(NULL), caption_button_container_(NULL), header_height_(0), - top_left_corner_(NULL), - top_edge_(NULL), - top_right_corner_(NULL), - header_left_edge_(NULL), - header_right_edge_(NULL), previous_theme_frame_id_(0), previous_theme_frame_overlay_id_(0), crossfade_theme_frame_id_(0), @@ -167,19 +168,6 @@ void HeaderPainter::Init( header_view_ = header_view; window_icon_ = window_icon; caption_button_container_ = caption_button_container; - - // Window frame image parts. - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - top_left_corner_ = rb.GetImageNamed( - IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP_LEFT).ToImageSkia(); - top_edge_ = rb.GetImageNamed( - IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP).ToImageSkia(); - top_right_corner_ = rb.GetImageNamed( - IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP_RIGHT).ToImageSkia(); - header_left_edge_ = rb.GetImageNamed( - IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_LEFT).ToImageSkia(); - header_right_edge_ = rb.GetImageNamed( - IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_RIGHT).ToImageSkia(); } // static @@ -236,6 +224,7 @@ int HeaderPainter::GetThemeBackgroundXInset() const { } void HeaderPainter::PaintHeader(gfx::Canvas* canvas, + Mode mode, int theme_frame_id, int theme_frame_overlay_id) { bool initial_paint = (previous_theme_frame_id_ == 0); @@ -321,55 +310,21 @@ void HeaderPainter::PaintHeader(gfx::Canvas* canvas, previous_theme_frame_id_ = theme_frame_id; previous_theme_frame_overlay_id_ = theme_frame_overlay_id; - // We don't need the extra lightness in the edges when the window is maximized - // or fullscreen. - if (frame_->IsMaximized() || frame_->IsFullscreen()) - return; - - // Draw the top corners and edge. - int top_left_width = top_left_corner_->width(); - int top_left_height = top_left_corner_->height(); - canvas->DrawImageInt(*top_left_corner_, - 0, 0, top_left_width, top_left_height, - 0, 0, top_left_width, top_left_height, - false); - canvas->TileImageInt(*top_edge_, - top_left_width, - 0, - header_view_->width() - top_left_width - top_right_corner_->width(), - top_edge_->height()); - int top_right_height = top_right_corner_->height(); - canvas->DrawImageInt(*top_right_corner_, - 0, 0, - top_right_corner_->width(), top_right_height, - header_view_->width() - top_right_corner_->width(), 0, - top_right_corner_->width(), top_right_height, - false); - - // Header left edge. - int header_left_height = theme_frame->height() - top_left_height; - canvas->TileImageInt(*header_left_edge_, - 0, top_left_height, - header_left_edge_->width(), header_left_height); - - // Header right edge. - int header_right_height = theme_frame->height() - top_right_height; - canvas->TileImageInt(*header_right_edge_, - header_view_->width() - header_right_edge_->width(), - top_right_height, - header_right_edge_->width(), - header_right_height); - - // We don't draw edges around the content area. Web content goes flush - // to the edge of the window. + PaintBorder(canvas, mode); } -void HeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { +void HeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas, + Mode mode) { + DCHECK_EQ(style_, STYLE_OTHER); + SkColor color = (mode == MODE_ACTIVE) ? + kHeaderContentSeparatorColor : + kHeaderContentSeparatorInactiveColor; + canvas->FillRect(gfx::Rect(0, header_height_ - kHeaderContentSeparatorSize, header_view_->width(), kHeaderContentSeparatorSize), - kHeaderContentSeparatorColor); + color); } int HeaderPainter::HeaderContentSeparatorSize() const { @@ -449,77 +404,189 @@ void HeaderPainter::AnimationProgressed(const gfx::Animation* animation) { /////////////////////////////////////////////////////////////////////////////// // HeaderPainter, private: +void HeaderPainter::PaintBorder(gfx::Canvas* canvas, Mode mode) { + if (frame_->IsMaximized() || + frame_->IsFullscreen() || + (style_ == STYLE_OTHER && mode == MODE_ACTIVE)) { + return; + } + + gfx::ImageSkia top_left_corner; + gfx::ImageSkia top_right_corner; + gfx::ImageSkia top_edge; + gfx::ImageSkia left_edge; + gfx::ImageSkia right_edge; + gfx::ImageSkia bottom_edge; + + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + if (style_ == STYLE_BROWSER) { + top_left_corner = *rb.GetImageSkiaNamed( + IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP_LEFT); + top_right_corner = *rb.GetImageSkiaNamed( + IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP_RIGHT); + top_edge = *rb.GetImageSkiaNamed(IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_TOP); + left_edge = *rb.GetImageSkiaNamed( + IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_LEFT); + right_edge = *rb.GetImageSkiaNamed( + IDR_AURA_BROWSER_WINDOW_HEADER_SHADE_RIGHT); + } else { + top_edge = *rb.GetImageSkiaNamed( + IDR_AURA_WINDOW_HEADER_SHADE_INACTIVE_TOP); + left_edge = *rb.GetImageSkiaNamed( + IDR_AURA_WINDOW_HEADER_SHADE_INACTIVE_LEFT); + right_edge = *rb.GetImageSkiaNamed( + IDR_AURA_WINDOW_HEADER_SHADE_INACTIVE_RIGHT); + bottom_edge = *rb.GetImageSkiaNamed( + IDR_AURA_WINDOW_HEADER_SHADE_INACTIVE_BOTTOM); + } + + DCHECK(!top_edge.isNull()); + DCHECK(!left_edge.isNull()); + DCHECK(!right_edge.isNull()); + + int top_left_width = top_left_corner.width(); + int top_left_height = top_left_corner.height(); + if (!top_left_corner.isNull()) { + canvas->DrawImageInt(top_left_corner, 0, 0); + } + + int top_right_height = top_right_corner.height(); + if (!top_right_corner.isNull()) { + canvas->DrawImageInt(top_right_corner, + header_view_->width() - top_right_corner.width(), + top_right_height); + } + + canvas->TileImageInt(top_edge, + top_left_width, + 0, + header_view_->width() - top_left_width - top_right_corner.width(), + top_edge.height()); + + // TODO(pkotwicz): Compute |bottom| more accurately. The computation is + // inaccurate for browser windows. + int bottom = header_height_ - kHeaderContentSeparatorSize; + int bottom_height = bottom_edge.height(); + if (!bottom_edge.isNull()) { + canvas->TileImageInt(bottom_edge, + 0, bottom - bottom_height, + header_view_->width(), bottom_height); + } + + int left_edge_height = bottom - bottom_height - top_left_height; + canvas->TileImageInt(left_edge, + 0, top_left_height, + left_edge.width(), left_edge_height); + + int right_edge_height = bottom - bottom_height - top_right_height; + canvas->TileImageInt(right_edge, + header_view_->width() - right_edge.width(), + top_right_height, + right_edge.width(), + right_edge_height); +} + void HeaderPainter::UpdateCaptionButtonImages() { - if (frame_->IsMaximized() || frame_->IsFullscreen()) { - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_CLOSE, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_H, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_LEFT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_RIGHT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_P); - } else if (style_ == STYLE_BROWSER) { - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, - IDR_AURA_WINDOW_MAXIMIZE, - IDR_AURA_WINDOW_MAXIMIZE_H, - IDR_AURA_WINDOW_MAXIMIZE_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_CLOSE, - IDR_AURA_WINDOW_CLOSE, - IDR_AURA_WINDOW_CLOSE_H, - IDR_AURA_WINDOW_CLOSE_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_LEFT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZE, - IDR_AURA_WINDOW_MAXIMIZE_H, - IDR_AURA_WINDOW_MAXIMIZE_P); - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_RIGHT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZE, - IDR_AURA_WINDOW_MAXIMIZE_H, - IDR_AURA_WINDOW_MAXIMIZE_P); + if (style_ == STYLE_BROWSER) { + if (frame_->IsMaximized() || frame_->IsFullscreen()) { + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_SIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_SIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_MAXIMIZED_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P); + } else { + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_MINIMIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_SIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_SIZE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_CLOSE, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_LEFT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P); + caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_ICON_RESTORED_RIGHT_SNAPPED, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H, + IDR_AURA_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P); + } } else { caption_button_container_->SetButtonImages( + CAPTION_BUTTON_ICON_MINIMIZE, + IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE, + IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); + caption_button_container_->SetButtonImages( CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); + IDR_AURA_WINDOW_CONTROL_ICON_SIZE, + IDR_AURA_WINDOW_CONTROL_ICON_SIZE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); caption_button_container_->SetButtonImages( CAPTION_BUTTON_ICON_CLOSE, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P); + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, + IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_I, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); + + // There is no dedicated icon for the snap-left and snap-right buttons + // when |frame_| is inactive because they should never be visible while + // |frame_| is inactive. caption_button_container_->SetButtonImages( CAPTION_BUTTON_ICON_LEFT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); + IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED, + IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); caption_button_container_->SetButtonImages( CAPTION_BUTTON_ICON_RIGHT_SNAPPED, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); + IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED, + IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, + IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); } - - caption_button_container_->SetButtonImages( - CAPTION_BUTTON_ICON_MINIMIZE, - IDR_AURA_WINDOW_MINIMIZE_SHORT, - IDR_AURA_WINDOW_MINIMIZE_SHORT_H, - IDR_AURA_WINDOW_MINIMIZE_SHORT_P); } gfx::Rect HeaderPainter::GetHeaderLocalBounds() const { diff --git a/ash/wm/header_painter.h b/ash/wm/header_painter.h index a9053ba..dd9f5f2 100644 --- a/ash/wm/header_painter.h +++ b/ash/wm/header_painter.h @@ -32,6 +32,11 @@ class FrameCaptionButtonContainerView; // Helper class for painting the window header. class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { public: + enum Mode { + MODE_ACTIVE, + MODE_INACTIVE + }; + // TODO(pkotwicz): Move code related to "browser" windows out of ash. enum Style { // Header style used for browser windows. @@ -82,16 +87,17 @@ class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { // Paints the header. // |theme_frame_overlay_id| is 0 if no overlay image should be used. + // |mode| indicates whether the window should be painted as active. void PaintHeader(gfx::Canvas* canvas, + Mode mode, int theme_frame_id, int theme_frame_overlay_id); - // Paints the header/content separator line. Exists as a separate function - // because some windows with complex headers (e.g. browsers with tab strips) - // need to draw their own line. - void PaintHeaderContentSeparator(gfx::Canvas* canvas); + // Paints the header/content separator line for non-browser windows. + void PaintHeaderContentSeparator(gfx::Canvas* canvas, Mode mode); - // Returns size of the header/content separator line in pixels. + // Returns size of the header/content separator line for non-browser windows + // in pixels. int HeaderContentSeparatorSize() const; // Paint the title bar, primarily the title string. @@ -123,6 +129,9 @@ class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { private: FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); + // Paints the border around the header. + void PaintBorder(gfx::Canvas* canvas, Mode mode); + // Updates the images used for the minimize, restore and close buttons. void UpdateCaptionButtonImages(); @@ -156,13 +165,6 @@ class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { // The height of the header. int header_height_; - // Window frame header/caption parts. - const gfx::ImageSkia* top_left_corner_; - const gfx::ImageSkia* top_edge_; - const gfx::ImageSkia* top_right_corner_; - const gfx::ImageSkia* header_left_edge_; - const gfx::ImageSkia* header_right_edge_; - // Image ids and opacity last used for painting header. int previous_theme_frame_id_; int previous_theme_frame_overlay_id_; diff --git a/ash/wm/panels/panel_frame_view.cc b/ash/wm/panels/panel_frame_view.cc index ee711d7..73d10b4 100644 --- a/ash/wm/panels/panel_frame_view.cc +++ b/ash/wm/panels/panel_frame_view.cc @@ -115,18 +115,19 @@ void PanelFrameView::OnPaint(gfx::Canvas* canvas) { if (!header_painter_) return; bool paint_as_active = ShouldPaintAsActive(); + caption_button_container_->SetPaintAsActive(paint_as_active); + int theme_frame_id = 0; if (paint_as_active) - theme_frame_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_ACTIVE; + theme_frame_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; else - theme_frame_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INACTIVE; + theme_frame_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; - header_painter_->PaintHeader( - canvas, - theme_frame_id, - 0); + HeaderPainter::Mode header_mode = paint_as_active ? + HeaderPainter::MODE_ACTIVE : HeaderPainter::MODE_INACTIVE; + header_painter_->PaintHeader(canvas, header_mode, theme_frame_id, 0); header_painter_->PaintTitleBar(canvas, title_font_list_); - header_painter_->PaintHeaderContentSeparator(canvas); + header_painter_->PaintHeaderContentSeparator(canvas, header_mode); } gfx::Rect PanelFrameView::GetBoundsForClientView() const { diff --git a/chrome/browser/resources/file_manager/foreground/js/media/video_player.js b/chrome/browser/resources/file_manager/foreground/js/media/video_player.js index 3bad4bb..a026bf7 100644 --- a/chrome/browser/resources/file_manager/foreground/js/media/video_player.js +++ b/chrome/browser/resources/file_manager/foreground/js/media/video_player.js @@ -248,7 +248,7 @@ function reload() { video.addEventListener('loadedmetadata', function() { // TODO: chrome.app.window soon will be able to resize the content area. // Until then use approximate title bar height. - var TITLE_HEIGHT = 28; + var TITLE_HEIGHT = 33; var aspect = video.videoWidth / video.videoHeight; var newWidth = video.videoWidth; diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc index a33b4ae..a79a29b 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc @@ -243,20 +243,26 @@ void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { return; } + caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); + // The primary header image changes based on window activation state and // theme, so we look it up for each paint. - int theme_frame_image_id = GetThemeFrameImageId(); - int theme_frame_overlay_image_id = GetThemeFrameOverlayImageId(); - - ui::ThemeProvider* theme_provider = GetThemeProvider(); - if (!theme_provider->HasCustomImage(theme_frame_image_id) && - (theme_frame_overlay_image_id == 0 || - !theme_provider->HasCustomImage(theme_frame_overlay_image_id))) { - if (frame()->IsMaximized() || frame()->IsFullscreen()) - theme_frame_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; + int theme_frame_image_id = 0; + int theme_frame_overlay_image_id = 0; + if (browser_view()->IsTabStripVisible()) { + GetFrameImageIdsForTabbedBrowser(&theme_frame_image_id, + &theme_frame_overlay_image_id); + } else if (browser_view()->browser()->is_app()) { + theme_frame_image_id = GetFrameImageIdForHostedApp(); + } else { + theme_frame_image_id = GetFrameImageIdForBrowserPopup(); } + + ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? + ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; header_painter_->PaintHeader( canvas, + header_mode, theme_frame_image_id, theme_frame_overlay_image_id); if (browser_view()->ShouldShowWindowTitle()) @@ -516,7 +522,9 @@ void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { if (UsePackagedAppHeaderStyle()) { - header_painter_->PaintHeaderContentSeparator(canvas); + ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? + ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; + header_painter_->PaintHeaderContentSeparator(canvas, header_mode); } else { canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), width(), kClientEdgeThickness), @@ -525,18 +533,41 @@ void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { } } -int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const { +void BrowserNonClientFrameViewAsh::GetFrameImageIdsForTabbedBrowser( + int* frame_image_id, + int* frame_overlay_image_id) const { + *frame_overlay_image_id = 0; + bool is_incognito = !browser_view()->IsRegularOrGuestSession(); - if (browser_view()->IsBrowserTypeNormal()) { - // Use the standard resource ids to allow users to theme the frames. - if (ShouldPaintAsActive()) { - return is_incognito ? - IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; - } - return is_incognito ? + ui::ThemeProvider* tp = GetThemeProvider(); + if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && + !is_incognito) { + *frame_overlay_image_id = ShouldPaintAsActive() ? + IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; + } + + if (ShouldPaintAsActive()) { + *frame_image_id = is_incognito ? + IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; + } else { + *frame_image_id = is_incognito ? IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; } - // Never theme app and popup windows. + + if ((frame()->IsMaximized() || frame()->IsFullscreen()) && + !tp->HasCustomImage(IDR_THEME_FRAME) && + !tp->HasCustomImage(*frame_image_id) && + *frame_overlay_image_id == 0) { + *frame_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; + } +} + +int BrowserNonClientFrameViewAsh::GetFrameImageIdForBrowserPopup() const { + // Browser popups are not themeable. + if (frame()->IsMaximized() || frame()->IsFullscreen()) + return IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; + + bool is_incognito = !browser_view()->IsRegularOrGuestSession(); if (ShouldPaintAsActive()) { return is_incognito ? IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INCOGNITO_ACTIVE : @@ -547,13 +578,11 @@ int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const { IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INACTIVE; } -int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { - ui::ThemeProvider* tp = GetThemeProvider(); - if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && - browser_view()->IsBrowserTypeNormal() && - !browser_view()->IsOffTheRecord()) { +int BrowserNonClientFrameViewAsh::GetFrameImageIdForHostedApp() const { + if (UsePackagedAppHeaderStyle()) { return ShouldPaintAsActive() ? - IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; + IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : + IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; } - return 0; + return GetFrameImageIdForBrowserPopup(); } diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h index 848a746..acc71a1 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h @@ -104,14 +104,21 @@ class BrowserNonClientFrameViewAsh // above the content area. void PaintContentEdge(gfx::Canvas* canvas); - // Returns the id of the header frame image based on the browser type, - // activation state and incognito mode. - int GetThemeFrameImageId() const; - - // Returns the id of the header frame overlay image based on the activation - // state and incognito mode. - // Returns 0 if no overlay image should be used. - int GetThemeFrameOverlayImageId() const; + // Sets |frame_image_id| and |frame_image_overlay_id| to the ids of the header + // frame image and the header frame overlay image respectively which should be + // used for tabbed browser windows. |frame_overlay_image_id| is set to 0 if no + // overlay image should be used. + void GetFrameImageIdsForTabbedBrowser(int* frame_image_id, + int* frame_overlay_image_id) const; + + + // Returns the id of the header frame image which should be used for browser + // popups. Browser popups are not themed and do not use a frame overlay image. + int GetFrameImageIdForBrowserPopup() const; + + // Returns the id of the header frame image which should be used for hosted + // apps. Hosted apps are not themed and do not use a frame overlay image. + int GetFrameImageIdForHostedApp() const; // View which contains the window controls. ash::FrameCaptionButtonContainerView* caption_button_container_; |