oxivgl 0.5.0

Safe no_std Rust bindings for LVGL — embedded GUI on ESP32 and host SDL2
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Style-setting methods for [`Obj`]. These are `impl` blocks on the same type
//! defined in `obj.rs` — no new types introduced.

use alloc::rc::Rc;
use core::ptr::null_mut;

use oxivgl_sys::*;

use super::obj::Obj;

// Style methods: zero-selector convenience variants take u32 hex colors;
// selector variants take lv_color_t for full control.
impl<'p> Obj<'p> {
    /// Set background color from RGB hex (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn bg_color(&self, color: u32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_color(self.handle(), lv_color_hex(color), 0) };
        self
    }

    /// Set background opacity (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn bg_opa(&self, opa: u8) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_opa(self.handle(), opa as lv_opa_t, 0) };
        self
    }

    /// Set background opacity for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn bg_opa_selector(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set border width (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn border_width(&self, w: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_border_width(self.handle(), w, 0) };
        self
    }

    /// Set padding on all sides (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn pad(&self, p: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_all(self.handle(), p, 0) };
        self
    }

    /// Set top padding (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn pad_top(&self, p: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_top(self.handle(), p, 0) };
        self
    }

    /// Set bottom padding (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn pad_bottom(&self, p: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_bottom(self.handle(), p, 0) };
        self
    }

    /// Set left padding (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn pad_left(&self, p: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_left(self.handle(), p, 0) };
        self
    }

    /// Set right padding (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn pad_right(&self, p: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_right(self.handle(), p, 0) };
        self
    }

    /// Set horizontal padding (left + right) for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_pad_hor(&self, p: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_hor(self.handle(), p, selector) };
        self
    }

    /// Apply a style to this object for the given selector.
    ///
    /// The style's `Rc` refcount is bumped and stored inside this widget,
    /// keeping the `lv_style_t` alive as long as the widget exists.
    ///
    /// ```ignore
    /// btn.add_style(&style, Selector::DEFAULT);
    /// btn.add_style(&style, ObjState::PRESSED);
    /// slider.add_style(&style, Part::Indicator | ObjState::PRESSED);
    /// ```
    pub fn add_style(&self, style: &crate::style::Style, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // Push clone first: if this panics (OOM), LVGL is not updated and
        // both sides remain consistent.
        self._styles.borrow_mut().push(style.clone());
        // SAFETY: handle non-null; style pointer valid for Rc's lifetime.
        // Pointer obtained via Rc::as_ptr + repr(C) offset-0 guarantee.
        unsafe { lv_obj_add_style(self.handle(), style.lv_ptr(), selector) };
        self
    }

    /// Remove all styles from this object.
    pub fn remove_style_all(&self) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null.
        unsafe { lv_obj_remove_style_all(self.handle()) };
        self._styles.borrow_mut().clear();
        self
    }

    /// Remove styles matching the given selector. Pass `None` for style to
    /// remove all styles for that selector.
    ///
    /// **Note**: when `style` is `None`, LVGL removes all styles for the
    /// selector, but the internal `_styles` Vec is not updated — the Rc
    /// clones remain alive until the widget is dropped. Use
    /// [`remove_style_all`](Self::remove_style_all) for full cleanup.
    pub fn remove_style(
        &self,
        style: Option<&crate::style::Style>,
        selector: impl Into<crate::style::Selector>,
    ) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        let style_ptr = match style {
            Some(s) => s.lv_ptr() as *mut lv_style_t,
            None => null_mut() as *mut lv_style_t,
        };
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_remove_style(self.handle(), style_ptr, selector) };
        // Remove exactly one entry by Rc pointer identity (not retain —
        // the same style can be added multiple times with different selectors).
        if let Some(s) = style {
            let target = Rc::as_ptr(&s.inner);
            let mut styles = self._styles.borrow_mut();
            if let Some(pos) = styles.iter().position(|e| Rc::as_ptr(&e.inner) == target) {
                styles.remove(pos);
            }
        }
        self
    }

    /// Set `clip_corner` — clip overflowing content at rounded corners.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_clip_corner(&self, clip: bool, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_clip_corner(self.handle(), clip, selector) };
        self
    }

    /// Set `translate_x` style property for the given selector.
    pub fn style_translate_x(&self, x: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_translate_x(self.handle(), x, selector) };
        self
    }

    /// Set text color from RGB hex (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn text_color(&self, color: u32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_text_color(self.handle(), lv_color_hex(color), 0) };
        self
    }

    /// Set text font (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn text_font(&self, font: crate::fonts::Font) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        assert_ne!(font.as_ptr(), null_mut(), "Font pointer cannot be null");
        // SAFETY: handle and font pointer non-null (asserted above).
        unsafe { lv_obj_set_style_text_font(self.handle(), font.as_ptr(), 0) };
        self
    }

    /// Alias for [`text_font`](Self::text_font).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    #[allow(deprecated)] // alias forwards to the (also deprecated) text_font
    pub fn font(&self, font: crate::fonts::Font) -> &Self {
        self.text_font(font)
    }

    /// Set text alignment (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn text_align(&self, align: super::obj::TextAlign) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_text_align(self.handle(), align as lv_text_align_t, 0) };
        self
    }

    /// Set overall opacity (selector 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn opa(&self, opa: u8) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_opa(self.handle(), opa as lv_opa_t, 0) };
        self
    }

    /// Set opacity for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_opa(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set padding on all sides for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_pad_all(&self, p: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_all(self.handle(), p, selector) };
        self
    }

    /// Set the corner radius for the given style selector.
    /// Use [`RADIUS_MAX`](super::RADIUS_MAX) for a pill/capsule shape.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn radius(&self, r: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_radius(self.handle(), r, selector) };
        self
    }

    /// Set local `bg_color` style for the given selector (part | state).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_bg_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_color(self.handle(), color, selector) };
        self
    }

    /// Set local `bg_grad_color` for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_bg_grad_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_grad_color(self.handle(), color, selector) };
        self
    }

    /// Set local `bg_grad_dir` for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_bg_grad_dir(&self, dir: crate::style::GradDir, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_grad_dir(self.handle(), dir as lv_grad_dir_t, selector) };
        self
    }

    /// Set transform rotation in 0.1 degree units for the given selector.
    pub fn style_transform_rotation(&self, angle: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_transform_rotation(self.handle(), angle, selector) };
        self
    }

    /// Set uniform transform scale (256 = 1.0x) for the given selector.
    pub fn style_transform_scale(&self, scale: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe {
            lv_obj_set_style_transform_scale_x(self.handle(), scale, selector);
            lv_obj_set_style_transform_scale_y(self.handle(), scale, selector);
        };
        self
    }

    /// Set transform pivot X for the given selector.
    pub fn style_transform_pivot_x(&self, x: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_transform_pivot_x(self.handle(), x, selector) };
        self
    }

    /// Set transform pivot Y for the given selector.
    pub fn style_transform_pivot_y(&self, y: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_transform_pivot_y(self.handle(), y, selector) };
        self
    }

    /// Set base text direction for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_base_dir(&self, dir: super::obj::BaseDir, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_base_dir(self.handle(), dir as lv_base_dir_t, selector) };
        self
    }

    /// Set `lv_obj_set_style_line_width` for the given LVGL style part.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn line_width(&self, part: super::obj::Part, width: i32) -> &Self {
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_line_width(self.handle(), width, part as u32) };
        self
    }

    /// Set image recolor tint.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_image_recolor(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_image_recolor(self.handle(), color, selector) };
        self
    }

    /// Set radial offset for parts on round scales (in pixels).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_radial_offset(&self, offset: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_radial_offset(self.handle(), offset, selector) };
        self
    }

    /// Set line opacity for a part (0–255).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_line_opa(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_line_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set text color for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_text_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_text_color(self.handle(), color, selector) };
        self
    }

    /// Set text font for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_text_font(&self, font: crate::fonts::Font, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        assert_ne!(font.as_ptr(), null_mut(), "Font pointer cannot be null");
        // SAFETY: handle and font pointer non-null (asserted above).
        unsafe { lv_obj_set_style_text_font(self.handle(), font.as_ptr(), selector) };
        self
    }

    /// Set arc width for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_arc_width(&self, width: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_arc_width(self.handle(), width, selector) };
        self
    }

    /// Set arc color for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_arc_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_arc_color(self.handle(), color, selector) };
        self
    }

    /// Set arc rounded end-caps for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_arc_rounded(&self, rounded: bool, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_arc_rounded(self.handle(), rounded, selector) };
        self
    }

    /// Set line color for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_line_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_line_color(self.handle(), color, selector) };
        self
    }

    /// Set the `length` property for the given style selector.
    ///
    /// Used for tick length on scale parts (Items=minor, Indicator=major).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_length(&self, length: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_length(self.handle(), length, selector) };
        self
    }

    /// Set line width for the given style selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_line_width(&self, width: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_line_width(self.handle(), width, selector) };
        self
    }

    /// Set the `width` style property for the given selector.
    ///
    /// Different from [`Obj::size`] — this sets the style property, useful
    /// for sub-parts like tick marks.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_width(&self, width: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_width(self.handle(), width, selector) };
        self
    }

    /// Set image recolor opacity (0–255).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_image_recolor_opa(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_image_recolor_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set column gap for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_pad_column(&self, gap: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_column(self.handle(), gap, selector) };
        self
    }

    /// Set row gap for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_pad_row(&self, gap: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_pad_row(self.handle(), gap, selector) };
        self
    }

    /// Set indicator/point width and height for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_size(&self, w: i32, h: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_size(self.handle(), w, h, selector) };
        self
    }

    /// Set background image source to a symbol string for the given selector.
    ///
    /// LVGL stores the raw pointer — the [`Symbol`](crate::symbols::Symbol)
    /// must be `'static` (all constants in [`symbols`](crate::symbols) are).
    pub fn style_bg_image_src_symbol(
        &self,
        symbol: &crate::symbols::Symbol,
        selector: impl Into<crate::style::Selector>,
    ) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null; symbol is a 'static NUL-terminated byte
        // slice. LVGL stores the pointer in the style property map — the
        // static lifetime guarantees it outlives the widget.
        unsafe { lv_obj_set_style_bg_image_src(self.handle(), symbol.as_ptr() as *const core::ffi::c_void, selector) };
        self
    }

    /// Set background image source to an image descriptor for the given
    /// selector.
    ///
    /// LVGL stores the raw pointer in the style property map, so the
    /// descriptor must be `'static` (spec §3.1). Use
    /// [`image_declare!`](crate::image_declare):
    /// `obj.style_bg_image_src(my_img(), Part::Main)`. For a symbol source,
    /// see [`style_bg_image_src_symbol`](Self::style_bg_image_src_symbol).
    pub fn style_bg_image_src(
        &self,
        src: &'static lv_image_dsc_t,
        selector: impl Into<crate::style::Selector>,
    ) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null; src is 'static and points to a valid
        // compiled image descriptor. LVGL stores the pointer — the static
        // lifetime guarantees it outlives the widget (spec §3.1).
        unsafe {
            lv_obj_set_style_bg_image_src(self.handle(), src as *const lv_image_dsc_t as *const core::ffi::c_void, selector)
        };
        self
    }

    /// Set the recolor tint blended over the background image for the given
    /// selector. Strength is set by
    /// [`style_bg_image_recolor_opa`](Self::style_bg_image_recolor_opa).
    pub fn style_bg_image_recolor(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_image_recolor(self.handle(), color, selector) };
        self
    }

    /// Set the background image recolor tint from RGB hex for the given
    /// selector.
    pub fn style_bg_image_recolor_hex(&self, hex: u32, selector: impl Into<crate::style::Selector>) -> &Self {
        // SAFETY: lv_color_hex is a pure value conversion.
        let color = unsafe { lv_color_hex(hex) };
        self.style_bg_image_recolor(color, selector)
    }

    /// Set the strength of the background image recolor tint for the given
    /// selector (0 = no tint, 255 = fully replace the image color).
    pub fn style_bg_image_recolor_opa(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_bg_image_recolor_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set shadow width for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_width(&self, w: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_width(self.handle(), w, selector) };
        self
    }

    /// Set shadow color for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_color(&self, color: lv_color_t, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_color(self.handle(), color, selector) };
        self
    }

    /// Set shadow X offset for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_offset_x(&self, x: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_offset_x(self.handle(), x, selector) };
        self
    }

    /// Set shadow Y offset for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_offset_y(&self, y: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_offset_y(self.handle(), y, selector) };
        self
    }

    /// Set shadow spread for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_spread(&self, s: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_spread(self.handle(), s, selector) };
        self
    }

    /// Set shadow opacity (0–255) for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_shadow_opa(&self, opa: u8, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_shadow_opa(self.handle(), opa as lv_opa_t, selector) };
        self
    }

    /// Set transform scale X (256 = 1.0x) for the given selector.
    pub fn style_transform_scale_x(&self, scale: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_transform_scale_x(self.handle(), scale, selector) };
        self
    }

    /// Set transform scale Y (256 = 1.0x) for the given selector.
    pub fn style_transform_scale_y(&self, scale: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_transform_scale_y(self.handle(), scale, selector) };
        self
    }

    /// Set text letter spacing for the given selector.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_text_letter_space(&self, space: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_text_letter_space(self.handle(), space, selector) };
        self
    }

    /// Set blur radius for the given selector.
    ///
    /// Requires GPU-accelerated backend for visible effect; may be a no-op on
    /// SDL host.
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_blur_radius(&self, r: i32, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_blur_radius(self.handle(), r, selector) };
        self
    }

    /// Enable/disable backdrop blur for the given selector.
    ///
    /// When enabled, the area behind the object is blurred (requires
    /// [`style_blur_radius`](Self::style_blur_radius) > 0).
    #[deprecated(note = "inline style setters allocate a per-object local style; build a shared Style (Style::new) and apply with add_style for memory efficiency at scale - see docs/memory-tuning.md")]
    pub fn style_blur_backdrop(&self, en: bool, selector: impl Into<crate::style::Selector>) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null (asserted above).
        unsafe { lv_obj_set_style_blur_backdrop(self.handle(), en, selector) };
        self
    }

    /// Set a bitmap mask source (L8 draw buffer) for the given selector.
    ///
    /// LVGL stores the raw pointer to the `lv_draw_buf_t` — the buffer must
    /// outlive the widget. The `&DrawBuf` reference is not lifetime-checked
    /// at this level; callers must ensure the `DrawBuf` lives long enough
    /// (typically stored in the same View struct as the masked widget).
    ///
    /// # Safety
    ///
    /// The `DrawBuf` must outlive the widget. LVGL stores the raw pointer
    /// directly in the style property map; if the buffer is freed while still
    /// referenced, LVGL will dereference a dangling pointer.
    ///
    /// Requires `LV_DRAW_SW_COMPLEX = 1` in `lv_conf.h`.
    pub unsafe fn style_bitmap_mask_src(
        &self,
        mask: &crate::draw_buf::DrawBuf,
        selector: impl Into<crate::style::Selector>,
    ) -> &Self {
        let selector = selector.into().raw();
        assert_ne!(self.handle(), null_mut(), "Obj handle cannot be null");
        // SAFETY: handle non-null; mask.as_ptr() is a valid lv_draw_buf_t
        // pointer. LVGL stores this pointer in the style property map.
        // Caller must ensure the DrawBuf outlives the widget.
        unsafe {
            lv_obj_set_style_bitmap_mask_src(
                self.handle(),
                mask.as_ptr() as *const core::ffi::c_void,
                selector,
            )
        };
        self
    }
}