summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 22:01:44 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 22:01:44 +0000
commit65992304784193ff1fbf313d5f9abcb23458d6c4 (patch)
treeeb8382ec28785da669c84a3070ded12e0a5f615a /ui
parent3970c4236565a19dbf42c3bff59419ac85d89832 (diff)
downloadchromium_src-65992304784193ff1fbf313d5f9abcb23458d6c4.zip
chromium_src-65992304784193ff1fbf313d5f9abcb23458d6c4.tar.gz
chromium_src-65992304784193ff1fbf313d5f9abcb23458d6c4.tar.bz2
Aura: Update window frames, allow resize from outside window
* New window frames, still behind a flag as there's more refinement to do for incognito, popups, and maximized windows. * Translucent frames now only require a single layer the size of the window instead of two. We may be able to cut the layer size in the future to the area of the window header + toolbar * Rewrite BrowserNonClientFrameViewAura * Use updated art assets from crrev.com/124602 * Allow windows optionally to specify that hit tests should include a region a few pixels outside the window. For Aura browser windows this area acts as non-client area resize handles which we need because the window frame borders are now very thin or not present at all. BUG=113075 TEST=manual, visual inspection of browser active, inactive, incognito, popup, hosted, and app windows. Updated aura_unittest for Window to check the expanded bounds. Review URL: https://chromiumcodereview.appspot.com/9580001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/window.cc7
-rw-r--r--ui/aura/window.h9
-rw-r--r--ui/aura/window_unittest.cc7
-rw-r--r--ui/gfx/compositor/debug_utils.cc2
-rw-r--r--ui/resources/ui_resources.grd29
-rw-r--r--ui/views/widget/root_view.cc6
6 files changed, 56 insertions, 4 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index febf221..60977c8 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -54,7 +54,8 @@ Window::Window(WindowDelegate* delegate)
transparent_(false),
user_data_(NULL),
stops_event_propagation_(false),
- ignore_events_(false) {
+ ignore_events_(false),
+ hit_test_bounds_inset_(0) {
}
Window::~Window() {
@@ -401,8 +402,10 @@ bool Window::ContainsPoint(const gfx::Point& local_point) {
}
bool Window::HitTest(const gfx::Point& local_point) {
+ gfx::Rect local_bounds(gfx::Point(), bounds().size());
+ local_bounds.Inset(hit_test_bounds_inset_, hit_test_bounds_inset_);
// TODO(beng): hittest masks.
- return ContainsPoint(local_point);
+ return local_bounds.Contains(local_point);
}
Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) {
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 6411440..20a9f7e 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -225,6 +225,12 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; }
+ // When non-zero insets the window's bounds by |inset| when performing hit
+ // tests for event handling. Pass a negative value for |inset| to respond to
+ // events that occur slightly outside a window's bounds.
+ void set_hit_test_bounds_inset(int inset) { hit_test_bounds_inset_ = inset; }
+ int hit_test_bounds_inset() const { return hit_test_bounds_inset_; }
+
// Returns true if the |point_in_root| in root window's coordinate falls
// within this window's bounds. Returns false if the window is detached
// from root window.
@@ -411,6 +417,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
// Makes the window pass all events through to any windows behind it.
bool ignore_events_;
+ // Inset the window bounds by this amount when doing hit testing for events.
+ int hit_test_bounds_inset_;
+
ObserverList<WindowObserver> observers_;
std::map<const void*, intptr_t> prop_map_;
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index f78ed7c..48592f7 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -273,7 +273,7 @@ TEST_F(WindowTest, HitTest) {
Window w1(new ColorTestWindowDelegate(SK_ColorWHITE));
w1.set_id(1);
w1.Init(ui::Layer::LAYER_TEXTURED);
- w1.SetBounds(gfx::Rect(10, 10, 50, 50));
+ w1.SetBounds(gfx::Rect(10, 20, 50, 60));
w1.Show();
w1.SetParent(NULL);
@@ -281,6 +281,11 @@ TEST_F(WindowTest, HitTest) {
EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1)));
EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
+ // We can expand the bounds slightly to track events outside our border.
+ w1.set_hit_test_bounds_inset(-1);
+ EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1)));
+ EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2)));
+
// TODO(beng): clip Window to parent.
}
diff --git a/ui/gfx/compositor/debug_utils.cc b/ui/gfx/compositor/debug_utils.cc
index 422051e..1f9be6f 100644
--- a/ui/gfx/compositor/debug_utils.cc
+++ b/ui/gfx/compositor/debug_utils.cc
@@ -48,6 +48,8 @@ void PrintLayerHierarchyImp(const Layer* layer, int indent,
break;
case Layer::LAYER_TEXTURED:
buf << L" textured";
+ if (layer->fills_bounds_opaquely())
+ buf << L" opaque";
break;
case Layer::LAYER_SOLID_COLOR:
buf << L" solid";
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index 6aef94f..59df19e 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -196,13 +196,42 @@
<include name="IDR_AURA_WALLPAPER_8_THUMB" file="aura/wallpaper_8_thumb.jpg" type="BINDATA" />
<include name="IDR_AURA_WALLPAPER_9" file="aura/wallpaper_9.jpg" type="BINDATA" />
<include name="IDR_AURA_WALLPAPER_9_THUMB" file="aura/wallpaper_9_thumb.jpg" type="BINDATA" />
+ <!-- TODO(jamescook): Delete these two corners if we ship translucent frames on all platforms. -->
<include name="IDR_AURA_WINDOW_BOTTOM_LEFT" file="aura/window_bottom_left.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_BOTTOM_RIGHT" file="aura/window_bottom_right.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_BUTTON_SEPARATOR" file="aura/window_button_separator.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_CLOSE_ICON" file="aura/slab_close.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_CLOSE" file="aura/window_close_normal.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_CLOSE_H" file="aura/window_close_hot.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_CLOSE_P" file="aura/window_close_pressed.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_FULLSCREEN_CLOSE" file="aura/window_fullscreen_close.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_FULLSCREEN_RESTORE" file="aura/window_fullscreen_restore.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_FULLSCREEN_SEPARATOR" file="aura/window_fullscreen_separator.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_FULLSCREEN_SHADOW" file="aura/window_fullscreen_shadow.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_BASE_ACTIVE" file="aura/window_header_base_active.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_BASE_INACTIVE" file="aura/window_header_base_inactive.png" type="BINDATA" />
+ <!-- TODO(jamescook): We need updated incognito art for Aura. -->
+ <include name="IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE" file="aura/window_header_base_incognito_active.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_INACTIVE" file="aura/window_header_base_incognito_inactive.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_BOTTOM" file="aura/window_header_shade_bottom.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_BOTTOM_LEFT" file="aura/window_header_shade_bottom_left.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_BOTTOM_RIGHT" file="aura/window_header_shade_bottom_right.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_LEFT" file="aura/window_header_shade_left.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_MIDDLE" file="aura/window_header_shade_middle.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_RIGHT" file="aura/window_header_shade_right.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_TOP" file="aura/window_header_shade_top.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_TOP_LEFT" file="aura/window_header_shade_top_left.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_HEADER_SHADE_TOP_RIGHT" file="aura/window_header_shade_top_right.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZE" file="aura/window_maximize_normal.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZE_H" file="aura/window_maximize_hot.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZE_P" file="aura/window_maximize_pressed.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_CLOSE" file="aura/window_maximized_close_normal.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H" file="aura/window_maximized_close_hot.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P" file="aura/window_maximized_close_pressed.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_RESTORE" file="aura/window_maximized_restore_normal.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H" file="aura/window_maximized_restore_hot.png" type="BINDATA" />
+ <include name="IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P" file="aura/window_maximized_restore_pressed.png" type="BINDATA" />
+ <!-- TODO(jamescook): Delete these two corners if we ship translucent frames on all platforms. -->
<include name="IDR_AURA_WINDOW_TOP_LEFT" file="aura/window_top_left.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_TOP_RIGHT" file="aura/window_top_right.png" type="BINDATA" />
<include name="IDR_AURA_WINDOW_ZOOM_ICON" file="aura/slab_zoom.png" type="BINDATA" />
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index efb6361..1433273 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -305,7 +305,11 @@ void RootView::OnMouseMoved(const MouseEvent& event) {
widget_->SetCursor(mouse_move_handler_->GetCursor(moved_event));
} else if (mouse_move_handler_ != NULL) {
mouse_move_handler_->OnMouseExited(e);
- widget_->SetCursor(gfx::kNullCursor);
+ // On Aura the non-client area extends slightly outside the root view for
+ // some windows. Let the non-client cursor handling code set the cursor
+ // as we do above.
+ if (!(e.flags() & ui::EF_IS_NON_CLIENT))
+ widget_->SetCursor(gfx::kNullCursor);
}
}