Migrating from 0.5 to 0.6
0.6 is a minor release of a pre-1.0 crate, so it carries breaking changes. This page gathers
the ones that need a code change. Each crate's CHANGELOG.md lists everything, in more
detail. The DSL crates are not part of 0.6 and stay at 0.5.1.
Toolchain
0.6 needs Rust 1.89 or newer. 0.5 declared 1.85, but its source already used let chains, which stabilised in 1.88, and the H.264 decoder's SIMD dependency needs 1.89.
Core
TextureDatahas no publicrgbafield and no struct literals. Build one withTextureData::new(bytes, width, height), and usewith_bytesfor optional retained CPU data.MeshDatavertices and indices areArc<Vec<_>>, and it gains morph data.Materialgains fields.ClipShape::RoundedRectgainscorner_shape.use_signalrequiresClone.DrawContextgains hooks with default bodies, so existing implementations still compile.draw_shaderis one of them.
GPU
LayerCommandhas more variants, so exhaustive matches need new arms, andSamplegainspaint.DynamicImage,PrimitiveBatchand command struct literals gain fields.render_mesh_datatakes aDirectionalLightslice in place oflight_dirandlight_intensity.blit_tight_texture_to_targettakesrotate_z_rad: pass0.0for no rotation.RendererConfiggainspipeline_cache_path.- The
repr(C)structs grew, so custom uploads and shaders must follow the new field offsets, not only the sizes:GpuPrimitive368 to 544 bytes,GpuImageInstance192 to 208,SdfVertexInstance128 to 144,GlassUniformsandMaskImageUniforms16 to 32.PathVertexandLayerCompositeUniformskeep their size but use former padding for new fields. FlowPipelineCache::compiletakes aFlowShader. See Flow shaders.
Layout and app
PendingSubtreeRebuildreplacesneeds_layoutwithRebuildKindand gainsepochandtree_scope.Button::newandwith_contenthave new signatures.WindowedContext::use_scroll_reftakes no argument. An explicit key isuse_scroll_ref_keyed.WindowedContext::use_statereturns a reactiveState<T>. State machines useuse_fsmanduse_fsm_keyed, anduse_state_foris deprecated. The inherentuse_effectis gone.- Public event, render and config records gain fields, so struct literals need
..Default::default()or the new fields.
Signals
Widgets bind to signals instead of State.
widgets::checkbox,checkbox_labeledandtoggletake aSignal<bool>.radio_groupandinput_otptake aSignal<String>, andnumber_inputtakes aSignal<f64>.- The same holds for the
cnwidgets:checkbox,switchandtoggletake aSignal<bool>, andradio_group,toggle_group,select,comboboxandinput_otptake aSignal<String>.number_inputtakes aSignal<f64>,slideraSignal<f32>orSignal<f64>, andpaginationa signal of an integer or float. .disabled(..),.label(..)and the placeholder of the text fields take a value, aSignalor aComputed, and follow it in place.widgets::rich_text_editor::selection_toolbartakes the editor's version as a&Signal<u32>.
Component derives
BlincComponent ordinary field hooks now return Signal<T>. Use get, set
and update on the signal and pass it directly to property bindings.
Named structs also generate NameProps and Name::props(...). Their fields
store Reactive<T>; the constructor and fluent field setters accept
IntoReactive<T>, including values, Signal and Computed. The original struct
keeps its declared types. Forward generated props to bindings so changes apply
in place. Consumers with named props depend directly on blinc_layout.
Explicit instance keys still isolate list items. Concrete generic types now have separate hook identities. See the derive guide.
CSS
theme(token)is removed. A theme's tokens are:rootvariables: writevar(--primary),var(--radius-lg)andvar(--shadow-md). The--shadow-*variables are realbox-shadowlists.- Colours follow CSS.
rgb()andrgba()components are 0 to 255, sorgb(0.2, 0.4, 0.9)is nearly black where it was a fraction. Named colours take their CSS values (orangeis#ffa500,purple#800080,gray#808080). @flow, theflow:property and theflowentries ofcss_style!andstyle!are removed. See below.
Flow shaders
Flow shaders are not part of CSS. They are drawn by a canvas.
| 0.5 | 0.6 |
|---|---|
@flow name { .. } in a stylesheet, flow: name; | flow!(name, fragment, { .. }) and canvas(..).flow(shader) |
div().flow(graph), FlowRef, RenderProps::flow | Canvas::flow(shader), with .rounded(r) for the corners |
flow! returned a FlowGraph, parsed at run time | flow! is a procedural macro: WGSL at compile time, a FlowShader constant |
FlowPipelineCache::compile(&FlowGraph) | compile(&FlowShader) |
blinc::gpu::flow_codegen | blinc_flow, re-exported as blinc::gpu::flow_to_wgsl |
In the macro body, step types take underscore names (pattern_noise) and colours are hex
integers (0x1a3a5a). blinc::layout::flow_shader(source) compiles @flow source text at run
time. A shader that reads time animates by default, and Canvas::flow_loop and FlowClock
control it.
cn components
Most cn widgets now take their look and motion from CSS rules instead of Rust. Where you set a
colour, size or animation through a builder method that is removed below, write a rule for the
widget's class instead.
cn::progress,cn::slider,cn::tabs,cn::spinner,cn::skeleton,cn::toast,cn::avatar,cn::breadcrumbandcn::paginationtake colours and weights from rules.progress_animated,AnimatedProgress,SpinnerBuilder::duration_ms,Skeleton::shimmer,AnimatedSkeleton, and the slider'strack_color,fill_colorandthumb_colorare removed.- Dialogs, sheets, drawers, toasts and tab panels enter and leave by CSS
@keyframesrules, keyed ondata-motion. Theenter_animation,exit_animationandanimation_durationbuilder methods are removed: a different motion is a rule of your own. cn::collapsible,accordion,tree_viewandsidebaropen and close by rule, keyed ondata-state.CollapsibleBuilder::{scale_anim, opacity_anim},CollapsibleWithContentandAccordionBuilder::springare removed.- The error look of
cn::inputandcn::textareais thedata-invalidrule. Thecn-input--errorandcn-textarea--errorclasses are gone, and so are.cn-toast--{info,success,warning,error},.cn-progress--{sm,md,lg}and thecn-*--disabledclasses. - The charts moved onto one shared plot:
line_chart,area_chart,bar_chart,spark_line,threshold_line_chart,histogramandcomparison_bar_charttake.series(..)and.data(..)as described in theblinc_cnchangelog. CN_STYLESsets the document's text colour, andcn::iconwithout a colour takes the surrounding text colour, ascurrentColordoes.cn::tree_viewis rebuilt, with new part classes. Theblinc_cnchangelog lists them.