@effindomv2/fui-rs 0.1.19 → 0.1.20
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/controls/nav_link.rs +3 -4
- package/src/lib.rs +8 -7
- package/src/node/mod.rs +79 -0
- package/src/node/text_node.rs +0 -4
- package/src/text.rs +24 -1
package/Cargo.toml
CHANGED
package/package.json
CHANGED
package/src/controls/nav_link.rs
CHANGED
|
@@ -59,6 +59,8 @@ impl NavLink {
|
|
|
59
59
|
label_node
|
|
60
60
|
.font_family(theme.fonts.body_family.clone())
|
|
61
61
|
.font_size(15.0)
|
|
62
|
+
.text_color(theme.colors.accent)
|
|
63
|
+
.selectable(false)
|
|
62
64
|
.cursor(CursorStyle::Pointer);
|
|
63
65
|
root.justify_content(JustifyContent::Start)
|
|
64
66
|
.align_items(AlignItems::Center)
|
|
@@ -440,10 +442,7 @@ impl NavLinkEventTarget {
|
|
|
440
442
|
let color = if self.hovered.get() {
|
|
441
443
|
theme.colors.accent_hovered
|
|
442
444
|
} else {
|
|
443
|
-
self.text_color_override
|
|
444
|
-
.get()
|
|
445
|
-
.or_else(|| self.label.configured_text_color())
|
|
446
|
-
.unwrap_or(theme.colors.accent)
|
|
445
|
+
self.text_color_override.get().unwrap_or(theme.colors.accent)
|
|
447
446
|
};
|
|
448
447
|
if self.label.handle() != NodeHandle::INVALID {
|
|
449
448
|
ui::set_text_color(self.label.handle().raw(), color);
|
package/src/lib.rs
CHANGED
|
@@ -488,10 +488,10 @@ pub mod prelude {
|
|
|
488
488
|
auto, column, custom_drawable, fill, flex_box, grid, image, pct, portal, px, row,
|
|
489
489
|
scroll_box, scroll_view, svg, text, viewport_height, viewport_width, virtual_list, Border,
|
|
490
490
|
Child, ContextMenuEventArgs, Corners, CustomDrawable, DrawableInvalidator, EdgeInsets,
|
|
491
|
-
FlexBox, FlexBoxSurface, GradientStop, Grid, GridTrack, HasFlexBoxRoot,
|
|
492
|
-
Length, Node, PresenterHostStyle, ScrollBar, ScrollBarStyle,
|
|
493
|
-
ScrollBox, ScrollState, ScrollView, Shadow, Svg, SvgNode, Text,
|
|
494
|
-
ThemeBindable, VirtualList,
|
|
491
|
+
FlexBox, FlexBoxSurface, GradientStop, Grid, GridTrack, HasFlexBoxRoot, HasTextNode, Image,
|
|
492
|
+
ImageNode, Length, Node, PresenterHostStyle, ScrollBar, ScrollBarStyle,
|
|
493
|
+
ScrollBarVisibility, ScrollBox, ScrollState, ScrollView, Shadow, Svg, SvgNode, Text,
|
|
494
|
+
TextCore, TextLayoutSurface, TextNode, ThemeBindable, VirtualList,
|
|
495
495
|
};
|
|
496
496
|
pub use crate::persisted;
|
|
497
497
|
pub use crate::platform;
|
|
@@ -609,9 +609,10 @@ pub use node::{
|
|
|
609
609
|
auto, column, custom_drawable, fill, flex_box, grid, image, pct, portal, px, row, scroll_box,
|
|
610
610
|
scroll_view, svg, text, viewport_height, viewport_width, virtual_list, Border, Child,
|
|
611
611
|
ContextMenuEventArgs, Corners, CustomDrawable, DrawableInvalidator, EdgeInsets, FlexBox,
|
|
612
|
-
FlexBoxSurface, GradientStop, Grid, GridTrack, HasFlexBoxRoot, Image, ImageNode,
|
|
613
|
-
PresenterHostStyle, ScrollBar, ScrollBarStyle, ScrollBarVisibility, ScrollBox,
|
|
614
|
-
ScrollView, Shadow, Svg, SvgNode, Text, TextCore,
|
|
612
|
+
FlexBoxSurface, GradientStop, Grid, GridTrack, HasFlexBoxRoot, HasTextNode, Image, ImageNode,
|
|
613
|
+
Length, Node, PresenterHostStyle, ScrollBar, ScrollBarStyle, ScrollBarVisibility, ScrollBox,
|
|
614
|
+
ScrollState, ScrollView, Shadow, Svg, SvgNode, Text, TextCore, TextLayoutSurface, TextNode,
|
|
615
|
+
ThemeBindable, VirtualList,
|
|
615
616
|
};
|
|
616
617
|
pub use persisted::*;
|
|
617
618
|
pub use platform::*;
|
package/src/node/mod.rs
CHANGED
|
@@ -100,6 +100,85 @@ impl ThemeBindable for FlexBox {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
pub trait HasTextNode {
|
|
104
|
+
fn text_node(&self) -> &TextNode;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
pub trait TextLayoutSurface: HasTextNode {
|
|
108
|
+
fn width(&self, width: f32, unit: Unit) -> &Self {
|
|
109
|
+
self.text_node().width(width, unit);
|
|
110
|
+
self
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fn height(&self, height: f32, unit: Unit) -> &Self {
|
|
114
|
+
self.text_node().height(height, unit);
|
|
115
|
+
self
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn fill_width(&self) -> &Self {
|
|
119
|
+
self.text_node().fill_width();
|
|
120
|
+
self
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
fn fill_height(&self) -> &Self {
|
|
124
|
+
self.text_node().fill_height();
|
|
125
|
+
self
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fn fill_size(&self) -> &Self {
|
|
129
|
+
self.text_node().fill_size();
|
|
130
|
+
self
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
fn line_height(&self, line_height: f32) -> &Self {
|
|
134
|
+
self.text_node().line_height(line_height);
|
|
135
|
+
self
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
fn text_align(&self, align: TextAlign) -> &Self {
|
|
139
|
+
self.text_node().text_align(align);
|
|
140
|
+
self
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
fn text_vertical_align(&self, align: TextVerticalAlign) -> &Self {
|
|
144
|
+
self.text_node().text_vertical_align(align);
|
|
145
|
+
self
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fn text_limits(&self, max_chars: i32, max_lines: i32) -> &Self {
|
|
149
|
+
self.text_node().text_limits(max_chars, max_lines);
|
|
150
|
+
self
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
fn max_lines(&self, max_lines: i32) -> &Self {
|
|
154
|
+
self.text_node().max_lines(max_lines);
|
|
155
|
+
self
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
fn wrapping(&self, wrap: bool) -> &Self {
|
|
159
|
+
self.text_node().wrapping(wrap);
|
|
160
|
+
self
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fn text_overflow(&self, overflow: TextOverflow) -> &Self {
|
|
164
|
+
self.text_node().text_overflow(overflow);
|
|
165
|
+
self
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fn text_overflow_fade(&self, horizontal: bool, vertical: bool) -> &Self {
|
|
169
|
+
self.text_node().text_overflow_fade(horizontal, vertical);
|
|
170
|
+
self
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
impl<T: HasTextNode> TextLayoutSurface for T {}
|
|
175
|
+
|
|
176
|
+
impl HasTextNode for TextNode {
|
|
177
|
+
fn text_node(&self) -> &TextNode {
|
|
178
|
+
self
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
103
182
|
pub trait FlexBoxSurface: HasFlexBoxRoot {
|
|
104
183
|
fn width(&self, width: f32, unit: Unit) -> &Self {
|
|
105
184
|
self.flex_box_root().width(width, unit);
|
package/src/node/text_node.rs
CHANGED
|
@@ -164,10 +164,6 @@ impl TextNode {
|
|
|
164
164
|
self
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
pub(crate) fn configured_text_color(&self) -> Option<u32> {
|
|
168
|
-
self.props.borrow().text_color
|
|
169
|
-
}
|
|
170
|
-
|
|
171
167
|
pub fn style_runs(&self, words: Vec<u32>) -> &Self {
|
|
172
168
|
{
|
|
173
169
|
let mut props = self.props.borrow_mut();
|
package/src/text.rs
CHANGED
|
@@ -3,7 +3,7 @@ use crate::bindings::ui;
|
|
|
3
3
|
use crate::ffi::{TextAlign, TextOverflow, TextVerticalAlign, Unit};
|
|
4
4
|
use crate::frame_scheduler::on_loaded;
|
|
5
5
|
use crate::logger::error;
|
|
6
|
-
use crate::node::{Node, TextNode};
|
|
6
|
+
use crate::node::{HasTextNode, Node, TextNode, ThemeBindable};
|
|
7
7
|
use crate::theme;
|
|
8
8
|
use crate::typography::{FontFamily, FontStack, FontStyle, FontWeight};
|
|
9
9
|
use std::cell::RefCell;
|
|
@@ -247,6 +247,29 @@ impl Deref for RichText {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
impl HasTextNode for RichText {
|
|
251
|
+
fn text_node(&self) -> &TextNode {
|
|
252
|
+
&self.node
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
impl ThemeBindable for RichText {
|
|
257
|
+
fn theme_binding_node(&self) -> crate::node::NodeRef {
|
|
258
|
+
self.node.retained_node_ref()
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
fn weak_theme_target(&self) -> Box<dyn Fn() -> Option<Self>> {
|
|
262
|
+
let weak_node = self.node.weak_theme_target();
|
|
263
|
+
let weak_state = Rc::downgrade(&self.state);
|
|
264
|
+
Box::new(move || {
|
|
265
|
+
Some(Self {
|
|
266
|
+
node: weak_node()?,
|
|
267
|
+
state: weak_state.upgrade()?,
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
250
273
|
impl Node for RichText {
|
|
251
274
|
fn retained_node_ref(&self) -> crate::node::NodeRef {
|
|
252
275
|
self.node.retained_node_ref()
|