Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_AURA_WINDOW_H_ | 5 #ifndef UI_AURA_WINDOW_H_ |
| 6 #define UI_AURA_WINDOW_H_ | 6 #define UI_AURA_WINDOW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 class KeyEvent; | 39 class KeyEvent; |
| 40 class LayoutManager; | 40 class LayoutManager; |
| 41 class MouseEvent; | 41 class MouseEvent; |
| 42 class ToplevelWindowContainer; | 42 class ToplevelWindowContainer; |
| 43 class TouchEvent; | 43 class TouchEvent; |
| 44 class WindowDelegate; | 44 class WindowDelegate; |
| 45 class WindowObserver; | 45 class WindowObserver; |
| 46 | 46 |
| 47 namespace internal { | 47 namespace internal { |
| 48 class FocusManager; | 48 class FocusManager; |
| 49 class Shadow; | |
| 49 } | 50 } |
| 50 | 51 |
| 51 // Aura window implementation. Interesting events are sent to the | 52 // Aura window implementation. Interesting events are sent to the |
| 52 // WindowDelegate. | 53 // WindowDelegate. |
| 53 // TODO(beng): resolve ownership. | 54 // TODO(beng): resolve ownership. |
| 54 class AURA_EXPORT Window : public ui::LayerDelegate { | 55 class AURA_EXPORT Window : public ui::LayerDelegate { |
| 55 public: | 56 public: |
| 56 typedef std::vector<Window*> Windows; | 57 typedef std::vector<Window*> Windows; |
| 57 | 58 |
| 58 explicit Window(WindowDelegate* delegate); | 59 explicit Window(WindowDelegate* delegate); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 83 const gfx::Rect& bounds() const; | 84 const gfx::Rect& bounds() const; |
| 84 const gfx::Rect& restore_bounds() const { return restore_bounds_; } | 85 const gfx::Rect& restore_bounds() const { return restore_bounds_; } |
| 85 | 86 |
| 86 Window* parent() { return parent_; } | 87 Window* parent() { return parent_; } |
| 87 const Window* parent() const { return parent_; } | 88 const Window* parent() const { return parent_; } |
| 88 | 89 |
| 89 // The Window does not own this object. | 90 // The Window does not own this object. |
| 90 void set_user_data(void* user_data) { user_data_ = user_data; } | 91 void set_user_data(void* user_data) { user_data_ = user_data; } |
| 91 void* user_data() const { return user_data_; } | 92 void* user_data() const { return user_data_; } |
| 92 | 93 |
| 94 // Just made available for tests; outside callers shouldn't need to modify it. | |
| 95 const internal::Shadow* shadow() const { return shadow_.get(); } | |
| 96 | |
| 93 // Changes the visibility of the window. | 97 // Changes the visibility of the window. |
| 94 void Show(); | 98 void Show(); |
| 95 void Hide(); | 99 void Hide(); |
| 96 // Returns true if this window and all its ancestors are visible. | 100 // Returns true if this window and all its ancestors are visible. |
| 97 bool IsVisible() const; | 101 bool IsVisible() const; |
| 98 | 102 |
| 99 // Returns the window's bounds in screen coordinates. | 103 // Returns the window's bounds in screen coordinates. |
| 100 gfx::Rect GetScreenBounds() const; | 104 gfx::Rect GetScreenBounds() const; |
| 101 | 105 |
| 102 // Activates this window. Only top level windows can be activated. Requests | 106 // Activates this window. Only top level windows can be activated. Requests |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 void SetIntProperty(const char* name, int value); | 262 void SetIntProperty(const char* name, int value); |
| 259 | 263 |
| 260 // Returns the window property for given |name|. Returns NULL or 0 if | 264 // Returns the window property for given |name|. Returns NULL or 0 if |
| 261 // the property does not exist. | 265 // the property does not exist. |
| 262 // TODO(oshima): Returning 0 for non existing property is problematic. | 266 // TODO(oshima): Returning 0 for non existing property is problematic. |
| 263 // Fix ViewProp to be able to tell if the property exists and | 267 // Fix ViewProp to be able to tell if the property exists and |
| 264 // change it to -1. | 268 // change it to -1. |
| 265 void* GetProperty(const char* name) const; | 269 void* GetProperty(const char* name) const; |
| 266 int GetIntProperty(const char* name) const; | 270 int GetIntProperty(const char* name) const; |
| 267 | 271 |
| 272 // Sets whether a drop shadow should be displayed around this window or not. | |
| 273 // By default, shadows aren't displayed. It's safe to call this method before | |
| 274 // calling Init(). | |
| 275 void SetShadowVisible(bool visible); | |
| 276 | |
| 268 protected: | 277 protected: |
| 269 // Returns the desktop or NULL if we aren't yet attached to a desktop. | 278 // Returns the desktop or NULL if we aren't yet attached to a desktop. |
| 270 virtual Desktop* GetDesktop(); | 279 virtual Desktop* GetDesktop(); |
| 271 | 280 |
| 272 // Called when the |window| is detached from the desktop by being | 281 // Called when the |window| is detached from the desktop by being |
| 273 // removed from its parent. | 282 // removed from its parent. |
| 274 virtual void WindowDetachedFromDesktop(aura::Window* window); | 283 virtual void WindowDetachedFromDesktop(aura::Window* window); |
| 275 | 284 |
| 276 private: | 285 private: |
| 277 friend class LayoutManager; | 286 friend class LayoutManager; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 293 // Gets a Window (either this one or a subwindow) containing |local_point|. | 302 // Gets a Window (either this one or a subwindow) containing |local_point|. |
| 294 // If |return_tightest| is true, returns the tightest-containing (i.e. | 303 // If |return_tightest| is true, returns the tightest-containing (i.e. |
| 295 // furthest down the hierarchy) Window containing the point; otherwise, | 304 // furthest down the hierarchy) Window containing the point; otherwise, |
| 296 // returns the loosest. If |for_event_handling| is true, then hit-test masks | 305 // returns the loosest. If |for_event_handling| is true, then hit-test masks |
| 297 // and StopsEventPropagation() are honored; otherwise, only bounds checks are | 306 // and StopsEventPropagation() are honored; otherwise, only bounds checks are |
| 298 // performed. | 307 // performed. |
| 299 Window* GetWindowForPoint(const gfx::Point& local_point, | 308 Window* GetWindowForPoint(const gfx::Point& local_point, |
| 300 bool return_tightest, | 309 bool return_tightest, |
| 301 bool for_event_handling); | 310 bool for_event_handling); |
| 302 | 311 |
| 312 // Initialize |shadow_|. Init() must be called first. | |
| 313 void InitShadow(); | |
| 314 | |
| 303 // Overridden from ui::LayerDelegate: | 315 // Overridden from ui::LayerDelegate: |
| 304 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 316 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
| 305 | 317 |
| 306 WindowType type_; | 318 WindowType type_; |
| 307 | 319 |
| 308 WindowDelegate* delegate_; | 320 WindowDelegate* delegate_; |
| 309 | 321 |
| 310 // The original bounds of a maximized/fullscreen window. | 322 // The original bounds of a maximized/fullscreen window. |
| 311 gfx::Rect restore_bounds_; | 323 gfx::Rect restore_bounds_; |
| 312 | 324 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 342 | 354 |
| 343 ObserverList<WindowObserver> observers_; | 355 ObserverList<WindowObserver> observers_; |
| 344 | 356 |
| 345 // We're using ViewProp to store the property (for now) instead of | 357 // We're using ViewProp to store the property (for now) instead of |
| 346 // just using std::map because chrome is still using |ViewProp| class | 358 // just using std::map because chrome is still using |ViewProp| class |
| 347 // to create and access property. | 359 // to create and access property. |
| 348 // TODO(oshima): Consolidcate ViewProp and aura::window property | 360 // TODO(oshima): Consolidcate ViewProp and aura::window property |
| 349 // implementation. | 361 // implementation. |
| 350 std::map<const char*, void*> prop_map_; | 362 std::map<const char*, void*> prop_map_; |
| 351 | 363 |
| 364 // NULL if SetShadowVisible(true) has never been called. | |
| 365 scoped_ptr<internal::Shadow> shadow_; | |
|
sky
2011/11/15 04:49:13
Would it work to make the shadow a transient child
| |
| 366 | |
| 367 // Is |shadow_| currently being shown? | |
| 368 bool show_shadow_; | |
| 369 | |
| 352 DISALLOW_COPY_AND_ASSIGN(Window); | 370 DISALLOW_COPY_AND_ASSIGN(Window); |
| 353 }; | 371 }; |
| 354 | 372 |
| 355 } // namespace aura | 373 } // namespace aura |
| 356 | 374 |
| 357 #endif // UI_AURA_WINDOW_H_ | 375 #endif // UI_AURA_WINDOW_H_ |
| OLD | NEW |