Draw every shape with Kryon widgets and remove draw.zi

src/app/draw.zi copied raylib's drawing calls for about 115 call sites in
practice, results, statistics, habits and profile screens, against the
rule that app UI uses Kryon widgets only. Rectangles, rounded cards,
outlines and gradients are now Box, lines Line, circles and radial glows
Circle, progress arcs Ring. Fade became one colour helper, color.zi.

Raylib drew those shapes at once, beneath all widget paint; as widgets
they paint in submission order, so the results chart's lines, a selected
profile tab's underline and the meditation and patterns circles are now
submitted before what covers them, and the canvas fills are the first
widgets of a frame. Two draws that never showed are removed rather than
made visible: the results chart's area fill, which raylib culled for its
winding, and a crescent the practice home's canvas always covered.

With no direct draws left, the direct-draw plan that compared them for
retained frames and its test are gone; a frame is reused whenever its
widget paint matches.
This commit is contained in:
waozi committed 2026-10-17 19:47:15 -03:00
1 parent f98ee2ca6d
commit 699981e31a
30 files changed
+435 -813

No files matched your search

-5
View File
@@ -2071,11 +2071,6 @@ modal-rules-test: build-laws $(ZI2C_BIN)
test: modal-rules-test
.PHONY: direct-draw-plan-test
test: direct-draw-plan-test
direct-draw-plan-test: $(ZI2C_BIN)
@sh tests/direct_draw_plan_test.sh $(ZIRAN_BUILD_DIR)/bin
.PHONY: elist-screen-test
test: elist-screen-test
elist-screen-test: cells $(ZI2C_BIN) $(ZIRAN_BUILD_DIR)/libziran.a
+4 -4
View File
@@ -6,7 +6,7 @@
#import, file "../../src/app/app_modal_state.zi";
#import, file "../../src/app/app_settings.zi";
#import, file "../../src/app/exercise_types.zi";
#import, file "../../src/app/draw.zi";
#import, file "../../src/app/color.zi";
#import, file "../../src/app/locale.zi";
#import, file "../../src/app/metrics.zi";
#import, file "../../src/app/text_buffers.zi";
@@ -404,7 +404,7 @@ PracticeDownloadDots :: (app: *InnerBreeze, bounds: Rectangle) {
if paint.dot_count < 6 {
return
}
color := Fade(StyleTokenColor("text"), 0.45)
color := color_with_alpha(StyleTokenColor("text"), 0.45)
radius := paint.dot0.width * 0.5
PaintRoundedFill(app.ui.session, -1, paint.dot0, radius, 6, color)
PaintRoundedFill(app.ui.session, -1, paint.dot1, radius, 6, color)
@@ -589,7 +589,7 @@ PracticeDownloadsContent :: (app: *InnerBreeze, x: s32, y: *s32, width: s32, dra
focus: s32) -> PracticeDownloadAreas {
areas: PracticeDownloadAreas
top := y.*
line := Fade(StyleTokenColor("text"), 0.12)
line := color_with_alpha(StyleTokenColor("text"), 0.12)
for index: cast(s32)0..cast(s32)4 {
practice := practice_ordered_id(index)
if PracticeHidden(practice) {
@@ -645,7 +645,7 @@ PracticeDownloadDrop :: (app: *InnerBreeze, scroll: ScrollResult, areas: Practic
row += 1
}
}
outline := Fade(StyleTokenColor("text"), 0.8)
outline := color_with_alpha(StyleTokenColor("text"), 0.8)
radius := cast(float32)AppScale(12)
if place >= 0 {
PaintRoundedOutline(app.ui.session, -1, place_bounds, radius, 12, cast(float32)AppScale(2), outline)
+24 -17
View File
@@ -136,9 +136,9 @@ PackageNow :: () -> s64 #foreign c "now_seconds";
#import, file "../practices/meditation/meditation_music.zi";
#import, file "metrics.zi";
#import, file "dpi_state.zi";
#import, file "draw.zi";
#import, file "direct_draw_plan.zi";
#import, file "current_app.zi";
#import "box_props"
#import "box_widget"
#import "button_widget"
#import "image_widget"
#import "text_widget"
@@ -1435,11 +1435,10 @@ app_last_frame_status: s32;
app_finish_frame :: (app: *InnerBreeze) {
status: s32
paint_unchanged: bool = false
// The previous frame is presented again only when the direct draws
// match too; otherwise the frame is repainted, widgets included.
direct_unchanged := DirectDrawFrameFinish()
// Everything the frame draws is widget paint, so the previous frame is
// presented again whenever that paint matches it.
if app.ui.retained_target_active {
result := EndFrameRetained(app.ui.session, direct_unchanged)
result := EndFrameRetained(app.ui.session, true)
status = cast(s32)result.status
paint_unchanged = result.paint_unchanged
} else {
@@ -1453,8 +1452,7 @@ app_finish_frame :: (app: *InnerBreeze) {
TreeFrameErrorKind(app.ui.session))
}
app_last_frame_status = status
app.ui.retained_frame_unchanged = status == 0 && paint_unchanged &&
direct_unchanged
app.ui.retained_frame_unchanged = status == 0 && paint_unchanged
}
#program_export
@@ -1566,8 +1564,6 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
app_device_preferences_update(app)
update_check_poll()
app_refresh_theme(app)
DirectDrawFrameBegin(viewport)
DrawRectangleRec(viewport, StyleTokenColor("canvas"))
content_w = full_width - rail_width
if content_w < 1 {
content_w = 1
@@ -1603,9 +1599,6 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
#if #defined(ANDROID_BUILD) {
TextMenuSetTransform(render_scale, app.camera.offset.x, app.camera.offset.y)
}
if PreviewMode() == 0 {
DirectDrawTransform(app.camera)
}
// Retained hit testing and widget bounds use the same logical coordinates
// as the camera. A left navigation rail occupies negative content x.
frame_origin := Vector2.{0.0, 0.0}
@@ -1619,8 +1612,21 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
logical_frame) != 0 {
return
}
// The canvas under the whole viewport comes first, under every widget.
// The camera maps the logical frame onto the viewport; a preview draws
// without the camera.
canvas_bounds := logical_frame
if PreviewMode() != 0 {
DrawRectangle(0, 0, view_width, view_height, StyleTokenColor("canvas"))
canvas_bounds = viewport
}
Box(app.ui.session, BoxProps.{.bounds = canvas_bounds,
.fill = StyleTokenColor("canvas")})
content_canvas := BoxProps.{
.bounds = Rectangle.{0.0, 0.0, cast(float32)view_width,
cast(float32)view_height},
.fill = StyleTokenColor("canvas")}
if PreviewMode() != 0 {
Box(app.ui.session, content_canvas)
profile_update_start = app_profile_now()
updateapp(app)
app_profile_record_update(profile_update_start)
@@ -1632,7 +1638,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
BeginScissorMode(cast(s32)viewport.x, cast(s32)viewport.y,
full_width, full_height)
BeginMode2D(app.camera)
DrawRectangle(0, 0, view_width, view_height, StyleTokenColor("canvas"))
Box(app.ui.session, content_canvas)
profile_update_start = app_profile_now()
updateapp(app)
app_profile_record_update(profile_update_start)
@@ -1764,8 +1770,6 @@ app_draw_android_picture_window :: (app: *InnerBreeze, viewport: Rectangle) {
camera.zoom = scale
camera.offset = Vector2.{viewport.x, viewport.y}
AppMetricsConfigure(1.0)
DirectDrawFrameBegin(viewport)
DrawRectangleRec(viewport, StyleTokenColor("surface"))
// A practice that finishes here shows that it has finished and its
// results instead of its last picture, also while its screen waits
// to be extended.
@@ -1779,6 +1783,9 @@ app_draw_android_picture_window :: (app: *InnerBreeze, viewport: Rectangle) {
}
if cast(s32)BeginFrame(app.ui.session, KeyHash("inbe/picture-window"), bounds) == 0 {
BeginMode2D(camera)
// The camera maps the bounds onto the whole window.
Box(app.ui.session, BoxProps.{.bounds = bounds,
.fill = StyleTokenColor("surface")})
if finished {
practice_draw_results_window(app, bounds, result)
} else {
+2 -2
View File
@@ -10,7 +10,7 @@
#import "session"
#import "text_props"
#import "text_widget"
#import, file "draw.zi";
#import, file "color.zi";
#import, file "metrics.zi";
using SemanticKind;
@@ -25,7 +25,7 @@ CardProps :: (bounds: Rectangle) -> BoxProps {
props: BoxProps
props.bounds = bounds
props.fill = LightenColor(StyleTokenColor("canvas"), 2)
props.border = Fade(StyleTokenColor("text"), 0.12)
props.border = color_with_alpha(StyleTokenColor("text"), 0.12)
props.radius = cast(float32)AppScale(CARD_RADIUS)
return props
}
+15
View File
@@ -0,0 +1,15 @@
#import "drawing_props"
// The colour at an opacity from 0 (clear) to 1 (opaque). Its alpha becomes
// 255 times the opacity, clamped to that range and rounded down, as raylib's
// Fade sets it.
color_with_alpha :: (color: Color, opacity: float32) -> Color {
if opacity < 0.0 {
opacity = 0.0
}
if opacity > 1.0 {
opacity = 1.0
}
color.a = cast(u8)(255.0 * opacity)
return color
}
-329
View File
@@ -1,329 +0,0 @@
#import "drawing_props"
#import "geometry"
#import "vec"
DirectDrawKind :: enum {
DirectDrawContext :: 1
DirectDrawTransform :: 2
DirectDrawLine :: 3
DirectDrawLineEx :: 4
DirectDrawTriangle :: 5
DirectDrawRectangle :: 6
DirectDrawRectangleRec :: 7
DirectDrawRectangleLines :: 8
DirectDrawRectangleLinesEx :: 9
DirectDrawRectangleRounded :: 10
DirectDrawRectangleRoundedLinesEx :: 11
DirectDrawRectangleGradient :: 12
DirectDrawCircle :: 13
DirectDrawCircleV :: 14
DirectDrawCircleGradient :: 15
DirectDrawCircleLines :: 16
DirectDrawRing :: 17
DirectDrawCircleLinesEx :: 18
}
using DirectDrawKind;
DirectDrawCommand :: struct {
kind: s32
a: s32
b: s32
c: s32
d: s32
values: [12] float32
color: Color
end_color: Color
}
direct_draw_current: Vec(DirectDrawCommand);
direct_draw_previous: Vec(DirectDrawCommand);
direct_draw_active: bool;
direct_draw_valid: bool;
direct_draw_unchanged: bool;
DirectDrawStore :: (command: DirectDrawCommand) {
if !direct_draw_active { return }
if !VecPush(direct_draw_current, command) {
direct_draw_valid = false
direct_draw_unchanged = false
}
}
DirectDrawCommandsEqual :: (left: DirectDrawCommand,
right: DirectDrawCommand) -> bool {
if left.kind != right.kind || left.a != right.a || left.b != right.b ||
left.c != right.c || left.d != right.d { return false }
if left.color.r != right.color.r || left.color.g != right.color.g ||
left.color.b != right.color.b || left.color.a != right.color.a { return false }
if left.end_color.r != right.end_color.r ||
left.end_color.g != right.end_color.g ||
left.end_color.b != right.end_color.b ||
left.end_color.a != right.end_color.a { return false }
index: s32 = 0
while index < 12 {
if left.values[index] != right.values[index] { return false }
index += 1
}
return true
}
#program_export
DirectDrawFrameBegin :: (viewport: Rectangle) {
VecClear(direct_draw_current)
direct_draw_active = true
direct_draw_valid = true
direct_draw_unchanged = false
context: DirectDrawCommand
context.kind = cast(s32)DirectDrawContext
context.values[0] = viewport.x
context.values[1] = viewport.y
context.values[2] = viewport.width
context.values[3] = viewport.height
DirectDrawStore(context)
}
#program_export
DirectDrawTransform :: (camera: Camera) {
transform: DirectDrawCommand
transform.kind = cast(s32)DirectDrawTransform
transform.values[0] = camera.offset.x
transform.values[1] = camera.offset.y
transform.values[2] = camera.target.x
transform.values[3] = camera.target.y
transform.values[4] = camera.rotation
transform.values[5] = camera.zoom
DirectDrawStore(transform)
}
DirectDrawRecordLine :: (start_x: s32, start_y: s32, end_x: s32,
end_y: s32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawLine
command.a = start_x
command.b = start_y
command.c = end_x
command.d = end_y
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordLineEx :: (start: Vector2, end: Vector2,
thickness: float32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawLineEx
command.values[0] = start.x
command.values[1] = start.y
command.values[2] = end.x
command.values[3] = end.y
command.values[4] = thickness
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordTriangle :: (v1: Vector2, v2: Vector2, v3: Vector2,
color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawTriangle
command.values[0] = v1.x
command.values[1] = v1.y
command.values[2] = v2.x
command.values[3] = v2.y
command.values[4] = v3.x
command.values[5] = v3.y
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangle :: (x: s32, y: s32, width: s32, height: s32,
color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangle
command.a = x
command.b = y
command.c = width
command.d = height
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleRec :: (bounds: Rectangle, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleRec
command.values[0] = bounds.x
command.values[1] = bounds.y
command.values[2] = bounds.width
command.values[3] = bounds.height
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleLines :: (x: s32, y: s32, width: s32, height: s32,
color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleLines
command.a = x
command.b = y
command.c = width
command.d = height
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleLinesEx :: (bounds: Rectangle, thick: float32,
color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleLinesEx
command.values[0] = bounds.x
command.values[1] = bounds.y
command.values[2] = bounds.width
command.values[3] = bounds.height
command.values[4] = thick
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleRounded :: (bounds: Rectangle, roundness: float32,
segments: s32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleRounded
command.values[0] = bounds.x
command.values[1] = bounds.y
command.values[2] = bounds.width
command.values[3] = bounds.height
command.values[4] = roundness
command.a = segments
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleRoundedLinesEx :: (bounds: Rectangle,
roundness: float32, segments: s32, thick: float32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleRoundedLinesEx
command.values[0] = bounds.x
command.values[1] = bounds.y
command.values[2] = bounds.width
command.values[3] = bounds.height
command.values[4] = roundness
command.values[5] = thick
command.a = segments
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRectangleGradient :: (x: s32, y: s32, width: s32,
height: s32, top: Color, bottom: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRectangleGradient
command.a = x
command.b = y
command.c = width
command.d = height
command.color = top
command.end_color = bottom
DirectDrawStore(command)
}
DirectDrawRecordCircle :: (center_x: s32, center_y: s32, radius: float32,
color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawCircle
command.a = center_x
command.b = center_y
command.values[0] = radius
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordCircleV :: (center: Vector2, radius: float32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawCircleV
command.values[0] = center.x
command.values[1] = center.y
command.values[2] = radius
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordCircleGradient :: (center: Vector2, radius: float32,
inner: Color, outer: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawCircleGradient
command.values[0] = center.x
command.values[1] = center.y
command.values[2] = radius
command.color = inner
command.end_color = outer
DirectDrawStore(command)
}
DirectDrawRecordCircleLines :: (center_x: s32, center_y: s32,
radius: float32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawCircleLines
command.a = center_x
command.b = center_y
command.values[0] = radius
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordRing :: (center: Vector2, inner_radius: float32,
outer_radius: float32, start_angle: float32, end_angle: float32,
segments: s32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawRing
command.values[0] = center.x
command.values[1] = center.y
command.values[2] = inner_radius
command.values[3] = outer_radius
command.values[4] = start_angle
command.values[5] = end_angle
command.a = segments
command.color = color
DirectDrawStore(command)
}
DirectDrawRecordCircleLinesEx :: (center: Vector2, radius: float32,
thickness: float32, color: Color) {
command: DirectDrawCommand
command.kind = cast(s32)DirectDrawCircleLinesEx
command.values[0] = center.x
command.values[1] = center.y
command.values[2] = radius
command.values[3] = thickness
command.color = color
DirectDrawStore(command)
}
#program_export
DirectDrawFrameFinish :: () -> bool {
if !direct_draw_active { return false }
direct_draw_active = false
unchanged: bool = direct_draw_valid &&
direct_draw_current.count == direct_draw_previous.count
index: s32 = 0
while unchanged && cast(s64)index < direct_draw_current.count {
if !DirectDrawCommandsEqual(direct_draw_current[index],
direct_draw_previous[index]) { unchanged = false }
index += 1
}
VecClear(direct_draw_previous)
if direct_draw_valid {
index = 0
while cast(s64)index < direct_draw_current.count {
if !VecPush(direct_draw_previous, direct_draw_current[index]) {
direct_draw_valid = false
unchanged = false
}
index += 1
}
}
direct_draw_unchanged = unchanged
return unchanged
}
#program_export
DirectDrawFrameUnchanged :: () -> bool {
return direct_draw_unchanged
}
-112
View File
@@ -1,112 +0,0 @@
// Direct raylib draw calls used by translated screens. The signatures mirror
// raylib.h, and the Ziran names stay scoped to this module so they do not
// define a second copy of raylib's C symbols.
raylib :: #system_library "raylib";
#import "drawing_props"
#import "geometry"
#import, file "direct_draw_plan.zi";
DrawLineHost :: (start_x: s32, start_y: s32, end_x: s32, end_y: s32, color: Color) #foreign raylib "DrawLine";
DrawLineExHost :: (start: Vector2, end: Vector2, thickness: float32, color: Color) #foreign raylib "DrawLineEx";
DrawTriangleHost :: (v1: Vector2, v2: Vector2, v3: Vector2, color: Color) #foreign raylib "DrawTriangle";
DrawRectangleHost :: (x: s32, y: s32, width: s32, height: s32, color: Color) #foreign raylib "DrawRectangle";
DrawRectangleRecHost :: (rec: Rectangle, color: Color) #foreign raylib "DrawRectangleRec";
DrawRectangleLinesHost :: (x: s32, y: s32, width: s32, height: s32, color: Color) #foreign raylib "DrawRectangleLines";
DrawRectangleLinesExHost :: (rec: Rectangle, thick: float32, color: Color) #foreign raylib "DrawRectangleLinesEx";
DrawRectangleRoundedHost :: (rec: Rectangle, roundness: float32, segments: s32, color: Color) #foreign raylib "DrawRectangleRounded";
DrawRectangleRoundedLinesExHost :: (rec: Rectangle, roundness: float32, segments: s32, thick: float32, color: Color) #foreign raylib "DrawRectangleRoundedLinesEx";
DrawRectangleGradientVHost :: (x: s32, y: s32, width: s32, height: s32, top: Color, bottom: Color) #foreign raylib "DrawRectangleGradientV";
DrawCircleHost :: (center_x: s32, center_y: s32, radius: float32, color: Color) #foreign raylib "DrawCircle";
DrawCircleVHost :: (center: Vector2, radius: float32, color: Color) #foreign raylib "DrawCircleV";
DrawCircleGradientHost :: (center: Vector2, radius: float32, inner: Color, outer: Color) #foreign raylib "DrawCircleGradient";
DrawCircleLinesHost :: (center_x: s32, center_y: s32, radius: float32, color: Color) #foreign raylib "DrawCircleLines";
DrawRingHost :: (center: Vector2, inner_radius: float32, outer_radius: float32,
start_angle: float32, end_angle: float32, segments: s32, color: Color) #foreign raylib "DrawRing";
FadeHost :: (color: Color, alpha: float32) -> Color #foreign raylib "Fade";
DrawCircleLinesExHost :: (center: Vector2, radius: float32, thickness: float32, color: Color) #foreign raylib "DrawCircleLinesEx";
DrawLine :: (start_x: s32, start_y: s32, end_x: s32, end_y: s32, color: Color) {
DirectDrawRecordLine(start_x, start_y, end_x, end_y, color)
DrawLineHost(start_x, start_y, end_x, end_y, color)
}
DrawLineEx :: (start: Vector2, end: Vector2, thickness: float32, color: Color) {
DirectDrawRecordLineEx(start, end, thickness, color)
DrawLineExHost(start, end, thickness, color)
}
DrawTriangle :: (v1: Vector2, v2: Vector2, v3: Vector2, color: Color) {
DirectDrawRecordTriangle(v1, v2, v3, color)
DrawTriangleHost(v1, v2, v3, color)
}
DrawRectangle :: (x: s32, y: s32, width: s32, height: s32, color: Color) {
DirectDrawRecordRectangle(x, y, width, height, color)
DrawRectangleHost(x, y, width, height, color)
}
DrawRectangleRec :: (rec: Rectangle, color: Color) {
DirectDrawRecordRectangleRec(rec, color)
DrawRectangleRecHost(rec, color)
}
DrawRectangleLines :: (x: s32, y: s32, width: s32, height: s32, color: Color) {
DirectDrawRecordRectangleLines(x, y, width, height, color)
DrawRectangleLinesHost(x, y, width, height, color)
}
DrawRectangleLinesEx :: (rec: Rectangle, thick: float32, color: Color) {
DirectDrawRecordRectangleLinesEx(rec, thick, color)
DrawRectangleLinesExHost(rec, thick, color)
}
DrawRectangleRounded :: (rec: Rectangle, roundness: float32, segments: s32, color: Color) {
DirectDrawRecordRectangleRounded(rec, roundness, segments, color)
DrawRectangleRoundedHost(rec, roundness, segments, color)
}
DrawRectangleRoundedLinesEx :: (rec: Rectangle, roundness: float32, segments: s32, thick: float32, color: Color) {
DirectDrawRecordRectangleRoundedLinesEx(rec, roundness, segments, thick, color)
DrawRectangleRoundedLinesExHost(rec, roundness, segments, thick, color)
}
DrawRectangleGradientV :: (x: s32, y: s32, width: s32, height: s32, top: Color, bottom: Color) {
DirectDrawRecordRectangleGradient(x, y, width, height, top, bottom)
DrawRectangleGradientVHost(x, y, width, height, top, bottom)
}
DrawCircle :: (center_x: s32, center_y: s32, radius: float32, color: Color) {
DirectDrawRecordCircle(center_x, center_y, radius, color)
DrawCircleHost(center_x, center_y, radius, color)
}
DrawCircleV :: (center: Vector2, radius: float32, color: Color) {
DirectDrawRecordCircleV(center, radius, color)
DrawCircleVHost(center, radius, color)
}
DrawCircleGradient :: (center: Vector2, radius: float32, inner: Color, outer: Color) {
DirectDrawRecordCircleGradient(center, radius, inner, outer)
DrawCircleGradientHost(center, radius, inner, outer)
}
DrawCircleLines :: (center_x: s32, center_y: s32, radius: float32, color: Color) {
DirectDrawRecordCircleLines(center_x, center_y, radius, color)
DrawCircleLinesHost(center_x, center_y, radius, color)
}
DrawRing :: (center: Vector2, inner_radius: float32, outer_radius: float32,
start_angle: float32, end_angle: float32, segments: s32, color: Color) {
DirectDrawRecordRing(center, inner_radius, outer_radius, start_angle, end_angle, segments, color)
DrawRingHost(center, inner_radius, outer_radius, start_angle, end_angle, segments, color)
}
Fade :: (color: Color, alpha: float32) -> Color {
return FadeHost(color, alpha)
}
DrawCircleLinesEx :: (center: Vector2, radius: float32, thickness: float32, color: Color) {
DirectDrawRecordCircleLinesEx(center, radius, thickness, color)
DrawCircleLinesExHost(center, radius, thickness, color)
}
+2 -2
View File
@@ -13,7 +13,7 @@
#import, file "locale.zi";
#import, file "metrics.zi";
#import, file "text_buffers.zi";
#import, file "draw.zi";
#import, file "color.zi";
#import, file "../practices/practice_registry.zi";
#import "box_props"
#import "box_widget"
@@ -390,7 +390,7 @@ app_session_window_draw :: (app: *InnerBreeze) {
PaintRoundedFill(session, -1, shadow, radius, 14, Color.{0, 0, 0, 64})
Box(session, BoxProps.{.key = KeyHash("inbe/session-window/card"),
.bounds = bounds, .fill = StyleTokenColor("surface"),
.border = Fade(StyleTokenColor("accent"), 0.35f), .radius = radius})
.border = color_with_alpha(StyleTokenColor("accent"), 0.35f), .radius = radius})
app_session_window_picture(app, window.screen, bounds,
cast(float32)AppScale(SESSION_WINDOW_BUTTON_ROW))
+27 -11
View File
@@ -27,8 +27,9 @@ using TextWrap;
#import "control_props"
#import, file "../../app/text_buffers.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/current_app.zi";
#import "box_props"
#import "box_widget"
#import "button_widget"
#import "dropdown_widget"
#import "text_widget"
@@ -37,6 +38,8 @@ using TextWrap;
#import "session"
#import "button_props"
#import "dropdown_props"
#import "shape_props"
#import "shape_widget"
#import, file "../../app/locale.zi";
#import, file "../../storage/path_join.zi";
#import, file "../../storage/paths.zi";
@@ -255,24 +258,37 @@ meditation_music_draw_download_progress :: (app: *InnerBreeze, x: s32, y: s32, w
fill_w = w
}
DrawRectangle(x, y, w, bar_h, DarkenColor(bg, 28))
session := app.ui.session
Box(session, BoxProps.{
.bounds = Rectangle.{cast(float32)x, cast(float32)y,
cast(float32)w, cast(float32)bar_h},
.fill = DarkenColor(bg, 28)})
dark := DarkenColor(bg, 55)
light := LightenColor(bg, 35)
DrawLine(x, y, x + w - 1, y, light)
DrawLine(x, y, x, y + bar_h - 1, light)
DrawLine(x, y + bar_h - 1, x + w - 1, y + bar_h - 1, dark)
DrawLine(x + w - 1, y, x + w - 1, y + bar_h - 1, dark)
left := cast(float32)x
top := cast(float32)y
right := cast(float32)(x + w - 1)
bottom := cast(float32)(y + bar_h - 1)
Line(session, LineProps.{.start = Vector2.{left, top},
.end = Vector2.{right, top}, .color = light})
Line(session, LineProps.{.start = Vector2.{left, top},
.end = Vector2.{left, bottom}, .color = light})
Line(session, LineProps.{.start = Vector2.{left, bottom},
.end = Vector2.{right, bottom}, .color = dark})
Line(session, LineProps.{.start = Vector2.{right, top},
.end = Vector2.{right, bottom}, .color = dark})
if fill_w > 0 {
inner_w := fill_w - AppScale(4)
if inner_w < AppScale(2) {
inner_w = AppScale(2)
}
DrawRectangle(x + AppScale(2),
y + AppScale(2),
inner_w,
bar_h - AppScale(4),
button)
Box(session, BoxProps.{
.bounds = Rectangle.{cast(float32)(x + AppScale(2)),
cast(float32)(y + AppScale(2)),
cast(float32)inner_w,
cast(float32)(bar_h - AppScale(4))},
.fill = button})
}
}
+16 -6
View File
@@ -37,7 +37,7 @@ app_draw_session_exit_modal :: (app: *InnerBreeze, can_save: s32,
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import, file "../practice_window.zi";
#import "button_widget"
@@ -48,6 +48,8 @@ app_draw_session_exit_modal :: (app: *InnerBreeze, can_save: s32,
#import "button_props"
#import "modal_props"
#import "modal_widget"
#import "shape_props"
#import "shape_widget"
using SessionExitModalResult;
using ModalType;
@@ -505,7 +507,7 @@ meditation_window_result :: (app: *InnerBreeze, result: *SessionResult) -> s32 {
meditation_draw_window :: (app: *InnerBreeze, picture: Rectangle, status: []u8) -> string {
// The screen's circle is 86 units inside a halo 20 units wider.
circle := PracticeWindowCircle(CurrentApp().ui.session, picture, 0.0, 86.0 / 106.0,
Fade(StyleTokenColor("accent"), 0.24f))
color_with_alpha(StyleTokenColor("accent"), 0.24f))
time_text: [32]u8
format_time(time_text[:], app.meditation.remaining_seconds)
PracticeWindowLabel(app, circle, AppTextFromCString(*time_text[0], 32))
@@ -520,6 +522,18 @@ meditation_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
circle_radius := AppScale(86)
title_h := PracticeTitleBarHeight()
// On a short screen the circle reaches under the title bar, so it comes
// first. The question asked on leaving shows the page without it.
if app.modal.active == 0 ||
app.modal.type != cast(ModalType)ModalConfirmExitSession {
center := Vector2.{cast(float32)center_x, cast(float32)center_y}
Circle(app.ui.session, CircleProps.{.center = center,
.radius = cast(float32)(circle_radius + AppScale(20)),
.fill = color_with_alpha(circle, 0.24f)})
Circle(app.ui.session, CircleProps.{.center = center,
.radius = cast(float32)circle_radius, .fill = circle})
}
if PracticeTitleBar(app, LocaleText("meditation_title"), title_h) {
meditation_request_exit(app)
return
@@ -531,10 +545,6 @@ meditation_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
practice_draw_audio_controls(app)
DrawCircle(center_x, center_y, cast(float32)(circle_radius + AppScale(20)),
Fade(circle, 0.24f))
DrawCircle(center_x, center_y, cast(float32)circle_radius, circle)
format_time(time_text[:], app.meditation.remaining_seconds)
time_label := AppTextFromCString(*time_text[0], 32)
font = AppFitFontSize(time_label, circle_radius * 2 - AppScale(20),
+19 -12
View File
@@ -45,7 +45,6 @@ sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c3;
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/current_app.zi";
#import, file "../practice_window.zi";
#import "button_widget"
@@ -53,6 +52,8 @@ sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c3;
#import "drawing_props"
#import "session"
#import "button_props"
#import "shape_props"
#import "shape_widget"
@@ -472,6 +473,17 @@ patterns_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
if app == null {
return
}
session_top = title_h + AppScale(114)
session_bottom = app.ui.view_height - AppScale(174)
if session_bottom > session_top {
center_y = (session_top + session_bottom) / 2 + AppScale(8)
}
// On a short screen the circle reaches under the title bar, so it comes
// first. The question asked on leaving shows the page without it.
if app.modal.active == 0 ||
app.modal.type != cast(ModalType)ModalConfirmExitSession {
pattern_circle_draw(app, center_x, center_y, patterns_circle_fraction(app))
}
if patterns_draw_session_title_bar(app, LocaleText("patterns_title"), title_h) != 0 {
patterns_request_exit(app)
return
@@ -480,13 +492,6 @@ patterns_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
return
}
practice_draw_audio_controls(app)
session_top = title_h + AppScale(114)
session_bottom = app.ui.view_height - AppScale(174)
if session_bottom > session_top {
center_y = (session_top + session_bottom) / 2 + AppScale(8)
}
pattern_circle_draw(app, center_x, center_y, patterns_circle_fraction(app))
label := LocaleText(patterns_phase_label_key(app.patterns.phase))
instruction_font: s32 = AppScale(Text32)
@@ -616,10 +621,12 @@ pattern_circle_draw :: (app: *InnerBreeze, center_x: s32, center_y: s32,
r := cast(s32)(cast(float32)min_r + fraction * cast(float32)(max_r - min_r))
circle := StyleTokenColor("accent")
DrawCircle(center_x, center_y, cast(float32)max_r,
DarkenColor(StyleTokenColor("canvas"), 8))
DrawCircle(center_x, center_y, cast(float32)r, circle)
unused app
center := Vector2.{cast(float32)center_x, cast(float32)center_y}
Circle(app.ui.session, CircleProps.{.center = center,
.radius = cast(float32)max_r,
.fill = DarkenColor(StyleTokenColor("canvas"), 8)})
Circle(app.ui.session, CircleProps.{.center = center,
.radius = cast(float32)r, .fill = circle})
}
pattern_text_color_for_background :: (background: Color) -> Color {
@@ -22,9 +22,12 @@
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/current_app.zi";
#import "box_props"
#import "box_widget"
#import "image_widget"
#import "shape_props"
#import "shape_widget"
#import "slider_widget"
#import "text_widget"
#import "drawing_props"
@@ -138,21 +141,26 @@ draw_preview :: (app: *InnerBreeze, x: s32, y: s32, w: s32) {
px := x + col * (thumb_w + gap) + (w - (thumb_w * 6 + gap * 5)) / 2
py := y + row * (thumb_h + AppScale(18))
DrawRectangle(px, py, thumb_w, thumb_h,
DarkenColor(StyleTokenColor("canvas"), 6))
// The step being shown is outlined.
outline := Color.{0, 0, 0, 0}
if i == active_step {
DrawRectangleLines(px, py, thumb_w, thumb_h, StyleTokenColor("accent-hover"))
outline = StyleTokenColor("accent-hover")
}
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)px, cast(float32)py,
cast(float32)thumb_w, cast(float32)thumb_h},
.fill = DarkenColor(StyleTokenColor("canvas"), 6),
.border = outline})
draw_preview_pose(i, px, py, thumb_w, thumb_h)
if i < SUN_SALUTATION_STEP_COUNT - 1 {
next_col := (i + 1) % 6
if next_col != 0 {
DrawLine(px + thumb_w + AppScale(1),
py + thumb_h / 2,
px + thumb_w + gap - AppScale(1),
py + thumb_h / 2,
muted)
link_y := cast(float32)(py + thumb_h / 2)
Line(app.ui.session, LineProps.{
.start = Vector2.{cast(float32)(px + thumb_w + AppScale(1)), link_y},
.end = Vector2.{cast(float32)(px + thumb_w + gap - AppScale(1)), link_y},
.color = muted})
}
}
i += 1
@@ -41,7 +41,6 @@ sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c3;
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/current_app.zi";
#import "image_widget"
#import "text_widget"
+21 -8
View File
@@ -28,8 +28,10 @@ GetFrameTime :: () -> float32 #foreign c;
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import "box_props"
#import "box_widget"
#import "button_widget"
#import "dropdown_widget"
#import "modal_frame_widget"
@@ -42,6 +44,8 @@ GetFrameTime :: () -> float32 #foreign c;
#import "dropdown_props"
#import "toggle_props"
#import "toggle"
#import "shape_props"
#import "shape_widget"
using BreathAnimation;
@@ -209,9 +213,16 @@ whm_config_draw_section_title :: (x: s32, y: *s32, title: string) {
whm_config_draw_card :: (x: s32, y: s32, w: s32, h: s32) {
bounds := Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w, cast(float32)h }
// The corners round off 8% of the card's shorter side.
shorter := w
if h < shorter {
shorter = h
}
DrawRectangleRounded(bounds, 0.08f, 10, StyleTokenColor("surface"))
DrawRectangleRoundedLinesEx(bounds, 0.08f, 10, 1.0f, StyleTokenColor("border"))
Box(CurrentApp().ui.session, BoxProps.{.bounds = bounds,
.fill = StyleTokenColor("surface"),
.border = StyleTokenColor("border"),
.radius = 0.08 * cast(float32)shorter * 0.5})
}
whm_config_breath_card_height :: (app: *InnerBreeze) -> s32 {
@@ -297,11 +308,13 @@ whm_config_draw_breath_card :: (app: *InnerBreeze, content_x: s32, content_w: s3
} else {
update_preview_bounds(*app.settings_preview, inner_w, preview_h)
}
DrawCircleGradient(Vector2.{cast(float32)(inner_x + inner_w / 2),
cast(float32)(inner_y + preview_h / 2)},
cast(float32)AppScale(72),
Fade(StyleTokenColor("link"), 0.16f),
Fade(StyleTokenColor("canvas"), 0.0f))
Circle(CurrentApp().ui.session, CircleProps.{
.center = Vector2.{cast(float32)(inner_x + inner_w / 2),
cast(float32)(inner_y + preview_h / 2)},
.radius = cast(float32)AppScale(72),
.fill = color_with_alpha(StyleTokenColor("link"), 0.16f),
.edge = color_with_alpha(StyleTokenColor("canvas"), 0.0f),
.has_edge = true})
// Customize itself may be a full-screen modal; any other modal covers
// this page, and the preview holds still behind it.
covered_by_modal := app.modal.active != 0 &&
+50 -31
View File
@@ -67,7 +67,7 @@ GetTime :: () -> float64 #foreign c;
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import "button_widget"
#import "text_widget"
@@ -76,6 +76,10 @@ GetTime :: () -> float64 #foreign c;
#import "paint_queue"
#import "session"
#import "button_props"
#import "box_props"
#import "box_widget"
#import "shape_props"
#import "shape_widget"
#import "toolbar_props"
@@ -821,11 +825,6 @@ draw_session_counter :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
})
}
color_with_alpha :: (color: Color, alpha: u8) -> Color {
color.a = alpha
return color
}
session_circle_progress :: (app: *InnerBreeze, total_ticks: *s32, progress: *float32,
countdown: *s32) {
total: s32 = BreathDigitsRead(app.breathing.maxbreaths[:])
@@ -928,29 +927,42 @@ draw_session_progress_circle :: (app: *InnerBreeze, center_x: s32, center_y: s32
return
}
band_bg = color_with_alpha(contrast, 30)
band_fill = color_with_alpha(contrast, 72)
tick_pending = color_with_alpha(contrast, 96)
tick_done = color_with_alpha(contrast, 235)
ring = color_with_alpha(contrast, 175)
band_bg = color_with_alpha(contrast, 30.0 / 255.0)
band_fill = color_with_alpha(contrast, 72.0 / 255.0)
tick_pending = color_with_alpha(contrast, 96.0 / 255.0)
tick_done = color_with_alpha(contrast, 235.0 / 255.0)
ring = color_with_alpha(contrast, 175.0 / 255.0)
DrawCircleV(Vector2.{cast(float32)center_x, cast(float32)center_y}, radius, circle)
DrawRing(Vector2.{cast(float32)center_x, cast(float32)center_y}, inner_radius, outer_radius,
0.0f, 360.0f, 128, band_bg)
session := app.ui.session
center := Vector2.{cast(float32)center_x, cast(float32)center_y}
Circle(session, CircleProps.{.center = center, .radius = radius,
.fill = circle})
Ring(session, RingProps.{.center = center,
.inner_radius = inner_radius, .outer_radius = outer_radius,
.start_angle = 0.0f, .end_angle = 360.0f, .color = band_bg})
if countdown != 0 {
if progress < 1.0f {
DrawRing(Vector2.{cast(float32)center_x, cast(float32)center_y}, inner_radius,
outer_radius, -450.0f, -90.0f - 360.0f * progress,
128, band_fill)
Ring(session, RingProps.{.center = center,
.inner_radius = inner_radius, .outer_radius = outer_radius,
.start_angle = -450.0f,
.end_angle = -90.0f - 360.0f * progress,
.color = band_fill})
}
} else if progress > 0.0f {
DrawRing(Vector2.{cast(float32)center_x, cast(float32)center_y}, inner_radius, outer_radius,
-90.0f, -90.0f + 360.0f * progress, 128, band_fill)
Ring(session, RingProps.{.center = center,
.inner_radius = inner_radius, .outer_radius = outer_radius,
.start_angle = -90.0f,
.end_angle = -90.0f + 360.0f * progress,
.color = band_fill})
}
DrawRing(Vector2.{cast(float32)center_x, cast(float32)center_y}, inner_radius - 0.75f,
inner_radius + 0.75f, 0.0f, 360.0f, 128, ring)
DrawRing(Vector2.{cast(float32)center_x, cast(float32)center_y}, outer_radius - 0.75f,
outer_radius + 0.75f, 0.0f, 360.0f, 128, ring)
Ring(session, RingProps.{.center = center,
.inner_radius = inner_radius - 0.75f,
.outer_radius = inner_radius + 0.75f,
.start_angle = 0.0f, .end_angle = 360.0f, .color = ring})
Ring(session, RingProps.{.center = center,
.inner_radius = outer_radius - 0.75f,
.outer_radius = outer_radius + 0.75f,
.start_angle = 0.0f, .end_angle = 360.0f, .color = ring})
{
i: s32 = 0
@@ -970,8 +982,9 @@ draw_session_progress_circle :: (app: *InnerBreeze, center_x: s32, center_y: s32
start: Vector2 = Vector2.{cast(float32)center_x + c * inner_radius, cast(float32)center_y + s * inner_radius}
end: Vector2 = Vector2.{cast(float32)center_x + c * outer_radius, cast(float32)center_y + s * outer_radius}
DrawLineEx(start, end, cast(float32)thickness,
ifx (tick_colored) then (tick_done) else (tick_pending))
Line(session, LineProps.{.start = start, .end = end,
.thickness = cast(float32)thickness,
.color = ifx (tick_colored) then (tick_done) else (tick_pending)})
i += 1
}
}
@@ -1372,15 +1385,19 @@ session_draw_results_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32,
AppFormatS32(ifx (rounds > 0) then (cast(s32)(total / rounds)) else (0), seconds_text[:])
AppCopyText(AppTextFromCString(*seconds_text[0], 16), lines[2][:])
}
DrawRectangle(box_x, box_y, box_w, AppScale(29) * 3,
DarkenColor(StyleTokenColor("canvas"), 6))
Box(CurrentApp().ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)box_x, cast(float32)box_y,
cast(float32)box_w, cast(float32)(AppScale(29) * 3)},
.fill = DarkenColor(StyleTokenColor("canvas"), 6)})
{
i: s32 = 0
while i < 3 {
info_y := box_y + i * AppScale(29)
if i > 0 {
DrawLine(box_x, info_y, box_x + box_w, info_y,
DarkenColor(StyleTokenColor("canvas"), 30))
Line(CurrentApp().ui.session, LineProps.{
.start = Vector2.{cast(float32)box_x, cast(float32)info_y},
.end = Vector2.{cast(float32)(box_x + box_w), cast(float32)info_y},
.color = DarkenColor(StyleTokenColor("canvas"), 30)})
}
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)(box_x + AppScale(10)),
@@ -1404,8 +1421,10 @@ session_draw_results_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32,
row_font: s32 = AppFontSize()
FormatTwoNumberTemplate(LocaleText("round_result_label"),
i + 1, round_times[i], row[:])
DrawRectangle(box_x, row_y - 1, box_w, row_h,
DarkenColor(StyleTokenColor("canvas"), 4))
Box(CurrentApp().ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)box_x, cast(float32)(row_y - 1),
cast(float32)box_w, cast(float32)row_h},
.fill = DarkenColor(StyleTokenColor("canvas"), 4)})
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)(box_x + AppScale(10)),
cast(float32)(row_y - 1), cast(float32)(box_w - AppScale(20)),
+2 -2
View File
@@ -33,7 +33,7 @@ c :: #system_library "c";
#import "text_align"
#import "text_props"
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import, file "../../app/cards.zi";
#import "box_props"
@@ -2018,7 +2018,7 @@ habit_edit_draw_form :: (app: *InnerBreeze) {
.bounds = Rectangle.{0.0,
cast(float32)(app.ui.view_height - footer),
cast(float32)app.ui.view_width, cast(float32)AppScale(1)},
.fill = Fade(StyleTokenColor("text"), 0.12)})
.fill = color_with_alpha(StyleTokenColor("text"), 0.12)})
if app.habit_edit.name_error != 0 {
message := LocaleText(ifx (app.habit_edit.name_error == 1)
then ("habit_name_required") else ("habit_name_duplicate"))
-1
View File
@@ -14,7 +14,6 @@
#import, file "../../app/modal_rules.zi";
#import, file "../../app/locale.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/text_buffers.zi";
#import, file "../../app/cards.zi";
#import, file "../../platform/raylib_text_input.zi";
+14 -7
View File
@@ -33,7 +33,7 @@ app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c3;
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/draw.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import "button_widget"
#import "text_widget"
@@ -43,6 +43,8 @@ app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c3;
#import "image_props"
#import "box_props"
#import "box_widget"
#import "shape_props"
#import "shape_widget"
#import "paint_queue"
#import, file "../../app/cards.zi";
@@ -302,7 +304,7 @@ habit_session_has_activity :: (ctx: *HabitLinkedContext, activity: s32) -> bool
habit_session_divider :: (app: *InnerBreeze, x: s32, y: s32, width: s32) {
PaintRoundedFill(app.ui.session, -1, Rectangle.{cast(float32)x,
cast(float32)y, cast(float32)width, cast(float32)AppScale(1)},
0.0, 1, Fade(StyleTokenColor("text"), 0.1))
0.0, 1, color_with_alpha(StyleTokenColor("text"), 0.1))
}
// One practice's sessions of the day on its card: the practice's name, each
@@ -462,8 +464,8 @@ habit_session_draw_practice :: (app: *InnerBreeze, ctx: *HabitLinkedContext,
cast(float32)(y + AppScale(2)),
cast(float32)width,
cast(float32)(row_h - AppScale(4))},
.fill = Fade(StyleTokenColor("surface"), 0.75),
.border = Fade(StyleTokenColor("text"), 0.55),
.fill = color_with_alpha(StyleTokenColor("surface"), 0.75),
.border = color_with_alpha(StyleTokenColor("text"), 0.55),
.radius = cast(float32)AppScale(8)})
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{
@@ -695,9 +697,14 @@ habit_session_draw_keyboard :: (app: *InnerBreeze, entry: *HabitLinkedEntry) ->
w := app.ui.view_width - x * 2
key_w := (w - gap * 2) / 3
DrawRectangle(0, y, app.ui.view_width, keyboard_h,
DarkenColor(StyleTokenColor("canvas"), 10))
DrawLine(0, y, app.ui.view_width, y, DarkenColor(StyleTokenColor("canvas"), 42))
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{0.0, cast(float32)y,
cast(float32)app.ui.view_width, cast(float32)keyboard_h},
.fill = DarkenColor(StyleTokenColor("canvas"), 10)})
Line(app.ui.session, LineProps.{
.start = Vector2.{0.0, cast(float32)y},
.end = Vector2.{cast(float32)app.ui.view_width, cast(float32)y},
.color = DarkenColor(StyleTokenColor("canvas"), 42)})
FormatLocaleCount(*round_label[0], size_of(type_of(round_label)),
"round_number_label", app.habit_session_edit.round + 1)
+16 -16
View File
@@ -18,7 +18,7 @@ GetTime :: () -> float64 #foreign raylib_input;
#import, file "../app/app_sync.zi";
#import, file "../app/widgets.zi";
#import, file "../app/app_nav_state.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/locale.zi";
#import, file "../app/metrics.zi";
#import, file "../app/text_buffers.zi";
@@ -419,7 +419,7 @@ HabitScreenStepButton :: (app: *InnerBreeze, id: s32, bounds: Rectangle,
center_x := bounds.x + bounds.width * 0.5
center_y := bounds.y + bounds.height * 0.5
color := StyleTokenColor("text")
if disabled { color = Fade(color, 0.35) }
if disabled { color = color_with_alpha(color, 0.35) }
PaintRoundedFill(app.ui.session, -1, Rectangle.{
center_x - length * 0.5, center_y - thickness * 0.5,
length, thickness}, thickness * 0.5, 6, color)
@@ -648,7 +648,7 @@ HabitScreenDayDot :: (app: *InnerBreeze, center_x: s32, center_y: s32,
highlight_radius = AppScale(2)
}
HabitScreenCircle(app, center_x, center_y + AppScale(1),
radius + AppScale(2), Fade(Color.{0, 0, 0, 255}, 0.16))
radius + AppScale(2), color_with_alpha(Color.{0, 0, 0, 255}, 0.16))
show_count := counting && count > 0
if complete {
HabitScreenCircle(app, center_x, center_y,
@@ -659,7 +659,7 @@ HabitScreenDayDot :: (app: *InnerBreeze, center_x: s32, center_y: s32,
radius - AppScale(2), accent)
HabitScreenCircle(app, center_x - radius / 3,
center_y - radius / 2, highlight_radius,
Fade(Color.{255, 255, 255, 255}, 0.3))
color_with_alpha(Color.{255, 255, 255, 255}, 0.3))
if !show_count {
// A check centred on the dot's face and sized to it, drawn as
// one smooth stroke, so it stays inside the dot at any scale.
@@ -675,7 +675,7 @@ HabitScreenDayDot :: (app: *InnerBreeze, center_x: s32, center_y: s32,
}
} else {
HabitScreenCircle(app, center_x, center_y,
radius + AppScale(1), Fade(foreground, 0.54))
radius + AppScale(1), color_with_alpha(foreground, 0.54))
HabitScreenCircle(app, center_x, center_y,
radius - AppScale(2), surface)
if half {
@@ -687,7 +687,7 @@ HabitScreenDayDot :: (app: *InnerBreeze, center_x: s32, center_y: s32,
if !show_count && !half {
HabitScreenCircle(app, center_x - AppScale(2),
center_y - AppScale(3), highlight_radius,
Fade(Color.{255, 255, 255, 255}, 0.16))
color_with_alpha(Color.{255, 255, 255, 255}, 0.16))
}
}
@@ -858,7 +858,7 @@ HabitScreenDayCell :: (app: *InnerBreeze, habit_index: s32, day_index: s32,
app.ui.mouse_y < cast(s32)(bounds.y + bounds.height)
if mouse_over {
HabitScreenCircle(app, center_x, center_y, radius + AppScale(5),
Fade(habit.color, 0.24))
color_with_alpha(habit.color, 0.24))
}
half := HabitScreenSpanRunning(habit, day_index)
if scheduled {
@@ -972,7 +972,7 @@ HabitScreenRowDetail :: (app: *InnerBreeze, index: s32, bounds: Rectangle,
panel_h := cast(s32)bounds.height - AppScale(4) - AppScale(12)
panel: BoxProps
panel.bounds = HabitScreenRect(panel_x, panel_y, panel_w, panel_h)
panel.fill = Fade(StyleTokenColor("text"), 0.04)
panel.fill = color_with_alpha(StyleTokenColor("text"), 0.04)
panel.radius = cast(float32)AppScale(CARD_RADIUS)
Box(app.ui.session, panel)
inner := AppScale(HABITS_DETAIL_PADDING)
@@ -1137,7 +1137,7 @@ HabitScreenEndDrag :: (app: *InnerBreeze) {
HabitScreenDragOutline :: (app: *InnerBreeze, bounds: Rectangle) {
PaintRoundedOutline(app.ui.session, -1, bounds,
cast(float32)AppScale(12), 12, cast(float32)AppScale(2),
Fade(StyleTokenColor("text"), 0.8))
color_with_alpha(StyleTokenColor("text"), 0.8))
}
// Three short bars at a row's end show that the row can be dragged.
@@ -1147,7 +1147,7 @@ HabitScreenGrip :: (app: *InnerBreeze, bounds: Rectangle) {
spacing := cast(float32)AppScale(5)
x := bounds.x + bounds.width - cast(float32)AppScale(16) - width
y := bounds.y + bounds.height * 0.5 - spacing - thickness * 0.5
color := Fade(StyleTokenColor("text"), 0.45)
color := color_with_alpha(StyleTokenColor("text"), 0.45)
bar: s32 = 0
while bar < 3 {
PaintRoundedFill(app.ui.session, -1, Rectangle.{x,
@@ -1223,7 +1223,7 @@ HabitScreenInactiveHeader :: (app: *InnerBreeze, bounds: Rectangle,
span := AppScale(5)
tip := ifx open then (chevron_y - span / 2) else (chevron_y + span / 2)
ends := ifx open then (chevron_y + span / 2) else (chevron_y - span / 2)
chevron_color := Fade(StyleTokenColor("text"), 0.7)
chevron_color := color_with_alpha(StyleTokenColor("text"), 0.7)
HabitScreenLine(app, chevron_x - span, ends, chevron_x, tip, chevron_color)
HabitScreenLine(app, chevron_x, tip, chevron_x + span, ends, chevron_color)
if clicked {
@@ -1476,7 +1476,7 @@ HabitScreenOverview :: (app: *InnerBreeze,
progress_w, AppScale(6))
PaintRoundedFill(app.ui.session, -1, progress_bounds,
cast(float32)AppScale(3), 8,
Fade(StyleTokenColor("text"), 0.12f))
color_with_alpha(StyleTokenColor("text"), 0.12f))
if due > 0 && done > 0 {
progress_fill := progress_w * done / due
if progress_fill > progress_w {
@@ -1564,7 +1564,7 @@ HabitScreenOverview :: (app: *InnerBreeze,
panel.bounds = HabitScreenRect(geometry.x, list_y, geometry.width,
header_h + panel_rows_h)
panel.fill = StyleTokenColor("surface")
panel.border = Fade(StyleTokenColor("text"), 0.12)
panel.border = color_with_alpha(StyleTokenColor("text"), 0.12)
panel.radius = cast(float32)AppScale(14)
Box(app.ui.session, panel)
// A card that just opened scrolls into view: all of it when it fits,
@@ -1623,7 +1623,7 @@ HabitScreenOverview :: (app: *InnerBreeze,
if position > 0 {
PaintRoundedFill(app.ui.session, -1, HabitScreenRect(table_x + pad,
cast(s32)row.y, table_w - pad * 2, HabitScreenHairline()), 0.0,
1, Fade(StyleTokenColor("text"), 0.08))
1, color_with_alpha(StyleTokenColor("text"), 0.08))
}
if position == 0 {
app.habits_guide_anchors[1] = row
@@ -1648,7 +1648,7 @@ HabitScreenOverview :: (app: *InnerBreeze,
if show_section {
PaintRoundedFill(app.ui.session, -1, HabitScreenRect(table_x,
cast(s32)section.y, table_w, HabitScreenHairline()), 0.0, 1,
Fade(StyleTokenColor("text"), 0.12))
color_with_alpha(StyleTokenColor("text"), 0.12))
HabitScreenInactiveHeader(app, HabitScreenRect(table_x,
cast(s32)section.y, table_w,
AppScale(HABITS_INACTIVE_HEADER_HEIGHT)),
@@ -1680,7 +1680,7 @@ HabitScreenOverview :: (app: *InnerBreeze,
layout, header_h)
PaintRoundedFill(app.ui.session, -1, HabitScreenRect(geometry.x, rows_y,
geometry.width, HabitScreenHairline()), 0.0, 1,
Fade(StyleTokenColor("text"), 0.12))
color_with_alpha(StyleTokenColor("text"), 0.12))
// A row dropped below the panel, while the rows do not fill the space,
// still goes last.
drop_list := scrolled
+15 -69
View File
@@ -43,6 +43,8 @@ storage_has_sync_account :: () -> s32 #foreign c3;
#import, file "../practices/practice_downloads.zi";
#import, file "../practices/patterns/patterns_session_rules.zi";
#import, file "practice_subscreen_layout.zi";
#import "box_props"
#import "box_widget"
#import "button_props"
#import "control_props"
#import "image_props"
@@ -52,7 +54,7 @@ storage_has_sync_account :: () -> s32 #foreign c3;
#import "text_props"
#import, file "../app/exercise_types.zi";
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/current_app.zi";
#import "button_widget"
#import "image_widget"
@@ -420,65 +422,6 @@ practice_home_metadata :: (app: *InnerBreeze, out: *u8, out_size: s64) {
}
}
practice_draw_title_crescent :: (center_x: s32, y: s32, w: s32,
color: Color) {
segments: s32 = 28
half := cast(float32)w * 0.5f
start := Vector2.{cast(float32)center_x - half, cast(float32)y - cast(float32)AppScale(3) }
control := Vector2.{cast(float32)center_x, cast(float32)y + cast(float32)AppScale(26) }
end := Vector2.{cast(float32)center_x + half, cast(float32)y - cast(float32)AppScale(4) }
{
layer: s32 = 0
while layer < 3 {
{
i: s32 = 0
while i < segments {
t0 := cast(float32)i / cast(float32)segments
t1 := cast(float32)(i + 1) / cast(float32)segments
u0 := 1.0f - t0
u1 := 1.0f - t1
p0 := Vector2.{
u0 * u0 * start.x + 2.0f * u0 * t0 * control.x + t0 * t0 * end.x,
u0 * u0 * start.y + 2.0f * u0 * t0 * control.y + t0 * t0 * end.y
}
p1 := Vector2.{
u1 * u1 * start.x + 2.0f * u1 * t1 * control.x + t1 * t1 * end.x,
u1 * u1 * start.y + 2.0f * u1 * t1 * control.y + t1 * t1 * end.y
}
mid := (t0 + t1) * 0.5f
edge := ifx (mid < 0.5f) then (mid * 2.0f) else ((1.0f - mid) * 2.0f)
if edge < 0.0f {
edge = 0.0f
}
if edge > 1.0f {
edge = 1.0f
}
thickness := cast(float32)AppScale(2)
alpha: float32 = 0.58f
draw_color := color
if layer == 0 {
thickness = cast(float32)AppScale(15)
alpha = 0.08f
} else if layer == 1 {
thickness = cast(float32)AppScale(7)
alpha = 0.20f
}
if layer == 2 {
draw_color = Color.{.r = 250, .g = 225, .b = 255, .a = 255}
}
DrawLineEx(p0, p1, thickness * (0.35f + edge * 0.65f),
Fade(draw_color, alpha * edge))
i += 1
}
}
layer += 1
}
}
}
PracticeHomeTitleLayout :: struct {
title: TextProps
subtitle: TextProps
@@ -582,10 +525,6 @@ practice_draw_home_title :: (app: *InnerBreeze, x: s32, y: s32, w: s32) {
subtitle_props: TextProps = layout.subtitle
Text(app.ui.session, subtitle_props)
}
underline_w := AppTextWidth(layout.title.text, layout.title.font) * 64 / 100
underline_w = clampi(underline_w, AppScale(170), AppScale(340))
practice_draw_title_crescent(x + w / 2, y + layout.height + AppScale(6),
underline_w, Color.{.r = 193, .g = 146, .b = 255, .a = 255})
}
// With every practice removed, Practice's home offers only Manage practices.
@@ -601,8 +540,9 @@ practice_screen_draw_home_empty :: (app: *InnerBreeze) -> s32 {
if view_h <= 0 {
return 0
}
DrawRectangleRec(Rectangle.{cast(float32)view_x, 0, cast(float32)view_w, cast(float32)view_h},
StyleTokenColor("canvas"))
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)view_x, 0, cast(float32)view_w, cast(float32)view_h},
.fill = StyleTokenColor("canvas")})
text_w := view_w - AppScale(48)
if text_w > AppScale(520) {
text_w = AppScale(520)
@@ -745,7 +685,8 @@ practice_screen_draw_home_hero :: (app: *InnerBreeze) -> s32 {
if banner_path.count > 0 {
practice_draw_card_banner(banner_path, Rectangle.{hero.x, hero.y, hero.width, cast(float32)(title_y + AppScale(8))})
} else {
DrawRectangleRec(hero, StyleTokenColor("surface"))
Box(app.ui.session, BoxProps.{.bounds = hero,
.fill = StyleTokenColor("surface")})
}
if practice_banner_probe_count == 1 {
@@ -759,7 +700,7 @@ practice_screen_draw_home_hero :: (app: *InnerBreeze) -> s32 {
PaintVerticalGradient(app.ui.session, -1,
Rectangle.{cast(float32)content_view_x, cast(float32)fade_y,
cast(float32)content_view_w, cast(float32)fade_h},
Fade(StyleTokenColor("canvas"), 0.0f), StyleTokenColor("canvas"))
color_with_alpha(StyleTokenColor("canvas"), 0.0f), StyleTokenColor("canvas"))
PaintRoundedFill(app.ui.session, -1,
Rectangle.{cast(float32)content_view_x, cast(float32)title_y,
cast(float32)content_view_w,
@@ -1098,7 +1039,12 @@ practice_screen_draw_modal :: (app: *InnerBreeze) {
if app.modal.type != cast(ModalType)ModalPracticeManual && app.modal.type != cast(ModalType)ModalPracticeConfig && app.modal.type != cast(ModalType)ModalEditProgressiveStartSpeed {
return
}
DrawRectangle(0, 0, app.ui.view_width, app.ui.view_height, StyleTokenColor("canvas"))
// The page is drawn over the canvas. The dock, already drawn this frame
// while a bottom dock shows, stays above it.
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{0.0, 0.0, cast(float32)app.ui.view_width,
cast(float32)(app.ui.view_height - app_content_bottom_reserved(app))},
.fill = StyleTokenColor("canvas")})
if app.modal.type == cast(ModalType)ModalEditProgressiveStartSpeed {
practice := practice_get(app.exercise_type)
if practice.draw_config != null {
-1
View File
@@ -24,7 +24,6 @@
#import, file "../platform/dew_payment.zi";
#import, file "../platform/raylib_text_input.zi";
#import, file "../app/app_types.zi";
#import, file "../app/draw.zi";
#import, file "../app/metrics.zi";
#import, file "../app/locale.zi";
#import, file "../app/text_buffers.zi";
-1
View File
@@ -19,7 +19,6 @@
#import, file "../platform/dew_payment.zi";
#import, file "../platform/raylib_text_input.zi";
#import, file "../app/app_types.zi";
#import, file "../app/draw.zi";
#import, file "../app/metrics.zi";
#import, file "../app/locale.zi";
#import, file "../app/text_buffers.zi";
+3 -3
View File
@@ -13,7 +13,7 @@
#import "toggle_widget"
#import, file "../app/app_types.zi";
#import, file "../app/app_sync.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/locale.zi";
#import, file "../app/metrics.zi";
#import, file "../app/text_buffers.zi";
@@ -188,7 +188,7 @@ ProfileDrawNodeCard :: (app: *InnerBreeze, index: s32, address: string,
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)(left + inner - badge_w), cast(float32)(top + AppScale(2)),
cast(float32)badge_w, cast(float32)AppScale(22)},
.fill = Fade(StyleTokenColor("accent"), 0.22),
.fill = color_with_alpha(StyleTokenColor("accent"), 0.22),
.radius = cast(float32)AppScale(11)})
ProfileNodeStorageText(app, badge, left + inner - badge_w, top + AppScale(2),
badge_w, AppScale(22), small, "", cast(TextAlign)TextAlignCenter)
@@ -247,7 +247,7 @@ ProfileDrawNodeCard :: (app: *InnerBreeze, index: s32, address: string,
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)left, cast(float32)top,
cast(float32)inner, cast(float32)AppScale(1)},
.fill = Fade(StyleTokenColor("text"), 0.10)})
.fill = color_with_alpha(StyleTokenColor("text"), 0.10)})
top += AppScale(6)
toggle_w := AppScale(50)
toggle_h := AppScale(28)
+51 -22
View File
@@ -43,11 +43,13 @@ c3 :: #system_library "c";
#import "control_props"
#import "text_props"
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/current_app.zi";
#import "button_widget"
#import "box_props"
#import "box_widget"
#import "shape_props"
#import "shape_widget"
#import "icon"
#import "image_props"
#import "image_widget"
@@ -322,13 +324,24 @@ profile_draw_identity :: (app: *InnerBreeze, x: s32, w: s32, y: *s32) {
}
}
// The corner radius that rounds off `roundness` of a box's shorter side.
profile_corner_radius :: (roundness: float32, w: s32, h: s32) -> float32 {
shorter := w
if h < shorter {
shorter = h
}
return roundness * cast(float32)shorter * 0.5
}
profile_draw_metric_card :: (x: s32, w: s32, y: *s32, label: string,
value: string) {
h := AppScale(58)
value_w := AppTextWidth(value, AppFontSize())
DrawRectangleRounded(Rectangle.{cast(float32)x, cast(float32)(y.*), cast(float32)w, cast(float32)h},
0.12f, 8, DarkenColor(StyleTokenColor("canvas"), 7))
Box(CurrentApp().ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)x, cast(float32)(y.*), cast(float32)w, cast(float32)h},
.fill = DarkenColor(StyleTokenColor("canvas"), 7),
.radius = profile_corner_radius(0.12, w, h)})
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)(x + AppScale(12)), cast(float32)(y.* + AppScale(20)), 0, 0},
.text = (label),
@@ -468,7 +481,7 @@ profile_draw_hub_route_divider :: (app: *InnerBreeze,
PaintRoundedFill(app.ui.session, -1,
Rectangle.{cast(float32)(x + AppScale(16)), cast(float32)y,
cast(float32)(w - AppScale(32)), cast(float32)AppScale(1)},
0.0, 4, Fade(StyleTokenColor("text"), 0.10f))
0.0, 4, color_with_alpha(StyleTokenColor("text"), 0.10f))
}
profile_draw_hub_identity :: (app: *InnerBreeze, x: s32, w: s32, y: *s32) {
@@ -499,12 +512,17 @@ profile_draw_hub_identity :: (app: *InnerBreeze, x: s32, w: s32, y: *s32) {
subtitle[:])
}
DrawRectangleRounded(bounds, 0.14f, 12, DarkenColor(StyleTokenColor("canvas"), 8))
DrawRectangleGradientV(x, y.*, w, card_h,
Fade(StyleTokenColor("accent"), 0.32f),
Fade(StyleTokenColor("canvas"), 0.0f))
DrawRectangleRoundedLinesEx(bounds, 0.14f, 12, 1.0f,
DarkenColor(StyleTokenColor("accent"), 18))
radius := profile_corner_radius(0.14, w, card_h)
Box(app.ui.session, BoxProps.{.bounds = bounds,
.fill = DarkenColor(StyleTokenColor("canvas"), 8),
.radius = radius})
// The fade covers the whole rectangle, its corners too.
Box(app.ui.session, BoxProps.{.bounds = bounds,
.fill = color_with_alpha(StyleTokenColor("accent"), 0.32f),
.fill_bottom = color_with_alpha(StyleTokenColor("canvas"), 0.0f),
.has_fill_bottom = true,
.border = DarkenColor(StyleTokenColor("accent"), 18),
.radius = radius})
profile_draw_avatar(app, avatar_x, avatar_y, avatar)
profile_draw_fitted_text(AppTextFromCString(*title[0], 96),
text_x, y.* + AppScale(34),
@@ -689,7 +707,10 @@ profile_draw_data_summary :: (x: s32, w: s32, y: *s32) {
}
profile_draw_divider :: (x: s32, w: s32, y: s32) {
DrawLine(x, y, x + w, y, DarkenColor(StyleTokenColor("canvas"), 28))
Line(CurrentApp().ui.session, LineProps.{
.start = Vector2.{cast(float32)x, cast(float32)y},
.end = Vector2.{cast(float32)(x + w), cast(float32)y},
.color = DarkenColor(StyleTokenColor("canvas"), 28)})
}
profile_tab_title :: (tab: s32) -> string {
@@ -717,9 +738,13 @@ profile_draw_tabs :: (app: *InnerBreeze, y: s32, h: s32) -> s32 {
view_width: s32 = app.ui.view_width
tab_w := view_width / PROFILE_TAB_COUNT
DrawRectangle(0, y, view_width, h, DarkenColor(StyleTokenColor("canvas"), 6))
DrawLine(0, y + h - 1, view_width, y + h - 1,
DarkenColor(StyleTokenColor("canvas"), 24))
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{0.0, cast(float32)y, cast(float32)view_width, cast(float32)h},
.fill = DarkenColor(StyleTokenColor("canvas"), 6)})
Line(app.ui.session, LineProps.{
.start = Vector2.{0.0, cast(float32)(y + h - 1)},
.end = Vector2.{cast(float32)view_width, cast(float32)(y + h - 1)},
.color = DarkenColor(StyleTokenColor("canvas"), 24)})
{
i: s32 = 0
while i < PROFILE_TAB_COUNT {
@@ -727,6 +752,18 @@ profile_draw_tabs :: (app: *InnerBreeze, y: s32, h: s32) -> s32 {
x := i * tab_w
w := ifx (i == PROFILE_TAB_COUNT - 1) then (view_width - x) else (tab_w)
selected := i == app.profile_tab
// The selected tab's underline lies under its button.
if selected {
line_w := w - AppScale(24)
if line_w < AppScale(24) {
line_w = AppScale(24)
}
Box(app.ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)(x + (w - line_w) / 2),
cast(float32)(y + h - AppScale(2)),
cast(float32)line_w, cast(float32)AppScale(2)},
.fill = StyleTokenColor("text")})
}
if Button(CurrentApp().ui.session, ButtonProps.{
.bounds = Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w, cast(float32)h},
.label = profile_tab_title(i),
@@ -735,14 +772,6 @@ profile_draw_tabs :: (app: *InnerBreeze, y: s32, h: s32) -> s32 {
}) != 0 {
clicked = i
}
if selected {
line_w := w - AppScale(24)
if line_w < AppScale(24) {
line_w = AppScale(24)
}
DrawRectangle(x + (w - line_w) / 2, y + h - AppScale(2),
line_w, AppScale(2), StyleTokenColor("text"))
}
i += 1
}
-1
View File
@@ -18,7 +18,6 @@ using TextWrap;
#import "control_props"
#import, file "../storage/storage_core.zi";
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/current_app.zi";
#import "button_widget"
#import "dropdown_widget"
+126 -64
View File
@@ -16,7 +16,7 @@
#import "text_props"
#import, file "../app/exercise_types.zi";
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/locale.zi";
#import, file "../storage/temporary_data.zi";
#import, file "../app/text_buffers.zi";
@@ -28,6 +28,8 @@
#import "button_props"
#import "box_props"
#import "box_widget"
#import "shape_props"
#import "shape_widget"
#import "kss_parser"
@@ -186,10 +188,21 @@ session_result_text :: (label: string, x: s32, y: s32, w: s32, h: s32,
})
}
// The corner radius that rounds off `roundness` of a box's shorter side.
session_result_corner_radius :: (roundness: float32, w: s32, h: s32) -> float32 {
shorter := w
if h < shorter {
shorter = h
}
return roundness * cast(float32)shorter * 0.5
}
session_result_card :: (x: s32, y: s32, w: s32, h: s32) {
bounds := Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w, cast(float32)h }
DrawRectangleRounded(bounds, 0.12f, 10, StyleTokenColor("surface"))
DrawRectangleRoundedLinesEx(bounds, 0.12f, 10, 1.0f, StyleTokenColor("border"))
Box(CurrentApp().ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w, cast(float32)h},
.fill = StyleTokenColor("surface"),
.border = StyleTokenColor("border"),
.radius = session_result_corner_radius(0.12, w, h)})
}
session_result_mood_picker :: (app: *InnerBreeze, x: s32, y: s32, w: s32) {
@@ -271,9 +284,10 @@ session_result_metrics :: (result: *SessionResult, x: s32, y: s32,
cell_x := x + i * (cell_w + gap)
actual_w := ifx (i == metric_count - 1) then (x + w - cell_x) else (cell_w)
session_result_card(cell_x, y, actual_w, AppScale(78))
DrawLine(cell_x + AppScale(14), y + AppScale(12),
cell_x + actual_w - AppScale(14), y + AppScale(12),
Fade(session_result_accent(), ifx (i == 1) then (0.72f) else (0.34f)))
Line(CurrentApp().ui.session, LineProps.{
.start = Vector2.{cast(float32)(cell_x + AppScale(14)), cast(float32)(y + AppScale(12))},
.end = Vector2.{cast(float32)(cell_x + actual_w - AppScale(14)), cast(float32)(y + AppScale(12))},
.color = color_with_alpha(session_result_accent(), ifx (i == 1) then (0.72f) else (0.34f))})
session_result_text(titles[i], cell_x + AppScale(5), y + AppScale(18),
actual_w - AppScale(10), AppScale(22),
AppFitFontSize(titles[i], actual_w - AppScale(12),
@@ -294,8 +308,28 @@ session_result_chart_height :: (result: *SessionResult) -> s32 {
return ifx (result.round_count <= 1) then (AppScale(165)) else (AppScale(220))
}
// Where a round's point sits across the chart.
session_result_chart_x :: (result: *SessionResult, index: s32, chart_x: s32,
chart_w: s32) -> s32 {
if result.round_count > 1 {
return chart_x + index * chart_w / (result.round_count - 1)
}
return chart_x + chart_w / 2
}
// How high a round's point sits above the chart's baseline.
session_result_chart_y :: (result: *SessionResult, index: s32, baseline: s32,
chart_h: s32, scale_max: s32) -> s32 {
value := result.round_values[index]
if value < 0 {
value = 0
}
return baseline - value * chart_h / scale_max
}
session_result_chart :: (result: *SessionResult, x: s32, y: s32, w: s32,
best: s32) {
session := CurrentApp().ui.session
chart_x := x + AppScale(34)
chart_y := y + AppScale(72)
chart_w := w - AppScale(68)
@@ -312,6 +346,21 @@ session_result_chart :: (result: *SessionResult, x: s32, y: s32, w: s32,
label_step = 1
}
session_result_card(x, y, w, session_result_chart_height(result))
// A single round's glow reaches under the title, so it comes first.
if result.round_count <= 1 {
glow_center := Vector2.{cast(float32)(x + w / 2),
cast(float32)(y + AppScale(91))}
Circle(session, CircleProps.{.center = glow_center,
.radius = cast(float32)AppScale(62),
.fill = color_with_alpha(accent, 0.18f),
.edge = color_with_alpha(StyleTokenColor("surface"), 0.0f),
.has_edge = true})
Ring(session, RingProps.{.center = glow_center,
.inner_radius = cast(float32)AppScale(46),
.outer_radius = cast(float32)AppScale(48),
.start_angle = 0.0f, .end_angle = 360.0f,
.color = color_with_alpha(accent, 0.70f)})
}
session_result_text(LocaleText("round_times_title"),
x + AppScale(18), y + AppScale(10), w - AppScale(36),
AppScale(32), AppScale(18), cast(TextAlign)TextAlignStart)
@@ -331,14 +380,6 @@ session_result_chart :: (result: *SessionResult, x: s32, y: s32, w: s32,
session_result_format_number("results_rounds", 0,
detail_label[:])
}
DrawCircleGradient(Vector2.{cast(float32)(x + w / 2),
cast(float32)(y + AppScale(91))},
cast(float32)AppScale(62), Fade(accent, 0.18f),
Fade(StyleTokenColor("surface"), 0.0f))
DrawRing(Vector2.{cast(float32)(x + w / 2),
cast(float32)(y + AppScale(91))},
cast(float32)AppScale(46), cast(float32)AppScale(48),
0.0f, 360.0f, 72, Fade(accent, 0.70f))
session_result_text(AppTextFromCString(*value_label[0], 32), x + AppScale(45), y + AppScale(57),
w - AppScale(90), AppScale(55), AppScale(38),
cast(TextAlign)TextAlignCenter)
@@ -346,51 +387,60 @@ session_result_chart :: (result: *SessionResult, x: s32, y: s32, w: s32,
w - AppScale(40), AppScale(25), AppScale(14),
cast(TextAlign)TextAlignCenter)
return
}
}
{
row: s32 = 0
while row < 3 {
guide_y := chart_y + row * chart_h / 2
DrawLine(chart_x, guide_y, chart_x + chart_w, guide_y,
Fade(StyleTokenColor("border"), 0.55f))
Line(session, LineProps.{
.start = Vector2.{cast(float32)chart_x, cast(float32)guide_y},
.end = Vector2.{cast(float32)(chart_x + chart_w), cast(float32)guide_y},
.color = color_with_alpha(StyleTokenColor("border"), 0.55f)})
row += 1
}
}
// The lines and points come before every label, so the labels stay
// above the lines that reach them.
{
i: s32 = 0
while i < result.round_count {
point_x := session_result_chart_x(result, i, chart_x, chart_w)
point_y := session_result_chart_y(result, i, baseline, chart_h,
scale_max)
point := Vector2.{cast(float32)point_x, cast(float32)point_y}
Line(session, LineProps.{.start = point,
.end = Vector2.{cast(float32)point_x, cast(float32)baseline},
.color = color_with_alpha(accent, 0.18f)})
if i > 0 {
previous_x := session_result_chart_x(result, i - 1, chart_x,
chart_w)
previous_y := session_result_chart_y(result, i - 1, baseline,
chart_h, scale_max)
Line(session, LineProps.{
.start = Vector2.{cast(float32)previous_x, cast(float32)previous_y},
.end = point,
.thickness = cast(float32)AppScale(3),
.color = accent})
}
Circle(session, CircleProps.{.center = point,
.radius = cast(float32)AppScale(5),
.fill = StyleTokenColor("text")})
i += 1
}
}
{
i: s32 = 0
while i < result.round_count {
value := result.round_values[i]
point_x := chart_x + (ifx (result.round_count > 1) then (i * chart_w / (result.round_count - 1)) else (chart_w / 2))
point_y: s32
if value < 0 {
value = 0
}
point_y = baseline - value * chart_h / scale_max
DrawLine(point_x, point_y, point_x, baseline,
Fade(accent, 0.18f))
if i > 0 {
previous := result.round_values[i - 1]
previous_x := chart_x + (ifx (result.round_count > 1) then ((i - 1) * chart_w / (result.round_count - 1)) else (chart_w / 2))
previous_y: s32
if previous < 0 {
previous = 0
}
previous_y = baseline - previous * chart_h / scale_max
DrawTriangle(Vector2.{cast(float32)previous_x, cast(float32)baseline},
Vector2.{cast(float32)previous_x, cast(float32)previous_y},
Vector2.{cast(float32)point_x, cast(float32)point_y},
Fade(accent, 0.08f))
DrawTriangle(Vector2.{cast(float32)previous_x, cast(float32)baseline},
Vector2.{cast(float32)point_x, cast(float32)point_y},
Vector2.{cast(float32)point_x, cast(float32)baseline},
Fade(accent, 0.08f))
DrawLineEx(Vector2.{cast(float32)previous_x, cast(float32)previous_y},
Vector2.{cast(float32)point_x, cast(float32)point_y},
cast(float32)AppScale(3), accent)
}
DrawCircle(point_x, point_y, cast(float32)AppScale(5), StyleTokenColor("text"))
if i % label_step == 0 || i == result.round_count - 1 {
value := result.round_values[i]
if value < 0 {
value = 0
}
point_x := session_result_chart_x(result, i, chart_x, chart_w)
point_y := session_result_chart_y(result, i, baseline, chart_h,
scale_max)
value_label: [24] u8
index_label: [16] u8
session_result_format_number("results_metric_seconds", value, value_label[:])
@@ -428,9 +478,11 @@ session_result_round_list :: (result: *SessionResult, x: s32, y: s32,
cell_y := y + AppScale(42) + row * AppScale(40)
session_result_format_two_numbers("round_result_label",
i + 1, result.round_values[i], label[:])
DrawRectangleRounded(Rectangle.{cast(float32)cell_x, cast(float32)cell_y,
cast(float32)cell_w, cast(float32)AppScale(32)},
0.16f, 6, Fade(StyleTokenColor("link"), 0.08f))
Box(CurrentApp().ui.session, BoxProps.{
.bounds = Rectangle.{cast(float32)cell_x, cast(float32)cell_y,
cast(float32)cell_w, cast(float32)AppScale(32)},
.fill = color_with_alpha(StyleTokenColor("link"), 0.08f),
.radius = session_result_corner_radius(0.16, cell_w, AppScale(32))})
session_result_text(AppTextFromCString(*label[0], 48), cell_x + AppScale(7), cell_y,
cell_w - AppScale(14), AppScale(32),
AppFitFontSize(AppTextFromCString(*label[0], 48), cell_w - AppScale(14),
@@ -480,9 +532,10 @@ session_result_other_summary :: (result: *SessionResult, x: s32, y: s32,
i: s32 = 0
while i < count {
if i > 0 {
DrawLine(x + AppScale(16), y + AppScale(30 + i * 38),
x + w - AppScale(16), y + AppScale(30 + i * 38),
Fade(StyleTokenColor("border"), 0.70f))
Line(CurrentApp().ui.session, LineProps.{
.start = Vector2.{cast(float32)(x + AppScale(16)), cast(float32)(y + AppScale(30 + i * 38))},
.end = Vector2.{cast(float32)(x + w - AppScale(16)), cast(float32)(y + AppScale(30 + i * 38))},
.color = color_with_alpha(StyleTokenColor("border"), 0.70f)})
}
session_result_text(AppTextFromCString(*labels[i][0], 80), x + AppScale(18),
y + AppScale(30) + i * AppScale(38),
@@ -506,14 +559,20 @@ session_result_status :: (result: *SessionResult, x: s32, y: s32,
icon = Color.{.r = 108, .g = 199, .b = 145, .a = 255}
}
status := LocaleText(status_key)
session := CurrentApp().ui.session
session_result_card(x, y, w, AppScale(50))
DrawRectangleRounded(Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w,
cast(float32)AppScale(50)}, 0.12f, 10, Fade(icon, 0.07f))
DrawRectangleRoundedLinesEx(Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w,
cast(float32)AppScale(50)}, 0.12f, 10, 1.0f,
Fade(icon, 0.34f))
DrawCircle(x + AppScale(29), y + AppScale(25), cast(float32)AppScale(12), Fade(icon, 0.25f))
DrawCircle(x + AppScale(29), y + AppScale(25), cast(float32)AppScale(5), icon)
Box(session, BoxProps.{
.bounds = Rectangle.{cast(float32)x, cast(float32)y, cast(float32)w,
cast(float32)AppScale(50)},
.fill = color_with_alpha(icon, 0.07f),
.border = color_with_alpha(icon, 0.34f),
.radius = session_result_corner_radius(0.12, w, AppScale(50))})
icon_center := Vector2.{cast(float32)(x + AppScale(29)), cast(float32)(y + AppScale(25))}
Circle(session, CircleProps.{.center = icon_center,
.radius = cast(float32)AppScale(12),
.fill = color_with_alpha(icon, 0.25f)})
Circle(session, CircleProps.{.center = icon_center,
.radius = cast(float32)AppScale(5), .fill = icon})
session_result_text(status, x + AppScale(52), y + AppScale(7),
w - AppScale(68), AppScale(36),
AppFitFontSize(status, w - AppScale(68),
@@ -541,9 +600,12 @@ session_result_draw_content :: (app: *InnerBreeze, result: *SessionResult,
box_x: s32, box_w: s32, top_y: s32,
center_x: s32, best: s32, avg: s32) {
content_y := top_y + AppScale(20)
DrawCircleGradient(Vector2.{cast(float32)center_x, cast(float32)(content_y + AppScale(20))},
cast(float32)AppScale(170), Fade(session_result_accent(), 0.17f),
Fade(StyleTokenColor("canvas"), 0.0f))
Circle(CurrentApp().ui.session, CircleProps.{
.center = Vector2.{cast(float32)center_x, cast(float32)(content_y + AppScale(20))},
.radius = cast(float32)AppScale(170),
.fill = color_with_alpha(session_result_accent(), 0.17f),
.edge = color_with_alpha(StyleTokenColor("canvas"), 0.0f),
.has_edge = true})
session_result_text(LocaleText("results_title"), box_x, content_y,
box_w, AppScale(25), AppScale(14), cast(TextAlign)TextAlignStart)
session_result_text(practice_label(result.activity), box_x,
+11 -11
View File
@@ -40,7 +40,7 @@ using TextWrap;
using TextAlign;
#import "control_props"
#import, file "../app/metrics.zi";
#import, file "../app/draw.zi";
#import, file "../app/color.zi";
#import, file "../app/current_app.zi";
#import "button_widget"
#import "text_widget"
@@ -264,7 +264,7 @@ statistics_draw_mood_panel :: (content_x: s32, y: s32, content_w: s32,
}
bar_color := statistics_mood_color(i + 1)
if count <= 0 {
bar_color = Fade(StyleTokenColor("text"), 0.16)
bar_color = color_with_alpha(StyleTokenColor("text"), 0.16)
}
statistics_bar(x, bar_y, w, bar_h, bar_color)
AppFormatS32(i + 1, label[:])
@@ -392,7 +392,7 @@ statistics_draw_hold_graph :: (app: *InnerBreeze, linked_ctx: *HabitLinkedContex
if graph_days == 7 || i % 5 == 0 {
x := plot_x + (plot_w * i) / graph_days
statistics_line(x, plot_y, x, plot_y + plot_h,
Fade(StyleTokenColor("text"), 0.1))
color_with_alpha(StyleTokenColor("text"), 0.1))
}
i += 1
}
@@ -406,7 +406,7 @@ statistics_draw_hold_graph :: (app: *InnerBreeze, linked_ctx: *HabitLinkedContex
axis_args: [1]FormatArg = .[FormatArg.{.number = seconds}]
FormatTemplate("%ds", axis_args[:], axis_label[:])
statistics_line(plot_x, line_y, plot_x + plot_w, line_y,
Fade(StyleTokenColor("text"), 0.1))
color_with_alpha(StyleTokenColor("text"), 0.1))
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)(content_x + AppScale(4)), cast(float32)(line_y - AppScale(8)), 0, 0},
.text = AppTextFromCString(*axis_label[0], 32),
@@ -417,7 +417,7 @@ statistics_draw_hold_graph :: (app: *InnerBreeze, linked_ctx: *HabitLinkedContex
}
statistics_line(plot_x, plot_y + plot_h, plot_x + plot_w, plot_y + plot_h,
Fade(StyleTokenColor("text"), 0.4))
color_with_alpha(StyleTokenColor("text"), 0.4))
{
day_seen: [STATISTICS_MAX_GRAPH_DAYS] s32
day_first_x: [STATISTICS_MAX_GRAPH_DAYS] s32
@@ -879,9 +879,9 @@ statistics_draw_answer_chart :: (stats: *HabitAnswerStats, chart: s32, x: s32,
stats.answer_type, cast(s32)low, bottom[:])),
.font = AppSmallFontSize(),
.good_color = accent,
.other_color = Fade(text, 0.35),
.band_color = Fade(accent, 0.14),
.grid_color = Fade(text, 0.15),
.other_color = color_with_alpha(text, 0.35),
.band_color = color_with_alpha(accent, 0.14),
.grid_color = color_with_alpha(text, 0.15),
.text_color = text,
.label_fill = LightenColor(StyleTokenColor("canvas"), 6)},
points[:stats.point_count], bands[:band_count])
@@ -918,7 +918,7 @@ statistics_draw_text_answers :: (stats: *HabitAnswerStats, answered: string,
PaintRoundedFill(session, -1, Rectangle.{cast(float32)row_x,
cast(float32)row_y, cast(float32)row_w,
cast(float32)AppScale(1)}, 0.0, 1,
Fade(StyleTokenColor("text"), 0.1))
color_with_alpha(StyleTokenColor("text"), 0.1))
day := stats.recent_days[index]
date: [16]u8
args: [3]FormatArg
@@ -1136,7 +1136,7 @@ statistics_draw_changes :: (active: *Habit, x: s32, y: s32, width: s32) {
PaintRoundedFill(session, -1, Rectangle.{cast(float32)row_x,
cast(float32)row_y, cast(float32)row_w,
cast(float32)AppScale(1)}, 0.0, 1,
Fade(StyleTokenColor("text"), 0.1))
color_with_alpha(StyleTokenColor("text"), 0.1))
}
day := storage_local_date_of(record.at)
minutes := storage_local_minutes_of(record.at)
@@ -1313,7 +1313,7 @@ statistics_draw_view :: (app: *InnerBreeze, active: *Habit, linked_ctx: *HabitLi
statistics_bar(x, bar_y, w, h,
ifx (weekday_counts[i] > 0) then
(LightenColor(active.color, 12)) else
(Fade(StyleTokenColor("text"), 0.16)))
(color_with_alpha(StyleTokenColor("text"), 0.16)))
Text(app.ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)x,
cast(float32)(y + chart_h - AppScale(24)),
-1
View File
@@ -28,7 +28,6 @@
#import, file "../cells/module_host.zi";
#import, file "../cells/node_apps.zi";
#import, file "../app/locale.zi";
#import, file "../app/draw.zi";
#import, file "../app/app_types.zi";
#import, file "../app/assets.zi";
#import, file "../app/metrics.zi";
-41
View File
@@ -1,41 +0,0 @@
#import, file "../src/app/direct_draw_plan.zi";
#import "drawing_props"
#import "geometry"
#program_export
Answer :: () -> s32 {
viewport := Rectangle.{0.0, 0.0, 320.0, 240.0}
camera := Camera.{Vector2.{0.0, 0.0}, Vector2.{0.0, 0.0}, 0.0, 1.0}
DirectDrawFrameBegin(viewport)
DirectDrawTransform(camera)
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 12.0,
Color.{10, 20, 30, 255})
if DirectDrawFrameFinish() { return 1 }
DirectDrawFrameBegin(viewport)
DirectDrawTransform(camera)
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 12.0,
Color.{10, 20, 30, 255})
if !DirectDrawFrameFinish() || !DirectDrawFrameUnchanged() { return 2 }
DirectDrawFrameBegin(viewport)
DirectDrawTransform(camera)
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
Color.{10, 20, 30, 255})
if DirectDrawFrameFinish() { return 3 }
camera.zoom = 2.0
DirectDrawFrameBegin(viewport)
DirectDrawTransform(camera)
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
Color.{10, 20, 30, 255})
if DirectDrawFrameFinish() { return 4 }
DirectDrawFrameBegin(Rectangle.{0.0, 0.0, 321.0, 240.0})
DirectDrawTransform(camera)
DirectDrawRecordCircleV(Vector2.{40.0, 50.0}, 13.0,
Color.{10, 20, 30, 255})
if DirectDrawFrameFinish() { return 5 }
return 0
}
-24
View File
@@ -1,24 +0,0 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
bin=${1:-"$root/build/ziran-toolchain/bin"}
work=${DIRECT_DRAW_PLAN_BUILD_DIR:-"$root/build/direct-draw-plan-test"}
source=$root/tests/direct_draw_plan_behavior.zi
mkdir -p "$work/ir"
"$bin/ziran" ir --root "$root/tests" --module-path "$root/src" \
--module-path "$root/build/packages/kryon/src/ui" \
--module-path "$root/build/packages/ziran/std" --module-path "$root/build/packages/daochi-client" --module-path "oqs=$root/build/packages/oqs/src" --module-path "$root/build/packages/kryon/src/backend" \
-o "$work/ir" "$source"
"$bin/ziran" bundle --root "$root/tests" --module-path "$root/src" \
--module-path "$root/build/packages/kryon/src/ui" \
--module-path "$root/build/packages/ziran/std" --module-path "$root/build/packages/daochi-client" --module-path "oqs=$root/build/packages/oqs/src" --module-path "$root/build/packages/kryon/src/backend" \
--entry direct_draw_plan_behavior:Answer \
-o "$work/source.zib" "$source"
"$bin/ziran" bundle --root "$work/ir" --module-path "$work/ir" \
--entry direct_draw_plan_behavior:Answer \
-o "$work/saved.zib" "$work/ir/direct_draw_plan_behavior.zir"
cmp "$work/source.zib" "$work/saved.zib"
test "$("$bin/ziran" run "$work/source.zib")" = 0
test "$("$bin/ziran" run "$work/saved.zib")" = 0