jiao_shapes/shapes/
text.rs1use jiao::base::RectF;
6use jiao::kernel::PainterTrait;
7
8use crate::ShapeTrait;
9
10#[derive(Debug, Clone)]
11pub struct TextShape {
12 text: String,
13 container_rect: RectF,
14 path_is_dirty: bool,
15}
16
17impl TextShape {
18 #[must_use]
19 pub const fn new(text: String, container_rect: RectF) -> Self {
20 Self {
21 text,
22 container_rect,
23 path_is_dirty: true,
24 }
25 }
26
27 #[must_use]
29 pub fn text(&self) -> &str {
30 &self.text
31 }
32
33 pub fn set_text(&mut self, text: String) {
35 if self.text != text {
36 self.text = text;
37 self.path_is_dirty = true;
38 }
39 }
40
41 #[must_use]
43 pub const fn container_rect(&self) -> &RectF {
44 &self.container_rect
45 }
46
47 pub fn set_container_rect(&mut self, container_rect: RectF) {
49 if self.container_rect != container_rect {
50 self.container_rect = container_rect;
51 self.path_is_dirty = true;
52 }
53 }
54}
55
56impl ShapeTrait for TextShape {
57 fn bounding_rect(&self) -> RectF {
58 todo!()
59 }
60
61 fn repaint(&mut self, _painter: &mut dyn PainterTrait) {}
62}