diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/window.cc | 26 | ||||
-rw-r--r-- | ui/aura/window.h | 36 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 4 | ||||
-rw-r--r-- | ui/oak/oak_aura_window_display.cc | 16 | ||||
-rw-r--r-- | ui/oak/oak_pretty_print.cc | 6 | ||||
-rw-r--r-- | ui/oak/oak_pretty_print.h | 3 |
6 files changed, 48 insertions, 43 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 0d609a3..b67b2b2 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -55,9 +55,7 @@ Window::Window(WindowDelegate* delegate) id_(-1), transparent_(false), user_data_(NULL), - ignore_events_(false), - hit_test_bounds_override_outer_(0), - hit_test_bounds_override_inner_(0) { + ignore_events_(false) { } Window::~Window() { @@ -374,18 +372,6 @@ void Window::RemoveObserver(WindowObserver* observer) { observers_.RemoveObserver(observer); } -void Window::SetHitTestBoundsOverride(int outer, int inner) { - DCHECK(outer >= 0); - DCHECK(inner >= 0); - hit_test_bounds_override_outer_ = outer; - hit_test_bounds_override_inner_ = inner; -} - -void Window::GetHitTestBoundsOverride(int* outer, int* inner) { - *outer = hit_test_bounds_override_outer_; - *inner = hit_test_bounds_override_inner_; -} - bool Window::ContainsPointInRoot(const gfx::Point& point_in_root) { Window* root_window = GetRootWindow(); if (!root_window) @@ -404,8 +390,7 @@ bool Window::HitTest(const gfx::Point& local_point) { // Expand my bounds for hit testing (override is usually zero but it's // probably cheaper to do the math every time than to branch). gfx::Rect local_bounds(gfx::Point(), bounds().size()); - local_bounds.Inset(-hit_test_bounds_override_outer_, - -hit_test_bounds_override_outer_); + local_bounds.Inset(hit_test_bounds_override_outer_); // TODO(beng): hittest masks. return local_bounds.Contains(local_point); } @@ -638,11 +623,10 @@ Window* Window::GetWindowForPoint(const gfx::Point& local_point, // Check if I should claim this event and not pass it to my children because // the location is inside my hit test override area. For details, see - // SetHitTestBoundsOverride(). - if (for_event_handling && hit_test_bounds_override_inner_ != 0) { + // set_hit_test_bounds_override_inner(). + if (for_event_handling && !hit_test_bounds_override_inner_.empty()) { gfx::Rect inset_local_bounds(gfx::Point(), bounds().size()); - inset_local_bounds.Inset(hit_test_bounds_override_inner_, - hit_test_bounds_override_inner_); + inset_local_bounds.Inset(hit_test_bounds_override_inner_); // We know we're inside the normal local bounds, so if we're outside the // inset bounds we must be in the special hit test override area. DCHECK(HitTest(local_point)); diff --git a/ui/aura/window.h b/ui/aura/window.h index c50bc20..5a865cf 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -20,6 +20,7 @@ #include "ui/gfx/compositor/layer_animator.h" #include "ui/gfx/compositor/layer_delegate.h" #include "ui/gfx/compositor/layer_type.h" +#include "ui/gfx/insets.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" @@ -220,15 +221,26 @@ class AURA_EXPORT Window : public ui::LayerDelegate { void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; } - // Sets the window to grab hits for an area extending |outer| pixels outside - // its bounds and |inner| pixels inside its bounds (even if that inner region - // overlaps a child window). This can be used to create an invisible non- - // client area, for example if your windows have no visible frames but still - // need to have resize edges. Both |outer| and |inner| must be >= 0. - void SetHitTestBoundsOverride(int outer, int inner); - - // Returns the hit test bounds override set above. - void GetHitTestBoundsOverride(int* outer, int* inner); + // Sets the window to grab hits for an area extending -|insets| pixels outside + // its bounds. This can be used to create an invisible non- client area, for + // example if your windows have no visible frames but still need to have + // resize edges. + void set_hit_test_bounds_override_outer(const gfx::Insets& insets) { + hit_test_bounds_override_outer_ = insets; + } + gfx::Insets hit_test_bounds_override_outer() const { + return hit_test_bounds_override_outer_; + } + + // Sets the window to grab hits for an area extending |insets| pixels inside + // its bounds (even if that inner region overlaps a child window). This can be + // used to create an invisible non-client area that overlaps the client area. + void set_hit_test_bounds_override_inner(const gfx::Insets& insets) { + hit_test_bounds_override_inner_ = insets; + } + gfx::Insets hit_test_bounds_override_inner() const { + return hit_test_bounds_override_inner_; + } // 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 @@ -422,9 +434,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // Makes the window pass all events through to any windows behind it. bool ignore_events_; - // See SetHitTestBoundsOverride(). - int hit_test_bounds_override_outer_; - int hit_test_bounds_override_inner_; + // See set_hit_test_outer_override(). + gfx::Insets hit_test_bounds_override_outer_; + gfx::Insets hit_test_bounds_override_inner_; ObserverList<WindowObserver> observers_; diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 9ea8a21..3eb940c 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -282,7 +282,7 @@ TEST_F(WindowTest, HitTest) { EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1))); // We can expand the bounds slightly to track events outside our border. - w1.SetHitTestBoundsOverride(1, 0); + w1.set_hit_test_bounds_override_outer(gfx::Insets(-1, -1, -1, -1)); EXPECT_TRUE(w1.HitTest(gfx::Point(-1, -1))); EXPECT_FALSE(w1.HitTest(gfx::Point(-2, -2))); @@ -330,7 +330,7 @@ TEST_F(WindowTest, GetEventHandlerForPointWithOverride) { // We can override the hit test bounds of the parent to make the parent grab // events along that edge. - parent->SetHitTestBoundsOverride(0, 1); + parent->set_hit_test_bounds_override_inner(gfx::Insets(1, 1, 1, 1)); EXPECT_EQ(parent.get(), parent->GetEventHandlerForPoint(gfx::Point(0, 0))); EXPECT_EQ(child.get(), parent->GetEventHandlerForPoint(gfx::Point(1, 1))); } diff --git a/ui/oak/oak_aura_window_display.cc b/ui/oak/oak_aura_window_display.cc index fce9406..a6e0fbe0 100644 --- a/ui/oak/oak_aura_window_display.cc +++ b/ui/oak/oak_aura_window_display.cc @@ -34,7 +34,8 @@ ROW_TRANSIENTPARENT, ROW_USERDATA, ROW_IGNOREEVENTS, ROW_CANFOCUS, -ROW_HITTESTBOUNDSOVERRIDE, +ROW_HITTESTBOUNDSOVERRIDEOUTER, +ROW_HITTESTBOUNDSOVERRIDEINNER, ROW_COUNT }; @@ -141,13 +142,12 @@ string16 OakAuraWindowDisplay::GetText(int row, int column_id) { window_->CanReceiveEvents()); case ROW_CANFOCUS: return PropertyWithBool("Can Focus: ", window_->CanFocus()); - case ROW_HITTESTBOUNDSOVERRIDE: { - int outer, inner; - window_->GetHitTestBoundsOverride(&outer, &inner); - return ASCIIToUTF16( - base::StringPrintf("Hit test bounds override: outer %d, inner %d", - outer, inner)); - } + case ROW_HITTESTBOUNDSOVERRIDEOUTER: + return PropertyWithInsets("Hit test bounds override outer: ", + window_->hit_test_bounds_override_outer()); + case ROW_HITTESTBOUNDSOVERRIDEINNER: + return PropertyWithInsets("Hit test bounds override inner: ", + window_->hit_test_bounds_override_inner()); default: NOTREACHED(); break; diff --git a/ui/oak/oak_pretty_print.cc b/ui/oak/oak_pretty_print.cc index c9c5b30..3b5cdb0 100644 --- a/ui/oak/oak_pretty_print.cc +++ b/ui/oak/oak_pretty_print.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "base/string_number_conversions.h" #include "base/stringprintf.h" +#include "ui/gfx/insets.h" #include "ui/gfx/rect.h" namespace oak { @@ -33,5 +34,10 @@ string16 PropertyWithBounds(const std::string& prefix, return ASCIIToUTF16(prefix + bounds.ToString()); } +string16 PropertyWithInsets(const std::string& prefix, + const gfx::Insets& insets) { + return ASCIIToUTF16(prefix + insets.ToString()); +} + } // namespace internal } // namespace oak diff --git a/ui/oak/oak_pretty_print.h b/ui/oak/oak_pretty_print.h index b99cd23..6d753bc 100644 --- a/ui/oak/oak_pretty_print.h +++ b/ui/oak/oak_pretty_print.h @@ -5,6 +5,7 @@ #include "base/string16.h" namespace gfx { +class Insets; class Rect; } @@ -17,6 +18,8 @@ string16 PropertyWithInteger(const std::string& prefix, int value); string16 PropertyWithVoidStar(const std::string& prefix, void* ptr); string16 PropertyWithBool(const std::string& prefix, bool value); string16 PropertyWithBounds(const std::string& prefix, const gfx::Rect& bounds); +string16 PropertyWithInsets(const std::string& prefix, + const gfx::Insets& insets); } // namespace internal } // namespace oak |