Text editor: prototype based setup

This commit is contained in:
Krzosa Karol
2024-06-08 15:26:38 +02:00
parent 27b197840b
commit 2ec4a2a28d
5 changed files with 575 additions and 486 deletions

View File

@@ -3,22 +3,6 @@ Rect2P :: struct {
max: Vector2;
}
F32_Max :: proc(a: f32, b: f32): f32 {
if a > b return a;
return b;
}
F32_Min :: proc(a: f32, b: f32): f32 {
if a > b return b;
return a;
}
F32_Clamp :: proc(val: f32, min: f32, max: f32): f32 {
if (val > max) return max;
if (val < min) return min;
return val;
}
GetRectSize :: proc(rect: Rect2P): Vector2 {
result: Vector2 = {rect.max.x - rect.min.x, rect.max.y - rect.min.y};
return result;
@@ -36,7 +20,7 @@ GetRectX :: proc(rect: Rect2P): f32 {
CutLeft :: proc(r: *Rect2P, value: f32): Rect2P {
minx := r.min.x;
r.min.x = F32_Min(r.max.x, r.min.x + value);
r.min.x = MinFloat(r.max.x, r.min.x + value);
return :Rect2P{
{ minx, r.min.y},
{r.min.x, r.max.y},
@@ -45,7 +29,7 @@ CutLeft :: proc(r: *Rect2P, value: f32): Rect2P {
CutRight :: proc(r: *Rect2P, value: f32): Rect2P {
maxx := r.max.x;
r.max.x = F32_Max(r.max.x - value, r.min.x);
r.max.x = MaxFloat(r.max.x - value, r.min.x);
return :Rect2P{
{r.max.x, r.min.y},
{ maxx, r.max.y},
@@ -54,7 +38,7 @@ CutRight :: proc(r: *Rect2P, value: f32): Rect2P {
CutBottom :: proc(r: *Rect2P, value: f32): Rect2P { // Y is down
maxy := r.max.y;
r.max.y = F32_Max(r.min.y, r.max.y - value);
r.max.y = MaxFloat(r.min.y, r.max.y - value);
return :Rect2P{
{r.min.x, r.max.y},
{r.max.x, maxy},
@@ -63,7 +47,7 @@ CutBottom :: proc(r: *Rect2P, value: f32): Rect2P { // Y is down
CutTop :: proc(r: *Rect2P, value: f32): Rect2P { // Y is down
miny := r.min.y;
r.min.y = F32_Min(r.min.y + value, r.max.y);
r.min.y = MinFloat(r.min.y + value, r.max.y);
return :Rect2P{
{r.min.x, miny},
{r.max.x, r.min.y},