OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_VIEWS_VIEW_H_ | 5 #ifndef UI_VIEWS_VIEW_H_ |
6 #define UI_VIEWS_VIEW_H_ | 6 #define UI_VIEWS_VIEW_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <set> | 13 #include <set> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
17 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
19 #include "base/macros.h" | 20 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "ui/accessibility/ax_enums.h" | 22 #include "ui/accessibility/ax_enums.h" |
23 #include "ui/base/accelerators/accelerator.h" | 23 #include "ui/base/accelerators/accelerator.h" |
24 #include "ui/base/dragdrop/drag_drop_types.h" | 24 #include "ui/base/dragdrop/drag_drop_types.h" |
25 #include "ui/base/dragdrop/drop_target_event.h" | 25 #include "ui/base/dragdrop/drop_target_event.h" |
26 #include "ui/base/dragdrop/os_exchange_data.h" | 26 #include "ui/base/dragdrop/os_exchange_data.h" |
27 #include "ui/base/ui_base_types.h" | 27 #include "ui/base/ui_base_types.h" |
28 #include "ui/compositor/layer_delegate.h" | 28 #include "ui/compositor/layer_delegate.h" |
29 #include "ui/compositor/layer_owner.h" | 29 #include "ui/compositor/layer_owner.h" |
30 #include "ui/compositor/paint_cache.h" | 30 #include "ui/compositor/paint_cache.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 // Sets whether this view paints to a layer. A view paints to a layer if | 308 // Sets whether this view paints to a layer. A view paints to a layer if |
309 // either of the following are true: | 309 // either of the following are true: |
310 // . the view has a non-identity transform. | 310 // . the view has a non-identity transform. |
311 // . SetPaintToLayer(true) has been invoked. | 311 // . SetPaintToLayer(true) has been invoked. |
312 // View creates the Layer only when it exists in a Widget with a non-NULL | 312 // View creates the Layer only when it exists in a Widget with a non-NULL |
313 // Compositor. | 313 // Compositor. |
314 void SetPaintToLayer(bool paint_to_layer); | 314 void SetPaintToLayer(bool paint_to_layer); |
315 | 315 |
316 // Overridden from ui::LayerOwner: | 316 // Overridden from ui::LayerOwner: |
317 scoped_ptr<ui::Layer> RecreateLayer() override; | 317 std::unique_ptr<ui::Layer> RecreateLayer() override; |
318 | 318 |
319 // RTL positioning ----------------------------------------------------------- | 319 // RTL positioning ----------------------------------------------------------- |
320 | 320 |
321 // Methods for accessing the bounds and position of the view, relative to its | 321 // Methods for accessing the bounds and position of the view, relative to its |
322 // parent. The position returned is mirrored if the parent view is using a RTL | 322 // parent. The position returned is mirrored if the parent view is using a RTL |
323 // layout. | 323 // layout. |
324 // | 324 // |
325 // NOTE: in the vast majority of the cases, the mirroring implementation is | 325 // NOTE: in the vast majority of the cases, the mirroring implementation is |
326 // transparent to the View subclasses and therefore you should use the | 326 // transparent to the View subclasses and therefore you should use the |
327 // bounds() accessor instead. | 327 // bounds() accessor instead. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // to paint itself via the various OnPaint*() event handlers and then paints | 497 // to paint itself via the various OnPaint*() event handlers and then paints |
498 // the hierarchy beneath it. | 498 // the hierarchy beneath it. |
499 void Paint(const ui::PaintContext& parent_context); | 499 void Paint(const ui::PaintContext& parent_context); |
500 | 500 |
501 // The background object is owned by this object and may be NULL. | 501 // The background object is owned by this object and may be NULL. |
502 void set_background(Background* b); | 502 void set_background(Background* b); |
503 const Background* background() const { return background_.get(); } | 503 const Background* background() const { return background_.get(); } |
504 Background* background() { return background_.get(); } | 504 Background* background() { return background_.get(); } |
505 | 505 |
506 // The border object is owned by this object and may be NULL. | 506 // The border object is owned by this object and may be NULL. |
507 virtual void SetBorder(scoped_ptr<Border> b); | 507 virtual void SetBorder(std::unique_ptr<Border> b); |
508 const Border* border() const { return border_.get(); } | 508 const Border* border() const { return border_.get(); } |
509 Border* border() { return border_.get(); } | 509 Border* border() { return border_.get(); } |
510 | 510 |
511 // Get the theme provider from the parent widget. | 511 // Get the theme provider from the parent widget. |
512 const ui::ThemeProvider* GetThemeProvider() const; | 512 const ui::ThemeProvider* GetThemeProvider() const; |
513 | 513 |
514 // Returns the NativeTheme to use for this View. This calls through to | 514 // Returns the NativeTheme to use for this View. This calls through to |
515 // GetNativeTheme() on the Widget this View is in, or provides a default | 515 // GetNativeTheme() on the Widget this View is in, or provides a default |
516 // theme if there's no widget. Warning: the default theme might not be | 516 // theme if there's no widget. Warning: the default theme might not be |
517 // correct; you should probably override OnNativeThemeChanged(). | 517 // correct; you should probably override OnNativeThemeChanged(). |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 // Convenience method to retrieve the InputMethod associated with the | 693 // Convenience method to retrieve the InputMethod associated with the |
694 // Widget that contains this view. | 694 // Widget that contains this view. |
695 ui::InputMethod* GetInputMethod() { | 695 ui::InputMethod* GetInputMethod() { |
696 return const_cast<ui::InputMethod*>( | 696 return const_cast<ui::InputMethod*>( |
697 const_cast<const View*>(this)->GetInputMethod()); | 697 const_cast<const View*>(this)->GetInputMethod()); |
698 } | 698 } |
699 const ui::InputMethod* GetInputMethod() const; | 699 const ui::InputMethod* GetInputMethod() const; |
700 | 700 |
701 // Sets a new ViewTargeter for the view, and returns the previous | 701 // Sets a new ViewTargeter for the view, and returns the previous |
702 // ViewTargeter. | 702 // ViewTargeter. |
703 scoped_ptr<ViewTargeter> SetEventTargeter(scoped_ptr<ViewTargeter> targeter); | 703 std::unique_ptr<ViewTargeter> SetEventTargeter( |
| 704 std::unique_ptr<ViewTargeter> targeter); |
704 | 705 |
705 // Returns the ViewTargeter installed on |this| if one exists, | 706 // Returns the ViewTargeter installed on |this| if one exists, |
706 // otherwise returns the ViewTargeter installed on our root view. | 707 // otherwise returns the ViewTargeter installed on our root view. |
707 // The return value is guaranteed to be non-null. | 708 // The return value is guaranteed to be non-null. |
708 ViewTargeter* GetEffectiveViewTargeter() const; | 709 ViewTargeter* GetEffectiveViewTargeter() const; |
709 | 710 |
710 ViewTargeter* targeter() const { return targeter_.get(); } | 711 ViewTargeter* targeter() const { return targeter_.get(); } |
711 | 712 |
712 // Overridden from ui::EventTarget: | 713 // Overridden from ui::EventTarget: |
713 bool CanAcceptEvent(const ui::Event& event) override; | 714 bool CanAcceptEvent(const ui::Event& event) override; |
714 ui::EventTarget* GetParentTarget() override; | 715 ui::EventTarget* GetParentTarget() override; |
715 scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 716 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
716 ui::EventTargeter* GetEventTargeter() override; | 717 ui::EventTargeter* GetEventTargeter() override; |
717 void ConvertEventToTarget(ui::EventTarget* target, | 718 void ConvertEventToTarget(ui::EventTarget* target, |
718 ui::LocatedEvent* event) override; | 719 ui::LocatedEvent* event) override; |
719 | 720 |
720 // Overridden from ui::EventHandler: | 721 // Overridden from ui::EventHandler: |
721 void OnKeyEvent(ui::KeyEvent* event) override; | 722 void OnKeyEvent(ui::KeyEvent* event) override; |
722 void OnMouseEvent(ui::MouseEvent* event) override; | 723 void OnMouseEvent(ui::MouseEvent* event) override; |
723 void OnScrollEvent(ui::ScrollEvent* event) override; | 724 void OnScrollEvent(ui::ScrollEvent* event) override; |
724 void OnTouchEvent(ui::TouchEvent* event) final; | 725 void OnTouchEvent(ui::TouchEvent* event) final; |
725 void OnGestureEvent(ui::GestureEvent* event) override; | 726 void OnGestureEvent(ui::GestureEvent* event) override; |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 // still into this view, this view receives a mouse-enter event if this flag | 1476 // still into this view, this view receives a mouse-enter event if this flag |
1476 // is turned off, but doesn't if this flag is turned on. | 1477 // is turned off, but doesn't if this flag is turned on. |
1477 // This flag is initialized to false. | 1478 // This flag is initialized to false. |
1478 bool notify_enter_exit_on_child_; | 1479 bool notify_enter_exit_on_child_; |
1479 | 1480 |
1480 // Whether or not RegisterViewForVisibleBoundsNotification on the RootView | 1481 // Whether or not RegisterViewForVisibleBoundsNotification on the RootView |
1481 // has been invoked. | 1482 // has been invoked. |
1482 bool registered_for_visible_bounds_notification_; | 1483 bool registered_for_visible_bounds_notification_; |
1483 | 1484 |
1484 // List of descendants wanting notification when their visible bounds change. | 1485 // List of descendants wanting notification when their visible bounds change. |
1485 scoped_ptr<Views> descendants_to_notify_; | 1486 std::unique_ptr<Views> descendants_to_notify_; |
1486 | 1487 |
1487 // Transformations ----------------------------------------------------------- | 1488 // Transformations ----------------------------------------------------------- |
1488 | 1489 |
1489 // Painting will be clipped to this path. TODO(estade): this doesn't work for | 1490 // Painting will be clipped to this path. TODO(estade): this doesn't work for |
1490 // layers. | 1491 // layers. |
1491 gfx::Path clip_path_; | 1492 gfx::Path clip_path_; |
1492 | 1493 |
1493 // Layout -------------------------------------------------------------------- | 1494 // Layout -------------------------------------------------------------------- |
1494 | 1495 |
1495 // Whether the view needs to be laid out. | 1496 // Whether the view needs to be laid out. |
1496 bool needs_layout_; | 1497 bool needs_layout_; |
1497 | 1498 |
1498 // The View's LayoutManager defines the sizing heuristics applied to child | 1499 // The View's LayoutManager defines the sizing heuristics applied to child |
1499 // Views. The default is absolute positioning according to bounds_. | 1500 // Views. The default is absolute positioning according to bounds_. |
1500 scoped_ptr<LayoutManager> layout_manager_; | 1501 std::unique_ptr<LayoutManager> layout_manager_; |
1501 | 1502 |
1502 // Whether this View's layer should be snapped to the pixel boundary. | 1503 // Whether this View's layer should be snapped to the pixel boundary. |
1503 bool snap_layer_to_pixel_boundary_; | 1504 bool snap_layer_to_pixel_boundary_; |
1504 | 1505 |
1505 // Painting ------------------------------------------------------------------ | 1506 // Painting ------------------------------------------------------------------ |
1506 | 1507 |
1507 // Background | 1508 // Background |
1508 scoped_ptr<Background> background_; | 1509 std::unique_ptr<Background> background_; |
1509 | 1510 |
1510 // Border. | 1511 // Border. |
1511 scoped_ptr<Border> border_; | 1512 std::unique_ptr<Border> border_; |
1512 | 1513 |
1513 // Cached output of painting to be reused in future frames until invalidated. | 1514 // Cached output of painting to be reused in future frames until invalidated. |
1514 ui::PaintCache paint_cache_; | 1515 ui::PaintCache paint_cache_; |
1515 | 1516 |
1516 // RTL painting -------------------------------------------------------------- | 1517 // RTL painting -------------------------------------------------------------- |
1517 | 1518 |
1518 // Indicates whether or not the gfx::Canvas object passed to View::Paint() | 1519 // Indicates whether or not the gfx::Canvas object passed to View::Paint() |
1519 // is going to be flipped horizontally (using the appropriate transform) on | 1520 // is going to be flipped horizontally (using the appropriate transform) on |
1520 // right-to-left locales for this View. | 1521 // right-to-left locales for this View. |
1521 bool flip_canvas_on_paint_for_rtl_ui_; | 1522 bool flip_canvas_on_paint_for_rtl_ui_; |
1522 | 1523 |
1523 // Accelerated painting ------------------------------------------------------ | 1524 // Accelerated painting ------------------------------------------------------ |
1524 | 1525 |
1525 bool paint_to_layer_; | 1526 bool paint_to_layer_; |
1526 | 1527 |
1527 // Accelerators -------------------------------------------------------------- | 1528 // Accelerators -------------------------------------------------------------- |
1528 | 1529 |
1529 // Focus manager accelerators registered on. | 1530 // Focus manager accelerators registered on. |
1530 FocusManager* accelerator_focus_manager_; | 1531 FocusManager* accelerator_focus_manager_; |
1531 | 1532 |
1532 // The list of accelerators. List elements in the range | 1533 // The list of accelerators. List elements in the range |
1533 // [0, registered_accelerator_count_) are already registered to FocusManager, | 1534 // [0, registered_accelerator_count_) are already registered to FocusManager, |
1534 // and the rest are not yet. | 1535 // and the rest are not yet. |
1535 scoped_ptr<std::vector<ui::Accelerator> > accelerators_; | 1536 std::unique_ptr<std::vector<ui::Accelerator>> accelerators_; |
1536 size_t registered_accelerator_count_; | 1537 size_t registered_accelerator_count_; |
1537 | 1538 |
1538 // Focus --------------------------------------------------------------------- | 1539 // Focus --------------------------------------------------------------------- |
1539 | 1540 |
1540 // Next view to be focused when the Tab key is pressed. | 1541 // Next view to be focused when the Tab key is pressed. |
1541 View* next_focusable_view_; | 1542 View* next_focusable_view_; |
1542 | 1543 |
1543 // Next view to be focused when the Shift-Tab key combination is pressed. | 1544 // Next view to be focused when the Shift-Tab key combination is pressed. |
1544 View* previous_focusable_view_; | 1545 View* previous_focusable_view_; |
1545 | 1546 |
1546 // Whether this view can be focused. | 1547 // Whether this view can be focused. |
1547 bool focusable_; | 1548 bool focusable_; |
1548 | 1549 |
1549 // Whether this view is focusable if the user requires full keyboard access, | 1550 // Whether this view is focusable if the user requires full keyboard access, |
1550 // even though it may not be normally focusable. | 1551 // even though it may not be normally focusable. |
1551 bool accessibility_focusable_; | 1552 bool accessibility_focusable_; |
1552 | 1553 |
1553 // Context menus ------------------------------------------------------------- | 1554 // Context menus ------------------------------------------------------------- |
1554 | 1555 |
1555 // The menu controller. | 1556 // The menu controller. |
1556 ContextMenuController* context_menu_controller_; | 1557 ContextMenuController* context_menu_controller_; |
1557 | 1558 |
1558 // Drag and drop ------------------------------------------------------------- | 1559 // Drag and drop ------------------------------------------------------------- |
1559 | 1560 |
1560 DragController* drag_controller_; | 1561 DragController* drag_controller_; |
1561 | 1562 |
1562 // Input -------------------------------------------------------------------- | 1563 // Input -------------------------------------------------------------------- |
1563 | 1564 |
1564 scoped_ptr<ViewTargeter> targeter_; | 1565 std::unique_ptr<ViewTargeter> targeter_; |
1565 | 1566 |
1566 // Accessibility ------------------------------------------------------------- | 1567 // Accessibility ------------------------------------------------------------- |
1567 | 1568 |
1568 // Belongs to this view, but it's reference-counted on some platforms | 1569 // Belongs to this view, but it's reference-counted on some platforms |
1569 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1570 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
1570 NativeViewAccessibility* native_view_accessibility_; | 1571 NativeViewAccessibility* native_view_accessibility_; |
1571 | 1572 |
1572 DISALLOW_COPY_AND_ASSIGN(View); | 1573 DISALLOW_COPY_AND_ASSIGN(View); |
1573 }; | 1574 }; |
1574 | 1575 |
1575 } // namespace views | 1576 } // namespace views |
1576 | 1577 |
1577 #endif // UI_VIEWS_VIEW_H_ | 1578 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |