1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Layout, Tile and TileExt traits
use crateRect;
use crate;
use crate;
use autoimpl;
use ;
use crate;
use kas_macros as macros;
/// Positioning and drawing routines for [`Widget`]s
///
/// `Layout` is used to implement [`Widget`] sizing and drawing operations
/// ("layout").
/// See [`Widget`] documentation and the [`#widget`] macro.
/// `Layout` may not be implemented independently.
///
/// # Implementation
///
/// The [`#widget`] macro will, when its `layout` property is specified,
/// generate an implementation of this trait (if omitted from the surrounding
/// `#[impl_self]`) or provide default implementations of its methods (if an
/// explicit impl of `Layout` is found but some methods are missing).
///
/// # Call order
///
/// Widgets must be [**configured**](Events#configuration) before any
/// `Layout` methods are called. This is not applicable to non-widgets.
///
/// ### Sizing
///
/// Sizing involves calling the following in order:
///
/// 1. [`Layout::size_rules`] for the horizontal axis
/// 2. [`Layout::size_rules`] for the vertical axis
/// 3. [`Layout::set_rect`]
///
/// This order is required initially. Resizing may start at any of the above
/// steps but must then proceed in-order for all remaining steps. If the scale
/// factor is changed, then resizing must start from step 1.
///
/// Typically parent widgets call these methods from their own implementations
/// of [`Layout::size_rules`] and [`Layout::set_rect`]. When calling these
/// methods at other times, be sure to respect the call order.
///
/// Other `Layout` methods may only be called once sizing is complete.
///
/// [`#widget`]: macros::widget
/// Macro-defined layout
///
/// This trait is a copy of [`Layout`], implemented by the
/// [`#[layout]`](macro@crate::layout) macro. In some cases it is useful to
/// invoke `kas::MacroDefinedLayout::set_rect` (or other method) from the
/// corresponding [`Layout`] method to perform some other action before using
/// the default implementation.
///
/// [`#[layout]`]: kas::layout