forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aura: Add an EasyResizeWindowTargeter.
Add EasyResizeWindowTargeter to allow easily resizing windows with mouse/touch with the new event-dispatch code. This will eventually allow getting rid of Window::SetHitTestBoundsOverrideOuter() once the new event-dispatch code is used for all event types. This patch installs an EasyResizeWindowTargeter for the shelf and status-area widgets. Subsequent CLs will install such targeters for the toplevel windows too. Collateral change includes adding some dependencies on wm_public (in DEPS and gyp). BUG=318879 R=ben@chromium.org Review URL: https://codereview.chromium.org/118553004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243177 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
sadrul@chromium.org
committed
Jan 6, 2014
1 parent
4ef896f
commit 3b66a3c
Showing
10 changed files
with
339 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include_rules = [ | ||
"+ui/aura", | ||
"+ui/gfx", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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/wm/public/easy_resize_window_targeter.h" | ||
|
||
#include "ui/aura/window.h" | ||
#include "ui/gfx/geometry/insets_f.h" | ||
#include "ui/gfx/geometry/rect.h" | ||
|
||
namespace wm { | ||
|
||
EasyResizeWindowTargeter::EasyResizeWindowTargeter( | ||
aura::Window* container, | ||
const gfx::Insets& mouse_extend, | ||
const gfx::Insets& touch_extend) | ||
: container_(container), | ||
mouse_extend_(mouse_extend), | ||
touch_extend_(touch_extend) { | ||
} | ||
|
||
EasyResizeWindowTargeter::~EasyResizeWindowTargeter() { | ||
} | ||
|
||
bool EasyResizeWindowTargeter::EventLocationInsideBounds( | ||
aura::Window* window, | ||
const ui::LocatedEvent& event) const { | ||
// Use the extended bounds only for immediate child windows of |container_|. | ||
// Use the default targetter otherwise. | ||
if (window->parent() == container_ && (!window->transient_parent() || | ||
window->transient_parent() == container_)) { | ||
gfx::RectF bounds(window->bounds()); | ||
gfx::Transform transform = window->layer()->transform(); | ||
transform.TransformRect(&bounds); | ||
if (event.IsTouchEvent() || event.IsGestureEvent()) { | ||
bounds.Inset(touch_extend_); | ||
} else { | ||
bounds.Inset(mouse_extend_); | ||
} | ||
|
||
// Note that |event|'s location is in the |container_|'s coordinate system, | ||
// as is |bounds|. | ||
return bounds.Contains(event.location()); | ||
} | ||
return WindowTargeter::EventLocationInsideBounds(window, event); | ||
} | ||
|
||
} // namespace wm |
Oops, something went wrong.