summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 23:08:04 +0000
committerfgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 23:08:04 +0000
commitb6f34fbeb011683117b33639ca78d66ff32d5bfd (patch)
tree8539c4cc395ddc3de5f7a37c50ef4287154dd647
parent40e3850331fee90d4964f18d466fa82d1634d98b (diff)
downloadchromium_src-b6f34fbeb011683117b33639ca78d66ff32d5bfd.zip
chromium_src-b6f34fbeb011683117b33639ca78d66ff32d5bfd.tar.gz
chromium_src-b6f34fbeb011683117b33639ca78d66ff32d5bfd.tar.bz2
Revert 272352 "Reland Linux Window Control Alignment"
> Reland Linux Window Control Alignment > > Modifying CustomFrameView to layout window controls based on user configurations. For linux begin observing the configs and changes. For other systems fall back on a default ordering. > > Update tests that were originally missed. > > Original review: https://codereview.chromium.org/240163006/ > Revert review: https://codereview.chromium.org/276173002/ > Revert "Revert of Linux Aura Task Manager Frame Buttons Misaligned (https://codereview.chromium.org/240163006/)" > > This reverts commit 9031ef57ba679037fc675bf2f081f3880380de3a. > > TEST=CustomFrameViewTest > BUG=351917 > > Review URL: https://codereview.chromium.org/281353009 TBR=jonross@chromium.org Review URL: https://codereview.chromium.org/294473016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272356 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/extended_desktop_unittest.cc6
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc21
-rw-r--r--ui/views/linux_ui/window_button_order_provider.cc83
-rw-r--r--ui/views/views.gyp7
-rw-r--r--ui/views/window/custom_frame_view.cc157
-rw-r--r--ui/views/window/custom_frame_view.h23
-rw-r--r--ui/views/window/custom_frame_view_unittest.cc253
-rw-r--r--ui/views/window/window_button_order_provider.cc41
-rw-r--r--ui/views/window/window_button_order_provider.h56
9 files changed, 71 insertions, 576 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index eb8591d..4ad8301 100644
--- a/ash/extended_desktop_unittest.cc
+++ b/ash/extended_desktop_unittest.cc
@@ -518,7 +518,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
// Transient child of the transient child.
views::Widget* w1_t11 = CreateTestWidgetWithParent(
- w1_t1, gfx::Rect(1200, 70, 35, 35), false /* transient */);
+ w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
views::Widget* w11 = CreateTestWidgetWithParent(
w1, gfx::Rect(10, 10, 40, 40), true /* child */);
@@ -532,7 +532,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
EXPECT_EQ("50,50 50x50",
w1_t1->GetWindowBoundsInScreen().ToString());
- EXPECT_EQ("1200,70 35x35",
+ EXPECT_EQ("1200,70 30x30",
w1_t11->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("20,20 40x40",
w11->GetWindowBoundsInScreen().ToString());
@@ -552,7 +552,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
// Transient window's screen bounds stays the same.
EXPECT_EQ("50,50 50x50",
w1_t1->GetWindowBoundsInScreen().ToString());
- EXPECT_EQ("1200,70 35x35",
+ EXPECT_EQ("1200,70 30x30",
w1_t11->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("1300,100 80x80",
w11_t1->GetWindowBoundsInScreen().ToString());
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index ee2a20f..072a714 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -4,8 +4,6 @@
#include "ash/wm/system_gesture_event_filter.h"
-#include <vector>
-
#include "ash/accelerators/accelerator_controller.h"
#include "ash/ash_switches.h"
#include "ash/display/display_manager.h"
@@ -40,7 +38,6 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/non_client_view.h"
-#include "ui/views/window/window_button_order_provider.h"
namespace ash {
namespace test {
@@ -141,20 +138,6 @@ class SystemGestureEventFilterTest
// Overridden from AshTestBase:
virtual void SetUp() OVERRIDE {
- // TODO(jonross): TwoFingerDragDelayed() and ThreeFingerGestureStopsDrag()
- // both use hardcoded touch points, assuming that they target empty header
- // space. Window control order now reflects configuration files and can
- // change. The tests should be improved to dynamically decide touch points.
- // To address this we specify the originally expected window control
- // positions to be consistent across tests.
- std::vector<views::FrameButton> leading;
- std::vector<views::FrameButton> trailing;
- trailing.push_back(views::FRAME_BUTTON_MINIMIZE);
- trailing.push_back(views::FRAME_BUTTON_MAXIMIZE);
- trailing.push_back(views::FRAME_BUTTON_CLOSE);
- views::WindowButtonOrderProvider::GetInstance()->
- SetWindowButtonOrder(leading, trailing);
-
if (!docked_enabled_) {
CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshDisableDockedWindows);
@@ -454,7 +437,7 @@ TEST_P(SystemGestureEventFilterTest,
}
TEST_P(SystemGestureEventFilterTest, TwoFingerDragDelayed) {
- gfx::Rect bounds(0, 0, 200, 100);
+ gfx::Rect bounds(0, 0, 100, 100);
aura::Window* root_window = Shell::GetPrimaryRootWindow();
views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
new ResizableWidgetDelegate, root_window, bounds);
@@ -489,7 +472,7 @@ TEST_P(SystemGestureEventFilterTest, TwoFingerDragDelayed) {
}
TEST_P(SystemGestureEventFilterTest, ThreeFingerGestureStopsDrag) {
- gfx::Rect bounds(0, 0, 200, 100);
+ gfx::Rect bounds(0, 0, 100, 100);
aura::Window* root_window = Shell::GetPrimaryRootWindow();
views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
new ResizableWidgetDelegate, root_window, bounds);
diff --git a/ui/views/linux_ui/window_button_order_provider.cc b/ui/views/linux_ui/window_button_order_provider.cc
deleted file mode 100644
index 9032478..0000000
--- a/ui/views/linux_ui/window_button_order_provider.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2014 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 "ui/views/window/window_button_order_provider.h"
-
-#include "ui/views/linux_ui/linux_ui.h"
-#include "ui/views/linux_ui/window_button_order_observer.h"
-
-namespace views {
-
-namespace {
-
-class WindowButtonOrderObserverDelegate : public WindowButtonOrderProvider,
- public WindowButtonOrderObserver {
- public:
- WindowButtonOrderObserverDelegate();
- virtual ~WindowButtonOrderObserverDelegate();
-
- // WindowButtonOrderObserver:
- virtual void OnWindowButtonOrderingChange(
- const std::vector<views::FrameButton>& leading_buttons,
- const std::vector<views::FrameButton>& trailing_buttons) OVERRIDE;
- private:
- DISALLOW_COPY_AND_ASSIGN(WindowButtonOrderObserverDelegate);
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowButtonOrderObserverDelegate, public:
-
-WindowButtonOrderObserverDelegate::WindowButtonOrderObserverDelegate() {
- views::LinuxUI* ui = views::LinuxUI::instance();
- if (ui)
- ui->AddWindowButtonOrderObserver(this);
-}
-
-WindowButtonOrderObserverDelegate::~WindowButtonOrderObserverDelegate() {
- views::LinuxUI* ui = views::LinuxUI::instance();
- if (ui)
- ui->RemoveWindowButtonOrderObserver(this);
-}
-
-void WindowButtonOrderObserverDelegate::OnWindowButtonOrderingChange(
- const std::vector<views::FrameButton>& leading_buttons,
- const std::vector<views::FrameButton>& trailing_buttons) {
- SetWindowButtonOrder(leading_buttons, trailing_buttons);
-}
-
-} // namespace
-
-// static
-WindowButtonOrderProvider* WindowButtonOrderProvider::instance_ = NULL;
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowButtonOrderProvider, public:
-
-// static
-WindowButtonOrderProvider* WindowButtonOrderProvider::GetInstance() {
- if (!instance_)
- instance_ = new WindowButtonOrderObserverDelegate;
- return instance_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowButtonOrderProvider, protected:
-
-WindowButtonOrderProvider::WindowButtonOrderProvider() {
- trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
- trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE);
- trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE);
-}
-
-WindowButtonOrderProvider::~WindowButtonOrderProvider() {
-}
-
-void WindowButtonOrderProvider::SetWindowButtonOrder(
- const std::vector<views::FrameButton>& leading_buttons,
- const std::vector<views::FrameButton>& trailing_buttons) {
- leading_buttons_ = leading_buttons;
- trailing_buttons_ = trailing_buttons;
-}
-
-} // namespace views
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index e67fbd0..f9e256e 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -298,7 +298,6 @@
'linux_ui/status_icon_linux.h',
'linux_ui/status_icon_linux.cc',
'linux_ui/window_button_order_observer.h',
- 'linux_ui/window_button_order_provider.cc',
'metrics.cc',
'metrics.h',
'metrics_aura.cc',
@@ -449,8 +448,6 @@
'window/native_frame_view.h',
'window/non_client_view.cc',
'window/non_client_view.h',
- 'window/window_button_order_provider.cc',
- 'window/window_button_order_provider.h',
'window/window_resources.h',
'window/window_shape.cc',
'window/window_shape.h',
@@ -479,9 +476,6 @@
'dependencies': [
'../shell_dialogs/shell_dialogs.gyp:shell_dialogs',
],
- 'sources!': [
- 'window/window_button_order_provider.cc',
- ],
}, { # OS=="linux" and chromeos==0
'sources/': [
['exclude', 'linux_ui'],
@@ -693,7 +687,6 @@
'widget/root_view_unittest.cc',
'widget/widget_unittest.cc',
'widget/window_reorderer_unittest.cc',
- 'window/custom_frame_view_unittest.cc',
'window/dialog_client_view_unittest.cc',
'window/dialog_delegate_unittest.cc',
],
diff --git a/ui/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc
index c20bd8a..766ba24 100644
--- a/ui/views/window/custom_frame_view.cc
+++ b/ui/views/window/custom_frame_view.cc
@@ -5,7 +5,6 @@
#include "ui/views/window/custom_frame_view.h"
#include <algorithm>
-#include <vector>
#include "base/strings/utf_string_conversions.h"
#include "grit/ui_resources.h"
@@ -17,7 +16,6 @@
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/path.h"
-#include "ui/gfx/rect.h"
#include "ui/views/color_constants.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/views_delegate.h"
@@ -26,7 +24,6 @@
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/client_view.h"
#include "ui/views/window/frame_background.h"
-#include "ui/views/window/window_button_order_provider.h"
#include "ui/views/window/window_resources.h"
#include "ui/views/window/window_shape.h"
@@ -70,13 +67,6 @@ const gfx::FontList& GetTitleFontList() {
return title_font_list;
}
-void LayoutButton(ImageButton* button, const gfx::Rect& bounds) {
- button->SetVisible(true);
- button->SetImageAlignment(ImageButton::ALIGN_LEFT,
- ImageButton::ALIGN_BOTTOM);
- button->SetBoundsRect(bounds);
-}
-
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -90,9 +80,7 @@ CustomFrameView::CustomFrameView()
restore_button_(NULL),
close_button_(NULL),
should_show_maximize_button_(false),
- frame_background_(new FrameBackground()),
- minimum_title_bar_x_(0),
- maximum_title_bar_x_(-1) {
+ frame_background_(new FrameBackground()) {
}
CustomFrameView::~CustomFrameView() {
@@ -101,12 +89,19 @@ CustomFrameView::~CustomFrameView() {
void CustomFrameView::Init(Widget* frame) {
frame_ = frame;
- close_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_CLOSE,
- IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P);
+ close_button_ = new ImageButton(this);
+ close_button_->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE));
+
+ // Close button images will be set in LayoutWindowControls().
+ AddChildView(close_button_);
+
minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE,
IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P);
+
maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE,
IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P);
+
restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE,
IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P);
@@ -281,7 +276,7 @@ int CustomFrameView::NonClientTopBorderHeight() const {
int CustomFrameView::CaptionButtonY() const {
// Maximized buttons start at window top so that even if their images aren't
// drawn flush with the screen edge, they still obey Fitts' Law.
- return frame_->IsMaximized() ? FrameBorderThickness() : kFrameBorderThickness;
+ return frame_->IsMaximized() ? FrameBorderThickness() : kFrameShadowThickness;
}
int CustomFrameView::TitlebarBottomThickness() const {
@@ -319,8 +314,7 @@ gfx::Rect CustomFrameView::IconBounds() const {
// 3D edge (or nothing at all, for maximized windows) above; hence the +1.
int y = unavailable_px_at_top + (NonClientTopBorderHeight() -
unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2;
- return gfx::Rect(frame_thickness + kIconLeftSpacing + minimum_title_bar_x_,
- y, size, size);
+ return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size);
}
bool CustomFrameView::ShouldShowTitleBarAndBorder() const {
@@ -474,68 +468,70 @@ const gfx::ImageSkia* CustomFrameView::GetFrameImage() const {
}
void CustomFrameView::LayoutWindowControls() {
- minimum_title_bar_x_ = 0;
- maximum_title_bar_x_ = width();
-
- if (bounds().IsEmpty())
- return;
-
+ close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT,
+ ImageButton::ALIGN_BOTTOM);
int caption_y = CaptionButtonY();
bool is_maximized = frame_->IsMaximized();
// There should always be the same number of non-shadow pixels visible to the
- // side of the caption buttons. In maximized mode we extend the edge button
- // to the screen corner to obey Fitts' Law.
- int extra_width = is_maximized ?
+ // side of the caption buttons. In maximized mode we extend the rightmost
+ // button to the screen corner to obey Fitts' Law.
+ int right_extra_width = is_maximized ?
(kFrameBorderThickness - kFrameShadowThickness) : 0;
- int next_button_x = FrameBorderThickness();
-
+ gfx::Size close_button_size = close_button_->GetPreferredSize();
+ close_button_->SetBounds(width() - FrameBorderThickness() -
+ right_extra_width - close_button_size.width(), caption_y,
+ close_button_size.width() + right_extra_width,
+ close_button_size.height());
+
+ // When the window is restored, we show a maximized button; otherwise, we show
+ // a restore button.
bool is_restored = !is_maximized && !frame_->IsMinimized();
ImageButton* invisible_button = is_restored ? restore_button_
: maximize_button_;
invisible_button->SetVisible(false);
- WindowButtonOrderProvider* button_order =
- WindowButtonOrderProvider::GetInstance();
- const std::vector<views::FrameButton>& leading_buttons =
- button_order->leading_buttons();
- const std::vector<views::FrameButton>& trailing_buttons =
- button_order->trailing_buttons();
-
- ImageButton* button = NULL;
- for (std::vector<views::FrameButton>::const_iterator it =
- leading_buttons.begin(); it != leading_buttons.end(); ++it) {
- button = GetImageButton(*it);
- if (!button)
- continue;
- gfx::Rect target_bounds(gfx::Point(next_button_x, caption_y),
- button->GetPreferredSize());
- if (it == leading_buttons.begin())
- target_bounds.set_width(target_bounds.width() + extra_width);
- LayoutButton(button, target_bounds);
- next_button_x += button->width();
- minimum_title_bar_x_ = std::min(width(), next_button_x);
+ ImageButton* visible_button = is_restored ? maximize_button_
+ : restore_button_;
+ FramePartImage normal_part, hot_part, pushed_part;
+ int next_button_x;
+ if (should_show_maximize_button_) {
+ visible_button->SetVisible(true);
+ visible_button->SetImageAlignment(ImageButton::ALIGN_LEFT,
+ ImageButton::ALIGN_BOTTOM);
+ gfx::Size visible_button_size = visible_button->GetPreferredSize();
+ visible_button->SetBounds(close_button_->x() - visible_button_size.width(),
+ caption_y, visible_button_size.width(),
+ visible_button_size.height());
+ next_button_x = visible_button->x();
+ } else {
+ visible_button->SetVisible(false);
+ next_button_x = close_button_->x();
}
- // Trailing buttions are laid out in a RTL fashion
- next_button_x = width() - FrameBorderThickness();
- for (std::vector<views::FrameButton>::const_reverse_iterator it =
- trailing_buttons.rbegin(); it != trailing_buttons.rend(); ++it) {
- button = GetImageButton(*it);
- if (!button)
- continue;
- gfx::Rect target_bounds(gfx::Point(next_button_x, caption_y),
- button->GetPreferredSize());
- if (it == trailing_buttons.rbegin())
- target_bounds.set_width(target_bounds.width() + extra_width);
- target_bounds.Offset(-target_bounds.width(), 0);
- LayoutButton(button, target_bounds);
- next_button_x = button->x();
- maximum_title_bar_x_ = std::max(minimum_title_bar_x_, next_button_x);
- }
+ minimize_button_->SetVisible(true);
+ minimize_button_->SetImageAlignment(ImageButton::ALIGN_LEFT,
+ ImageButton::ALIGN_BOTTOM);
+ gfx::Size minimize_button_size = minimize_button_->GetPreferredSize();
+ minimize_button_->SetBounds(
+ next_button_x - minimize_button_size.width(), caption_y,
+ minimize_button_size.width(),
+ minimize_button_size.height());
+
+ normal_part = IDR_CLOSE;
+ hot_part = IDR_CLOSE_H;
+ pushed_part = IDR_CLOSE_P;
+
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+
+ close_button_->SetImage(CustomButton::STATE_NORMAL,
+ rb.GetImageNamed(normal_part).ToImageSkia());
+ close_button_->SetImage(CustomButton::STATE_HOVERED,
+ rb.GetImageNamed(hot_part).ToImageSkia());
+ close_button_->SetImage(CustomButton::STATE_PRESSED,
+ rb.GetImageNamed(pushed_part).ToImageSkia());
}
void CustomFrameView::LayoutTitleBar() {
- DCHECK_GE(maximum_title_bar_x_, 0);
// The window title position is calculated based on the icon position, even
// when there is no icon.
gfx::Rect icon_bounds(IconBounds());
@@ -557,7 +553,7 @@ void CustomFrameView::LayoutTitleBar() {
// title from overlapping the 3D edge at the bottom of the titlebar.
title_bounds_.SetRect(title_x,
icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2),
- std::max(0, maximum_title_bar_x_ - kTitleCaptionSpacing -
+ std::max(0, minimize_button_->x() - kTitleCaptionSpacing -
title_x), title_height);
}
@@ -592,31 +588,4 @@ ImageButton* CustomFrameView::InitWindowCaptionButton(
return button;
}
-ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) {
- ImageButton* button = NULL;
- switch (frame_button) {
- case views::FRAME_BUTTON_MINIMIZE: {
- button = minimize_button_;
- break;
- }
- case views::FRAME_BUTTON_MAXIMIZE: {
- bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized();
- button = is_restored ? maximize_button_ : restore_button_;
- if (!should_show_maximize_button_) {
- // If we should not show the maximize/restore button, then we return
- // NULL as we don't want this button to become visible and to be laid
- // out.
- button->SetVisible(false);
- return NULL;
- }
- break;
- }
- case views::FRAME_BUTTON_CLOSE: {
- button = close_button_;
- break;
- }
- }
- return button;
-}
-
} // namespace views
diff --git a/ui/views/window/custom_frame_view.h b/ui/views/window/custom_frame_view.h
index fe5a3e4..1c25f04 100644
--- a/ui/views/window/custom_frame_view.h
+++ b/ui/views/window/custom_frame_view.h
@@ -9,7 +9,6 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/views/controls/button/button.h"
-#include "ui/views/window/frame_buttons.h"
#include "ui/views/window/non_client_view.h"
namespace gfx {
@@ -30,8 +29,8 @@ class Widget;
// rendering the non-standard window caption, border, and controls.
//
////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
- public ButtonListener {
+class CustomFrameView : public NonClientFrameView,
+ public ButtonListener {
public:
CustomFrameView();
virtual ~CustomFrameView();
@@ -60,8 +59,6 @@ class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE;
private:
- friend class CustomFrameViewTest;
-
// Returns the thickness of the border that makes up the window frame edges.
// This does not include any client edge.
int FrameBorderThickness() const;
@@ -107,13 +104,8 @@ class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
SkColor GetFrameColor() const;
const gfx::ImageSkia* GetFrameImage() const;
- // Performs the layout for the window control buttons based on the
- // configuration specified in WindowButtonOrderProvider. The sizing and
- // positions of the buttons affects LayoutTitleBar, call this beforehand.
+ // Layout various sub-components of this view.
void LayoutWindowControls();
-
- // Calculations depend on the positions of the window controls. Always call
- // LayoutWindowControls beforehand.
void LayoutTitleBar();
void LayoutClientView();
@@ -124,10 +116,6 @@ class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
int hot_image_id,
int pushed_image_id);
- // Returns the window caption button for the given FrameButton type, if it
- // should be visible. Otherwise NULL.
- ImageButton* GetImageButton(views::FrameButton button);
-
// The bounds of the client view, in this view's coordinates.
gfx::Rect client_view_bounds_;
@@ -152,11 +140,6 @@ class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
// Background painter for the window frame.
scoped_ptr<FrameBackground> frame_background_;
- // The horizontal boundaries for the title bar to layout within. Restricted
- // by the space used by the leading and trailing buttons.
- int minimum_title_bar_x_;
- int maximum_title_bar_x_;
-
DISALLOW_COPY_AND_ASSIGN(CustomFrameView);
};
diff --git a/ui/views/window/custom_frame_view_unittest.cc b/ui/views/window/custom_frame_view_unittest.cc
deleted file mode 100644
index c9a09b4..0000000
--- a/ui/views/window/custom_frame_view_unittest.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright 2014 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 "ui/views/window/custom_frame_view.h"
-
-#include <vector>
-
-#include "ui/views/controls/button/image_button.h"
-#include "ui/views/test/views_test_base.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_delegate.h"
-#include "ui/views/window/window_button_order_provider.h"
-
-namespace views {
-
-namespace {
-
-// Allows for the control of whether or not the widget can maximize or not.
-// This can be set after initial setup in order to allow testing of both forms
-// of delegates. By default this can maximize.
-class MaximizeStateControlDelegate : public WidgetDelegateView {
- public:
- MaximizeStateControlDelegate() : can_maximize_(true) {}
- virtual ~MaximizeStateControlDelegate() {}
-
- void set_can_maximize(bool can_maximize) {
- can_maximize_ = can_maximize;
- }
-
- // WidgetDelegate:
- virtual bool CanMaximize() const OVERRIDE { return can_maximize_; }
-
- private:
- bool can_maximize_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeStateControlDelegate);
-};
-
-} // namespace
-
-class CustomFrameViewTest : public ViewsTestBase {
- public:
- CustomFrameViewTest() {}
- virtual ~CustomFrameViewTest() {}
-
- CustomFrameView* custom_frame_view() {
- return custom_frame_view_;
- }
-
- MaximizeStateControlDelegate* maximize_state_control_delegate() {
- return maximize_state_control_delegate_;
- }
-
- Widget* widget() {
- return widget_;
- }
-
- // ViewsTestBase:
- virtual void SetUp() OVERRIDE;
- virtual void TearDown() OVERRIDE;
-
- protected:
- const std::vector<views::FrameButton>& leading_buttons() {
- return WindowButtonOrderProvider::GetInstance()->leading_buttons();
- }
-
- const std::vector<views::FrameButton>& trailing_buttons() {
- return WindowButtonOrderProvider::GetInstance()->trailing_buttons();
- }
-
- ImageButton* minimize_button() {
- return custom_frame_view_->minimize_button_;
- }
-
- ImageButton* maximize_button() {
- return custom_frame_view_->maximize_button_;
- }
-
- ImageButton* restore_button() {
- return custom_frame_view_->restore_button_;
- }
-
- ImageButton* close_button() {
- return custom_frame_view_->close_button_;
- }
-
- gfx::Rect title_bounds() {
- return custom_frame_view_->title_bounds_;
- }
-
- void SetWindowButtonOrder(
- const std::vector<views::FrameButton> leading_buttons,
- const std::vector<views::FrameButton> trailing_buttons);
-
- private:
- // Parent container for |custom_frame_view_|
- Widget* widget_;
-
- // Owned by |widget_|
- CustomFrameView* custom_frame_view_;
-
- // Delegate of |widget_| which controls maximizing
- MaximizeStateControlDelegate* maximize_state_control_delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(CustomFrameViewTest);
-};
-
-void CustomFrameViewTest::SetUp() {
- ViewsTestBase::SetUp();
-
- maximize_state_control_delegate_ = new MaximizeStateControlDelegate;
- widget_ = new Widget;
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
- params.delegate = maximize_state_control_delegate_;
- params.remove_standard_frame = true;
- params.top_level = true;
- widget_->Init(params);
-
- custom_frame_view_ = new CustomFrameView;
- widget_->non_client_view()->SetFrameView(custom_frame_view_);
-}
-
-void CustomFrameViewTest::TearDown() {
- widget_->CloseNow();
-
- ViewsTestBase::TearDown();
-}
-
-void CustomFrameViewTest::SetWindowButtonOrder(
- const std::vector<views::FrameButton> leading_buttons,
- const std::vector<views::FrameButton> trailing_buttons) {
- WindowButtonOrderProvider::GetInstance()->
- SetWindowButtonOrder(leading_buttons, trailing_buttons);
-}
-
-// Tests that there is a default button ordering before initialization causes
-// a configuration file check.
-TEST_F(CustomFrameViewTest, DefaultButtons) {
- const std::vector<views::FrameButton>& trailing = trailing_buttons();
- EXPECT_EQ(trailing.size(), 3u);
- EXPECT_TRUE(leading_buttons().empty());
- EXPECT_EQ(trailing[0], FRAME_BUTTON_MINIMIZE);
- EXPECT_EQ(trailing[1], FRAME_BUTTON_MAXIMIZE);
- EXPECT_EQ(trailing[2], FRAME_BUTTON_CLOSE);
-}
-
-// Tests that layout places the buttons in order, that the restore button is
-// hidden and the buttons are placed after the title.
-TEST_F(CustomFrameViewTest, DefaultButtonLayout) {
- Widget* parent = widget();
- CustomFrameView* view = custom_frame_view();
- view->Init(parent);
- parent->SetBounds(gfx::Rect(0, 0, 300, 100));
- parent->Show();
-
- EXPECT_LT(minimize_button()->x(), maximize_button()->x());
- EXPECT_LT(maximize_button()->x(), close_button()->x());
- EXPECT_FALSE(restore_button()->visible());
-
- EXPECT_GT(minimize_button()->x(),
- title_bounds().x() + title_bounds().width());
-}
-
-// Tests that setting the buttons to leading places them before the title.
-TEST_F(CustomFrameViewTest, LeadingButtonLayout) {
- Widget* parent = widget();
- CustomFrameView* view = custom_frame_view();
-
- std::vector<views::FrameButton> leading;
- leading.push_back(views::FRAME_BUTTON_CLOSE);
- leading.push_back(views::FRAME_BUTTON_MINIMIZE);
- leading.push_back(views::FRAME_BUTTON_MAXIMIZE);
-
- std::vector<views::FrameButton> trailing;
-
- SetWindowButtonOrder(leading, trailing);
-
- view->Init(parent);
- parent->SetBounds(gfx::Rect(0, 0, 300, 100));
- parent->Show();
- EXPECT_LT(close_button()->x(), minimize_button()->x());
- EXPECT_LT(minimize_button()->x(), maximize_button()->x());
- EXPECT_FALSE(restore_button()->visible());
- EXPECT_LT(maximize_button()->x() + maximize_button()->width(),
- title_bounds().x());
-}
-
-// Tests that layouts occuring while maximized swap the maximize button for the
-// restore button
-TEST_F(CustomFrameViewTest, MaximizeRevealsRestoreButton) {
- Widget* parent = widget();
- CustomFrameView* view = custom_frame_view();
- view->Init(parent);
- parent->SetBounds(gfx::Rect(0, 0, 300, 100));
- parent->Show();
-
- ASSERT_FALSE(restore_button()->visible());
- ASSERT_TRUE(maximize_button()->visible());
-
- parent->Maximize();
- view->Layout();
-
- EXPECT_TRUE(restore_button()->visible());
- EXPECT_FALSE(maximize_button()->visible());
-}
-
-// Tests that when the parent cannot maximize that the maximize button is not
-// visible
-TEST_F(CustomFrameViewTest, CannotMaximizeHidesButton) {
- Widget* parent = widget();
- CustomFrameView* view = custom_frame_view();
- MaximizeStateControlDelegate* delegate = maximize_state_control_delegate();
- delegate->set_can_maximize(false);
-
- view->Init(parent);
- parent->SetBounds(gfx::Rect(0, 0, 300, 100));
- parent->Show();
-
- EXPECT_FALSE(restore_button()->visible());
- EXPECT_FALSE(maximize_button()->visible());
-}
-
-// Tests that when maximized that the edge button has an increased width.
-TEST_F(CustomFrameViewTest, LargerEdgeButtonsWhenMaximized) {
- Widget* parent = widget();
- CustomFrameView* view = custom_frame_view();
-
- // Custom ordering to have a button on each edge.
- std::vector<views::FrameButton> leading;
- leading.push_back(views::FRAME_BUTTON_CLOSE);
- leading.push_back(views::FRAME_BUTTON_MAXIMIZE);
- std::vector<views::FrameButton> trailing;
- trailing.push_back(views::FRAME_BUTTON_MINIMIZE);
- SetWindowButtonOrder(leading, trailing);
-
- view->Init(parent);
- parent->SetBounds(gfx::Rect(0, 0, 300, 100));
- parent->Show();
-
- gfx::Rect close_button_initial_bounds = close_button()->bounds();
- gfx::Rect minimize_button_initial_bounds = minimize_button()->bounds();
-
- parent->Maximize();
- view->Layout();
-
- EXPECT_GT(close_button()->bounds().width(),
- close_button_initial_bounds.width());
- EXPECT_GT(minimize_button()->bounds().width(),
- minimize_button_initial_bounds.width());
-}
-
-} // namespace views
diff --git a/ui/views/window/window_button_order_provider.cc b/ui/views/window/window_button_order_provider.cc
deleted file mode 100644
index b1ac70e4..0000000
--- a/ui/views/window/window_button_order_provider.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 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 "ui/views/window/window_button_order_provider.h"
-
-namespace views {
-
-// static
-WindowButtonOrderProvider* WindowButtonOrderProvider::instance_ = NULL;
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowButtonOrderProvider, public:
-
-// static
-WindowButtonOrderProvider* WindowButtonOrderProvider::GetInstance() {
- if (!instance_)
- instance_ = new WindowButtonOrderProvider;
- return instance_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowButtonOrderProvider, protected:
-
-WindowButtonOrderProvider::WindowButtonOrderProvider() {
- trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
- trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE);
- trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE);
-}
-
-WindowButtonOrderProvider::~WindowButtonOrderProvider() {
-}
-
-void WindowButtonOrderProvider::SetWindowButtonOrder(
- const std::vector<views::FrameButton>& leading_buttons,
- const std::vector<views::FrameButton>& trailing_buttons) {
- leading_buttons_ = leading_buttons;
- trailing_buttons_ = trailing_buttons;
-}
-
-} // namespace views
diff --git a/ui/views/window/window_button_order_provider.h b/ui/views/window/window_button_order_provider.h
deleted file mode 100644
index f50a49f..0000000
--- a/ui/views/window/window_button_order_provider.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2014 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 UI_VIEWS_WINDOW_WINDOW_BUTTON_ORDER_PROVIDER_H_
-#define UI_VIEWS_WINDOW_WINDOW_BUTTON_ORDER_PROVIDER_H_
-
-#include <vector>
-
-#include "base/macros.h"
-#include "ui/views/views_export.h"
-#include "ui/views/window/frame_buttons.h"
-
-namespace views {
-
-// Stores the ordering of window control buttons. Provides a default ordering
-// of |FRAME_BUTTON_MINIMZE|, |FRAME_BUTTON_MAXIMIZE|, |FRAME_BUTTON_CLOSE|,
-// where all controls are on the trailing end of a window.
-//
-// On Linux users can provide configuration files to control the ordering. This
-// configuration is checked and overrides the defaults.
-class VIEWS_EXPORT WindowButtonOrderProvider {
- public:
- static WindowButtonOrderProvider* GetInstance();
-
- const std::vector<views::FrameButton>& leading_buttons() const {
- return leading_buttons_;
- }
-
- const std::vector<views::FrameButton>& trailing_buttons() const {
- return trailing_buttons_;
- }
-
- void SetWindowButtonOrder(
- const std::vector<views::FrameButton>& leading_buttons,
- const std::vector<views::FrameButton>& trailing_buttons);
-
- protected:
- WindowButtonOrderProvider();
- virtual ~WindowButtonOrderProvider();
-
- private:
- static WindowButtonOrderProvider* instance_;
-
- // Layout arrangement of the window caption buttons. On linux these will be
- // set via a WindowButtonOrderObserver. On other platforms a default
- // arrangement of a trailing minimize, maximize, close, will be set.
- std::vector<views::FrameButton> leading_buttons_;
- std::vector<views::FrameButton> trailing_buttons_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowButtonOrderProvider);
-};
-
-} // namespace views
-
-#endif // UI_VIEWS_WINDOW_WINDOW_BUTTON_ORDER_PROVIDER_H_