| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "ui/base/events.h" | 16 #include "ui/base/events.h" |
| 17 #include "ui/base/ui_base_types.h" | |
| 18 #include "ui/aura/aura_export.h" | 17 #include "ui/aura/aura_export.h" |
| 19 #include "ui/gfx/compositor/layer.h" | 18 #include "ui/gfx/compositor/layer.h" |
| 20 #include "ui/gfx/compositor/layer_animator.h" | 19 #include "ui/gfx/compositor/layer_animator.h" |
| 21 #include "ui/gfx/compositor/layer_delegate.h" | 20 #include "ui/gfx/compositor/layer_delegate.h" |
| 22 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
| 23 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 24 | 23 |
| 25 class SkCanvas; | 24 class SkCanvas; |
| 26 | 25 |
| 27 namespace ui { | 26 namespace ui { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // The Window does not own this object. | 86 // The Window does not own this object. |
| 88 void set_user_data(void* user_data) { user_data_ = user_data; } | 87 void set_user_data(void* user_data) { user_data_ = user_data; } |
| 89 void* user_data() const { return user_data_; } | 88 void* user_data() const { return user_data_; } |
| 90 | 89 |
| 91 // Changes the visibility of the window. | 90 // Changes the visibility of the window. |
| 92 void Show(); | 91 void Show(); |
| 93 void Hide(); | 92 void Hide(); |
| 94 // Returns true if this window and all its ancestors are visible. | 93 // Returns true if this window and all its ancestors are visible. |
| 95 bool IsVisible() const; | 94 bool IsVisible() const; |
| 96 | 95 |
| 97 // Maximize the window. | |
| 98 void Maximize(); | |
| 99 | |
| 100 // Go into fullscreen mode. | |
| 101 void Fullscreen(); | |
| 102 | |
| 103 // Restore the window to its original bounds. | |
| 104 void Restore(); | |
| 105 | |
| 106 // Returns the window's bounds in screen coordinates. | 96 // Returns the window's bounds in screen coordinates. |
| 107 gfx::Rect GetScreenBounds() const; | 97 gfx::Rect GetScreenBounds() const; |
| 108 | 98 |
| 109 // Returns the window's show state. | |
| 110 ui::WindowShowState show_state() const { return show_state_; } | |
| 111 | |
| 112 // Activates this window. Only top level windows can be activated. Requests | 99 // Activates this window. Only top level windows can be activated. Requests |
| 113 // to activate a non-top level window are ignored. | 100 // to activate a non-top level window are ignored. |
| 114 void Activate(); | 101 void Activate(); |
| 115 | 102 |
| 116 // Deactivates this window. Only top level windows can be | 103 // Deactivates this window. Only top level windows can be |
| 117 // deactivated. Requests to deactivate a non-top level window are ignored. | 104 // deactivated. Requests to deactivate a non-top level window are ignored. |
| 118 void Deactivate(); | 105 void Deactivate(); |
| 119 | 106 |
| 120 // Returns true if this window is active. | 107 // Returns true if this window is active. |
| 121 bool IsActive() const; | 108 bool IsActive() const; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Releases a mouse capture. | 238 // Releases a mouse capture. |
| 252 void ReleaseCapture(); | 239 void ReleaseCapture(); |
| 253 | 240 |
| 254 // Returns true if this window has a mouse capture. | 241 // Returns true if this window has a mouse capture. |
| 255 bool HasCapture(); | 242 bool HasCapture(); |
| 256 | 243 |
| 257 // Returns the first ancestor whose parent window returns true from | 244 // Returns the first ancestor whose parent window returns true from |
| 258 // IsToplevelWindowContainer. | 245 // IsToplevelWindowContainer. |
| 259 Window* GetToplevelWindow(); | 246 Window* GetToplevelWindow(); |
| 260 | 247 |
| 261 // Returns true if this window is fullscreen or contains a fullscreen window. | 248 // Sets the window property |value| for given |name|. Setting NULL or 0 |
| 262 bool IsOrContainsFullscreenWindow() const; | |
| 263 | |
| 264 // Sets the window property |value| for given |name|. Setting NULL | |
| 265 // removes the property. It uses |ui::ViewProp| to store the property. | 249 // removes the property. It uses |ui::ViewProp| to store the property. |
| 266 // Please see the description of |prop_map_| for more details. | 250 // Please see the description of |prop_map_| for more details. |
| 267 void SetProperty(const char* name, void* value); | 251 void SetProperty(const char* name, void* value); |
| 252 void SetIntProperty(const char* name, int value); |
| 268 | 253 |
| 269 // Returns the window property for given |name|. Returns NULL if | 254 // Returns the window property for given |name|. Returns NULL or 0 if |
| 270 // the property does not exist. | 255 // the property does not exist. |
| 256 // TODO(oshima): Returning 0 for non existing property is problematic. |
| 257 // Fix ViewProp to be able to tell if the property exists and |
| 258 // change it to -1. |
| 271 void* GetProperty(const char* name) const; | 259 void* GetProperty(const char* name) const; |
| 260 int GetIntProperty(const char* name) const; |
| 272 | 261 |
| 273 protected: | 262 protected: |
| 274 // Returns the desktop or NULL if we aren't yet attached to a desktop. | 263 // Returns the desktop or NULL if we aren't yet attached to a desktop. |
| 275 virtual Desktop* GetDesktop(); | 264 virtual Desktop* GetDesktop(); |
| 276 | 265 |
| 277 private: | 266 private: |
| 278 friend class LayoutManager; | 267 friend class LayoutManager; |
| 279 | 268 |
| 280 // Changes the bounds of the window without condition. | 269 // Changes the bounds of the window without condition. |
| 281 void SetBoundsInternal(const gfx::Rect& new_bounds); | 270 void SetBoundsInternal(const gfx::Rect& new_bounds); |
| 282 | 271 |
| 283 // Updates the visible state of the layer, but does not make visible-state | 272 // Updates the visible state of the layer, but does not make visible-state |
| 284 // specific changes. Called from Show()/Hide(). | 273 // specific changes. Called from Show()/Hide(). |
| 285 void SetVisible(bool visible); | 274 void SetVisible(bool visible); |
| 286 | 275 |
| 287 // Schedules a paint for the Window's entire bounds. | 276 // Schedules a paint for the Window's entire bounds. |
| 288 void SchedulePaint(); | 277 void SchedulePaint(); |
| 289 | 278 |
| 290 // This window is currently stopping event propagation for any windows behind | 279 // This window is currently stopping event propagation for any windows behind |
| 291 // it in the z-order. | 280 // it in the z-order. |
| 292 bool StopsEventPropagation() const; | 281 bool StopsEventPropagation() const; |
| 293 | 282 |
| 294 // Update the show state and restore bounds. Returns false | |
| 295 // if |new_show_state| is same as current show state. | |
| 296 bool UpdateShowStateAndRestoreBounds(ui::WindowShowState new_show_state); | |
| 297 | |
| 298 // Gets a Window (either this one or a subwindow) containing |local_point|. | 283 // Gets a Window (either this one or a subwindow) containing |local_point|. |
| 299 // If |return_tightest| is true, returns the tightest-containing (i.e. | 284 // If |return_tightest| is true, returns the tightest-containing (i.e. |
| 300 // furthest down the hierarchy) Window containing the point; otherwise, | 285 // furthest down the hierarchy) Window containing the point; otherwise, |
| 301 // returns the loosest. If |for_event_handling| is true, then hit-test masks | 286 // returns the loosest. If |for_event_handling| is true, then hit-test masks |
| 302 // and StopsEventPropagation() are honored; otherwise, only bounds checks are | 287 // and StopsEventPropagation() are honored; otherwise, only bounds checks are |
| 303 // performed. | 288 // performed. |
| 304 Window* GetWindowForPoint(const gfx::Point& local_point, | 289 Window* GetWindowForPoint(const gfx::Point& local_point, |
| 305 bool return_tightest, | 290 bool return_tightest, |
| 306 bool for_event_handling); | 291 bool for_event_handling); |
| 307 | 292 |
| 308 // Overridden from ui::LayerDelegate: | 293 // Overridden from ui::LayerDelegate: |
| 309 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 294 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
| 310 virtual void OnLayerAnimationEnded( | 295 virtual void OnLayerAnimationEnded( |
| 311 const ui::LayerAnimationSequence* animation) OVERRIDE; | 296 const ui::LayerAnimationSequence* animation) OVERRIDE; |
| 312 | 297 |
| 313 int type_; | 298 int type_; |
| 314 | 299 |
| 315 WindowDelegate* delegate_; | 300 WindowDelegate* delegate_; |
| 316 | 301 |
| 317 ui::WindowShowState show_state_; | |
| 318 | |
| 319 // The original bounds of a maximized/fullscreen window. | 302 // The original bounds of a maximized/fullscreen window. |
| 320 gfx::Rect restore_bounds_; | 303 gfx::Rect restore_bounds_; |
| 321 | 304 |
| 322 // The minimum size of the window a user can resize to. | 305 // The minimum size of the window a user can resize to. |
| 323 gfx::Size minimum_size_; | 306 gfx::Size minimum_size_; |
| 324 | 307 |
| 325 scoped_ptr<ui::Layer> layer_; | 308 scoped_ptr<ui::Layer> layer_; |
| 326 | 309 |
| 327 // The Window's parent. | 310 // The Window's parent. |
| 328 Window* parent_; | 311 Window* parent_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 355 // TODO(oshima): Consolidcate ViewProp and aura::window property | 338 // TODO(oshima): Consolidcate ViewProp and aura::window property |
| 356 // implementation. | 339 // implementation. |
| 357 std::map<const char*, ui::ViewProp*> prop_map_; | 340 std::map<const char*, ui::ViewProp*> prop_map_; |
| 358 | 341 |
| 359 DISALLOW_COPY_AND_ASSIGN(Window); | 342 DISALLOW_COPY_AND_ASSIGN(Window); |
| 360 }; | 343 }; |
| 361 | 344 |
| 362 } // namespace aura | 345 } // namespace aura |
| 363 | 346 |
| 364 #endif // UI_AURA_WINDOW_H_ | 347 #endif // UI_AURA_WINDOW_H_ |
| OLD | NEW |