Index: apps/ui/views/shell_window_frame_view.cc |
diff --git a/chrome/browser/ui/views/extensions/shell_window_frame_view.cc b/apps/ui/views/shell_window_frame_view.cc |
similarity index 85% |
rename from chrome/browser/ui/views/extensions/shell_window_frame_view.cc |
rename to apps/ui/views/shell_window_frame_view.cc |
index 7143e1156a36988730e34466670c3e25f0fe11da..d0e15b5216ab78712b62097ba90821b206e9ee2e 100644 |
--- a/chrome/browser/ui/views/extensions/shell_window_frame_view.cc |
+++ b/apps/ui/views/shell_window_frame_view.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" |
+#include "apps/ui/views/shell_window_frame_view.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/ui/views/apps/native_app_window_views.h" |
stevenjb
2013/10/12 00:16:42
Is the intention to check this in with the chrome
|
@@ -21,30 +21,17 @@ |
#include "ui/views/views_delegate.h" |
#include "ui/views/widget/widget.h" |
-#if defined(OS_WIN) && !defined(USE_AURA) |
-#include "chrome/browser/shell_integration.h" |
-#include "chrome/browser/web_applications/web_app.h" |
-#include "ui/base/win/shell.h" |
-#endif |
- |
-#if defined(USE_ASH) |
-#include "ash/ash_constants.h" |
-#include "chrome/browser/ui/ash/ash_util.h" |
-#include "ui/aura/env.h" |
-#endif |
- |
#if defined(USE_AURA) |
+#include "ui/aura/env.h" |
#include "ui/aura/window.h" |
#endif |
namespace { |
-const int kResizeInsideBoundsSize = 5; |
-const int kResizeAreaCornerSize = 16; |
- |
// Height of the chrome-style caption, in pixels. |
const int kCaptionHeight = 25; |
} // namespace |
+namespace apps { |
const char ShellWindowFrameView::kViewClassName[] = |
"browser/ui/views/extensions/ShellWindowFrameView"; |
@@ -52,14 +39,25 @@ const char ShellWindowFrameView::kViewClassName[] = |
ShellWindowFrameView::ShellWindowFrameView(NativeAppWindowViews* window) |
: window_(window), |
frame_(NULL), |
- close_button_(NULL) { |
+ close_button_(NULL), |
+ maximize_button_(NULL), |
+ restore_button_(NULL), |
+ minimize_button_(NULL), |
+ resize_inside_bounds_size_(0), |
+ resize_area_corner_size_(0) { |
} |
ShellWindowFrameView::~ShellWindowFrameView() { |
} |
-void ShellWindowFrameView::Init(views::Widget* frame) { |
+void ShellWindowFrameView::Init(views::Widget* frame, |
+ int resize_inside_bounds_size, |
+ int resize_outside_bounds_size, |
+ int resize_outside_scale_for_touch, |
+ int resize_area_corner_size) { |
frame_ = frame; |
+ resize_inside_bounds_size_ = resize_inside_bounds_size; |
+ resize_area_corner_size_ = resize_area_corner_size; |
if (!window_->frameless()) { |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
@@ -108,29 +106,23 @@ void ShellWindowFrameView::Init(views::Widget* frame) { |
} |
#if defined(USE_AURA) |
- int resize_inside_bounds_size = kResizeInsideBoundsSize; |
aura::Window* window = frame->GetNativeWindow(); |
-#if defined(USE_ASH) |
- if (chrome::IsNativeWindowInAsh(window)) { |
- gfx::Insets mouse_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, |
- -ash::kResizeOutsideBoundsSize, |
- -ash::kResizeOutsideBoundsSize, |
- -ash::kResizeOutsideBoundsSize); |
- gfx::Insets touch_insets = mouse_insets.Scale( |
- ash::kResizeOutsideBoundsScaleForTouch); |
+ // Some Aura implementations (Ash) allow resize handles outside the window. |
+ if (resize_outside_bounds_size > 0) { |
+ gfx::Insets mouse_insets = gfx::Insets(-resize_outside_bounds_size, |
+ -resize_outside_bounds_size, |
+ -resize_outside_bounds_size, |
+ -resize_outside_bounds_size); |
+ gfx::Insets touch_insets = |
+ mouse_insets.Scale(resize_outside_scale_for_touch); |
// Ensure we get resize cursors for a few pixels outside our bounds. |
window->SetHitTestBoundsOverrideOuter(mouse_insets, touch_insets); |
- |
- // If the window is in ash, the inside area used for resizing will be |
- // smaller due to the fact that outside area is also used for resizing. |
- resize_inside_bounds_size = ash::kResizeInsideBoundsSize; |
} |
-#endif |
// Ensure we get resize cursors just inside our bounds as well. |
// TODO(jeremya): do we need to update these when in fullscreen/maximized? |
window->set_hit_test_bounds_override_inner( |
- gfx::Insets(resize_inside_bounds_size, resize_inside_bounds_size, |
- resize_inside_bounds_size, resize_inside_bounds_size)); |
+ gfx::Insets(resize_inside_bounds_size_, resize_inside_bounds_size_, |
+ resize_inside_bounds_size_, resize_inside_bounds_size_)); |
#endif |
} |
@@ -170,24 +162,19 @@ int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
if (frame_->IsFullscreen()) |
return HTCLIENT; |
- int resize_inside_bounds_size = kResizeInsideBoundsSize; |
- int resize_area_corner_size = kResizeAreaCornerSize; |
- |
-#if defined(USE_ASH) |
+ gfx::Rect expanded_bounds = bounds(); |
+#if defined(USE_AURA) |
+ // Some Aura implementations (Ash) optionally allow resize handles just |
+ // outside the window bounds. |
aura::Window* window = frame_->GetNativeWindow(); |
- if (chrome::IsNativeWindowInAsh(window)) { |
- gfx::Rect expanded_bounds = bounds(); |
- int outside_bounds = ash::kResizeOutsideBoundsSize; |
- if (aura::Env::GetInstance()->is_touch_down()) |
- outside_bounds *= ash::kResizeOutsideBoundsScaleForTouch; |
- expanded_bounds.Inset(-outside_bounds, -outside_bounds); |
- if (!expanded_bounds.Contains(point)) |
James Cook
2013/10/11 23:05:06
This was subtly wrong - the code should have been
|
- return HTNOWHERE; |
- |
- resize_inside_bounds_size = ash::kResizeInsideBoundsSize; |
- resize_area_corner_size = ash::kResizeAreaCornerSize; |
- } |
+ if (aura::Env::GetInstance()->is_touch_down()) |
+ expanded_bounds.Inset(window->hit_test_bounds_override_outer_touch()); |
James Cook
2013/10/11 23:05:06
These bounds override insets are 0 in the normal (
|
+ else |
+ expanded_bounds.Inset(window->hit_test_bounds_override_outer_mouse()); |
#endif |
+ // Points outside the (possibly expanded) bounds can be discarded. |
+ if (!expanded_bounds.Contains(point)) |
+ return HTNOWHERE; |
// Check the frame first, as we allow a small area overlapping the contents |
// to be used for resize handles. |
@@ -198,12 +185,12 @@ int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
// fullscreen, as it can't be resized in those states. |
int resize_border = |
(frame_->IsMaximized() || frame_->IsFullscreen()) ? 0 : |
- resize_inside_bounds_size; |
+ resize_inside_bounds_size_; |
int frame_component = GetHTComponentForFrame(point, |
resize_border, |
resize_border, |
- resize_area_corner_size, |
- resize_area_corner_size, |
+ resize_area_corner_size_, |
+ resize_area_corner_size_, |
can_ever_resize); |
if (frame_component != HTNOWHERE) |
return frame_component; |
@@ -368,3 +355,5 @@ void ShellWindowFrameView::ButtonPressed(views::Button* sender, |
else if (sender == minimize_button_) |
frame_->Minimize(); |
} |
+ |
+} // namespace apps |