egui_charts/ui_kit/ext/
widget_ext.rs1use egui::{Button, TextEdit, Vec2};
16
17pub trait ButtonWidgetExt<'a>: Sized {
19 fn fill_width(self) -> Self;
21
22 fn min_width(self, width: f32) -> Self;
24
25 fn min_height(self, height: f32) -> Self;
27
28 fn exact_size(self, size: Vec2) -> Self;
30}
31
32impl<'a> ButtonWidgetExt<'a> for Button<'a> {
33 fn fill_width(self) -> Self {
34 self.min_size(Vec2::new(f32::INFINITY, 0.0))
35 }
36
37 fn min_width(self, width: f32) -> Self {
38 self.min_size(Vec2::new(width, 0.0))
39 }
40
41 fn min_height(self, height: f32) -> Self {
42 self.min_size(Vec2::new(0.0, height))
43 }
44
45 fn exact_size(self, size: Vec2) -> Self {
46 self.min_size(size)
47 }
48}
49
50pub trait TextEditWidgetExt<'a>: Sized {
52 fn fill_width(self) -> Self;
54
55 fn fixed_width(self, width: f32) -> Self;
57
58 fn char_limit(self, limit: usize) -> Self;
60}
61
62impl<'a> TextEditWidgetExt<'a> for TextEdit<'a> {
63 fn fill_width(self) -> Self {
64 self.desired_width(f32::INFINITY)
65 }
66
67 fn fixed_width(self, width: f32) -> Self {
68 self.desired_width(width)
69 }
70
71 fn char_limit(self, limit: usize) -> Self {
72 self.char_limit(limit)
73 }
74}
75
76pub trait RoundingExt: Sized {
78 fn button_rounding(self) -> Self;
80
81 fn panel_rounding(self) -> Self;
83
84 fn no_rounding(self) -> Self;
86
87 fn pill_rounding(self) -> Self;
89}
90
91