From b88dd88595272eadf476de43d0d38f8f18f8ea20 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 18 Feb 2021 07:11:54 -0600 Subject: [PATCH] random changes; started adding images --- build.sh | 2 +- src/prez.onyx | 15 ++++++++------- src/slides.onyx | 21 ++++++++++++++++++--- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 77aba6e..f967216 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/sh -onyx -V -r js src/build.onyx -o dist/prez.wasm +onyx -V -r js src/build.onyx -o dist/prez.wasm --use-post-mvp-features diff --git a/src/prez.onyx b/src/prez.onyx index e99dc9c..7c29f85 100644 --- a/src/prez.onyx +++ b/src/prez.onyx @@ -108,13 +108,14 @@ create_dummy_show :: () { slide.items[1].text.justify = Slide_Item_Text.Justify.Left; slide.items[2] = slideshow_make_item(^the_slideshow); - slide.items[2].kind = Slide_Item.Kind.Text; - slide.items[2].text.text = "Here is a block of much longer text that will not wrap correctly, which is annoying but I think the best thing to do is... I don't know yet."; - slide.items[2].text.y_pos = .45; - slide.items[2].text.font_name = "Calibri"; - slide.items[2].text.font_size = 36; - slide.items[2].text.padding = .07; - slide.items[2].text.justify = Slide_Item_Text.Justify.Left; + slide.items[2].text = Slide_Item_Text.{ + text = "Here is a block of much longer text that will not wrap correctly, which is annoying but I think the best thing to do is... I don't know yet.", + y_pos = .45, + font_name = "Calibri", + font_size = 36, + padding = .07, + justify = Slide_Item_Text.Justify.Left, + }; } } diff --git a/src/slides.onyx b/src/slides.onyx index 273a526..452244f 100644 --- a/src/slides.onyx +++ b/src/slides.onyx @@ -37,13 +37,13 @@ Slide_Item_Base :: struct { } Slide_Item_Text :: struct { - use base : Slide_Item_Base; + use base := Slide_Item_Base.{ Slide_Item.Kind.Text }; - color : Color; + color : Color = Color.{ 1, 1, 1 }; font_name : str; font_size : u32; - font_attr : FontAttributes; + font_attr : FontAttributes = ~~ 0; FontAttributes :: enum #flags { Bold; Italic; Underline; } @@ -55,6 +55,17 @@ Slide_Item_Text :: struct { Justify :: enum { Left; Center; Right; } } +Slide_Item_Image :: struct { + use base := Slide_Item_Base.{ Slide_Item.Kind.Text }; + + path : str; + x, y : f32; // Between 0 and 1 + width : f32; // Between 0 and 1 + + // Currently the image maintains the original aspect ratio, + // so the height of the image is automatically determined. +} + slideshow_make :: (allocator := context.allocator) -> Slideshow { @@ -158,6 +169,10 @@ slide_item_render :: (use slide_item: ^Slide_Item, slide: ^Slide) { } } } + + case Image { + assert(false, "Slide_Item_Image not implemented!"); + } } -- 2.25.1