2#include "TinyMaterialDesign/Core/Bounds.h"
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
27 : container_(container), axis_(axis), spacing_(spacing) {}
31 if (count <= 0) count = 1;
33 const int32_t extent = (total - (count - 1) * spacing_) / count;
34 return rectAt(index * (extent + spacing_), extent);
42 for (
int i = 0; i < count; ++i) sum += weights[i];
46 const int32_t available = total - (count - 1) * spacing_;
49 for (
int i = 0; i < index; ++i) offset +=
static_cast<int32_t>(available * (weights[i] / sum)) + spacing_;
50 const int32_t extent =
static_cast<int32_t>(available * (weights[index] / sum));
51 return rectAt(offset, extent);
55 Bounds rectAt(int32_t offset, int32_t extent)
const {
Computes equal- or weighted-split rects along one axis of a container.
Definition: LinearLayout.h:24
Bounds itemRect(int index, const float *weights, int count) const
Definition: LinearLayout.h:39
Bounds itemRect(int index, int count) const
Bounds for the index-th of count equally-sized items (0-based).
Definition: LinearLayout.h:30
LinearLayout(Bounds container, LayoutAxis axis, int32_t spacing=8)
Definition: LinearLayout.h:26
Definition: AnchorLayout.h:4
LayoutAxis
Definition: LinearLayout.h:6
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21
int32_t w
Definition: Bounds.h:24
Bounds(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: Bounds.h:28
int32_t h
Definition: Bounds.h:25
int32_t y
Definition: Bounds.h:23
int32_t x
Definition: Bounds.h:22