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
|
package main
import "core:fmt"
import "core:math"
import "core:strings"
import rl "vendor:raylib"
main :: proc() {
workdays: [dynamic]^Workday
default_workday: = new_workday({10, 22, 4, 5, 2023},
{00, 08, 5, 5, 2023},
{00, 22, 6, 5, 2023},
{30, 21, 5, 5, 2023})
append(&workdays, &default_workday)
append(&workdays, &default_workday)
append(&workdays, &default_workday)
append(&workdays, &default_workday)
call_text: cstring = "noffin"
wrap_text: cstring = "noffin"
total_sum: cstring = "3500 NOK + 26%"
inc_soc: cstring = "4276 NOK"
text_height: f32
using rl
width: i32 = 500
height: i32 = 400
InitWindow(width, height, "satscalc")
defer CloseWindow()
SetTargetFPS(60)
SetWindowState({.WINDOW_RESIZABLE})
SetWindowMinSize(width, height)
// Loading fonts - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
font_size :: 18
font: Font = LoadFontEx("res/UbuntuMono-Regular.ttf", font_size, nil, 0)
defer UnloadFont(font)
small_font_size :: 14
small_font: Font = LoadFontEx("res/UbuntuMono-Regular.ttf", small_font_size, nil, 0)
defer UnloadFont(small_font)
big_font_size :: 24
big_font: Font = LoadFontEx("res/UbuntuMono-Regular.ttf", big_font_size, nil, 0)
defer UnloadFont(big_font)
for !WindowShouldClose() {
if IsWindowResized() {
height = GetScreenHeight()
width = GetScreenWidth()
fmt.println("Resized to:", width, 'x', height)
}
// TODO: Find a good way to calculate the size and location
// of all the timeblocks in every day.
//
// I know I want them to scale with the window, and
// that the width of them should be normalized.
// If you add a day that lasts until 4 AM the morning
// after, all the other days should scale down to keep
// the vertical alignment of time accurate
//
// TODO: Hovering over a timeblock should put a white border
// around the timeblock's timeline square, and display
// information about the block in the bottom left of
// the screen.
// DRAW
// ------------------------------------------
BeginDrawing()
ClearBackground(BGCOLOR)
//DrawTextEx(font, "Test text", {20, 20}, 18, 0, RAYWHITE);
for day, i in workdays {
DrawRectangle(10, DAY_HEIGHT*i32(i+1)-4, width-20, DAY_HEIGHT-1, PBGCOLOR)
for block in day.blocks {
DrawRectangle(80,
DAY_HEIGHT*i32(i+1)-4, width-170, DAY_HEIGHT-1, BLUE)
}
call_text = strings.clone_to_cstring(clockprint(day.call))
wrap_text = strings.clone_to_cstring(clockprint(day.wrap))
text_height = math.round(f32(i+1)*DAY_HEIGHT+(DAY_HEIGHT-font_size)*0.25)
DrawTextEx(font, call_text, {20, text_height}, font_size, 0, RAYWHITE);
DrawTextEx(font, wrap_text, {f32(width)-70, text_height}, font_size, 0, RAYWHITE);
if i == len(workdays)-1 {
DrawTextEx(big_font, "+", {20, DAY_HEIGHT*f32(i+2)}, big_font_size, 0, RAYWHITE)
}
}
DrawRectangle(0, height-50, width+10, 60, PBGCOLOR)
DrawTextEx(small_font, total_sum, {f32(width)-120, f32(height)-43}, small_font_size, 0, RAYWHITE);
DrawTextEx(big_font, inc_soc, {f32(width)-120, f32(height)-29}, big_font_size, 0, RAYWHITE);
EndDrawing()
}
}
BGCOLOR : rl.Color : {30, 30, 30, 255}
PBGCOLOR : rl.Color : {40, 40, 40, 255}
DAY_HEIGHT :: 35
|