diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-21 08:03:00 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-21 08:03:00 +0000 |
commit | 32bc0dc9317fe14adb1b5ce25f40fa922820b941 (patch) | |
tree | 4d1a626cead02f2c5fb01ccac52b14a5cc8b75ca /ash | |
parent | 852c78c6b6bff6051600c7aa88904d7c3581a77e (diff) | |
download | chromium_src-32bc0dc9317fe14adb1b5ce25f40fa922820b941.zip chromium_src-32bc0dc9317fe14adb1b5ce25f40fa922820b941.tar.gz chromium_src-32bc0dc9317fe14adb1b5ce25f40fa922820b941.tar.bz2 |
Remove the obsolete AlternateFrameCaptionButton.
This CL changes the --ash-enable-alternate-caption-button flag to add a dedicated minimize button to the window header and do nothing else.
BUG=None
TEST=None
Review URL: https://codereview.chromium.org/78903005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
6 files changed, 81 insertions, 490 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index af5c2f5..8fa1276 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -422,8 +422,6 @@ 'wm/base_layout_manager.h', 'wm/boot_splash_screen_chromeos.cc', 'wm/boot_splash_screen_chromeos.h', - 'wm/caption_buttons/alternate_frame_caption_button.cc', - 'wm/caption_buttons/alternate_frame_caption_button.h', 'wm/caption_buttons/bubble_contents_button_row.cc', 'wm/caption_buttons/bubble_contents_button_row.h', 'wm/caption_buttons/frame_caption_button_container_view.cc', diff --git a/ash/wm/caption_buttons/alternate_frame_caption_button.cc b/ash/wm/caption_buttons/alternate_frame_caption_button.cc deleted file mode 100644 index 6f6b41f..0000000 --- a/ash/wm/caption_buttons/alternate_frame_caption_button.cc +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/caption_buttons/alternate_frame_caption_button.h" - -#include "ui/gfx/animation/slide_animation.h" -#include "ui/gfx/canvas.h" - -namespace ash { - -namespace { - -// The width and height of the region of the button which does not overlap -// with other buttons. -const int kSize = 32; - -// A bubble is painted in the background when the mouse button is pressed. -// When the button is pressed: -// - The bubble is faded in from opacity 0 to |kShownBubbleOpacity|. -// - The bubble is expanded from |kInitialGrowBubbleRadius| to -// |kFullyGrownBubbleRadius|. -// When the button is unpressed (STATE_NORMAL) -// - The bubble is faded out from its current opacity back to 0. -// - The bubble is further expanded from its current radius to -// |kFinalBurstBubbleRadius|. -const int kInitialGrowBubbleRadius = 16; -const int kFullyGrownBubbleRadius = 22; -const int kFinalBurstBubbleRadius = 26; -const int kShownBubbleOpacity = 100; - -// The duraton of the animations for hiding and showing the bubble. -const int kBubbleAnimationDuration = 100; - -// TODO(pkotwicz): Replace these colors with colors from UX. -const SkColor kPathColor = SK_ColorDKGRAY; -const SkColor kPressedHoveredPathColor = SK_ColorBLACK; -const SkColor kBubbleColor = SK_ColorWHITE; - -struct Line { - int x1, y1, x2, y2; -}; - -// Line segments for the button icons. The line segments are painted in a 12x12 -// centered box. -const Line kMinimizeLineSegments[] = { - {1, 11, 11, 11} -}; -const Line kMaximizeRestoreLineSegments[] = { - {1, 1, 11, 1}, - {11, 1, 11, 11}, - {11, 11, 1, 11}, - {1, 11, 1, 1} -}; -const Line kCloseLineSegments[] = { - {1, 1, 11, 11}, - {1, 11, 11, 1} -}; - -// The amount that the origin of the icon's 12x12 box should be offset from the -// center of the button. -const int kIconOffsetFromCenter = -6; - -// Sets |line_segments| to the line segments for the icon for |action|. -void GetLineSegmentsForAction(AlternateFrameCaptionButton::Action action, - const Line** line_segments, - size_t* num_line_segments) { - switch(action) { - case AlternateFrameCaptionButton::ACTION_MINIMIZE: - *line_segments = kMinimizeLineSegments; - *num_line_segments = arraysize(kMinimizeLineSegments); - break; - case AlternateFrameCaptionButton::ACTION_MAXIMIZE_RESTORE: - *line_segments = kMaximizeRestoreLineSegments; - *num_line_segments = arraysize(kMaximizeRestoreLineSegments); - break; - case AlternateFrameCaptionButton::ACTION_CLOSE: - *line_segments = kCloseLineSegments; - *num_line_segments = arraysize(kCloseLineSegments); - break; - default: - NOTREACHED(); - break; - } -} - -} // namespace - -const char AlternateFrameCaptionButton::kViewClassName[] = - "AlternateFrameCaptionButton"; - -AlternateFrameCaptionButton::AlternateFrameCaptionButton( - views::ButtonListener* listener, - Action action) - : views::CustomButton(listener), - action_(action), - hidden_bubble_radius_(0), - shown_bubble_radius_(0), - bubble_animation_(new gfx::SlideAnimation(this)) { -} - -AlternateFrameCaptionButton::~AlternateFrameCaptionButton() { -} - -// static -int AlternateFrameCaptionButton::GetXOverlap() { - return kFinalBurstBubbleRadius - kSize / 2; -} - -gfx::Size AlternateFrameCaptionButton::GetPreferredSize() { - gfx::Insets insets(GetInsets()); - return gfx::Size( - std::max(kFinalBurstBubbleRadius * 2, kSize + insets.width()), - kSize + insets.height()); -} - -const char* AlternateFrameCaptionButton::GetClassName() const { - return kViewClassName; -} - -bool AlternateFrameCaptionButton::HitTestRect(const gfx::Rect& rect) const { - gfx::Rect bounds(GetLocalBounds()); - if (state_ == STATE_PRESSED) - return bounds.Intersects(rect); - - int x_overlap = GetXOverlap(); - bounds.set_x(x_overlap); - bounds.set_width(width() - x_overlap * 2); - return bounds.Intersects(rect); -} - -void AlternateFrameCaptionButton::OnPaint(gfx::Canvas* canvas) { - gfx::Point content_bounds_center(GetContentsBounds().CenterPoint()); - - int bubble_alpha = bubble_animation_->CurrentValueBetween( - 0, kShownBubbleOpacity); - if (bubble_alpha != 0) { - int bubble_radius = bubble_animation_->CurrentValueBetween( - hidden_bubble_radius_, shown_bubble_radius_); - - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(SkColorSetA(kBubbleColor, bubble_alpha)); - canvas->DrawCircle(content_bounds_center, bubble_radius, paint); - } - - SkColor color = kPathColor; - if (state_ == STATE_HOVERED || state_ == STATE_PRESSED) - color = kPressedHoveredPathColor; - - const Line* line_segments = NULL; - size_t num_line_segments = 0; - GetLineSegmentsForAction(action_, &line_segments, &num_line_segments); - - gfx::Vector2d top_left_offset( - content_bounds_center.x() + kIconOffsetFromCenter, - content_bounds_center.y() + kIconOffsetFromCenter); - canvas->Translate(top_left_offset); - SkPaint paint; - paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeWidth(SkIntToScalar(2)); - paint.setStrokeCap(SkPaint::kSquare_Cap); - paint.setColor(color); - for (size_t i = 0; i < num_line_segments; ++i) { - canvas->DrawLine(gfx::Point(line_segments[i].x1, line_segments[i].y1), - gfx::Point(line_segments[i].x2, line_segments[i].y2), - paint); - } - canvas->Translate(-top_left_offset); -} - -void AlternateFrameCaptionButton::MaybeStartNewBubbleAnimation() { - bool should_show = (state_ == STATE_PRESSED); - if (should_show == bubble_animation_->IsShowing()) - return; - - if (!bubble_animation_->is_animating()) { - if (should_show) - hidden_bubble_radius_ = kInitialGrowBubbleRadius; - else - hidden_bubble_radius_ = kFinalBurstBubbleRadius; - shown_bubble_radius_ = kFullyGrownBubbleRadius; - - bubble_animation_->SetSlideDuration(kBubbleAnimationDuration); - if (should_show) - bubble_animation_->Show(); - else - bubble_animation_->Hide(); - } else { - if (!should_show) { - // The change in radius during a hide animation if there was no currently - // running animation. - int normal_radius_change = - kFinalBurstBubbleRadius - kFullyGrownBubbleRadius; - - // Start a fade out animation from the bubble's current radius and - // opacity. Update the bubble radius and opacity at the same rate that it - // gets updated during a normal hide animation. - int current_bubble_radius = bubble_animation_->CurrentValueBetween( - kInitialGrowBubbleRadius, kFullyGrownBubbleRadius); - hidden_bubble_radius_ = current_bubble_radius + - bubble_animation_->GetCurrentValue() * normal_radius_change; - shown_bubble_radius_ = hidden_bubble_radius_ - normal_radius_change; - bubble_animation_->SetSlideDuration( - bubble_animation_->GetCurrentValue() * kBubbleAnimationDuration); - bubble_animation_->Hide(); - } - // Else: The bubble is currently fading out. Wait till the hide animation - // completes before starting an animation to show a new bubble. - } -} - -void AlternateFrameCaptionButton::StateChanged() { - MaybeStartNewBubbleAnimation(); -} - -void AlternateFrameCaptionButton::AnimationProgressed( - const gfx::Animation* animation) { - SchedulePaint(); -} - -void AlternateFrameCaptionButton::AnimationEnded( - const gfx::Animation* animation) { - // The bubble animation was postponed if the button became pressed when the - // bubble was fading out. Do the animation now. - MaybeStartNewBubbleAnimation(); -} - -} // namespace ash diff --git a/ash/wm/caption_buttons/alternate_frame_caption_button.h b/ash/wm/caption_buttons/alternate_frame_caption_button.h deleted file mode 100644 index 5c0ebda..0000000 --- a/ash/wm/caption_buttons/alternate_frame_caption_button.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_CAPTION_BUTTONS_ALTERNATE_FRAME_CAPTION_BUTTON_H_ -#define ASH_WM_CAPTION_BUTTONS_ALTERNATE_FRAME_CAPTION_BUTTON_H_ - -#include "ash/ash_export.h" -#include "base/memory/scoped_ptr.h" -#include "ui/views/controls/button/custom_button.h" - -namespace gfx { -class SlideAnimation; -} - -namespace ash { - -// Base class for buttons using the alternate button style. -class ASH_EXPORT AlternateFrameCaptionButton : public views::CustomButton { - public: - static const char kViewClassName[]; - - enum Action { - ACTION_MINIMIZE, - ACTION_MAXIMIZE_RESTORE, - ACTION_CLOSE - }; - - AlternateFrameCaptionButton(views::ButtonListener* listener, Action action); - virtual ~AlternateFrameCaptionButton(); - - // Returns the amount in pixels that the button should overlap with the button - // on the left and right of it. - static int GetXOverlap(); - - // views::View overrides: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual const char* GetClassName() const OVERRIDE; - virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - private: - // Animates the background bubble for the current views::ButtonState. - void MaybeStartNewBubbleAnimation(); - - // views::CustomButton override: - virtual void StateChanged() OVERRIDE; - - // ui::AnimateDelegate overrides. (views::CustomButton inherits from - // gfx::AnimationDelegate). - virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; - virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; - - Action action_; - - // The radius of the background bubble when it is hidden. - double hidden_bubble_radius_; - - // The radius of the background bubble when it is visible. - double shown_bubble_radius_; - - scoped_ptr<gfx::SlideAnimation> bubble_animation_; - - DISALLOW_COPY_AND_ASSIGN(AlternateFrameCaptionButton); -}; - -} // namespace ash - -#endif // ASH_WM_CAPTION_BUTTONS_ALTERNATE_FRAME_CAPTION_BUTTON_H_ 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 41f9e08..320ab95 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.cc @@ -7,7 +7,6 @@ #include "ash/ash_switches.h" #include "ash/shell.h" #include "ash/shell_delegate.h" -#include "ash/wm/caption_buttons/alternate_frame_caption_button.h" #include "ash/wm/caption_buttons/frame_maximize_button.h" #include "ash/wm/window_state.h" #include "grit/ash_resources.h" @@ -26,28 +25,9 @@ namespace ash { namespace { -// Constants for normal button style ------------------------------------------- - -// The distance between buttons. AlternateFrameCaptionButton::GetXOverlap() is -// used to compute the distance between buttons for the alternate button style. +// The distance between buttons. const int kDistanceBetweenButtons = -1; -// Constants for alternate button style ---------------------------------------- - -// Spacings between the buttons and the view's top and bottom borders (if any). -const int kAlternateStyleShortHeaderTopInset = 0; -const int kAlternateStyleTallHeaderTopInset = 2; -const int kAlternateStyleShortHeaderBottomInset = 0; -const int kAlternateStyleTallHeaderBottomInset = 1; - -// Ideal spacing between: -// - Right edge of the leftmost button's overlappable region and the view's left -// edge. -// - Left edge of the rightmost button's overlappable region and the view's -// right edge. -// Used in GetLeftInset() and GetRightInset(). -const int kAlternateStyleSideInset = 5; - // Converts |point| from |src| to |dst| and hittests against |dst|. bool ConvertPointToViewAndHitTest(const views::View* src, const views::View* dst, @@ -71,38 +51,29 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( minimize_button_(NULL), size_button_(NULL), close_button_(NULL) { - bool alternate_style = switches::UseAlternateFrameCaptionButtonStyle(); + bool alternate_style = switches::UseAlternateFrameCaptionButtonStyle(); // Insert the buttons left to right. - if (alternate_style) { - minimize_button_ = new AlternateFrameCaptionButton(this, - AlternateFrameCaptionButton::ACTION_MINIMIZE); - size_button_ = new AlternateFrameCaptionButton(this, - AlternateFrameCaptionButton::ACTION_MAXIMIZE_RESTORE); - close_button_ = new AlternateFrameCaptionButton(this, - AlternateFrameCaptionButton::ACTION_CLOSE); - } else { - minimize_button_ = new views::ImageButton(this); - size_button_ = new FrameMaximizeButton(this, frame); - close_button_ = new views::ImageButton(this); - } - + minimize_button_ = new views::ImageButton(this); minimize_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); // Hide |minimize_button_| when using the non-alternate button style because // |size_button_| is capable of minimizing in this case. - // TODO(pkotwicz): We should probably show the minimize button when in - // "always maximized" mode. minimize_button_->SetVisible( minimize_allowed == MINIMIZE_ALLOWED && (alternate_style || !frame_->widget_delegate()->CanMaximize())); AddChildView(minimize_button_); + if (alternate_style) + size_button_ = new views::ImageButton(this); + else + size_button_ = new FrameMaximizeButton(this, frame); size_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); size_button_->SetVisible(frame_->widget_delegate()->CanMaximize()); AddChildView(size_button_); + close_button_ = new views::ImageButton(this); close_button_->SetAccessibleName( l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); AddChildView(close_button_); @@ -141,8 +112,6 @@ int FrameCaptionButtonContainerView::NonClientHitTest( } gfx::Size FrameCaptionButtonContainerView::GetPreferredSize() { - int button_separation = GetDistanceBetweenButtons(); - int width = 0; bool first_visible = true; for (int i = 0; i < child_count(); ++i) { @@ -152,85 +121,66 @@ gfx::Size FrameCaptionButtonContainerView::GetPreferredSize() { width += child_at(i)->GetPreferredSize().width(); if (!first_visible) - width += button_separation; + width += kDistanceBetweenButtons; first_visible = false; } gfx::Insets insets(GetInsets()); - return gfx::Size( - width + insets.width() + GetLeftInset() + GetRightInset(), + return gfx::Size(width + insets.width(), close_button_->GetPreferredSize().height() + insets.height()); } void FrameCaptionButtonContainerView::Layout() { - if (switches::UseAlternateFrameCaptionButtonStyle()) { - int top_inset = kAlternateStyleShortHeaderTopInset; - int bottom_inset = kAlternateStyleShortHeaderBottomInset; - if (header_style_ == HEADER_STYLE_TALL) { - top_inset = kAlternateStyleTallHeaderTopInset; - bottom_inset = kAlternateStyleTallHeaderBottomInset; - } - - minimize_button_->set_border( - views::Border::CreateEmptyBorder(top_inset, 0, bottom_inset, 0)); - size_button_->set_border( - views::Border::CreateEmptyBorder(top_inset, 0, bottom_inset, 0)); - close_button_->set_border( - views::Border::CreateEmptyBorder(top_inset, 0, bottom_inset, 0)); - } else { - SetButtonImages(minimize_button_, - IDR_AURA_WINDOW_MINIMIZE_SHORT, - IDR_AURA_WINDOW_MINIMIZE_SHORT_H, - IDR_AURA_WINDOW_MINIMIZE_SHORT_P); - - if (header_style_ == HEADER_STYLE_MAXIMIZED_HOSTED_APP) { + SetButtonImages(minimize_button_, + IDR_AURA_WINDOW_MINIMIZE_SHORT, + IDR_AURA_WINDOW_MINIMIZE_SHORT_H, + IDR_AURA_WINDOW_MINIMIZE_SHORT_P); + if (header_style_ == HEADER_STYLE_MAXIMIZED_HOSTED_APP) { + SetButtonImages(size_button_, + IDR_AURA_WINDOW_FULLSCREEN_RESTORE, + IDR_AURA_WINDOW_FULLSCREEN_RESTORE_H, + IDR_AURA_WINDOW_FULLSCREEN_RESTORE_P); + SetButtonImages(close_button_, + IDR_AURA_WINDOW_FULLSCREEN_CLOSE, + IDR_AURA_WINDOW_FULLSCREEN_CLOSE_H, + IDR_AURA_WINDOW_FULLSCREEN_CLOSE_P); + } else if (header_style_ == HEADER_STYLE_SHORT) { + // The new assets only make sense if the window is maximized or fullscreen + // because we usually use a black header in this case. + if ((frame_->IsMaximized() || frame_->IsFullscreen()) && + wm::GetWindowState( + frame_->GetNativeWindow())->tracked_by_workspace()) { SetButtonImages(size_button_, - IDR_AURA_WINDOW_FULLSCREEN_RESTORE, - IDR_AURA_WINDOW_FULLSCREEN_RESTORE_H, - IDR_AURA_WINDOW_FULLSCREEN_RESTORE_P); + IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, + IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, + IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_P); SetButtonImages(close_button_, - IDR_AURA_WINDOW_FULLSCREEN_CLOSE, - IDR_AURA_WINDOW_FULLSCREEN_CLOSE_H, - IDR_AURA_WINDOW_FULLSCREEN_CLOSE_P); - } else if (header_style_ == HEADER_STYLE_SHORT) { - // The new assets only make sense if the window is maximized or fullscreen - // because we usually use a black header in this case. - if ((frame_->IsMaximized() || frame_->IsFullscreen()) && - wm::GetWindowState( - frame_->GetNativeWindow())->tracked_by_workspace()) { - SetButtonImages(size_button_, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE2_P); - SetButtonImages(close_button_, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_H, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_P); - } else { - SetButtonImages(size_button_, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, - IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); - SetButtonImages(close_button_, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H, - IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P); - } + IDR_AURA_WINDOW_MAXIMIZED_CLOSE2, + IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_H, + IDR_AURA_WINDOW_MAXIMIZED_CLOSE2_P); } else { SetButtonImages(size_button_, - IDR_AURA_WINDOW_MAXIMIZE, - IDR_AURA_WINDOW_MAXIMIZE_H, - IDR_AURA_WINDOW_MAXIMIZE_P); + IDR_AURA_WINDOW_MAXIMIZED_RESTORE, + IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, + IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); SetButtonImages(close_button_, - IDR_AURA_WINDOW_CLOSE, - IDR_AURA_WINDOW_CLOSE_H, - IDR_AURA_WINDOW_CLOSE_P); + IDR_AURA_WINDOW_MAXIMIZED_CLOSE, + IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H, + IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P); } + } else { + SetButtonImages(size_button_, + IDR_AURA_WINDOW_MAXIMIZE, + IDR_AURA_WINDOW_MAXIMIZE_H, + IDR_AURA_WINDOW_MAXIMIZE_P); + SetButtonImages(close_button_, + IDR_AURA_WINDOW_CLOSE, + IDR_AURA_WINDOW_CLOSE_H, + IDR_AURA_WINDOW_CLOSE_P); } gfx::Insets insets(GetInsets()); - int x = insets.left() + GetLeftInset(); + int x = insets.left(); int y_inset = insets.top(); - int button_separation = GetDistanceBetweenButtons(); for (int i = 0; i < child_count(); ++i) { views::View* child = child_at(i); if (!child->visible()) @@ -238,12 +188,7 @@ void FrameCaptionButtonContainerView::Layout() { gfx::Size size = child->GetPreferredSize(); child->SetBounds(x, y_inset, size.width(), size.height()); - - // Do not allow |child| to paint over the left border. - child->set_clip_insets( - gfx::Insets(0, std::max(0, insets.left() - x), 0, 0)); - - x += size.width() + button_separation; + x += size.width() + kDistanceBetweenButtons; } } @@ -269,38 +214,6 @@ void FrameCaptionButtonContainerView::OnPaint(gfx::Canvas* canvas) { } } -int FrameCaptionButtonContainerView::GetDistanceBetweenButtons() const { - if (switches::UseAlternateFrameCaptionButtonStyle()) - return AlternateFrameCaptionButton::GetXOverlap() * -2; - return kDistanceBetweenButtons; -} - -int FrameCaptionButtonContainerView::GetLeftInset() const { - if (switches::UseAlternateFrameCaptionButtonStyle()) { - // If using the alternate button style and there is a border, clip the - // left overlappable region of the leftmost button to - // |kAlternateStyleSideInset|. - // Otherwise, allow enough room for the entire left overlappable region of - // the leftmost button to fit in the view. - if (border() && border()->GetInsets().left()) { - return kAlternateStyleSideInset - - AlternateFrameCaptionButton::GetXOverlap(); - } - } - return 0; -} - -int FrameCaptionButtonContainerView::GetRightInset() const { - if (switches::UseAlternateFrameCaptionButtonStyle()) { - // Always clip the right overlappable region of the rightmost button to - // |kAlternateStyleSideInset| because the caption buttons are always - // at the right edge of the screen. (The left edge in RTL mode). - return kAlternateStyleSideInset - - AlternateFrameCaptionButton::GetXOverlap(); - } - return 0; -} - void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender, const ui::Event& event) { // When shift-clicking, slow down animations for visual debugging. @@ -341,21 +254,17 @@ void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender, } void FrameCaptionButtonContainerView::SetButtonImages( - views::CustomButton* button, + views::ImageButton* button, int normal_image_id, int hot_image_id, int pushed_image_id) { - // When using the alternate button style, |button| does not inherit from - // views::ImageButton. - DCHECK(!switches::UseAlternateFrameCaptionButtonStyle()); - views::ImageButton* image_button = static_cast<views::ImageButton*>(button); ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); - image_button->SetImage(views::CustomButton::STATE_NORMAL, - resource_bundle.GetImageSkiaNamed(normal_image_id)); - image_button->SetImage(views::CustomButton::STATE_HOVERED, - resource_bundle.GetImageSkiaNamed(hot_image_id)); - image_button->SetImage(views::CustomButton::STATE_PRESSED, - resource_bundle.GetImageSkiaNamed(pushed_image_id)); + button->SetImage(views::CustomButton::STATE_NORMAL, + resource_bundle.GetImageSkiaNamed(normal_image_id)); + button->SetImage(views::CustomButton::STATE_HOVERED, + resource_bundle.GetImageSkiaNamed(hot_image_id)); + button->SetImage(views::CustomButton::STATE_PRESSED, + resource_bundle.GetImageSkiaNamed(pushed_image_id)); } } // namespace ash 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 6dd9521..2c7f5e3 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.h +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.h @@ -11,7 +11,7 @@ #include "ui/views/view.h" namespace views { -class CustomButton; +class ImageButton; class Widget; } @@ -57,15 +57,15 @@ class ASH_EXPORT FrameCaptionButtonContainerView : container_view_(container_view) { } - views::CustomButton* minimize_button() const { + views::ImageButton* minimize_button() const { return container_view_->minimize_button_; } - views::CustomButton* size_button() const { + views::ImageButton* size_button() const { return container_view_->size_button_; } - views::CustomButton* close_button() const { + views::ImageButton* close_button() const { return container_view_->close_button_; } @@ -101,26 +101,12 @@ class ASH_EXPORT FrameCaptionButtonContainerView private: friend class FrameCaptionButtonContainerViewTest; - // Returns the distance between buttons which are next to each other. A - // negative value is returned if the buttons overlap. - int GetDistanceBetweenButtons() const; - - // Returns the inset of the leftmost visible button from the view's border - // (if any). - int GetLeftInset() const; - - // Returns the inset of the rightmost visible button from the view's border - // (if any). - int GetRightInset() const; - // views::ButtonListener override: virtual void ButtonPressed(views::Button* sender, const ui::Event& event) OVERRIDE; - // Methods specific to normal button style ----------------------------------- - // // Sets the images for a button based on the given ids. - void SetButtonImages(views::CustomButton* button, + void SetButtonImages(views::ImageButton* button, int normal_image_id, int hot_image_id, int pushed_image_id); @@ -135,9 +121,9 @@ class ASH_EXPORT FrameCaptionButtonContainerView // The buttons. In the normal button style, at most one of |minimize_button_| // and |size_button_| is visible. - views::CustomButton* minimize_button_; - views::CustomButton* size_button_; - views::CustomButton* close_button_; + views::ImageButton* minimize_button_; + views::ImageButton* size_button_; + views::ImageButton* close_button_; DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerView); }; 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 81f2ea3..84a7347a 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 @@ -71,7 +71,6 @@ class FrameCaptionButtonContainerViewTest : public ash::test::AshTestBase { const views::CustomButton& leftmost, const views::CustomButton& rightmost) { gfx::Rect expected(container->GetPreferredSize()); - expected.Inset(container->GetLeftInset(), 0, container->GetRightInset(), 0); gfx::Rect container_size(container->GetPreferredSize()); if (leftmost.y() == rightmost.y() && @@ -89,26 +88,11 @@ class FrameCaptionButtonContainerViewTest : public ash::test::AshTestBase { return false; } - private: - DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTest); -}; - -class FrameCaptionButtonContainerViewTestOldStyle - : public FrameCaptionButtonContainerViewTest { - public: - FrameCaptionButtonContainerViewTestOldStyle() { - } - - virtual ~FrameCaptionButtonContainerViewTestOldStyle() { - } - // Returns true if the images for |button|'s states match the passed in ids. - bool ImagesMatch(views::CustomButton* custom_button, + bool ImagesMatch(views::ImageButton* button, int normal_image_id, int hovered_image_id, int pressed_image_id) { - views::ImageButton* button = - static_cast<views::ImageButton*>(custom_button); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); gfx::ImageSkia* normal = rb.GetImageSkiaNamed(normal_image_id); gfx::ImageSkia* hovered = rb.GetImageSkiaNamed(hovered_image_id); @@ -122,6 +106,19 @@ class FrameCaptionButtonContainerViewTestOldStyle actual_pressed.BackedBySameObjectAs(*pressed); } + private: + DISALLOW_COPY_AND_ASSIGN(FrameCaptionButtonContainerViewTest); +}; + +class FrameCaptionButtonContainerViewTestOldStyle + : public FrameCaptionButtonContainerViewTest { + public: + FrameCaptionButtonContainerViewTestOldStyle() { + } + + virtual ~FrameCaptionButtonContainerViewTestOldStyle() { + } + virtual void SetUp() OVERRIDE { FrameCaptionButtonContainerViewTest::SetUp(); CommandLine::ForCurrentProcess()->AppendSwitch( |