aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.odin31
-rw-r--r--src/ui_implementation.odin69
2 files changed, 60 insertions, 40 deletions
diff --git a/src/main.odin b/src/main.odin
index 1f2d46f..e0232c7 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -158,6 +158,13 @@ main :: proc() {
fmt.println("Resized to:", width, 'x', height)
}
+ pre_sos_price : f64 = 0
+
+ for each_day in workdays {
+ pre_sos_price += f64(each_day.price)
+ }
+
+ post_sos_price : f64 = pre_sos_price * 1.26
// TODO: Find a good way to calculate the size and location
// of all the timeblocks in every day.
@@ -235,13 +242,13 @@ when true {
bottom_bar.layout_cut_children = .Right
oui.item_insert(bottom_bar, totals)
- pre_sos_price := label("120 000 kr", small_font, 0, .Right)
- pre_sos_price.layout_size.y = 11
- oui.item_insert(totals, pre_sos_price)
+ pre_sos_price_label := label(fmt.tprintf("%.2f Kr", pre_sos_price), small_font, 0, .Right)
+ pre_sos_price_label.layout_size.y = 11
+ oui.item_insert(totals, pre_sos_price_label)
- post_sos_price := label("160 000 kr", big_font, 300, .Right)
- post_sos_price.layout_size.y = 27
- oui.item_insert(totals, post_sos_price)
+ post_sos_price_label := label(fmt.tprintf("%.2f Kr", post_sos_price), big_font, 300, .Right)
+ post_sos_price_label.layout_size.y = 27
+ oui.item_insert(totals, post_sos_price_label)
}
{
@@ -267,11 +274,19 @@ when true {
oui.item_insert(line, label(clockprint(day.call), font, sizings.call, .Center))
line.layout_cut_children = .Right
- oui.item_insert(line, label(fmt.tprintf("%.2f kr", day.price), font, sizings.price, .Center))
+ oui.item_insert(line, label(fmt.tprintf("%.2f Kr", day.price), font, sizings.price, .Center))
oui.item_insert(line, label(clockprint(day.wrap), font, sizings.wrap, .Center))
line.layout_cut_children = .Fill
- timeline(line, &day)
+ {
+ a_timeline := timeline(line, &day)
+
+ /*x_offset := i32(int(f32(width)*fracts.start) - int(f32(width)*FRACT_MIN))
+ i32(rect.t),
+ i32(f32(width) * (fracts.end - fracts.start)+0.99),
+ i32(rect.b - rect.t),
+ color)*/
+ }
}
new_workday := button("+", 100)
middle_section.layout_cut_children = .Top
diff --git a/src/ui_implementation.odin b/src/ui_implementation.odin
index 71f0e94..3a2ddc0 100644
--- a/src/ui_implementation.odin
+++ b/src/ui_implementation.odin
@@ -71,6 +71,7 @@ Data_Element :: enum int {
Text_Input,
Timeblock,
Timeline,
+ Timeline_Block,
// ...
}
@@ -115,6 +116,10 @@ Data_Timeline :: struct {
using _: Data_Head,
day: ^Workday,
}
+Data_Timeline_Block :: struct {
+ using _: Data_Head,
+ timeblock: ^Timeblock,
+}
panel :: proc(color : rl.Color = rl.RED) -> ^Item {
item := oui.item_make(c0)
@@ -237,9 +242,23 @@ timeline :: proc(parent: ^Item, day: ^Workday) -> ^Item {
data.subtype = .Timeline
data.day = day
+ for block in &day.blocks {
+ oui.item_insert(item, timeline_block(&block))
+ }
+
oui.item_insert(parent, item)
return item
}
+timeline_block :: proc(timeblock: ^Timeblock) -> ^Item {
+ item := oui.item_make(c0)
+ item.layout = .Fractional
+
+ data := oui.alloc_typed(c0, item, Data_Timeline_Block)
+ data.subtype = .Timeline_Block
+ data.timeblock = timeblock
+
+ return item
+}
Text_Alignment :: enum int {
// Techically called justification, but text_alignment is more self-explanatory.
@@ -350,40 +369,26 @@ ui_draw :: proc(item: ^oui.Item) {
rl.DrawTextEx(data.font, text, i2f(position), f32(data.font.baseSize), 0.0, theme.text);
case .Timeline:
- data := cast(^Data_Timeline) item.handle
+ rl.DrawRectangle(i32(rect.l),
+ i32(rect.t),
+ i32(rect.r - rect.l),
+ i32(rect.b - rect.t),
+ theme.background_bar)
+ case .Timeline_Block:
+ data := cast(^Data_Timeline_Block) item.handle
- width := int(f32(rect.r - rect.l)/(FRACT_MAX - FRACT_MIN))
+ color := theme.price_100
+ value := data.timeblock.value
- for fracts, i in data.day.fractions {
-
- color := theme.price_100
- value := data.day.blocks[i].value
-
- switch {
- case value>2.1:
- color = theme.price_300
- case value>1.6:
- color = theme.price_200
- case value>1.1:
- color = theme.price_150
- }
-
-
-
- rl.DrawRectangle(i32(rect.l + int(f32(width)*fracts.start) - int(f32(width)*FRACT_MIN)),
- i32(rect.t),
- i32(f32(width) * (fracts.end - fracts.start)+0.99),
- i32(rect.b - rect.t),
- color)
- // Dark middle of blocks, glowing edge. Disabled for now.
- /*rl.DrawRectangle(i32(rect.l + int(f32(width)*fracts.start) - int(f32(width)*FRACT_MIN) + 1),
- i32(rect.t) + 1,
- i32(f32(width+1) * (fracts.end - fracts.start)-1.01),
- i32(rect.b - rect.t)-2,
- {0,0,0,100})*/
- if i+1 == data.day.total_timeblocks {
- break
- }
+ switch {
+ case value>2.1:
+ color = theme.price_300
+ case value>1.6:
+ color = theme.price_200
+ case value>1.1:
+ color = theme.price_150
}
+
+ rl.DrawRectangle(i32(rect.l), i32(rect.t), i32(rect.r-rect.l), i32(rect.b-rect.t), color)
}
} \ No newline at end of file