};
}
-from_array :: #match {
- (arr: [..] $T) -> Iterator(^T) {
- return from_array((#type [] T).{ arr.data, arr.count });
- },
-
- (arr: [] $T) -> Iterator(^T) {
- Context :: struct (T: type_expr) {
- data: ^T;
- count: u32;
- current: u32;
- }
-
- c := make(#type Context(T));
- c.data = arr.data;
- c.count = arr.count;
- c.current = 0;
+from_array :: (arr: [] $T) -> Iterator(^T) {
+ Context :: struct (T: type_expr) {
+ data: ^T;
+ count: u32;
+ current: u32;
+ }
- next :: ($T: type_expr, use _: ^Context(T)) -> (^T, bool) {
- if current < count {
- defer current += 1;
- return ^data[current], true;
+ c := make(#type Context(T));
+ c.data = arr.data;
+ c.count = arr.count;
+ c.current = 0;
- } else {
- return null, false;
- }
- }
+ next :: ($T: type_expr, use _: ^Context(T)) -> (^T, bool) {
+ if current < count {
+ defer current += 1;
+ return ^data[current], true;
- close :: (data: rawptr) {
- cfree(data);
+ } else {
+ return null, false;
}
+ }
- return .{
- data = c,
- next = #solidify next { T = T },
- close = close,
- };
+ close :: (data: rawptr) {
+ cfree(data);
}
+
+ return .{
+ data = c,
+ next = #solidify next { T = T },
+ close = close,
+ };
}
fold :: (it: Iterator($T), initial_value: R, combine: (T, $R) -> R) -> R {
Scrollable_Region_Controls :: struct {
minimum_y := 0.0f;
- maximum_y := 10000.0f; // Senseless default
+ maximum_y := 340000000000000000000000000000000000000.0f; // Senseless default
minimum_x := 0.0f;
- maximum_x := 10000.0f; // Senseless default
+ maximum_x := 340000000000000000000000000000000000000.0f; // Senseless default
}
scrollable_region_start :: (use r: Rectangle, use src: Scrollable_Region_Controls = .{},
scrollable_region_stop :: () {
gfx.pop_scissor();
gfx.pop_matrix();
-}
\ No newline at end of file
+}
x0, y0 := Rectangle.top_left(r);
x1, y1 := Rectangle.bottom_right(r);
- return .{ x0=x0, x1=x1, y0=y0, y1=y0+top_height },
- .{ x0=x0, x1=x1, y0=y0+top_height+padding, y1=y1 };
+ return .{ x0=x0, x1=x1, y0=y0, y1=math.max(y0, y0+top_height) },
+ .{ x0=x0, x1=x1, y0=math.min(y1, y0+top_height+padding), y1=y1 };
},
(r: Rectangle, bottom_height: f32, padding := 0.0f) -> (top: Rectangle, bottom: Rectangle) {
x0, y0 := Rectangle.top_left(r);
x1, y1 := Rectangle.bottom_right(r);
- return .{ x0=x0, x1=x1, y0=y0, y1=y1-bottom_height-padding },
- .{ x0=x0, x1=x1, y0=y1-bottom_height, y1=y1 };
+ return .{ x0=x0, x1=x1, y0=y0, y1=math.max(y0, y1-bottom_height-padding) },
+ .{ x0=x0, x1=x1, y0=math.min(y1,y1-bottom_height), y1=y1 };
}
}
return .{ x0=x0 + left, x1=x1 - right, y0=y0 + top, y1=y1 - bottom };
}
-}
\ No newline at end of file
+}