random changes; started adding images
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 18 Feb 2021 13:11:54 +0000 (07:11 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 18 Feb 2021 13:11:54 +0000 (07:11 -0600)
build.sh
src/prez.onyx
src/slides.onyx

index 77aba6efb3b7770a9b7469de9ab1f67ace1fac80..f967216d1c355ffa86b3c966fd69a04e381d7cdf 100755 (executable)
--- 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
index e99dc9c3b186ba61f55ca302a99197081a0f8ef8..7c29f856b223b1206e52efcd960cb1a914d8d7f2 100644 (file)
@@ -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,
+        };
     }
 }
 
index 273a526c148b28362f7761650c4d138ad3d0fade..452244fa4fbddde8999d3c304d470c7ee0877938 100644 (file)
@@ -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!");
+        }
     }