diff --git a/bench/arcade_bench.zi b/bench/arcade_bench.zi index 0837af8..9bb186a 100644 --- a/bench/arcade_bench.zi +++ b/bench/arcade_bench.zi @@ -19,7 +19,6 @@ #import "kryon/tree" #import "kryon/paint_queue" #import "kryon/widget_host" -#import "kryon/text_input_props" #import, file "../src/protocol.zi"; #import, file "../src/tree.zi"; #import, file "../src/host.zi"; diff --git a/fixtures/consumer/main.zi b/fixtures/consumer/main.zi index 4f38b91..4c4f162 100644 --- a/fixtures/consumer/main.zi +++ b/fixtures/consumer/main.zi @@ -3,7 +3,9 @@ #import "apps/protocol" #import "apps/controller" Launcher :: #import "apps/launcher"; -UI :: #import "kryon/Widgets"; +KryonSession :: #import "kryon/session"; +Geometry :: #import "kryon/geometry"; +Drawing :: #import "kryon/drawing_props"; #import "std/c_string" #import "std/bundle_host" Node :: #import "apps/node_types"; @@ -27,14 +29,14 @@ OpenEffect :: (context: *void, account: string, locator: *AppLocator, request: * } // Independent public imports must use the same Kryon package identity. -TypedScreen :: (session: UI.Session, bounds: UI.Rectangle, fill: UI.Color) -> bool { +TypedScreen :: (session: KryonSession.Session, bounds: Geometry.Rectangle, fill: Drawing.Color) -> bool { frame := Node.AppUiFrame.{.session = session} state: Launcher.AppLauncherState props := Launcher.AppLauncherProps.{.bounds = bounds, .scale = 1.0, .locale = "en"} - shared_fill: Launcher.Color = fill + shared_bounds: Geometry.Rectangle = props.bounds items: [1]Launcher.AppLauncherItem unused Launcher.AppLauncherScreen(frame.session, *state, props, items[:]) - return shared_fill.a == 255 + return fill.a == 255 && shared_bounds.width == bounds.width } #program_export @@ -78,10 +80,10 @@ Check :: () -> s32 { if launcher.count != 1 || launcher.visible[0] != 2 || launcher.favorites != 0 { return 9 } if !Launcher.AppLauncherMatches("Écrire", "éC") || Launcher.AppLauncherMatches("Clock", "other") { return 10 } // Type-check TypedScreen above without linking a graphical test host. - frame := Node.AppUiFrame.{.session = UI.Session.{.slot = 3, .epoch = cast(u64)7}} - props := Launcher.AppLauncherProps.{.bounds = UI.Rectangle.{0.0, 0.0, 800.0, 600.0}} - fill: Launcher.Color = UI.Color.{1, 2, 3, 255} + frame := Node.AppUiFrame.{.session = KryonSession.Session.{.slot = 3, .epoch = cast(u64)7}} + props := Launcher.AppLauncherProps.{.bounds = Geometry.Rectangle.{0.0, 0.0, 800.0, 600.0}} + bounds: Geometry.Rectangle = props.bounds if frame.session.slot != 3 || frame.session.epoch != cast(u64)7 || - props.bounds.width != 800.0 || fill.a != 255 { return 11 } + bounds.width != 800.0 { return 11 } return 0 } diff --git a/fixtures/node.zi b/fixtures/node.zi index 1e9483c..d3a22f3 100644 --- a/fixtures/node.zi +++ b/fixtures/node.zi @@ -1,5 +1,5 @@ #import "node_types" -#import "kryon/text_input_props" +TextField :: #import "kryon/text_field"; #import "kryon/input_protocol" #import "kryon/frame_snapshot" @@ -14,7 +14,7 @@ AppKeyHost :: () -> s32 #foreign host_api; AppSoundHost :: (path: string) -> bool #foreign host_api; AppSupportsHost :: (capability: string) -> bool #foreign host_api; AppServiceHost :: (name: string, request: string) -> string #foreign host_api; -AppFieldInputHost :: () -> TextFieldInput #foreign host_api; +AppFieldInputHost :: () -> TextField.Input #foreign host_api; #program_export Main :: () -> s32 { diff --git a/src/connection.zi b/src/connection.zi index d9f190d..dd5bd63 100644 --- a/src/connection.zi +++ b/src/connection.zi @@ -5,12 +5,9 @@ #import "kryon/app_files" #import "kryon/session" #import "kryon/geometry" -#import "kryon/box_widget" -#import "kryon/box_props" -#import "kryon/text_widget" -#import "kryon/text_props" -#import "kryon/button_widget" -#import "kryon/button_props" +Box :: #import "kryon/box"; +Button :: #import "kryon/button"; +Text :: #import "kryon/text"; #import "kryon/control_props" #import "kryon/drawing_props" #import "kryon/widget_palette" @@ -49,27 +46,27 @@ AppConnectionNotice :: (session: Session, bounds: Rectangle, locale: string, origin: string, key: u64) -> s32 { unused WidgetPaletteUse(session, AppCoversPalette()) defer { unused WidgetPaletteRestore(session) } - Box(session, BoxProps.{.key = key, .bounds = bounds, .fill = Color.{17, 18, 35, 255}}) + Box.Draw(session, Box.Props.{.key = key, .bounds = bounds, .fill = Color.{17, 18, 35, 255}}) width := ifx bounds.width - 32.0 < 480.0 then bounds.width - 32.0 else 480.0 height := ifx bounds.height - 24.0 < 292.0 then bounds.height - 24.0 else 292.0 x := bounds.x + (bounds.width - width) / 2.0 y := bounds.y + (bounds.height - height) / 2.0 - Box(session, BoxProps.{.key = key + 1, .bounds = Rectangle.{x, y, width, height}, + Box.Draw(session, Box.Props.{.key = key + 1, .bounds = Rectangle.{x, y, width, height}, .fill = Color.{32, 34, 56, 255}, .border = Color.{65, 66, 96, 255}, .radius = 18.0}) - Text(session, TextProps.{.key = key + 2, .text = AppsLabel(locale, "allow_content_title"), - .font = 22, .wrap = TextWrap.TextWrapAuto, + Text.Draw(session, Text.Props.{.key = key + 2, .text = AppsLabel(locale, "allow_content_title"), + .size = 22, .wrap = Text.Wrap.TextWrapAuto, .bounds = Rectangle.{x + 20.0, y + 18.0, width - 40.0, 56.0}}) - Text(session, TextProps.{.key = key + 3, .text = AppsLabel(locale, "allow_content_description"), - .font = 16, .wrap = TextWrap.TextWrapAuto, + Text.Draw(session, Text.Props.{.key = key + 3, .text = AppsLabel(locale, "allow_content_description"), + .size = 16, .wrap = Text.Wrap.TextWrapAuto, .bounds = Rectangle.{x + 20.0, y + 82.0, width - 40.0, height - 166.0}}) button_width := (width - 52.0) / 2.0 - if Button(session, ButtonProps.{.key = key + 5, .id = 1, + if Button.Draw(session, Button.Props.{.key = key + 5, .id = 1, .label = AppsLabel(locale, "stay_offline"), .bounds = Rectangle.{x + 20.0, y + height - 52.0, button_width, 40.0}, .tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 { return APP_CONNECTION_OFFLINE } - if Button(session, ButtonProps.{.key = key + 6, .id = 2, + if Button.Draw(session, Button.Props.{.key = key + 6, .id = 2, .label = AppsLabel(locale, "allow_content"), .bounds = Rectangle.{x + 32.0 + button_width, y + height - 52.0, button_width, 40.0}, .tone = ButtonTone.ButtonToneAccent}) != 0 { diff --git a/src/game_hud.zi b/src/game_hud.zi index e37d40e..f472702 100644 --- a/src/game_hud.zi +++ b/src/game_hud.zi @@ -1,16 +1,12 @@ // Shared painted game actions. The caller owns translations, balance and routes. #import "kryon/session" #import "kryon/geometry" -#import "kryon/image_widget" -#import "kryon/image_props" -#import "kryon/button_widget" -#import "kryon/button_props" +Box :: #import "kryon/box"; +Button :: #import "kryon/button"; +Image :: #import "kryon/image"; +Text :: #import "kryon/text"; #import "kryon/control_props" -#import "kryon/text_widget" -#import "kryon/text_props" #import "kryon/text_align" -#import "kryon/box_widget" -#import "kryon/box_props" #import "kryon/drawing_props" #import "kryon/widget_palette" @@ -42,34 +38,34 @@ AppGameHud :: (session: Session, props: AppGameHudProps) -> s32 { size := area.height - pad * 2.0 if size > area.width * 0.22 { size = area.width * 0.22 } bevel := pad * 0.25 - unused Box(session, BoxProps.{.key = props.key + 5, .bounds = area, + unused Box.Draw(session, Box.Props.{.key = props.key + 5, .bounds = area, .fill = Color.{222, 188, 109, 255}, .fill_bottom = Color.{84, 57, 26, 255}, .has_fill_bottom = true, .border = Color.{239, 211, 146, 255}, .radius = area.height * 0.2}) - unused Box(session, BoxProps.{.key = props.key + 6, + unused Box.Draw(session, Box.Props.{.key = props.key + 6, .bounds = Rectangle.{area.x + bevel, area.y + bevel, area.width - bevel * 2.0, area.height - bevel * 2.0}, .fill = Color.{42, 39, 34, 255}, .fill_bottom = Color.{17, 19, 22, 255}, .has_fill_bottom = true, .border = Color.{102, 78, 43, 255}, .radius = area.height * 0.18}) profile := Rectangle.{area.x + area.width - pad - size, area.y + (area.height - size) / 2.0, size, size} - unused Box(session, BoxProps.{.key = props.key + 7, + unused Box.Draw(session, Box.Props.{.key = props.key + 7, .bounds = Rectangle.{profile.x - bevel, profile.y - bevel, size + bevel * 2.0, size + bevel * 2.0}, .fill = Color.{173, 132, 62, 255}, .border = Color.{238, 209, 142, 255}, .radius = size / 2.0 + bevel}) - unused Image(session, ImageProps.{.key = props.key + 1, .bounds = profile, + Image.Draw(session, Image.Props.{.key = props.key + 1, .bounds = profile, .asset_path = ifx props.profile_image.count > 0 then props.profile_image else "assets/hud/profile.webp", .preview_path = "assets/hud/profile.webp", - .fit = ImageFit.ImageFitContain, .smooth = true, .radius = size / 2.0}) - profile_action := Button(session, ButtonProps.{.key = props.key, .bounds = profile, + .fit = Image.ImageFit.ImageFitContain, .smooth = true, .radius = size / 2.0}) + profile_action := Button.Draw(session, Button.Props.{.key = props.key, .bounds = profile, .label = props.profile_label, .invisible = true, .circle = true}) jewel := Rectangle.{area.x + pad, profile.y, size, size} - unused Image(session, ImageProps.{.key = props.key + 3, .bounds = jewel, + Image.Draw(session, Image.Props.{.key = props.key + 3, .bounds = jewel, .asset_path = ifx props.dew_image.count > 0 then props.dew_image else "assets/hud/dew.webp", .preview_path = "assets/hud/dew.webp", - .fit = ImageFit.ImageFitContain, .smooth = true}) + .fit = Image.ImageFit.ImageFitContain, .smooth = true}) text_x := jewel.x + size + pad * 0.5 - unused Text(session, TextProps.{.key = props.key + 4, + Text.Draw(session, Text.Props.{.key = props.key + 4, .bounds = Rectangle.{text_x, area.y, profile.x - pad - text_x, area.height}, - .text = props.dew_text, .font = 18, - .vertical_align = TextAlign.TextAlignCenter, .wrap = TextWrap.TextWrapEllipsis}) - dew_action := Button(session, ButtonProps.{.key = props.key + 2, + .text = props.dew_text, .size = 18, + .vertical_align = TextAlign.TextAlignCenter, .wrap = Text.Wrap.TextWrapEllipsis}) + dew_action := Button.Draw(session, Button.Props.{.key = props.key + 2, .bounds = Rectangle.{area.x, area.y, profile.x - pad * 0.5 - area.x, area.height}, .label = props.dew_label, .invisible = true}) if profile_action != 0 { return 1 } @@ -90,7 +86,7 @@ AppGameHome :: (session: Session, props: AppGameHomeProps) -> bool { .base = 0x2a2722ff, .text = 0xffeec1ff, .selected = 0xad843eff, .selected_text = 0xffeec1ff, .border = 0x66522bff}) defer { unused WidgetPaletteRestore(session) } - return Button(session, ButtonProps.{.key = props.key, .bounds = props.bounds, + return Button.Draw(session, Button.Props.{.key = props.key, .bounds = props.bounds, .label = props.label, .icon_shape = "S1.8rr:M3 11L12 3L21 11M5 10V21H10V15H14V21H19V10", .emphasis = ButtonEmphasis.ButtonEmphasisSoft}) != 0 } diff --git a/src/host.zi b/src/host.zi index aaadee1..6ed58a3 100644 --- a/src/host.zi +++ b/src/host.zi @@ -17,8 +17,7 @@ #import "kryon/geometry" #import "kryon/tree" #import "kryon/tree_input" -#import "kryon/box_widget" -#import "kryon/box_props" +Box :: #import "kryon/box"; #import "kryon/drawing_props" #import, file "game_hud.zi"; #import, file "appearance.zi"; @@ -1497,7 +1496,7 @@ AppHostRun :: (host: *AppHost, mode: s32) -> bool { runtime.app.bounds = Rectangle.{guest_area.x, guest_area.y + 64.0, guest_area.width, guest_area.height - 64.0} runtime.legacy.frame.top += 64 guest_area = runtime.app.bounds - unused Box(frame_session, BoxProps.{.key = cast(u64)49190, + unused Box.Draw(frame_session, Box.Props.{.key = cast(u64)49190, .bounds = Rectangle.{home_bounds.x, home_bounds.y, home_bounds.width, 64.0}, .fill = ColorFromPacked(AppCoversPalette().background)}) } diff --git a/src/launcher.zi b/src/launcher.zi index f171094..584dcde 100644 --- a/src/launcher.zi +++ b/src/launcher.zi @@ -4,7 +4,15 @@ #import "std/byte_text_linux" #import "std/text_buffer" #import "std/utf8" -using UI :: #import "kryon/Widgets"; +#import "kryon/session" +#import "kryon/geometry" +#import "kryon/control_props" +#import "kryon/tree" +Button :: #import "kryon/button"; +Scroll :: #import "kryon/scroll"; +Separator :: #import "kryon/separator"; +Text :: #import "kryon/text"; +TextField :: #import "kryon/text_field"; #import, file "../ui/words.zi"; APP_LAUNCHER_LIST :: "S2rr:M9 6H20M9 12H20M9 18H20M4 6H4.01M4 12H4.01M4 18H4.01" @@ -32,13 +40,13 @@ AppLauncherState :: struct { } AppLauncherCards :: #type (context: *void, indices: []s32, bounds: Rectangle, - input: TextFieldInput, section_break: s32, columns: s32) -> bool; + input: TextField.Input, section_break: s32, columns: s32) -> bool; AppLauncherProps :: struct { bounds: Rectangle scale: float32 locale: string - input: TextFieldInput + input: TextField.Input search_class: s32 heading_class: s32 muted_class: s32 @@ -52,7 +60,7 @@ AppLauncherProps :: struct { AppLauncherResult :: struct { search_bounds: Rectangle scroll_bounds: Rectangle - scrolled: ScrollResult + scrolled: Scroll.ScrollResult favorites_bounds: Rectangle library_bounds: Rectangle cards_bounds: Rectangle @@ -98,7 +106,7 @@ AppLauncherMatches :: (name: string, query: string) -> bool { return false } -AppLauncherReplace :: (buffer: []u8, edit: TextFieldEdit) { +AppLauncherReplace :: (buffer: []u8, edit: TextField.Edit) { length := cast(s32)TextUntilNul(buffer).count size := length - (edit.end - edit.start) + cast(s32)edit.replacement.count if edit.start < 0 || edit.end < edit.start || edit.end > length || @@ -145,13 +153,13 @@ AppLauncherScreen :: (session: Session, state: *AppLauncherState, result.search_bounds = Rectangle.{bounds.x, bounds.y, bounds.width - 104.0 * scale, field_height} snapshot: [128]u8 for index: cast(s32)0..127 { snapshot[index] = state.query[index] } - field := TextField(session, TextFieldProps.{.key = cast(u64)30001, .focus_id = 6791, + field := TextField.Draw(session, TextField.Props.{.key = cast(u64)30001, .focus_id = 6791, .bounds = result.search_bounds, .value = TextUntilNul(snapshot[:]), .label = AppsLabel(props.locale, "search"), .placeholder = AppsLabel(props.locale, "search"), .clear_label = AppsLabel(props.locale, "clear_search"), .class_name = props.search_class, .cursor = state.cursor, .anchor = state.anchor, .scroll_x = state.scroll_x, .focused = state.focused, .max_bytes = 127, .max_codepoints = 80, .scale = scale, - .input = ifx state.focused then props.input else TextFieldInput.{}}) + .input = ifx state.focused then props.input else TextField.Input.{}}) if field.edit.changed { AppLauncherReplace(state.query[:], field.edit) state.scroll = 0 @@ -164,7 +172,7 @@ AppLauncherScreen :: (session: Session, state: *AppLauncherState, if field.clipboard_write { unused CopyCString(field.clipboard_text, result.clipboard_text[:]) } for mode: cast(s32)0..1 { grid := mode == 1 - if Button(session, ButtonProps.{.key = cast(u64)(30002 + mode), + if Button.Draw(session, Button.Props.{.key = cast(u64)(30002 + mode), .label = AppsLabel(props.locale, ifx grid then "grid_view" else "list_view"), .icon_shape = ifx grid then APP_LAUNCHER_GRID else APP_LAUNCHER_LIST, .icon_only = true, .selected = state.grid == grid, @@ -198,12 +206,12 @@ AppLauncherScreen :: (session: Session, state: *AppLauncherState, if state.count == 0 { library_height += cast(s32)(64.0 * scale) } top := bounds.y + 68.0 * scale if props.status.count > 0 { - Text(session, TextProps.{.key = cast(u64)30004, .text = props.status, + Text.Draw(session, Text.Props.{.key = cast(u64)30004, .text = props.status, .class_name = props.muted_class, .bounds = Rectangle.{bounds.x, top, bounds.width, 44.0 * scale}}) top += 48.0 * scale } result.scroll_bounds = Rectangle.{bounds.x, top, bounds.width, bounds.y + bounds.height - top} - result.scrolled = Scroll(session, ScrollProps.{.key = cast(u64)30005, .bounds = result.scroll_bounds, + result.scrolled = Scroll.Draw(session, Scroll.Props.{.key = cast(u64)30005, .bounds = result.scroll_bounds, .scale = scale, .scroll_offset = state.scroll, .content_height = favorites_height + library_height}) state.scroll = result.scrolled.scroll_offset if result.scrolled.opened { @@ -214,17 +222,17 @@ AppLauncherScreen :: (session: Session, state: *AppLauncherState, result.cards_bounds = Rectangle.{area.x, area.y + cast(float32)heading, area.width, cast(float32)(favorites_height + library_height - heading)} if sections { - Text(session, TextProps.{.key = cast(u64)30006, .text = AppsLabel(props.locale, "favorites"), + Text.Draw(session, Text.Props.{.key = cast(u64)30006, .text = AppsLabel(props.locale, "favorites"), .class_name = props.heading_class, .bounds = Rectangle.{area.x, area.y, area.width, 28.0 * scale}}) - Separator(session, SeparatorProps.{.key = cast(u64)30009, + Separator.Draw(session, Separator.Props.{.key = cast(u64)30009, .bounds = Rectangle.{area.x, result.library_bounds.y + 28.0 * scale, area.width, 8.0 * scale}}) } - input := ifx state.focused then TextFieldInput.{} else props.input + input := ifx state.focused then TextField.Input.{} else props.input if props.cards != null && state.count > 0 { result.ran = props.cards(props.context, state.visible[:state.count], result.cards_bounds, input, ifx sections then state.favorites else -1, result.columns) } else { - Text(session, TextProps.{.key = cast(u64)30008, .text = AppsLabel(props.locale, "no_results"), + Text.Draw(session, Text.Props.{.key = cast(u64)30008, .text = AppsLabel(props.locale, "no_results"), .class_name = props.muted_class, .bounds = result.cards_bounds}) result.ran = true } diff --git a/src/node_host.zi b/src/node_host.zi index e93f841..60e4b92 100644 --- a/src/node_host.zi +++ b/src/node_host.zi @@ -14,7 +14,7 @@ #import "kryon/notification_schedule_host" #import "kryon/widget_host" #import "kryon/widget_codec" -#import "kryon/text_input_props" +TextField :: #import "kryon/text_field"; #import, file "protocol.zi"; #import, file "node_types.zi"; #import, file "node_codec.zi"; @@ -44,7 +44,7 @@ NodeContext :: struct { succeeded: bool key: s32 // Typing for the text field that has focus, as app/1 apps receive it. - input: TextFieldInput + input: TextField.Input input_codec: WidgetTextFieldInputCodec } @@ -194,7 +194,7 @@ NodeCall :: (context: *void, module: *u8, function: *u8, arguments: *HostValue, return 1 } if name == "AppFieldInputHost" && count == 0 { - input := ifx node.message.action == APP_FRAME then node.input else TextFieldInput.{} + input := ifx node.message.action == APP_FRAME then node.input else TextField.Input.{} result.* = WidgetEncodeTextFieldInput(input, *node.input_codec) return 1 } diff --git a/tests/aggregate_guest.zi b/tests/aggregate_guest.zi deleted file mode 100644 index 5590e2a..0000000 --- a/tests/aggregate_guest.zi +++ /dev/null @@ -1,6 +0,0 @@ -// An aggregate import must remain usable even when a native consumer only -// calls a narrow subset of widgets. This catches imported slot record types. -#import "kryon/Widgets" - -#program_export -Check :: () -> s32 { return 0 } diff --git a/tests/game_hud_hosted.zi b/tests/game_hud_hosted.zi index 4ea75da..868d2a6 100644 --- a/tests/game_hud_hosted.zi +++ b/tests/game_hud_hosted.zi @@ -1,42 +1,42 @@ #import "game_hud" #import "kryon/session" #import "kryon/geometry" -#import "kryon/image_props" -#import "kryon/button_props" -#import "kryon/text_props" -#import "kryon/box_props" -boxes: [3]BoxProps; +Box :: #import "kryon/box"; +Button :: #import "kryon/button"; +Image :: #import "kryon/image"; +Text :: #import "kryon/text"; +boxes: [3]Box.Props; box_count: s32; #program_export -HudBox :: (session: Session, props: BoxProps) -> s32 { +HudBox :: (session: Session, props: Box.Props) -> s32 { unused session if box_count < 3 { boxes[box_count] = props } box_count += 1 return 0 } -images: [2]ImageProps; -buttons: [2]ButtonProps; -amount: TextProps; +images: [2]Image.Props; +buttons: [2]Button.Props; +amount: Text.Props; image_count: s32; button_count: s32; activation: s32; palette_text: u32; restores: s32; #program_export -HudImage :: (session: Session, props: ImageProps) { +HudImage :: (session: Session, props: Image.Props) { unused session if image_count < 2 { images[image_count] = props } image_count += 1 } #program_export -HudButton :: (session: Session, props: ButtonProps) -> s32 { +HudButton :: (session: Session, props: Button.Props) -> s32 { unused session if button_count < 2 { buttons[button_count] = props } button_count += 1 return ifx button_count == activation then 1 else 0 } #program_export -HudText :: (session: Session, props: TextProps) { unused session; amount = props } +HudText :: (session: Session, props: Text.Props) { unused session; amount = props } #program_export Check :: () -> s32 { props := AppGameHudProps.{.key = 700, .bounds = Rectangle.{31.0, 47.0, 240.0, 56.0}, diff --git a/tests/game_hud_test.py b/tests/game_hud_test.py index 5ba7881..5b579e0 100644 --- a/tests/game_hud_test.py +++ b/tests/game_hud_test.py @@ -78,10 +78,10 @@ def main(): '--entry', 'game_hud_behavior:Check', *args, '-o', bundle, ROOT / 'tests/game_hud_behavior.zi') assert run(toolchain / 'build/bin/zi2zx', 'run', '--vm', bundle).strip() == '0' print('PASS portable: same retained-tree behavior and bounds') - args = [arg for source, target in [('image_widget:ImageHostedHost', 'HudImage'), - ('button_widget:ButtonHostedHost', 'HudButton'), ('box_widget:BoxHostedHost', 'HudBox'), + args = [arg for source, target in [('image:ImageHostedHost', 'HudImage'), + ('button:ButtonHostedHost', 'HudButton'), ('box:BoxHostedHost', 'HudBox'), ('widget_palette:WidgetPaletteHostedHost', 'HudPalette'), - ('widget_palette:WidgetPaletteRestoreHostedHost', 'HudPaletteRestore'), ('text_widget:TextHostedHost', 'HudText')] + ('widget_palette:WidgetPaletteRestoreHostedHost', 'HudPaletteRestore'), ('text:TextHostedHost', 'HudText')] for arg in ('--bind', f'kryon/{source}=game_hud_hosted:{target}')] bundle = WORK / 'hosted.zx' run(toolchain / 'build/bin/zi2zx', 'bundle', '--module-path', toolchain / 'std', '--root', ROOT / 'tests', '--define', 'KRYON_HOSTED_UI', diff --git a/tests/native_behavior.zi b/tests/native_behavior.zi index 83ae418..2ffe78f 100644 --- a/tests/native_behavior.zi +++ b/tests/native_behavior.zi @@ -22,10 +22,8 @@ #import "kryon/input_protocol" #import "kryon/frame_snapshot" #import "kryon/widget_codec" -#import "kryon/button_props" -#import "kryon/scroll_widget" -#import "kryon/scroll_props" -#import "kryon/text_input_props" +Scroll :: #import "kryon/scroll"; +TextField :: #import "kryon/text_field"; #import, file "../src/controller.zi"; #import, file "../src/protocol.zi"; #import, file "../src/catalog.zi"; @@ -420,7 +418,7 @@ NativeDraw :: (quiet: bool = false, cards_only: bool = true) -> bool { native_controller.app.bounds = Rectangle.{0.0, 0.0, 480.0, 600.0} outer: bool if native_icon_mode { - group := Scroll(ui_session, ScrollProps.{.key = cast(u64)99, .bounds = Rectangle.{0.0, 0.0, 480.0, 88.0}, .content_height = 200}) + group := Scroll.Draw(ui_session, Scroll.Props.{.key = cast(u64)99, .bounds = Rectangle.{0.0, 0.0, 480.0, 88.0}, .content_height = 200}) if !group.opened { return false } outer = true native_controller.app.bounds = Rectangle.{group.content.x, group.content.y, group.content.width, 88.0} @@ -563,11 +561,11 @@ NativeControllerCheck :: () -> s32 { if leaf < 0 || !TreeActivateAt(ui_session, leaf) || !NativeDraw() { return 77 } field := NativeLabel("Name", WidgetKindTextField) if field < 0 || !TreeFocusAt(ui_session, field) || !NativeDraw() || !NativeDraw() { return 78 } - native_controller.app.input = TextFieldInput.{.select_all = true} + native_controller.app.input = TextField.Input.{.select_all = true} if !NativeDraw() { return 79 } - native_controller.app.input = TextFieldInput.{.text = "Calm"} + native_controller.app.input = TextField.Input.{.text = "Calm"} if !NativeDraw() { return 80 } - native_controller.app.input = TextFieldInput.{} + native_controller.app.input = TextField.Input.{} if !NativeDraw() || !NativeClick("Save", WidgetKindButton) || !NativeDraw() || native_queued != 5 || native_request.operation != APPS_PROPERTIES || TextUntilNul(native_request.id[:]) != "native.breathing" || TextUntilNul(native_request.title[:]) != "Calm" || TextUntilNul(native_request.icon[:]) != "leaf" || diff --git a/ui/apps.zi b/ui/apps.zi index b2924b0..5d9d395 100644 --- a/ui/apps.zi +++ b/ui/apps.zi @@ -8,39 +8,31 @@ #import "std/text_buffer" #import "kryon/app_context" #import "kryon/app_protocol" -#import "kryon/text_widget" -#import "kryon/text_props" #import "kryon/text_align" -#import "kryon/image_widget" -#import "kryon/image_props" -#import "kryon/button_widget" -#import "kryon/button_props" #import "kryon/control_props" -#import "kryon/box_widget" -#import "kryon/box_props" -#import "kryon/scroll_widget" -#import "kryon/scroll_props" -#import "kryon/text_field_widget" -#import "kryon/text_input_props" -#import "kryon/context_menu_widget" -#import "kryon/modal_widget" -#import "kryon/modal_frame_widget" -#import "kryon/modal_props" #import "kryon/drawing_props" #import "kryon/session" #import "kryon/geometry" #import "kryon/tree" -#import "kryon/carousel" -#import "kryon/joystick" #import "kryon/input_protocol" -#import "kryon/loading_indicator" #import "kryon/widget_palette" +Box :: #import "kryon/box"; +Button :: #import "kryon/button"; +Carousel :: #import "kryon/carousel"; +ContextMenu :: #import "kryon/context_menu"; +Image :: #import "kryon/image"; +Joystick :: #import "kryon/joystick"; +LoadingIndicator :: #import "kryon/loading_indicator"; +Modal :: #import "kryon/modal"; +Scroll :: #import "kryon/scroll"; +Text :: #import "kryon/text"; +TextField :: #import "kryon/text_field"; #import "appearance" Rules :: #import "protocol"; #import, file "words.zi"; -using ImageFit; -using TextWrap; +using Image.ImageFit; +using Text.Wrap; using TextAlign; using ButtonTone; using ButtonEmphasis; @@ -111,7 +103,7 @@ can_back: bool; icon_mode: bool; cover_mode: bool; cover_grid: bool; -cover_state: CarouselState; +cover_state: Carousel.CarouselState; // The launcher transition advances with rendered frames; no game clock or // optional host time capability is required by icon/list-only controllers. cover_time: float64; @@ -150,7 +142,7 @@ download_fresh: bool; last_download_request: s64; // Console games use the same artwork title as standalone cover collections. title_id: [128]u8; -title_state: CarouselState; +title_state: Carousel.CarouselState; title_fresh: bool; ConsoleDownload :: struct { id: [128]u8 @@ -422,7 +414,7 @@ AppsAct :: (operation: string, target: [128]u8, version: Rules.AppVersion = Rule } AppsText :: (session: Session, key: u64, bounds: Rectangle, text: string, font: s32) { - Text(session, TextProps.{.key = key, .bounds = bounds, .text = text, .font = font, .wrap = cast(TextWrap)TextWrapEllipsis}) + Text.Draw(session, Text.Props.{.key = key, .bounds = bounds, .text = text, .size = font, .wrap = cast(Text.Wrap)TextWrapEllipsis}) } AppsFind :: (id: [128]u8) -> *AppCard { @@ -432,17 +424,17 @@ AppsFind :: (id: [128]u8) -> *AppCard { return null } -AppsMenuItem :: (items: []ContextMenuItem, count: *s32, card: *AppCard, operation: s32, +AppsMenuItem :: (items: []ContextMenu.ContextMenuItem, count: *s32, card: *AppCard, operation: s32, language: string, label: string, disabled: bool = false) { if !AppsSupported(card, operation) { return } - items[count.*] = ContextMenuItem.{.id = operation, .label = AppsLabel(language, label), .disabled = disabled} + items[count.*] = ContextMenu.ContextMenuItem.{.id = operation, .label = AppsLabel(language, label), .disabled = disabled} count.* += 1 } AppsMenu :: (session: Session, scale: float32, language: string) { card := AppsFind(menu_id) if card == null || card.disabled { menu_id[0] = cast(u8)0; return } - items: [7]ContextMenuItem + items: [7]ContextMenu.ContextMenuItem count: s32 // The options' dot leads here, so an update not yet installed comes first. if card.update_available { AppsMenuItem(items[:], *count, card, Rules.APPS_UPDATE, language, "update") } @@ -457,7 +449,7 @@ AppsMenu :: (session: Session, scale: float32, language: string) { if card.history_count > 0 { AppsMenuItem(items[:], *count, card, Rules.APPS_ROLLBACK, language, "rollback") } AppsMenuItem(items[:], *count, card, Rules.APPS_PROPERTIES, language, "properties") if count == 0 { menu_id[0] = cast(u8)0; return } - menu := ContextMenu(session, ContextMenuProps.{.key = cast(u64)7, .open = true, .x = menu_x, .y = menu_y, + menu := ContextMenu.Draw(session, ContextMenu.Props.{.key = cast(u64)7, .open = true, .x = menu_x, .y = menu_y, .scale = scale, .escape = AppKey() == 256 || AppKey() == 27}, items[:count]) if menu.activated_id == Rules.APPS_UPDATE { dialog_id = card.id; dialog = 1; dialog_target = card.available } else if menu.activated_id == Rules.APPS_ROLLBACK { dialog_id = card.id; dialog = 2 } @@ -471,8 +463,8 @@ AppsMenu :: (session: Session, scale: float32, language: string) { } AppsActionProps :: (key: u64, card: *AppCard, action_class: s32, bounds: Rectangle, - language: string, cover_grid: bool) -> ButtonProps { - props := ButtonProps.{.key = key, .label = AppsLabel(language, "options"), + language: string, cover_grid: bool) -> Button.Props { + props := Button.Props.{.key = key, .label = AppsLabel(language, "options"), .icon_shape = APP_ELLIPSIS, .icon_only = true, .class_name = action_class, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost, .bounds = bounds, .disabled = card.disabled, .fit_content = true} @@ -574,7 +566,7 @@ AppsProperties :: (session: Session, card: *AppCard, scale: float32, language: s // when the window is shorter than the dialog. content_height := line + 4.0 * scale + control + gap + control if count > 0 { content_height += line + 4.0 * scale + cast(float32)((count + 7) / 8) * cell_height + 8.0 * scale + gap } - frame := ModalFrame(session, ModalFrameProps.{.key = cast(u64)12, .title = AppsLabel(language, "properties"), + frame := Modal.Draw(session, Modal.Props.{.key = cast(u64)12, .title = AppsLabel(language, "properties"), .width = cast(s32)(440.0 * scale), .height = cast(s32)(content_height + 74.0 * scale), .scale = scale}) if frame.dismissed { AppsPropertiesClose(); return } if !frame.opened { return } @@ -590,12 +582,12 @@ AppsProperties :: (session: Session, card: *AppCard, scale: float32, language: s // The field reads a snapshot, so its edit can change the title itself. snapshot: [256]u8 for byte: cast(s64)0..snapshot.count - 1 { snapshot[byte] = properties_title[byte] } - field := TextFieldProps.{.key = cast(u64)14, .bounds = Rectangle.{x, y, width, control}, + field := TextField.Props.{.key = cast(u64)14, .bounds = Rectangle.{x, y, width, control}, .value = TextUntilNul(snapshot[:]), .label = AppsLabel(language, "name"), .placeholder = placeholder, .cursor = properties_cursor, .anchor = properties_anchor, .scroll_x = properties_scroll_x, .focused = properties_focused, .scale = scale, .max_bytes = cast(s32)properties_title.count - 1} if properties_focused { field.input = AppFieldInput() } - edited := TextField(session, field) + edited := TextField.Draw(session, field) if edited.edit.changed { AppsReplaceText(properties_title[:], edited.edit.start, edited.edit.end, edited.edit.replacement) } @@ -613,7 +605,7 @@ AppsProperties :: (session: Session, card: *AppCard, scale: float32, language: s rows := (count + columns - 1) / columns visible := bottom - control - gap - y if visible < cell_height { visible = cell_height } - grid := Scroll(session, ScrollProps.{.key = cast(u64)16, .bounds = Rectangle.{x, y, width, visible}, .scale = scale, + grid := Scroll.Draw(session, Scroll.Props.{.key = cast(u64)16, .bounds = Rectangle.{x, y, width, visible}, .scale = scale, .content_height = cast(s32)(cast(float32)rows * cell_height + 8.0 * scale), .scroll_offset = icon_scroll}) icon_scroll = grid.scroll_offset if grid.opened { @@ -622,24 +614,24 @@ AppsProperties :: (session: Session, card: *AppCard, scale: float32, language: s chosen := TextUntilNul(choice.id[:]) == TextUntilNul(properties_icon[:]) label := TextUntilNul(choice.id[:]) if label == "" { label = placeholder } - icon := ButtonProps.{.key = cast(u64)(100 + index), .label = label, .icon_only = true, .circle = true, + icon := Button.Props.{.key = cast(u64)(100 + index), .label = label, .icon_only = true, .circle = true, .icon_shape = TextUntilNul(choice.shape[:]), .selected = chosen, - .image = ImageProps.{.asset_path = TextUntilNul(choice.image[:]), .alt_text = label}, + .image = Image.Props.{.asset_path = TextUntilNul(choice.image[:]), .alt_text = label}, .bounds = Rectangle.{grid.content.x + cast(float32)(index % columns) * cell_width + 4.0 * scale, grid.content.y + cast(float32)(index / columns) * cell_height + 4.0 * scale, 40.0 * scale, 40.0 * scale}, .tone = cast(ButtonTone)(ifx chosen then ButtonToneAccent else ButtonToneNeutral), .emphasis = cast(ButtonEmphasis)(ifx chosen then ButtonEmphasisFilled else ButtonEmphasisSoft)} - if Button(session, icon) != 0 { properties_icon = choice.id } + if Button.Draw(session, icon) != 0 { properties_icon = choice.id } } End(session) } } button_width := (width - gap) * 0.5 if button_width > 160.0 * scale { button_width = 160.0 * scale } - save := Button(session, ButtonProps.{.key = cast(u64)17, .label = AppsLabel(language, "save"), + save := Button.Draw(session, Button.Props.{.key = cast(u64)17, .label = AppsLabel(language, "save"), .bounds = Rectangle.{x + width - button_width, bottom - control, button_width, control}, .tone = cast(ButtonTone)ButtonToneAccent, .emphasis = cast(ButtonEmphasis)ButtonEmphasisFilled}) != 0 - cancel := Button(session, ButtonProps.{.key = cast(u64)18, .label = AppsLabel(language, "cancel"), + cancel := Button.Draw(session, Button.Props.{.key = cast(u64)18, .label = AppsLabel(language, "cancel"), .bounds = Rectangle.{x + width - button_width * 2.0 - gap, bottom - control, button_width, control}, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 End(session) @@ -723,9 +715,9 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str viewport := AppBounds() art := ifx viewport.width > viewport.height then TextUntilNul(card.cover.landscape[:]) else TextUntilNul(card.cover.portrait[:]) if art == "" { art = TextUntilNul(card.preview[:]) } - unused Image(session, ImageProps.{.key = cast(u64)50030, .bounds = viewport, - .asset_path = art, .alt_text = TextUntilNul(card.title[:]), .fit = ImageFit.ImageFitCover, .smooth = true}) - unused Box(session, BoxProps.{.key = cast(u64)50031, .bounds = viewport, + unused Image.Draw(session, Image.Props.{.key = cast(u64)50030, .bounds = viewport, + .asset_path = art, .alt_text = TextUntilNul(card.title[:]), .fit = Image.ImageFit.ImageFitCover, .smooth = true}) + unused Box.Draw(session, Box.Props.{.key = cast(u64)50031, .bounds = viewport, .fill = Color.{5, 13, 20, 35}, .fill_bottom = Color.{5, 13, 20, 245}, .has_fill_bottom = true}) width := viewport.width - 48.0 * scale if width > 560.0 * scale { width = 560.0 * scale } @@ -734,12 +726,12 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str if area.y < viewport.y + 120.0 * scale { area.y = viewport.y + 120.0 * scale } AppsText(session, cast(u64)50032, Rectangle.{area.x, area.y - 64.0 * scale, width, 52.0 * scale}, TextUntilNul(card.title[:]), font + 18) - if Button(session, ButtonProps.{.key = cast(u64)50033, + if Button.Draw(session, Button.Props.{.key = cast(u64)50033, .bounds = Rectangle.{viewport.x + 12.0 * scale, viewport.y + 12.0 * scale, 108.0 * scale, 48.0 * scale}, .label = AppsLabel(language, "back"), .icon_shape = "S2rr:M15 18L9 12L15 6", .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 { AppsPropertiesClose(); return } } else { - frame := ModalFrame(session, ModalFrameProps.{.key = cast(u64)19, .title = TextUntilNul(card.title[:]), + frame := Modal.Draw(session, Modal.Props.{.key = cast(u64)19, .title = TextUntilNul(card.title[:]), .width = cast(s32)(440.0 * scale), .height = cast(s32)(content_height + 74.0 * scale), .scale = scale, .dismiss_disabled = opening}) if frame.dismissed { AppsPropertiesClose(); return } @@ -751,9 +743,9 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str width := area.width bottom := area.y + area.height // The card's own picture or symbol, as its tile shows it. - unused Button(session, ButtonProps.{.key = cast(u64)20, .label = TextUntilNul(card.title[:]), .icon_only = true, + unused Button.Draw(session, Button.Props.{.key = cast(u64)20, .label = TextUntilNul(card.title[:]), .icon_only = true, .icon_shape = TextUntilNul(card.icon_shape[:]), - .image = ImageProps.{.asset_path = TextUntilNul(card.icon[:]), .alt_text = TextUntilNul(card.title[:])}, + .image = Image.Props.{.asset_path = TextUntilNul(card.icon[:]), .alt_text = TextUntilNul(card.title[:])}, .bounds = Rectangle.{x, y, icon_size, icon_size}, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) // One line beside the icon says where the download stands. state: Vec(u8) @@ -766,13 +758,13 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str else { BuilderPrint(*state, "%", AppsLabel(language, "download")) } unused CopyCString(TextView(VecSlice(state, 0, state.count)), dialog_message[:]) VecFree(state) - Text(session, TextProps.{.key = cast(u64)21, .text = TextUntilNul(dialog_message[:]), .font = font + 2, + Text.Draw(session, Text.Props.{.key = cast(u64)21, .text = TextUntilNul(dialog_message[:]), .size = font + 2, .bounds = Rectangle.{x + icon_size + gap, y, width - icon_size - gap, icon_size}, - .wrap = cast(TextWrap)TextWrapEllipsis, .vertical_align = cast(TextAlign)TextAlignCenter}) + .wrap = cast(Text.Wrap)TextWrapEllipsis, .vertical_align = cast(TextAlign)TextAlignCenter}) y += icon_size + gap if editor_addon { - Text(session, TextProps.{.key = cast(u64)29, .text = AppsLabel(language, "editor_addon"), - .font = font, .bounds = Rectangle.{x, y, width, line * 3.0}, .wrap = cast(TextWrap)TextWrapAuto}) + Text.Draw(session, Text.Props.{.key = cast(u64)29, .text = AppsLabel(language, "editor_addon"), + .size = font, .bounds = Rectangle.{x, y, width, line * 3.0}, .wrap = cast(Text.Wrap)TextWrapAuto}) y += line * 3.0 + gap } if card.download_count > 1 { @@ -812,17 +804,17 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str if card.downloading || (download_started && !card.on_device && !card.download_failed) { track := Rectangle.{x, y, width, bar} if card.downloading && card.progress >= 0 { - unused Box(session, BoxProps.{.key = cast(u64)28, .bounds = track, .radius = bar * 0.5, + unused Box.Draw(session, Box.Props.{.key = cast(u64)28, .bounds = track, .radius = bar * 0.5, .fill = ifx AppDark() then Color.{58, 74, 68, 255} else Color.{221, 232, 226, 255}}) fill := track fill.width = width * cast(float32)card.progress / 100.0 if fill.width >= bar { - unused Box(session, BoxProps.{.key = cast(u64)29, .bounds = fill, .radius = bar * 0.5, + unused Box.Draw(session, Box.Props.{.key = cast(u64)29, .bounds = fill, .radius = bar * 0.5, .fill = Color.{46, 125, 74, 255}}) } } else { // Until its size is known, Kryon's loading dots, as every app shows. - LoadingIndicator(session, LoadingIndicatorProps.{.key = cast(u64)29, + LoadingIndicator.Draw(session, LoadingIndicator.Props.{.key = cast(u64)29, .bounds = Rectangle.{x, y - bar, width, bar * 3.0}, .now = cast(float64)download_frames / 60.0, .scale = scale}) } @@ -834,10 +826,10 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str secondary := Rectangle.{x + width - button_width * 2.0 - gap, bottom - control, button_width, control} if asking || card.download_failed || card.on_device { label := ifx card.on_device then (ifx card.installed then "open" else "install") else (ifx card.download_failed then "try_again" else "download") - go := Button(session, ButtonProps.{.key = cast(u64)30, .label = AppsLabel(language, label), .bounds = primary, + go := Button.Draw(session, Button.Props.{.key = cast(u64)30, .label = AppsLabel(language, label), .bounds = primary, .tone = cast(ButtonTone)ButtonToneAccent, .emphasis = cast(ButtonEmphasis)ButtonEmphasisFilled, .disabled = !AppsSupported(card, ifx card.on_device && card.installed then Rules.APPS_OPEN else Rules.APPS_INSTALL)}) != 0 - close := Button(session, ButtonProps.{.key = cast(u64)31, .bounds = secondary, + close := Button.Draw(session, Button.Props.{.key = cast(u64)31, .bounds = secondary, .label = AppsLabel(language, ifx asking then "cancel" else "close"), .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 if !cover_grid { End(session) } @@ -847,7 +839,7 @@ AppsDownload :: (session: Session, card: *AppCard, scale: float32, language: str return } // The download goes on without the dialog. - hide := Button(session, ButtonProps.{.key = cast(u64)32, .label = AppsLabel(language, "hide"), .bounds = primary, + hide := Button.Draw(session, Button.Props.{.key = cast(u64)32, .label = AppsLabel(language, "hide"), .bounds = primary, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 if !cover_grid { End(session) } if hide { AppsPropertiesClose() } @@ -870,13 +862,13 @@ AppsDialog :: (session: Session, scale: float32, language: string, font: s32) { (dialog >= 2 && !AppsSupported(card, Rules.APPS_ROLLBACK)) { dialog = 0; return } message: Vec(u8) BuilderPrint(*message, "%\n%: %", TextUntilNul(card.title[:]), AppsLabel(language, "current_version"), TextUntilNul(card.current_version[:])) - actions: [4]ActionModalAction + actions: [4]Modal.ActionModalAction count: s32 valid: bool if dialog == 2 { BuilderPrint(*message, "\n%", AppsLabel(language, "choose_version")) for index: cast(s32)0..card.history_count - 1 { - actions[count] = ActionModalAction.{.label = TextUntilNul(card.history[index].version[:]), .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft} + actions[count] = Modal.ActionModalAction.{.label = TextUntilNul(card.history[index].version[:]), .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft} count += 1 } } else { @@ -888,15 +880,15 @@ AppsDialog :: (session: Session, scale: float32, language: string, font: s32) { if AppsVersionEqual(*card.history[index], *dialog_target) { valid = true } } } - actions[count] = ActionModalAction.{.label = AppsLabel(language, ifx dialog == 1 then "update" else "rollback"), + actions[count] = Modal.ActionModalAction.{.label = AppsLabel(language, ifx dialog == 1 then "update" else "rollback"), .tone = cast(ButtonTone)ButtonToneAccent, .emphasis = cast(ButtonEmphasis)ButtonEmphasisFilled, .disabled = !valid} count += 1 } - actions[count] = ActionModalAction.{.label = AppsLabel(language, "cancel"), .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost} + actions[count] = Modal.ActionModalAction.{.label = AppsLabel(language, "cancel"), .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost} count += 1 unused CopyCString(TextView(VecSlice(message, 0, message.count)), dialog_message[:]) VecFree(message) - result := ActionModal(session, ActionModalProps.{.key = cast(u64)(8 + dialog), .title = AppsLabel(language, ifx dialog == 1 then "update" else "rollback"), + result := Modal.ActionModal(session, Modal.ActionModalProps.{.key = cast(u64)(8 + dialog), .title = AppsLabel(language, ifx dialog == 1 then "update" else "rollback"), .message = TextUntilNul(dialog_message[:]), .scale = scale, .max_width = 440}, actions[:count]) if result.action < 0 || result.action == count { dialog = 0 } else if result.action > 0 { @@ -925,7 +917,7 @@ AppsSize :: (bytes: s64, output: []u8) -> bool { // Reuse the collection's artwork, logo, caption and Play control unchanged. AppsTitleOpen :: (card: *AppCard) { title_id = card.id - title_state = CarouselState.{} + title_state = Carousel.CarouselState.{} title_fresh = true } @@ -975,9 +967,9 @@ AppsConsoleOpen :: (card: *AppCard) { AppsTitle :: (session: Session, bounds: Rectangle, scale: float32, language: string) { card := AppsFind(title_id) if card == null || card.disabled { title_id[0] = 0; return } - items: [1]CarouselItem + items: [1]Carousel.CarouselItem action := TextUntilNul(card.cover.action[:]) - items[0] = CarouselItem.{.label = TextUntilNul(card.title[:]), + items[0] = Carousel.CarouselItem.{.label = TextUntilNul(card.title[:]), .portrait = ifx card.cover.portrait[0] != 0 then TextUntilNul(card.cover.portrait[:]) else TextUntilNul(card.preview[:]), .landscape = TextUntilNul(card.cover.landscape[:]), .logo = TextUntilNul(card.cover.logo[:]), .caption = TextUntilNul(card.cover.caption[:]), @@ -986,7 +978,7 @@ AppsTitle :: (session: Session, bounds: Rectangle, scale: float32, language: str (ifx action == "buy" then !AppsSupported(card, Rules.APPS_INSTALL) else (!AppsSupported(card, Rules.APPS_OPEN) && !((!card.on_device || !card.installed) && AppsSupported(card, Rules.APPS_INSTALL))))} cover_time += 1.0 / 60.0 - entered := Carousel(session, CarouselProps.{.key = cast(u64)50000, .bounds = bounds, + entered := Carousel.Draw(session, Carousel.Props.{.key = cast(u64)50000, .bounds = bounds, .logo_max_width = cover_logo_width, .logo_top = cover_logo_top, .label = TextUntilNul(card.title[:]), .now = cover_time, .key_pressed = ifx title_fresh || dialog != 0 then 0 else AppKey(), .scale = scale, .dark = AppDark(), @@ -997,7 +989,7 @@ AppsTitle :: (session: Session, bounds: Rectangle, scale: float32, language: str if (!card.on_device || !card.installed) && AppsSupported(card, Rules.APPS_INSTALL) { AppsDownloadOpen(card) } else { AppsAct("open", card.id); title_id[0] = 0 } } - if AppKey() == 256 || AppKey() == 27 || AppKey() == 290 || Button(session, ButtonProps.{.key = cast(u64)2, + if AppKey() == 256 || AppKey() == 27 || AppKey() == 290 || Button.Draw(session, Button.Props.{.key = cast(u64)2, .label = AppsLabel(language, "back"), .bounds = Rectangle.{bounds.x + 12.0 * scale, bounds.y + 12.0 * scale, 84.0 * scale, 44.0 * scale}, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 { title_id[0] = 0 } @@ -1005,7 +997,7 @@ AppsTitle :: (session: Session, bounds: Rectangle, scale: float32, language: str } AppsSceneryCircle :: (session: Session, key: u64, x: float32, y: float32, radius: float32, fill: Color) { - Box(session, BoxProps.{.key = key, .bounds = Rectangle.{x - radius, y - radius, radius * 2.0, radius * 2.0}, + Box.Draw(session, Box.Props.{.key = key, .bounds = Rectangle.{x - radius, y - radius, radius * 2.0, radius * 2.0}, .radius = radius, .fill = fill}) } @@ -1021,7 +1013,7 @@ AppsSceneryStart :: (shift: float32, tile: float32) -> float32 { // repeats across any width, drifts gently with the selection and never paints a // game's own artwork behind its cover. AppsScenery :: (session: Session, bounds: Rectangle, scale: float32, position: float32) { - Box(session, BoxProps.{.key = cast(u64)50400, .bounds = bounds, + Box.Draw(session, Box.Props.{.key = cast(u64)50400, .bounds = bounds, .fill = Color.{17, 42, 66, 255}, .fill_bottom = Color.{58, 124, 122, 255}, .has_fill_bottom = true}) // A low moon with a faint halo. moon_x := bounds.x + bounds.width * 0.17 @@ -1048,7 +1040,7 @@ AppsScenery :: (session: Session, bounds: Rectangle, scale: float32, position: f cloud_y := bounds.y + bounds.height * (ifx index % 2 == 0 then 0.17 else 0.31) // Solid, so overlapping puffs read as one soft cloud. cloud := Color.{50, 88, 106, 255} - Box(session, BoxProps.{.key = key + cast(u64)6, .bounds = Rectangle.{x + tile * 0.30, cloud_y, tile * 0.42, 22.0 * scale}, + Box.Draw(session, Box.Props.{.key = key + cast(u64)6, .bounds = Rectangle.{x + tile * 0.30, cloud_y, tile * 0.42, 22.0 * scale}, .radius = 11.0 * scale, .fill = cloud}) AppsSceneryCircle(session, key + cast(u64)7, x + tile * 0.44, cloud_y + 2.0 * scale, 20.0 * scale, cloud) AppsSceneryCircle(session, key + cast(u64)8, x + tile * 0.56, cloud_y + 4.0 * scale, 14.0 * scale, cloud) @@ -1058,7 +1050,7 @@ AppsScenery :: (session: Session, bounds: Rectangle, scale: float32, position: f top := bounds.y + bounds.height * (0.58 + cast(float32)layer * 0.13) radius := tile * (0.56 - cast(float32)layer * 0.06) fill := ifx layer == 0 then Color.{56, 122, 124, 255} else ifx layer == 1 then Color.{36, 96, 96, 255} else Color.{21, 64, 68, 255} - Box(session, BoxProps.{.key = cast(u64)(50410 + layer), + Box.Draw(session, Box.Props.{.key = cast(u64)(50410 + layer), .bounds = Rectangle.{bounds.x, top, bounds.width, bounds.y + bounds.height - top}, .fill = fill}) layer_start := AppsSceneryStart(-position * cast(float32)(24 + layer * 28) * scale - cast(float32)layer * tile * 0.37, tile) for index: cast(s32)0..tiles - 1 { @@ -1076,7 +1068,7 @@ AppsScenery :: (session: Session, bounds: Rectangle, scale: float32, position: f tree_x := x + tile * (0.12 + cast(float32)tree * 0.31) size := cast(float32)(13 + (tree * 5 + index * 3) % 8) * scale base := top - radius * (0.18 - cast(float32)tree * 0.05) - Box(session, BoxProps.{.key = key + cast(u64)(tree * 2), .bounds = Rectangle.{tree_x - 2.0 * scale, base - size, 4.0 * scale, size + 4.0 * scale}, + Box.Draw(session, Box.Props.{.key = key + cast(u64)(tree * 2), .bounds = Rectangle.{tree_x - 2.0 * scale, base - size, 4.0 * scale, size + 4.0 * scale}, .fill = Color.{30, 62, 58, 255}}) AppsSceneryCircle(session, key + cast(u64)(tree * 2 + 1), tree_x, base - size * 1.4, size, Color.{28, 82, 78, 255}) @@ -1084,7 +1076,7 @@ AppsScenery :: (session: Session, bounds: Rectangle, scale: float32, position: f } } shade := bounds.y + bounds.height * 0.62 - Box(session, BoxProps.{.key = cast(u64)50420, .bounds = Rectangle.{bounds.x, shade, bounds.width, bounds.y + bounds.height - shade}, + Box.Draw(session, Box.Props.{.key = cast(u64)50420, .bounds = Rectangle.{bounds.x, shade, bounds.width, bounds.y + bounds.height - shade}, .fill = Color.{6, 18, 24, 0}, .fill_bottom = Color.{6, 18, 24, 170}, .has_fill_bottom = true}) } @@ -1106,13 +1098,13 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s if key == 263 || key == 265 { delta = -1 } cover_time += 1.0 / 60.0 if dialog == 0 && menu_id[0] == 0 { - wheel := CarouselWheel(session, bounds) + wheel := Carousel.CarouselWheel(session, bounds) if wheel != 0.0 && cover_time - cover_state.wheel_time > 0.18 { delta = ifx wheel < 0.0 then 1 else -1 cover_state.wheel_time = cover_time } } - CarouselSelect(*cover_state, count, delta, cover_time) + Carousel.CarouselSelect(*cover_state, count, delta, cover_time) selected_index := cover_state.selected AppsScenery(session, bounds, scale, cover_state.position) gap := 18.0 * scale @@ -1147,27 +1139,27 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s if focused { for glow: cast(s32)0..2 { pad := cast(float32)(10 - glow * 3) * scale - Box(session, BoxProps.{.key = card_key + cast(u64)(10 + glow), + Box.Draw(session, Box.Props.{.key = card_key + cast(u64)(10 + glow), .bounds = Rectangle.{frame.x - pad, frame.y - pad, w + pad * 2.0, h + pad * 2.0}, .radius = 20.0 * scale + pad, .fill = ifx glow == 2 then Color.{211, 255, 219, 255} else Color.{80, 235, 219, cast(u8)(35 + glow * 35)}}) } } else { - Box(session, BoxProps.{.key = card_key + cast(u64)10, + Box.Draw(session, Box.Props.{.key = card_key + cast(u64)10, .bounds = Rectangle.{frame.x - 2.0 * scale, frame.y - 2.0 * scale, w + 4.0 * scale, h + 4.0 * scale}, .radius = 18.0 * scale, .fill = Color.{151, 182, 167, 190}}) } art := ifx wide then TextUntilNul(card.cover.landscape[:]) else TextUntilNul(card.cover.portrait[:]) if art == "" { art = TextUntilNul(card.preview[:]) } - Image(session, ImageProps.{.key = card_key + cast(u64)2, .asset_path = art, + Image.Draw(session, Image.Props.{.key = card_key + cast(u64)2, .asset_path = art, .alt_text = TextUntilNul(card.title[:]), .bounds = frame, .radius = 16.0 * scale, - .fit = ImageFit.ImageFitCover, .smooth = true}) + .fit = Image.ImageFit.ImageFitCover, .smooth = true}) if !focused { - Box(session, BoxProps.{.key = card_key + cast(u64)13, .bounds = frame, + Box.Draw(session, Box.Props.{.key = card_key + cast(u64)13, .bounds = frame, .radius = 16.0 * scale, .fill = Color.{0, 10, 18, 65}}) } download_first := (!card.on_device || !card.installed) && AppsSupported(card, Rules.APPS_INSTALL) - if Button(session, ButtonProps.{.key = card_key, .bounds = frame, .label = TextUntilNul(card.title[:]), + if Button.Draw(session, Button.Props.{.key = card_key, .bounds = frame, .label = TextUntilNul(card.title[:]), .selected = focused, .invisible = true, .disabled = dialog != 0 || card.disabled || ((key == 257 || key == 32) && !focused) || (!AppsSupported(card, Rules.APPS_OPEN) && !download_first)}) != 0 { if focused { activated = index } @@ -1176,12 +1168,12 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s pending := AppsConsolePending(card.id) >= 0 if card.downloading || pending { track := Rectangle.{frame.x + 10.0 * scale, frame.y + h - 24.0 * scale, w - 64.0 * scale, 14.0 * scale} - Box(session, BoxProps.{.key = card_key + cast(u64)14, .bounds = track, + Box.Draw(session, Box.Props.{.key = card_key + cast(u64)14, .bounds = track, .radius = 7.0 * scale, .fill = Color.{20, 39, 42, 240}}) fill := track progress := ifx card.on_device then 100 else (ifx card.progress >= 0 then card.progress else 1) fill.width = track.width * cast(float32)progress / 100.0 - Box(session, BoxProps.{.key = card_key + cast(u64)15, .bounds = fill, + Box.Draw(session, Box.Props.{.key = card_key + cast(u64)15, .bounds = fill, .radius = 7.0 * scale, .fill = Color.{131, 246, 183, 255}}) AppsText(session, card_key + cast(u64)16, Rectangle.{track.x, track.y - 24.0 * scale, track.width, 22.0 * scale}, @@ -1199,8 +1191,8 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s focused_action_enabled = !action.disabled if !card.on_device || !card.installed { action.label = AppsLabel(language, ifx card.on_device then "install" else "download"); action.icon_shape = APP_DOWNLOAD - if Button(session, action) != 0 { AppsConsoleDownload(card) } - } else if Button(session, action) != 0 || key == 77 { + if Button.Draw(session, action) != 0 { AppsConsoleDownload(card) } + } else if Button.Draw(session, action) != 0 || key == 77 { menu_id = card.id; menu_x = action.bounds.x; menu_y = action.bounds.y if card.update_available && !card.update_seen && AppsSupported(card, Rules.APPS_SEEN) { AppsAct("seen", card.id, card.available) } } @@ -1223,17 +1215,17 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s markers[index] = target focused := index == selected_index if focused { - Box(session, BoxProps.{.key = cast(u64)(50100 + index), + Box.Draw(session, Box.Props.{.key = cast(u64)(50100 + index), .bounds = Rectangle.{target.x - 3.0 * scale, target.y - 3.0 * scale, target.width + 6.0 * scale, target.height + 6.0 * scale}, .radius = 10.0 * scale, .fill = Color.{211, 255, 219, 255}}) } marker := *cards[visible[index]] marker_art := ifx wide then TextUntilNul(marker.cover.landscape[:]) else TextUntilNul(marker.cover.portrait[:]) if marker_art == "" { marker_art = TextUntilNul(marker.preview[:]) } - Image(session, ImageProps.{.key = cast(u64)(50300 + index), .bounds = target, + Image.Draw(session, Image.Props.{.key = cast(u64)(50300 + index), .bounds = target, .asset_path = marker_art, .alt_text = "", .radius = 8.0 * scale, - .fit = ImageFit.ImageFitCover, .smooth = true}) - if Button(session, ButtonProps.{.key = cast(u64)(50200 + index), .bounds = target, + .fit = Image.ImageFit.ImageFitCover, .smooth = true}) + if Button.Draw(session, Button.Props.{.key = cast(u64)(50200 + index), .bounds = target, .label = TextUntilNul(cards[visible[index]].title[:]), .invisible = true, .disabled = dialog != 0 || key == 257 || key == 32}) != 0 { cover_state.selected = index } } @@ -1242,11 +1234,11 @@ AppsConsole :: (session: Session, bounds: Rectangle, scale: float32, language: s // never become the underlying cover's click when the finger is released. // The named buttons retain keyboard and assistive activation. if dialog == 0 && menu_id[0] == 0 { - gesture := SwipeArea(session, SwipeAreaProps.{.key = cast(u64)50020, + gesture := Joystick.SwipeArea(session, Joystick.SwipeAreaProps.{.key = cast(u64)50020, .bounds = Rectangle.{bounds.x, bounds.y + 88.0 * scale, bounds.width, bounds.height - 88.0 * scale}, .label = "", .now = cover_time, .min_distance = 40.0 * scale}) - if gesture.swiped == 0 { CarouselSelect(*cover_state, count, 1, cover_time) } - if gesture.swiped == 2 { CarouselSelect(*cover_state, count, -1, cover_time) } + if gesture.swiped == 0 { Carousel.CarouselSelect(*cover_state, count, 1, cover_time) } + if gesture.swiped == 2 { Carousel.CarouselSelect(*cover_state, count, -1, cover_time) } if gesture.tapped { handled: bool for index: cast(s32)0..count - 1 { @@ -1296,7 +1288,7 @@ AppsFrame :: () -> bool { language := TextUntilNul(locale[:]) if cover_grid { unused WidgetPaletteUse(session, AppCoversPalette()) - Box(session, BoxProps.{.key = cast(u64)50010, .bounds = bounds, + Box.Draw(session, Box.Props.{.key = cast(u64)50010, .bounds = bounds, .fill = Color.{17, 18, 35, 255}, .fill_bottom = Color.{28, 24, 46, 255}, .has_fill_bottom = true}) } if request > 0 && TextUntilNul(status[:]) == "queued" { @@ -1312,11 +1304,11 @@ AppsFrame :: () -> bool { return true } if cover_mode && !icon_mode && !cover_grid { - cover_items: [4096]CarouselItem + cover_items: [4096]Carousel.CarouselItem for index: cast(s32)0..cast(s32)cards.count - 1 { card := *cards[index] action := TextUntilNul(card.cover.action[:]) - cover_items[index] = CarouselItem.{.label = TextUntilNul(card.title[:]), + cover_items[index] = Carousel.CarouselItem.{.label = TextUntilNul(card.title[:]), .portrait = ifx card.cover.portrait[0] != 0 then TextUntilNul(card.cover.portrait[:]) else TextUntilNul(card.preview[:]), .landscape = TextUntilNul(card.cover.landscape[:]), .logo = TextUntilNul(card.cover.logo[:]), .caption = TextUntilNul(card.cover.caption[:]), @@ -1326,7 +1318,7 @@ AppsFrame :: () -> bool { (!AppsSupported(card, Rules.APPS_OPEN) && !((!card.on_device || !card.installed) && AppsSupported(card, Rules.APPS_INSTALL))))} } cover_time += 1.0 / 60.0 - entered := Carousel(session, CarouselProps.{.key = cast(u64)50000, .bounds = bounds, + entered := Carousel.Draw(session, Carousel.Props.{.key = cast(u64)50000, .bounds = bounds, .logo_max_width = cover_logo_width, .logo_top = cover_logo_top, .label = TextUntilNul(title[:]), .now = cover_time, .key_pressed = ifx dialog != 0 then 0 else AppKey(), .scale = scale, .dark = AppDark(), .previous_label = AppsLabel(language, "previous"), .next_label = AppsLabel(language, "next")}, @@ -1342,7 +1334,7 @@ AppsFrame :: () -> bool { AppsAct("open", card.id) } } - if can_back && Button(session, ButtonProps.{.key = cast(u64)2, .label = AppsLabel(language, "back"), + if can_back && Button.Draw(session, Button.Props.{.key = cast(u64)2, .label = AppsLabel(language, "back"), .bounds = Rectangle.{bounds.x + 12.0 * scale, bounds.y + 12.0 * scale, 84.0 * scale, 44.0 * scale}, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 { AppsAct("back", empty_target) } if TextUntilNul(status[:]) == "rejected" { @@ -1355,7 +1347,7 @@ AppsFrame :: () -> bool { gap := (ifx cover_grid then 20.0 else 12.0) * scale area := bounds if !icon_mode { - if can_back && Button(session, ButtonProps.{.key = cast(u64)2, .label = AppsLabel(language, "back"), + if can_back && Button.Draw(session, Button.Props.{.key = cast(u64)2, .label = AppsLabel(language, "back"), .bounds = Rectangle.{bounds.x + gap, bounds.y + gap, 84.0 * scale, 44.0 * scale}, .fit_content = true}) != 0 { AppsAct("back", empty_target) } @@ -1407,7 +1399,7 @@ AppsFrame :: () -> bool { rows := (cast(s32)cards.count + columns - 1) / columns opened: bool if !icon_mode { - scroll := Scroll(session, ScrollProps.{.key = cast(u64)5, .bounds = area, .scale = scale, + scroll := Scroll.Draw(session, Scroll.Props.{.key = cast(u64)5, .bounds = area, .scale = scale, .content_height = rows * cast(s32)(card_height + gap), .scroll_offset = scroll_offset}) scroll_offset = scroll.scroll_offset if !scroll.opened { return true } @@ -1426,17 +1418,17 @@ AppsFrame :: () -> bool { x := area.x + cast(float32)(position % columns) * (card_width + gap) y := area.y + cast(float32)(position / columns) * (card_height + gap) + section_y key := Rules.AppCardKey(TextUntilNul(card.id[:])) - tile := ButtonProps.{.key = key, .label = TextUntilNul(card.title[:]), .class_name = tile_class, + tile := Button.Props.{.key = key, .label = TextUntilNul(card.title[:]), .class_name = tile_class, .bounds = Rectangle.{x, y, card_width, card_height}, .disabled = card.disabled, .selected = card.selected, .fit_content = true, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft} if card.selected { tile.tone = cast(ButtonTone)ButtonToneAccent; tile.emphasis = cast(ButtonEmphasis)ButtonEmphasisFilled } download_first := !card.on_device && AppsSupported(card, Rules.APPS_INSTALL) tile.disabled = tile.disabled || (!AppsSupported(card, Rules.APPS_OPEN) && !download_first) activated: bool - if cover_grid { tile.invisible = true; activated = Button(session, tile) != 0 } + if cover_grid { tile.invisible = true; activated = Button.Draw(session, tile) != 0 } if icon_mode { tile.icon_shape = TextUntilNul(card.icon_shape[:]) - tile.image = ImageProps.{.asset_path = TextUntilNul(card.icon[:]), .alt_text = TextUntilNul(card.title[:])} + tile.image = Image.Props.{.asset_path = TextUntilNul(card.icon[:]), .alt_text = TextUntilNul(card.title[:])} tile.icon_placement = cast(IconPlacement)(ifx list_mode then IconPlacementLeading else IconPlacementAbove) if list_mode { tile.content_alignment = cast(ContentAlignment)ContentAlignmentStart @@ -1449,7 +1441,7 @@ AppsFrame :: () -> bool { } else { fill := ifx AppDark() then Color.{33, 47, 44, 255} else Color.{249, 252, 250, 255} if !cover_grid { - unused Box(session, BoxProps.{.key = key + cast(u64)1, .bounds = tile.bounds, .radius = 12.0 * scale, .fill = fill}) + unused Box.Draw(session, Box.Props.{.key = key + cast(u64)1, .bounds = tile.bounds, .radius = 12.0 * scale, .fill = fill}) } preview := TextUntilNul(card.preview[:]) if cover_grid && card.cover.portrait[0] != 0 { @@ -1459,16 +1451,16 @@ AppsFrame :: () -> bool { } } if preview != "" { - Image(session, ImageProps.{.key = key + cast(u64)2, .asset_path = preview, .alt_text = TextUntilNul(card.title[:]), + Image.Draw(session, Image.Props.{.key = key + cast(u64)2, .asset_path = preview, .alt_text = TextUntilNul(card.title[:]), .class_name = ifx cover_grid then image_class else 0, .bounds = ifx cover_grid then Rectangle.{x, y, card_width, picture_height} else Rectangle.{x + gap, y + gap, card_width - gap * 2.0, picture_height}, .radius = ifx cover_grid then 20.0 * scale else 0.0, - .fit = ifx cover_grid then ImageFit.ImageFitCover else ImageFit.ImageFitContain, .smooth = true}) + .fit = ifx cover_grid then Image.ImageFit.ImageFitCover else Image.ImageFit.ImageFitContain, .smooth = true}) } if cover_grid && card.cover.logo[0] != 0 { logo_width := card_width - gap * 4.0 - Image(session, ImageProps.{.key = key + cast(u64)8, .asset_path = TextUntilNul(card.cover.logo[:]), - .alt_text = TextUntilNul(card.title[:]), .smooth = true, .fit = ImageFit.ImageFitContain, + Image.Draw(session, Image.Props.{.key = key + cast(u64)8, .asset_path = TextUntilNul(card.cover.logo[:]), + .alt_text = TextUntilNul(card.title[:]), .smooth = true, .fit = Image.ImageFit.ImageFitContain, .bounds = Rectangle.{x + gap * 2.0, y + gap * 2.0, logo_width, logo_width * 0.36}}) } title_y := ifx cover_grid then y + picture_height + 10.0 * scale else y + 188.0 * scale @@ -1477,10 +1469,10 @@ AppsFrame :: () -> bool { if cover_grid && !card.on_device && !hide_sizes { size_text: [32]u8 if AppsSize(card.bytes, size_text[:]) { - Text(session, TextProps.{.key = key + cast(u64)9, .text = TextUntilNul(size_text[:]), - .font = cast(s32)(14.0 * scale), .class_name = muted_class, + Text.Draw(session, Text.Props.{.key = key + cast(u64)9, .text = TextUntilNul(size_text[:]), + .size = cast(s32)(14.0 * scale), .class_name = muted_class, .bounds = Rectangle.{x + 4.0 * scale, title_y, card_width - 8.0 * scale, 20.0 * scale}, - .wrap = cast(TextWrap)TextWrapNone}) + .wrap = cast(Text.Wrap)TextWrapNone}) } } tile.invisible = true @@ -1492,13 +1484,13 @@ AppsFrame :: () -> bool { } // An app not on this device opens its download dialog instead of a // screen that has nothing to show yet. - if !cover_grid { activated = Button(session, tile) != 0 } + if !cover_grid { activated = Button.Draw(session, tile) != 0 } if activated { if download_first { AppsDownloadOpen(card) } else { AppsAct("open", card.id) } } if icon_mode && card.reorderable { - unused Button(session, ButtonProps.{.key = Rules.AppReorderKey(TextUntilNul(card.id[:])), + unused Button.Draw(session, Button.Props.{.key = Rules.AppReorderKey(TextUntilNul(card.id[:])), .label = AppsLabel(language, "move_app"), .icon_shape = APP_REORDER, .icon_only = true, .disabled = card.disabled, .class_name = action_class, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost, @@ -1510,9 +1502,9 @@ AppsFrame :: () -> bool { unused CopyCString(AppsLabel(language, "downloading"), size_text[:]) } if !list_mode && (card.downloading || (!card.on_device && !hide_sizes && AppsSize(card.bytes, size_text[:]))) { - Text(session, TextProps.{.key = key + cast(u64)4, .text = TextUntilNul(size_text[:]), .font = cast(s32)(11.0 * scale), + Text.Draw(session, Text.Props.{.key = key + cast(u64)4, .text = TextUntilNul(size_text[:]), .size = cast(s32)(11.0 * scale), .bounds = Rectangle.{x + 8.0 * scale, y + card_height - 16.0 * scale, card_width - 16.0 * scale, 12.0 * scale}, - .wrap = cast(TextWrap)TextWrapNone, .align = cast(TextAlign)TextAlignCenter, .class_name = muted_class}) + .wrap = cast(Text.Wrap)TextWrapNone, .align = cast(TextAlign)TextAlignCenter, .class_name = muted_class}) } } action := AppsActionProps(key + cast(u64)5, card, action_class, @@ -1524,8 +1516,8 @@ AppsFrame :: () -> bool { action.icon_shape = APP_DOWNLOAD // While it downloads, the same symbol shows the progress again. action.disabled = card.disabled || !AppsSupported(card, Rules.APPS_INSTALL) - if Button(session, action) != 0 { AppsDownloadOpen(card) } - } else if Button(session, action) != 0 { + if Button.Draw(session, action) != 0 { AppsDownloadOpen(card) } + } else if Button.Draw(session, action) != 0 { menu_id = card.id; menu_x = action.bounds.x; menu_y = action.bounds.y + action.bounds.height // Opening the menu shows its Update entry, so the dot has been seen. if card.update_available && !card.update_seen && AppsSupported(card, Rules.APPS_SEEN) { @@ -1535,7 +1527,7 @@ AppsFrame :: () -> bool { // An update not yet installed or seen marks the options with a dot. if card.update_available && !card.update_seen { dot := 8.0 * scale - unused Box(session, BoxProps.{.key = key + cast(u64)6, .radius = dot * 0.5, .fill = Color.{163, 98, 0, 255}, + unused Box.Draw(session, Box.Props.{.key = key + cast(u64)6, .radius = dot * 0.5, .fill = Color.{163, 98, 0, 255}, .bounds = Rectangle.{action.bounds.x + action.bounds.width - dot - 6.0 * scale, action.bounds.y + 6.0 * scale, dot, dot}}) } } diff --git a/ziran.lock b/ziran.lock index a43f42d..5728377 100644 --- a/ziran.lock +++ b/ziran.lock @@ -99,6 +99,15 @@ "source": true, "url": "https://github.com/open-quantum-safe/liboqs.git" }, + { + "commit": "bd693c1ea91c328e3cccd24faac3e4f2bc3eeb41", + "dependencies": {"audio": "pd258d453b63edc1f", "avif": "p872d871f84f2284f", "image_codec": "p69c0e968ae5735d9", "libaom": "p74ab3cb6eb3b86fa", "libavif": "p57c0272208aae8db", "libwebp": "p3b3c785a0e17e605", "raylib": "pcc7aa76725f2fb2f", "sdl3": "p16cd0434af3dff7b", "webp": "pa068bd09450b2a80"}, + "dependency_refs": {"audio": "f5eed1e6c817997d51508f9c3c7b948a0bb4ad0b", "avif": "f84c162594e518cb306bfd0ce41783ad55b6c730", "image_codec": "360553150917f352e49e1beb78917370792ccaef", "libaom": "b141d9c45db236335351c8a4b2a14b3ade27c937", "libavif": "1aadfad932c98c069a1204261b1856f81f3bc199", "libwebp": "1844042d1ca751e62e61df7617dba19c98588339", "raylib": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e", "sdl3": "829a65d769d935c4852f8159e964312c0957260a", "webp": "02145a00a1f0df2a111da04a75f3fef260883897"}, + "id": "p9f0003944eecc81f", + "name": "kryon", + "ref": "bd693c1ea91c328e3cccd24faac3e4f2bc3eeb41", + "url": "https://github.com/kryonlabs/kryon.git" + }, { "commit": "02145a00a1f0df2a111da04a75f3fef260883897", "dependencies": {"image_codec": "p69c0e968ae5735d9", "libwebp": "p3b3c785a0e17e605"}, @@ -151,25 +160,16 @@ "ref": "ddbe48383984d56acd9e1ab6a090c54ca6b735a6", "source": true, "url": "https://github.com/xiph/opus.git" - }, - { - "commit": "a139f22c5eb3c5b97994a727cfca94ab63104d79", - "dependencies": {"audio": "pd258d453b63edc1f", "avif": "p872d871f84f2284f", "image_codec": "p69c0e968ae5735d9", "libaom": "p74ab3cb6eb3b86fa", "libavif": "p57c0272208aae8db", "libwebp": "p3b3c785a0e17e605", "raylib": "pcc7aa76725f2fb2f", "sdl3": "p16cd0434af3dff7b", "webp": "pa068bd09450b2a80"}, - "dependency_refs": {"audio": "f5eed1e6c817997d51508f9c3c7b948a0bb4ad0b", "avif": "f84c162594e518cb306bfd0ce41783ad55b6c730", "image_codec": "360553150917f352e49e1beb78917370792ccaef", "libaom": "b141d9c45db236335351c8a4b2a14b3ade27c937", "libavif": "1aadfad932c98c069a1204261b1856f81f3bc199", "libwebp": "1844042d1ca751e62e61df7617dba19c98588339", "raylib": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e", "sdl3": "829a65d769d935c4852f8159e964312c0957260a", "webp": "02145a00a1f0df2a111da04a75f3fef260883897"}, - "id": "pfd8e8aefe24677c6", - "name": "kryon", - "ref": "a139f22c5eb3c5b97994a727cfca94ab63104d79", - "url": "https://github.com/kryonlabs/kryon.git" } ], "root": { - "dependencies": {"crypto": "pc23fbf455e97614d", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "pfd8e8aefe24677c6"}, - "dependency_refs": {"crypto": "master", "daochi_client": "970d5e44b1702158cb16469892da6ff50f142427", "kryon": "a139f22c5eb3c5b97994a727cfca94ab63104d79"}, + "dependencies": {"crypto": "pc23fbf455e97614d", "daochi_client": "p6af0b5bd9fd0cd31", "kryon": "p9f0003944eecc81f"}, + "dependency_refs": {"crypto": "master", "daochi_client": "970d5e44b1702158cb16469892da6ff50f142427", "kryon": "bd693c1ea91c328e3cccd24faac3e4f2bc3eeb41"}, "name": "Apps" }, "toolchain": { - "commit": "0e91eb43bd665f02db86eb9b9cdd875b5436a066", - "ref": "0e91eb43bd665f02db86eb9b9cdd875b5436a066", + "commit": "37a64372a6171808d1373b619f9b4f32cc367092", + "ref": "37a64372a6171808d1373b619f9b4f32cc367092", "url": "https://github.com/ziranlang/ziran.git" } } diff --git a/ziran.toml b/ziran.toml index 3b9ea19..030ca75 100644 --- a/ziran.toml +++ b/ziran.toml @@ -4,7 +4,7 @@ module_roots = ["src", "ui", "fixtures"] [toolchain] git = "https://github.com/ziranlang/ziran.git" -ref = "0e91eb43bd665f02db86eb9b9cdd875b5436a066" +ref = "37a64372a6171808d1373b619f9b4f32cc367092" [exports] game_hud = "src/game_hud.zi" @@ -25,7 +25,7 @@ node_codec = "src/node_codec.zi" [dependencies.kryon] git = "https://github.com/kryonlabs/kryon.git" -ref = "a139f22c5eb3c5b97994a727cfca94ab63104d79" +ref = "bd693c1ea91c328e3cccd24faac3e4f2bc3eeb41" [dependencies.crypto] git = "https://github.com/ziranlang/crypto.git"