* Center window on GRoot * 在 GRoot 上居中窗口
(r: GRoot, bRestraint?: boolean)
| 255 | * 在 GRoot 上居中窗口 |
| 256 | */ |
| 257 | public centerOn(r: GRoot, bRestraint?: boolean): void { |
| 258 | this.setXY( |
| 259 | Math.round((r.width - this.width) / 2), |
| 260 | Math.round((r.height - this.height) / 2) |
| 261 | ); |
| 262 | |
| 263 | if (bRestraint) { |
| 264 | this.relations.add(r, ERelationType.CenterCenter); |
| 265 | this.relations.add(r, ERelationType.MiddleMiddle); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Toggle window visibility |