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> |
(...skipping 11 matching lines...) Expand all Loading... |
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/class_property.h" | 24 #include "ui/base/class_property.h" |
25 #include "ui/base/dragdrop/drag_drop_types.h" | 25 #include "ui/base/dragdrop/drag_drop_types.h" |
26 #include "ui/base/dragdrop/drop_target_event.h" | 26 #include "ui/base/dragdrop/drop_target_event.h" |
27 #include "ui/base/dragdrop/os_exchange_data.h" | 27 #include "ui/base/dragdrop/os_exchange_data.h" |
28 #include "ui/base/ui_base_types.h" | 28 #include "ui/base/ui_base_types.h" |
29 #include "ui/compositor/layer_delegate.h" | 29 #include "ui/compositor/layer_delegate.h" |
30 #include "ui/compositor/layer_owner.h" | 30 #include "ui/compositor/layer_owner.h" |
31 #include "ui/compositor/paint_cache.h" | 31 #include "ui/compositor/paint_cache.h" |
| 32 #include "ui/compositor/paint_info.h" |
32 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
33 #include "ui/events/event_target.h" | 34 #include "ui/events/event_target.h" |
34 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
35 #include "ui/gfx/geometry/point.h" | 36 #include "ui/gfx/geometry/point.h" |
36 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
37 #include "ui/gfx/geometry/vector2d.h" | 38 #include "ui/gfx/geometry/vector2d.h" |
38 #include "ui/gfx/native_widget_types.h" | 39 #include "ui/gfx/native_widget_types.h" |
39 #include "ui/gfx/path.h" | 40 #include "ui/gfx/path.h" |
40 #include "ui/views/view_targeter.h" | 41 #include "ui/views/view_targeter.h" |
41 #include "ui/views/views_export.h" | 42 #include "ui/views/views_export.h" |
(...skipping 12 matching lines...) Expand all Loading... |
54 } | 55 } |
55 | 56 |
56 namespace ui { | 57 namespace ui { |
57 struct AXActionData; | 58 struct AXActionData; |
58 struct AXNodeData; | 59 struct AXNodeData; |
59 class Compositor; | 60 class Compositor; |
60 class InputMethod; | 61 class InputMethod; |
61 class Layer; | 62 class Layer; |
62 class NativeTheme; | 63 class NativeTheme; |
63 class PaintContext; | 64 class PaintContext; |
| 65 // class PaintInfo; |
64 class ThemeProvider; | 66 class ThemeProvider; |
65 class TransformRecorder; | 67 class TransformRecorder; |
66 } | 68 } |
67 | 69 |
68 namespace views { | 70 namespace views { |
69 | 71 |
70 class Background; | 72 class Background; |
71 class Border; | 73 class Border; |
72 class ContextMenuController; | 74 class ContextMenuController; |
73 class DragController; | 75 class DragController; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // transformations are applied to it to convert it into the parent coordinate | 538 // transformations are applied to it to convert it into the parent coordinate |
537 // system before propagating SchedulePaint up the view hierarchy. | 539 // system before propagating SchedulePaint up the view hierarchy. |
538 // TODO(beng): Make protected. | 540 // TODO(beng): Make protected. |
539 void SchedulePaint(); | 541 void SchedulePaint(); |
540 virtual void SchedulePaintInRect(const gfx::Rect& r); | 542 virtual void SchedulePaintInRect(const gfx::Rect& r); |
541 | 543 |
542 // Called by the framework to paint a View. Performs translation and clipping | 544 // Called by the framework to paint a View. Performs translation and clipping |
543 // for View coordinates and language direction as required, allows the View | 545 // for View coordinates and language direction as required, allows the View |
544 // to paint itself via the various OnPaint*() event handlers and then paints | 546 // to paint itself via the various OnPaint*() event handlers and then paints |
545 // the hierarchy beneath it. | 547 // the hierarchy beneath it. |
546 void Paint(const ui::PaintContext& parent_context); | 548 void Paint(const ui::PaintInfo& parent_paint_info); |
547 | 549 |
548 // The background object may be null. | 550 // The background object may be null. |
549 void SetBackground(std::unique_ptr<Background> b); | 551 void SetBackground(std::unique_ptr<Background> b); |
550 const Background* background() const { return background_.get(); } | 552 const Background* background() const { return background_.get(); } |
551 Background* background() { return background_.get(); } | 553 Background* background() { return background_.get(); } |
552 | 554 |
553 // The border object may be null. | 555 // The border object may be null. |
554 virtual void SetBorder(std::unique_ptr<Border> b); | 556 virtual void SetBorder(std::unique_ptr<Border> b); |
555 const Border* border() const { return border_.get(); } | 557 const Border* border() const { return border_.get(); } |
556 Border* border() { return border_.get(); } | 558 Border* border() { return border_.get(); } |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 virtual void AddedToWidget(); | 1147 virtual void AddedToWidget(); |
1146 | 1148 |
1147 // This method is invoked for a view when it is removed from a hierarchy with | 1149 // This method is invoked for a view when it is removed from a hierarchy with |
1148 // a widget or moved to a different widget. | 1150 // a widget or moved to a different widget. |
1149 virtual void RemovedFromWidget(); | 1151 virtual void RemovedFromWidget(); |
1150 | 1152 |
1151 // Painting ------------------------------------------------------------------ | 1153 // Painting ------------------------------------------------------------------ |
1152 | 1154 |
1153 // Responsible for calling Paint() on child Views. Override to control the | 1155 // Responsible for calling Paint() on child Views. Override to control the |
1154 // order child Views are painted. | 1156 // order child Views are painted. |
1155 virtual void PaintChildren(const ui::PaintContext& context); | 1157 virtual void PaintChildren(const ui::PaintInfo& info); |
1156 | 1158 |
1157 // Override to provide rendering in any part of the View's bounds. Typically | 1159 // Override to provide rendering in any part of the View's bounds. Typically |
1158 // this is the "contents" of the view. If you override this method you will | 1160 // this is the "contents" of the view. If you override this method you will |
1159 // have to call the subsequent OnPaint*() methods manually. | 1161 // have to call the subsequent OnPaint*() methods manually. |
1160 virtual void OnPaint(gfx::Canvas* canvas); | 1162 virtual void OnPaint(gfx::Canvas* canvas); |
1161 | 1163 |
1162 // Override to paint a background before any content is drawn. Typically this | 1164 // Override to paint a background before any content is drawn. Typically this |
1163 // is done if you are satisfied with a default OnPaint handler but wish to | 1165 // is done if you are satisfied with a default OnPaint handler but wish to |
1164 // supply a different background. | 1166 // supply a different background. |
1165 virtual void OnPaintBackground(gfx::Canvas* canvas); | 1167 virtual void OnPaintBackground(gfx::Canvas* canvas); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 static int GetHorizontalDragThreshold(); | 1266 static int GetHorizontalDragThreshold(); |
1265 static int GetVerticalDragThreshold(); | 1267 static int GetVerticalDragThreshold(); |
1266 | 1268 |
1267 // NativeTheme --------------------------------------------------------------- | 1269 // NativeTheme --------------------------------------------------------------- |
1268 | 1270 |
1269 // Invoked when the NativeTheme associated with this View changes, including | 1271 // Invoked when the NativeTheme associated with this View changes, including |
1270 // when one first becomes available (after the view is added to a widget | 1272 // when one first becomes available (after the view is added to a widget |
1271 // hierarchy). | 1273 // hierarchy). |
1272 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) {} | 1274 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) {} |
1273 | 1275 |
| 1276 // Pixel Canvas -------------------------------------------------------------- |
| 1277 |
| 1278 // Returns the type of scaling to be done for this View. Values should be from |
| 1279 // ui::PaintInfo::ScaleType. |
| 1280 virtual ui::PaintInfo::ScaleType GetPaintScaleType() const; |
| 1281 |
1274 // Debugging ----------------------------------------------------------------- | 1282 // Debugging ----------------------------------------------------------------- |
1275 | 1283 |
1276 #if !defined(NDEBUG) | 1284 #if !defined(NDEBUG) |
1277 // Returns string containing a graph of the views hierarchy in graphViz DOT | 1285 // Returns string containing a graph of the views hierarchy in graphViz DOT |
1278 // language (http://graphviz.org/). Can be called within debugger and save | 1286 // language (http://graphviz.org/). Can be called within debugger and save |
1279 // to a file to compile/view. | 1287 // to a file to compile/view. |
1280 // Note: Assumes initial call made with first = true. | 1288 // Note: Assumes initial call made with first = true. |
1281 virtual std::string PrintViewGraph(bool first); | 1289 virtual std::string PrintViewGraph(bool first); |
1282 | 1290 |
1283 // Some classes may own an object which contains the children to displayed in | 1291 // Some classes may own an object which contains the children to displayed in |
(...skipping 28 matching lines...) Expand all Loading... |
1312 | 1320 |
1313 // Schedules a paint on the parent View if it exists. | 1321 // Schedules a paint on the parent View if it exists. |
1314 void SchedulePaintOnParent(); | 1322 void SchedulePaintOnParent(); |
1315 | 1323 |
1316 // Returns whether this view is eligible for painting, i.e. is visible and | 1324 // Returns whether this view is eligible for painting, i.e. is visible and |
1317 // nonempty. Note that this does not behave like IsDrawn(), since it doesn't | 1325 // nonempty. Note that this does not behave like IsDrawn(), since it doesn't |
1318 // check ancestors recursively; rather, it's used to prune subtrees of views | 1326 // check ancestors recursively; rather, it's used to prune subtrees of views |
1319 // during painting. | 1327 // during painting. |
1320 bool ShouldPaint() const; | 1328 bool ShouldPaint() const; |
1321 | 1329 |
1322 // Returns the offset that should be used when constructing the paint context | 1330 // Returns the bounds that should be used when constructing the |PaintInfo| |
1323 // for this view. | 1331 // for this view. |
1324 gfx::Vector2d GetPaintContextOffset() const; | 1332 gfx::Rect GetPaintRecordingBounds() const; |
1325 | 1333 |
1326 // Adjusts the transform of |recorder| in advance of painting. | 1334 // Adjusts the transform of |recorder| in advance of painting. |
1327 void SetupTransformRecorderForPainting(ui::TransformRecorder* recorder) const; | 1335 void SetupTransformRecorderForPainting( |
| 1336 ui::TransformRecorder* recorder, |
| 1337 const gfx::Vector2d& offset_from_parent) const; |
1328 | 1338 |
1329 // Recursively calls the painting method |func| on all non-layered children, | 1339 // Recursively calls the painting method |func| on all non-layered children, |
1330 // in Z order. | 1340 // in Z order. |
1331 void RecursivePaintHelper(void (View::*func)(const ui::PaintContext&), | 1341 void RecursivePaintHelper(void (View::*func)(const ui::PaintInfo&), |
1332 const ui::PaintContext& context); | 1342 const ui::PaintInfo& info); |
1333 | 1343 |
1334 // Invokes Paint() and, if necessary, PaintDebugRects(). Should be called | 1344 // Invokes Paint() and, if necessary, PaintDebugRects(). Should be called |
1335 // only on the root of a widget/layer. PaintDebugRects() is invoked as a | 1345 // only on the root of a widget/layer. PaintDebugRects() is invoked as a |
1336 // separate pass, instead of being rolled into Paint(), so that siblings will | 1346 // separate pass, instead of being rolled into Paint(), so that siblings will |
1337 // not obscure debug rects. | 1347 // not obscure debug rects. |
1338 void PaintFromPaintRoot(const ui::PaintContext& parent_context); | 1348 void PaintFromPaintRoot(const ui::PaintContext& parent_context); |
1339 | 1349 |
1340 // Draws a semitransparent rect to indicate the bounds of this view. | 1350 // Draws a semitransparent rect to indicate the bounds of this view. |
1341 // Recursively does the same for all children. Invoked only with | 1351 // Recursively does the same for all children. Invoked only with |
1342 // --draw-view-bounds-rects. | 1352 // --draw-view-bounds-rects. |
1343 void PaintDebugRects(const ui::PaintContext& parent_context); | 1353 void PaintDebugRects(const ui::PaintInfo& paint_info); |
1344 | 1354 |
1345 // Tree operations ----------------------------------------------------------- | 1355 // Tree operations ----------------------------------------------------------- |
1346 | 1356 |
1347 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true, | 1357 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true, |
1348 // the next and previous focusable views of views pointing to this view are | 1358 // the next and previous focusable views of views pointing to this view are |
1349 // updated. If |update_tool_tip| is true, the tooltip is updated. If | 1359 // updated. If |update_tool_tip| is true, the tooltip is updated. If |
1350 // |delete_removed_view| is true, the view is also deleted (if it is parent | 1360 // |delete_removed_view| is true, the view is also deleted (if it is parent |
1351 // owned). If |new_parent| is not NULL, the remove is the result of | 1361 // owned). If |new_parent| is not NULL, the remove is the result of |
1352 // AddChildView() to a new parent. For this case, |new_parent| is the View | 1362 // AddChildView() to a new parent. For this case, |new_parent| is the View |
1353 // that |view| is going to be added to after the remove completes. | 1363 // that |view| is going to be added to after the remove completes. |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 // Observers ------------------------------------------------------------- | 1722 // Observers ------------------------------------------------------------- |
1713 | 1723 |
1714 base::ObserverList<ViewObserver> observers_; | 1724 base::ObserverList<ViewObserver> observers_; |
1715 | 1725 |
1716 DISALLOW_COPY_AND_ASSIGN(View); | 1726 DISALLOW_COPY_AND_ASSIGN(View); |
1717 }; | 1727 }; |
1718 | 1728 |
1719 } // namespace views | 1729 } // namespace views |
1720 | 1730 |
1721 #endif // UI_VIEWS_VIEW_H_ | 1731 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |