@effindomv2/fui-rs 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +1 -1
- package/package.json +1 -1
- package/src/bridge_callbacks.rs +1 -0
- package/src/controls/appearance.rs +200 -0
- package/src/controls/button.rs +48 -122
- package/src/controls/checkbox.rs +27 -3
- package/src/controls/combobox.rs +61 -23
- package/src/controls/context_menu.rs +156 -256
- package/src/controls/control_template_set.rs +2 -3
- package/src/controls/control_tokens.rs +76 -0
- package/src/controls/dialog.rs +80 -78
- package/src/controls/dropdown.rs +46 -5
- package/src/controls/form.rs +6 -0
- package/src/controls/internal/button_presenter.rs +21 -20
- package/src/controls/internal/pressable_labeled_control.rs +11 -11
- package/src/controls/internal/text_input_core.rs +40 -22
- package/src/controls/internal/text_input_presenter.rs +29 -23
- package/src/controls/mod.rs +7 -2
- package/src/controls/nav_link.rs +15 -11
- package/src/controls/popup.rs +24 -40
- package/src/controls/progress_bar.rs +80 -109
- package/src/controls/radio_button.rs +27 -3
- package/src/controls/radio_group.rs +6 -0
- package/src/controls/slider.rs +38 -14
- package/src/controls/switch.rs +27 -3
- package/src/controls/tests.rs +796 -56
- package/src/controls/text_area.rs +12 -2
- package/src/controls/text_input.rs +19 -3
- package/src/lib.rs +44 -38
- package/src/node/core.rs +2 -0
- package/src/node/flex_box.rs +245 -2
- package/src/node/grid.rs +5 -0
- package/src/node/mod.rs +48 -0
- package/src/node/presenter_host_style.rs +177 -0
- package/src/node/text_node.rs +35 -0
- package/src/popup_presenter.rs +32 -0
package/src/controls/combobox.rs
CHANGED
|
@@ -85,45 +85,46 @@ fn resolve_text_input_colors(
|
|
|
85
85
|
|
|
86
86
|
#[derive(Clone, Default)]
|
|
87
87
|
struct ComboBoxEditorPresenter {
|
|
88
|
-
host: RefCell<Option<FlexBox>>,
|
|
89
88
|
editor_host: RefCell<Option<TextCore>>,
|
|
90
89
|
placeholder_host: RefCell<Option<FlexBox>>,
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
impl TextInputPresenter for ComboBoxEditorPresenter {
|
|
94
|
-
fn bind(&self,
|
|
95
|
-
*self.host.borrow_mut() = Some(host);
|
|
93
|
+
fn bind(&self, editor_host: TextCore, placeholder_host: FlexBox) {
|
|
96
94
|
*self.editor_host.borrow_mut() = Some(editor_host);
|
|
97
95
|
*self.placeholder_host.borrow_mut() = Some(placeholder_host);
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
fn
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
fn present(
|
|
99
|
+
&self,
|
|
100
|
+
_theme: Theme,
|
|
101
|
+
state: &TextInputVisualState,
|
|
102
|
+
_colors: Option<TextInputColors>,
|
|
103
|
+
) -> crate::PresenterHostStyle {
|
|
104
104
|
let Some(editor_host) = self.editor_host.borrow().clone() else {
|
|
105
|
-
return;
|
|
105
|
+
return crate::PresenterHostStyle::new();
|
|
106
106
|
};
|
|
107
107
|
let Some(placeholder_host) = self.placeholder_host.borrow().clone() else {
|
|
108
|
-
return;
|
|
108
|
+
return crate::PresenterHostStyle::new();
|
|
109
109
|
};
|
|
110
110
|
let editable_cursor = if state.enabled {
|
|
111
111
|
CursorStyle::Text
|
|
112
112
|
} else {
|
|
113
113
|
CursorStyle::Default
|
|
114
114
|
};
|
|
115
|
-
host.bg_color(0x00000000)
|
|
116
|
-
.corner_radius(0.0)
|
|
117
|
-
.border(0.0, 0x00000000)
|
|
118
|
-
.padding(0.0, 0.0, 0.0, 0.0)
|
|
119
|
-
.align_items(AlignItems::Center)
|
|
120
|
-
.cursor(editable_cursor)
|
|
121
|
-
.opacity(if state.enabled { 1.0 } else { 0.6 });
|
|
122
115
|
editor_host.cursor(editable_cursor);
|
|
123
116
|
placeholder_host
|
|
124
117
|
.position(0.0, 0.0)
|
|
125
118
|
.width(100.0, Unit::Percent)
|
|
126
119
|
.cursor(editable_cursor);
|
|
120
|
+
crate::PresenterHostStyle::new()
|
|
121
|
+
.background(0x00000000)
|
|
122
|
+
.corners(crate::Corners::all(0.0))
|
|
123
|
+
.border(crate::Border::solid(0.0, 0x00000000))
|
|
124
|
+
.padding(crate::EdgeInsets::all(0.0))
|
|
125
|
+
.align_items(AlignItems::Center)
|
|
126
|
+
.cursor(editable_cursor)
|
|
127
|
+
.opacity(if state.enabled { 1.0 } else { 0.6 })
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
@@ -252,7 +253,7 @@ impl ComboBox {
|
|
|
252
253
|
let editor = TextInput::new();
|
|
253
254
|
editor
|
|
254
255
|
.text(text.clone())
|
|
255
|
-
.template(
|
|
256
|
+
.template(Rc::new(ComboBoxEditorTemplate));
|
|
256
257
|
editor.fill_width();
|
|
257
258
|
|
|
258
259
|
let chevron_presenter = create_chevron_presenter(None, None);
|
|
@@ -395,6 +396,7 @@ impl ComboBox {
|
|
|
395
396
|
});
|
|
396
397
|
*shared.self_weak.borrow_mut() = Rc::downgrade(&shared);
|
|
397
398
|
*shared_slot.borrow_mut() = Some(Rc::downgrade(&shared));
|
|
399
|
+
root.retained_node_ref().retain_attachment(shared.clone());
|
|
398
400
|
shared.rebuild_filtered_indices();
|
|
399
401
|
|
|
400
402
|
popup_list.popup_presenter.overlay_node().on_click({
|
|
@@ -753,7 +755,15 @@ impl ComboBox {
|
|
|
753
755
|
self
|
|
754
756
|
}
|
|
755
757
|
|
|
756
|
-
pub fn sizing(&self, sizing:
|
|
758
|
+
pub fn sizing(&self, sizing: DropdownSizing) -> &Self {
|
|
759
|
+
self.set_sizing(Some(sizing))
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
pub fn clear_sizing(&self) -> &Self {
|
|
763
|
+
self.set_sizing(None)
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
fn set_sizing(&self, sizing: Option<DropdownSizing>) -> &Self {
|
|
757
767
|
self.shared.sizing_value.set(sizing);
|
|
758
768
|
let previous_presenter = self.shared.chevron_presenter.borrow().clone();
|
|
759
769
|
let next_presenter =
|
|
@@ -769,14 +779,30 @@ impl ComboBox {
|
|
|
769
779
|
self
|
|
770
780
|
}
|
|
771
781
|
|
|
772
|
-
pub fn colors(&self, colors:
|
|
782
|
+
pub fn colors(&self, colors: DropdownColors) -> &Self {
|
|
783
|
+
self.set_colors(Some(colors))
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
pub fn clear_colors(&self) -> &Self {
|
|
787
|
+
self.set_colors(None)
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
fn set_colors(&self, colors: Option<DropdownColors>) -> &Self {
|
|
773
791
|
self.shared.colors_value.set(colors);
|
|
774
792
|
self.shared.popup_list.colors(colors);
|
|
775
793
|
self.shared.handle_theme_changed();
|
|
776
794
|
self
|
|
777
795
|
}
|
|
778
796
|
|
|
779
|
-
pub fn chevron_template(&self, template:
|
|
797
|
+
pub fn chevron_template(&self, template: Rc<dyn DropdownChevronTemplate>) -> &Self {
|
|
798
|
+
self.set_chevron_template(Some(template))
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
pub fn clear_chevron_template(&self) -> &Self {
|
|
802
|
+
self.set_chevron_template(None)
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
fn set_chevron_template(&self, template: Option<Rc<dyn DropdownChevronTemplate>>) -> &Self {
|
|
780
806
|
*self.shared.chevron_template_value.borrow_mut() = template.clone();
|
|
781
807
|
let previous_presenter = self.shared.chevron_presenter.borrow().clone();
|
|
782
808
|
let next_presenter = create_chevron_presenter(template, self.shared.sizing_value.get());
|
|
@@ -790,7 +816,15 @@ impl ComboBox {
|
|
|
790
816
|
self
|
|
791
817
|
}
|
|
792
818
|
|
|
793
|
-
pub fn option_row_template(
|
|
819
|
+
pub fn option_row_template(&self, template: Rc<dyn DropdownOptionRowTemplate>) -> &Self {
|
|
820
|
+
self.set_option_row_template(Some(template))
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
pub fn clear_option_row_template(&self) -> &Self {
|
|
824
|
+
self.set_option_row_template(None)
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
fn set_option_row_template(
|
|
794
828
|
&self,
|
|
795
829
|
template: Option<Rc<dyn DropdownOptionRowTemplate>>,
|
|
796
830
|
) -> &Self {
|
|
@@ -1490,8 +1524,12 @@ impl ComboBoxShared {
|
|
|
1490
1524
|
self.editor
|
|
1491
1525
|
.height(field_content_height, Unit::Pixel)
|
|
1492
1526
|
.font_size(field_font_size)
|
|
1493
|
-
.line_height(field_content_height)
|
|
1494
|
-
|
|
1527
|
+
.line_height(field_content_height);
|
|
1528
|
+
if let Some(colors) = resolve_text_input_colors(colors, &theme) {
|
|
1529
|
+
self.editor.colors(colors);
|
|
1530
|
+
} else {
|
|
1531
|
+
self.editor.clear_colors();
|
|
1532
|
+
}
|
|
1495
1533
|
self.chevron_host
|
|
1496
1534
|
.width(chevron_box_size, Unit::Pixel)
|
|
1497
1535
|
.height(field_content_height, Unit::Pixel)
|