Skip to content

Commit 7972642

Browse files
authored
style improvements (#798)
1 parent 7cc6c22 commit 7972642

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

examples/counter/src/main.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ fn app_view() -> impl IntoView {
7272
})
7373
.keyboard_navigable(),
7474
)
75-
.style(|s| {
76-
s.class(LabelClass, |s| {
77-
s.apply(LabelCustomStyle::new().selectable(false).style())
78-
})
79-
}),
75+
.style(|s| s.custom_style_class(|s: LabelCustomStyle| s.selectable(false))),
8076
)
8177
.style(|s| {
8278
s.size(100.pct(), 100.pct())

src/style.rs

+15
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,21 @@ pub trait CustomStyle: Default + Clone + Into<Style> + From<Style> {
25932593
}
25942594
self_style.into()
25952595
}
2596+
2597+
fn apply_if(self, cond: bool, style: impl FnOnce(Self) -> Self) -> Self {
2598+
if cond {
2599+
style(self)
2600+
} else {
2601+
self
2602+
}
2603+
}
2604+
fn transition<P: StyleProp>(self, _prop: P, transition: Transition) -> Self {
2605+
let mut self_style: Style = self.into();
2606+
self_style
2607+
.map
2608+
.insert(P::prop_ref().info().transition_key, Rc::new(transition));
2609+
self_style.into()
2610+
}
25962611
}
25972612

25982613
pub trait CustomStylable<S: CustomStyle + 'static>: IntoView<V = Self::DV> + Sized {

src/views/label.rs

-5
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,6 @@ impl LabelCustomStyle {
556556
self = Self(self.0.set(CursorColor, color));
557557
self
558558
}
559-
560-
/// Get the inner style
561-
pub fn style(self) -> Style {
562-
self.0
563-
}
564559
}
565560
impl Default for LabelCustomStyle {
566561
fn default() -> Self {

src/window.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ impl Default for WindowConfig {
5353
transparent: false,
5454
fullscreen: None,
5555
window_icon: None,
56-
title: "Floem window".to_owned(),
56+
title: std::env::current_exe()
57+
.ok()
58+
.and_then(|p| p.file_name().map(|f| f.to_string_lossy().into_owned()))
59+
.unwrap_or("Floem Window".to_string()),
5760
enabled_buttons: WindowButtons::all(),
5861
resizable: true,
5962
undecorated: false,

0 commit comments

Comments
 (0)