From d4ea66aa3b6fd9ffedbf42ab21a4eb34bc91ccbe Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Wed, 11 Sep 2024 18:45:51 +0200 Subject: Updated odin again, odin version dev-2024-09:9b06ea5bf should work now --- src/main.odin | 25 ++++++++++++++++++++----- src/time.odin | 2 +- src/ui_implementation.odin | 7 +------ 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main.odin b/src/main.odin index 21d081d..f0e174a 100644 --- a/src/main.odin +++ b/src/main.odin @@ -122,7 +122,7 @@ main :: proc() { // Setting up the timelines - for day, f in &workdays { + for &day, f in &workdays { beginning: Moment = {0, 0, day.call.day, day.call.month, day.call.year} fmt.println("\nNew day!") @@ -280,9 +280,24 @@ when true { line.layout_cut_children = .Fill { a_timeline := timeline(line, &day) + + x_offset := int(f32(width) * day.fractions[0].start) + for &block, i in day.blocks { + // TODO: Why isn't this rendering?? + block_ui := timeline_block(&block) + block_width := int(f32(width) * (day.fractions[i].end - day.fractions[i].start)) + block_ui.layout_size.x = block_width + block_ui.layout_offset.x = x_offset + oui.item_insert(a_timeline, block_ui) + x_offset += block_width + //fmt.printf("%#v\n", block_ui) + } - /*x_offset := i32(int(f32(width)*fracts.start) - int(f32(width)*FRACT_MIN)) - i32(rect.t), + oui.item_insert(line, a_timeline) + + //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)*/ @@ -303,7 +318,7 @@ when true { info := runtime.type_info_base(type_info_of(Sizings)) st := info.variant.(runtime.Type_Info_Struct) root := uintptr(&sizings) - for offset, i in st.offsets { + for offset, i in st.offsets[:st.field_count] { line := panel_line(middle_section, theme.background, 25) line.id = oui.push_id(c0, fmt.tprintf("sizings_line_%d", i)) @@ -333,7 +348,7 @@ when true { info := runtime.type_info_base(type_info_of(Theme)) st := info.variant.(runtime.Type_Info_Struct) root := uintptr(&theme) - for offset, i in st.offsets { + for offset, i in st.offsets[:st.field_count] { line := panel_line(middle_section, theme.background, 25) line.layout_cut_gap = 10 diff --git a/src/time.odin b/src/time.odin index 5ab879f..00891bf 100644 --- a/src/time.odin +++ b/src/time.odin @@ -155,7 +155,7 @@ new_workday :: proc(previous_wrap : Moment, fmt.println(total_timeblocks) - for &block, i in &blocks { + for &block, i in blocks { if i >= total_timeblocks do break //using Weekday diff --git a/src/ui_implementation.odin b/src/ui_implementation.odin index d351761..c175fb5 100644 --- a/src/ui_implementation.odin +++ b/src/ui_implementation.odin @@ -242,16 +242,11 @@ 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 + item.layout = .Absolute data := oui.alloc_typed(c0, item, Data_Timeline_Block) data.subtype = .Timeline_Block -- cgit v1.2.1