Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Views Overview | 1 # Views Overview |
| 2 | 2 |
| 3 This document is an overview of Views concepts, terminology, and architecture. | 3 This document is an overview of Views concepts, terminology, and architecture. |
| 4 The target audience is engineers using or working on Views. | 4 The target audience is engineers using or working on Views. |
| 5 | 5 |
| 6 ## General Things | 6 ## General Things |
| 7 | 7 |
| 8 Points in this document are written as `(x,y)`, and rectangles are written as | 8 Points in this document are written as `(x,y)`, and rectangles are written as |
| 9 `[(x,y) wxh]`. For example, the rectangle `[(100,100) 50x20]` contains the point | 9 `[(x,y) wxh]`. For example, the rectangle `[(100,100) 50x20]` contains the point |
| 10 `(130,110)`. | 10 `(130,110)`. |
| 11 | 11 |
| 12 Views uses a coordinate system with `(0,0)` at the top-left, with increasing | 12 Views uses a coordinate system with `(0,0)` at the top-left, with increasing |
| 13 x-coordinates moving rightwards and increasing y-coordinates moving downwards. | 13 x-coordinates moving rightwards and increasing y-coordinates moving downwards. |
| 14 This is the same as the Windows and GTK coordinate systems, but *different from* | 14 This is the same as the Windows and GTK coordinate systems, but *different from* |
| 15 the Cocoa coordinate system, which has `(0,0)` at the bottom-right. Coordinates | 15 the Cocoa coordinate system, which has `(0,0)` at the bottom-left. Coordinates |
|
Elly Fong-Jones
2017/05/22 14:53:42
ooops! thanks for noticing & fixing :)
| |
| 16 in this document use the Views coordinate system. | 16 in this document use the Views coordinate system. |
| 17 | 17 |
| 18 Views generally *take ownership* of objects passed to them even via raw | 18 Views generally *take ownership* of objects passed to them even via raw |
| 19 pointers, although there are some exceptions, such as delegates. | 19 pointers, although there are some exceptions, such as delegates. |
| 20 | 20 |
| 21 ## Views | 21 ## Views |
| 22 | 22 |
| 23 A **View** is a UI element, similar to an HTML DOM element. Each View occupies a | 23 A **View** is a UI element, similar to an HTML DOM element. Each View occupies a |
| 24 rectangle, called its **bounds**, which is expressed in the coordinate system of | 24 rectangle, called its **bounds**, which is expressed in the coordinate system of |
| 25 its parent View. Views may have child Views, which are laid out according to the | 25 its parent View. Views may have child Views, which are laid out according to the |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 97 |
| 98 ## Widgets | 98 ## Widgets |
| 99 | 99 |
| 100 Views need an underlying canvas to paint onto. This has to be supplied by the | 100 Views need an underlying canvas to paint onto. This has to be supplied by the |
| 101 operating system, usually by creating a native drawing surface of some kind. | 101 operating system, usually by creating a native drawing surface of some kind. |
| 102 Views calls these **widgets**. A Widget is the bridge between a tree of Views | 102 Views calls these **widgets**. A Widget is the bridge between a tree of Views |
| 103 and a native window of some sort, which Views calls a **native widget**. Each | 103 and a native window of some sort, which Views calls a **native widget**. Each |
| 104 Widget has a **root view**, which is a special subclass of View that helps with | 104 Widget has a **root view**, which is a special subclass of View that helps with |
| 105 this bridging; the root view in turn has a single child view, called the | 105 this bridging; the root view in turn has a single child view, called the |
| 106 Widget's **contents view**, which fills the entire root view. All other Views | 106 Widget's **contents view**, which fills the entire root view. All other Views |
| 107 inside a given Widget are children of that Widget's content view. | 107 inside a given Widget are children of that Widget's contents view. |
| 108 | 108 |
| 109 Widgets have many responsibilities, including but not limited to: | 109 Widgets have many responsibilities, including but not limited to: |
| 110 | 110 |
| 111 1. Keyboard focus management, via [FocusManager] | 111 1. Keyboard focus management, via [FocusManager] |
| 112 2. Window resizing/minimization/maximization | 112 2. Window resizing/minimization/maximization |
| 113 3. Window shaping, for non-rectangular windows | 113 3. Window shaping, for non-rectangular windows |
| 114 4. Input event routing | 114 4. Input event routing |
| 115 | 115 |
| 116 For more details, see [widget.h]. | 116 For more details, see [widget.h]. |
| 117 | 117 |
| 118 ### Client and Non-Client Views | 118 ### Client and Non-Client Views |
| 119 | 119 |
| 120 The content view of most Widgets is a **Non-Client View**, which is either a | 120 The contents view of most Widgets is a **Non-Client View**, which is either a |
| 121 [NonClientView] or one of its descendants. The Non-Client View has two children, | 121 [NonClientView] or one of its descendants. The Non-Client View has two children, |
| 122 which are the **Non-Client Frame View** (a [NonClientFrameView]) and the | 122 which are the **Non-Client Frame View** (a [NonClientFrameView]) and the |
| 123 **Client View** (a [ClientView]). The non-client frame view is responsible for | 123 **Client View** (a [ClientView]). The non-client frame view is responsible for |
| 124 painting window decorations, the Widget's border, the shadow, and so on; the | 124 painting window decorations, the Widget's border, the shadow, and so on; the |
| 125 client view is responsible for painting the Widget's contents. The area the | 125 client view is responsible for painting the Widget's contents. The area the |
| 126 client view occupies is sometimes referred to as the Widget's "client area". The | 126 client view occupies is sometimes referred to as the Widget's "client area". The |
| 127 non-client frame view may be swapped out as the system theme changes without | 127 non-client frame view may be swapped out as the system theme changes without |
| 128 affecting the client view. | 128 affecting the client view. |
| 129 | 129 |
| 130 ## Dialogs | 130 ## Dialogs |
| 131 | 131 |
| 132 A commonly-used type of client view is a **dialog client view**, which has a | 132 A commonly-used type of client view is a **dialog client view**, which has a |
| 133 **content view**, optional buttons on the lower-right, and an optional extra | 133 **contents view**, optional buttons on the lower-right, and an optional extra |
| 134 view on the lower-left. Dialogs are usually created by subclassing | 134 view on the lower-left. Dialogs are usually created by subclassing |
| 135 [DialogDelegate] or [DialogDelegateView] and then calling | 135 [DialogDelegate] or [DialogDelegateView] and then calling |
| 136 `DialogDelegate::CreateDialogWidget`. The dialog's content view fills the entire | 136 `DialogDelegate::CreateDialogWidget`. The dialog's contents view fills the |
| 137 top part of the widget's client view, and the bottom part is taken over by the | 137 entire top part of the widget's client view, and the bottom part is taken over |
| 138 dialog's buttons and extra view. | 138 by the dialog's buttons and extra view. |
| 139 | 139 |
| 140 ## Bubbles | 140 ## Bubbles |
| 141 | 141 |
| 142 A common type of dialog is a **bubble**, which is a dialog that is anchored to a | 142 A common type of dialog is a **bubble**, which is a dialog that is anchored to a |
| 143 parent View and moves as the parent View moves. Bubbles are usually created by | 143 parent View and moves as the parent View moves. Bubbles are usually created by |
| 144 subclassing [BubbleDialogDelegateView] and then calling | 144 subclassing [BubbleDialogDelegateView] and then calling |
| 145 `BubbleDialogDelegateView::CreateBubble`. Bubbles can have a title, which is | 145 `BubbleDialogDelegateView::CreateBubble`. Bubbles can have a title, which is |
| 146 drawn alongside the window controls as part of the Bubble's Widget's | 146 drawn alongside the window controls as part of the Bubble's Widget's |
| 147 NonClientFrameView. | 147 NonClientFrameView. |
| 148 | 148 |
| 149 [BoxLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/box_layout.h | 149 [BoxLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/box_layout.h |
| 150 [BubbleDialogDelegateView]: https://cs.chromium.org/chromium/src/ui/views/bubble /bubble_dialog_delegate.h | 150 [BubbleDialogDelegateView]: https://cs.chromium.org/chromium/src/ui/views/bubble /bubble_dialog_delegate.h |
| 151 [ClientView]: https://cs.chromium.org/chromium/src/ui/views/window/client_view.h | 151 [ClientView]: https://cs.chromium.org/chromium/src/ui/views/window/client_view.h |
| 152 [DialogDelegate]: https://cs.chromium.org/chromium/src/ui/views/window/dialog_de legate.h | 152 [DialogDelegate]: https://cs.chromium.org/chromium/src/ui/views/window/dialog_de legate.h |
| 153 [DialogDelegateView]: https://cs.chromium.org/chromium/src/ui/views/window/dialo g_delegate.h | 153 [DialogDelegateView]: https://cs.chromium.org/chromium/src/ui/views/window/dialo g_delegate.h |
| 154 [FillLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/fill_layout.h | 154 [FillLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/fill_layout.h |
| 155 [FocusManager]: https://cs.chromium.org/chromium/src/ui/views/focus/focus_manage r.h | 155 [FocusManager]: https://cs.chromium.org/chromium/src/ui/views/focus/focus_manage r.h |
| 156 [GridLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/grid_layout.h | 156 [GridLayout]: https://cs.chromium.org/chromium/src/ui/views/layout/grid_layout.h |
| 157 | 157 |
| 158 [NonClientView]: https://cs.chromium.org/chromium/src/ui/views/window/non_client _view.h | 158 [NonClientView]: https://cs.chromium.org/chromium/src/ui/views/window/non_client _view.h |
| 159 [NonClientFrameView]: https://cs.chromium.org/chromium/src/ui/views/window/non_c lient_view.h | 159 [NonClientFrameView]: https://cs.chromium.org/chromium/src/ui/views/window/non_c lient_view.h |
| 160 [background.h]: https://cs.chromium.org/chromium/src/ui/views/background.h | 160 [background.h]: https://cs.chromium.org/chromium/src/ui/views/background.h |
| 161 [border.h]: https://cs.chromium.org/chromium/src/ui/views/border.h | 161 [border.h]: https://cs.chromium.org/chromium/src/ui/views/border.h |
| 162 [canvas.h]: https://cs.chromium.org/chromium/src/ui/gfx/canvas.h | 162 [canvas.h]: https://cs.chromium.org/chromium/src/ui/gfx/canvas.h |
| 163 [view.h]: https://cs.chromium.org/chromium/src/ui/views/view.h | 163 [view.h]: https://cs.chromium.org/chromium/src/ui/views/view.h |
| 164 [widget.h]: https://cs.chromium.org/chromium/src/ui/views/widget/widget.h | 164 [widget.h]: https://cs.chromium.org/chromium/src/ui/views/widget/widget.h |
| OLD | NEW |