@@ -805,6 +805,17 @@ pub const Element = struct {
805805 return texture ;
806806 }
807807
808+ pub inline fn clear_image (
809+ self : * Element ,
810+ gpa : Allocator ,
811+ display : * Display ,
812+ ) void {
813+ if (self .texture != null ) {
814+ display .release_texture_resource (gpa , self .texture .? );
815+ self .texture = null ;
816+ }
817+ }
818+
808819 pub inline fn set_background_image (
809820 self : * Element ,
810821 gpa : Allocator ,
@@ -827,6 +838,17 @@ pub const Element = struct {
827838 return texture ;
828839 }
829840
841+ pub inline fn clear_background_image (
842+ self : * Element ,
843+ gpa : Allocator ,
844+ display : * Display ,
845+ ) void {
846+ if (self .background .image != null ) {
847+ display .release_texture_resource (gpa , self .background .image .? );
848+ self .background .image = null ;
849+ }
850+ }
851+
830852 /// set_text updates the `text` and `translation` fields of labels,
831853 /// checkboxes and buttons, and regenerates the grahpics/image
832854 /// textures for each word if the text was changed or `forced`
@@ -3353,12 +3375,12 @@ pub const Display = struct {
33533375 // do start/centre/end alignment.
33543376 if (expanders .len > 0 ) {
33553377 // Relayout the children with expanders
3356- trace ("expanders: {s} has {any}. needed_height: {d} available_height: {d}" , .{
3357- parent .name ,
3358- expanders .len ,
3359- needed_height ,
3360- parent .rect .height ,
3361- });
3378+ // trace("expanders: {s} has {any}. needed_height: {d} available_height: {d}", .{
3379+ // parent.name,
3380+ // expanders.len,
3381+ // needed_height,
3382+ // parent.rect.height,
3383+ // });
33623384
33633385 if (parent .rect .height > needed_height ) {
33643386 const spare_height = parent .rect .height - needed_height ;
@@ -3368,10 +3390,10 @@ pub const Display = struct {
33683390 }
33693391 const percent = expander .type .expander .weight / expander_weights ;
33703392 expander .rect .height = @trunc (spare_height * percent );
3371- trace (" expander: weight {d} given: {d}" , .{
3372- percent ,
3373- expander .rect .height ,
3374- });
3393+ // trace(" expander: weight {d} given: {d}", .{
3394+ // percent,
3395+ // expander.rect.height,
3396+ // });
33753397 }
33763398 var new_y : f32 = parent .rect .y + parent .pad .top ;
33773399 for (parent .type .panel .children .items ) | child | {
@@ -3560,8 +3582,8 @@ pub const Display = struct {
35603582 old .start_time ,
35613583 old .end_time ,
35623584 });
3563- if (old .on_end ) | callback | {
3564- callback (display , old .target );
3585+ if (old .on_end . func ) | callback | {
3586+ try callback (old . on_end . ptr , display , old .target , display . allocator );
35653587 }
35663588 display .allocator .destroy (old );
35673589 } else {
@@ -3644,7 +3666,14 @@ pub const Display = struct {
36443666
36453667 /// Add an animator that points to a currently active/valid element.
36463668 /// The element must not be destroyed for the lifetime of the animation.
3647- pub inline fn add_animator (self : * Display , allocator : Allocator , animator : Animator ) error {OutOfMemory }! void {
3669+ pub inline fn add_animator (self : * Display , allocator : Allocator , animator : Animator ) Allocator.Error ! void {
3670+ //err("add animator: {t} {d}x{d} -> {d}x{d}", .{
3671+ // animator.mode,
3672+ // animator.start.x,
3673+ // animator.start.y,
3674+ // animator.end.x,
3675+ // animator.end.y,
3676+ //});
36483677 var new_animator = try allocator .create (Animator );
36493678 new_animator .* = animator ;
36503679 new_animator .setup = false ;
0 commit comments