Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ default-members = [
license = "MIT"
version = "0.2.0"
edition = "2024"
rust-version = "1.87"
rust-version = "1.90"
repository = "https://github.com/lapce/floem"

[package]
Expand Down
18 changes: 9 additions & 9 deletions src/animate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ impl PropCache {
}

fn remove_prop(&mut self, prop: StylePropRef, idx: u16) {
if let imbl::hashmap::Entry::Occupied(mut oe) = self.prop_map.entry(prop) {
if let Ok(pos) = oe.get().binary_search(&PropFrameKind::Normal(idx)) {
oe.get_mut().remove(pos);
}
if let imbl::hashmap::Entry::Occupied(mut oe) = self.prop_map.entry(prop)
&& let Ok(pos) = oe.get().binary_search(&PropFrameKind::Normal(idx))
{
oe.get_mut().remove(pos);
}
}

Expand Down Expand Up @@ -510,11 +510,11 @@ impl Animation {
) -> Self {
let frame = key_frame(KeyFrame::new(frame_id));
let frame_style = frame.style.clone();
if let Some(f) = self.key_frames.insert(frame_id, frame) {
if let KeyFrameStyle::Style(style) = f.style {
for prop in style.style_props() {
self.cache.remove_prop(prop, frame_id);
}
if let Some(f) = self.key_frames.insert(frame_id, frame)
&& let KeyFrameStyle::Style(style) = f.style
{
for prop in style.style_props() {
self.cache.remove_prop(prop, frame_id);
}
}
if let KeyFrameStyle::Style(style) = frame_style {
Expand Down
24 changes: 12 additions & 12 deletions src/app_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ impl ApplicationHandle {
.reduce(window_handle.scale, &event)
{
Some(WindowEventTranslation::Keyboard(ke)) => {
if let WindowEvent::KeyboardInput { is_synthetic, .. } = event {
if !is_synthetic {
window_handle.key_event(ke)
}
if let WindowEvent::KeyboardInput { is_synthetic, .. } = event
&& !is_synthetic
{
window_handle.key_event(ke)
}
}
Some(WindowEventTranslation::Pointer(pe)) => {
Expand Down Expand Up @@ -526,16 +526,16 @@ impl ApplicationHandle {
return;
};
#[cfg(target_os = "macos")]
if let Some(mac) = &mac_os_config {
if let Some((x, y)) = mac.traffic_lights_offset {
use raw_window_handle::HasWindowHandle;
if let Some(mac) = &mac_os_config
&& let Some((x, y)) = mac.traffic_lights_offset
{
use raw_window_handle::HasWindowHandle;

if let Ok(wh) = window.window_handle() {
use raw_window_handle::RawWindowHandle;
if let Ok(wh) = window.window_handle() {
use raw_window_handle::RawWindowHandle;

if let RawWindowHandle::AppKit(app_kit) = wh.as_raw() {
let _ = setup_traffic_light_constraints_all_pixels(&app_kit, x, y, 6.);
}
if let RawWindowHandle::AppKit(app_kit) = wh.as_raw() {
let _ = setup_traffic_light_constraints_all_pixels(&app_kit, x, y, 6.);
}
}
}
Expand Down
308 changes: 149 additions & 159 deletions src/context.rs

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ impl ViewId {
// Remove the cached root, in the (unlikely) case that this view is
// re-added to a different window
s.root.remove(*self);
if let Some(Some(parent)) = s.parent.get(*self) {
if let Some(children) = s.children.get_mut(*parent) {
children.retain(|c| c != self);
}
if let Some(Some(parent)) = s.parent.get(*self)
&& let Some(children) = s.children.get_mut(*parent)
{
children.retain(|c| c != self);
}
s.view_ids.remove(*self);
});
Expand Down Expand Up @@ -207,11 +207,11 @@ impl ViewId {
// root_view_id() always returns SOMETHING. If the view is not yet added
// to a window, it can be itself or its nearest ancestor, which means we
// will store garbage permanently.
if let Some(root) = root_view_id {
if is_known_root(&root) {
s.root.insert(*self, root_view_id);
return Some(root);
}
if let Some(root) = root_view_id
&& is_known_root(&root)
{
s.root.insert(*self, root_view_id);
return Some(root);
}
None
})
Expand Down
27 changes: 14 additions & 13 deletions src/inspector/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ pub fn capture(window_id: WindowId) {
stack
.style(|s| s.width_full().height_full())
.on_event(EventListener::KeyUp, move |e| {
if let Event::Key(e) = e {
if e.key == keyboard::Key::Named(NamedKey::F11) && e.modifiers.shift() {
id.inspect();
return EventPropagation::Stop;
}
if let Event::Key(e) = e
&& e.key == keyboard::Key::Named(NamedKey::F11)
&& e.modifiers.shift()
{
id.inspect();
return EventPropagation::Stop;
}
EventPropagation::Continue
})
Expand Down Expand Up @@ -559,14 +560,14 @@ fn tree_node(
let scroll_to = capture_signal.scroll_to;
let expanding_selection = capture_signal.expanding_selection;
create_effect(move |_| {
if let Some((selection, request_focus)) = expanding_selection.get() {
if selection == id {
// Scroll to the row, then to the name part of the row.
scroll_to.set(Some(row_id));
scroll_to.set(Some(name_id));
if request_focus {
row_id.request_focus();
}
if let Some((selection, request_focus)) = expanding_selection.get()
&& selection == id
{
// Scroll to the row, then to the name part of the row.
scroll_to.set(Some(row_id));
scroll_to.set(Some(name_id));
if request_focus {
row_id.request_focus();
}
}
});
Expand Down
109 changes: 55 additions & 54 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,16 +1546,16 @@ impl<T: StylePropValue> TransitionState<T> {
if let Some(transition) = &self.transition {
let time = now.saturating_duration_since(active.start);
let time_percent = time.as_secs_f64() / transition.duration.as_secs_f64();
if time < transition.duration || !transition.easing.finished(time_percent) {
if let Some(i) = T::interpolate(
if (time < transition.duration || !transition.easing.finished(time_percent))
&& let Some(i) = T::interpolate(
&active.before,
&active.after,
transition.easing.eval(time_percent),
) {
active.current = i;
*request_transition = true;
return true;
}
)
{
active.current = i;
*request_transition = true;
return true;
}
}
// time has past duration, or the value is not interpolatable
Expand Down Expand Up @@ -2073,13 +2073,13 @@ fn resolve_nested_maps_internal(
}

// DarkMode
if interact_state.is_dark_mode {
if let Some(map) = style.get_nested_map(StyleSelector::DarkMode.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::DarkMode.to_key());
changed = true;
}
if interact_state.is_dark_mode
&& let Some(map) = style.get_nested_map(StyleSelector::DarkMode.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::DarkMode.to_key());
changed = true;
}

// Disabled state (takes precedence)
Expand All @@ -2094,33 +2094,33 @@ fn resolve_nested_maps_internal(
// Other states only apply if not disabled

// Selected
if interact_state.is_selected || style.get(Selected) {
if let Some(map) = style.get_nested_map(StyleSelector::Selected.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Selected.to_key());
changed = true;
}
if (interact_state.is_selected || style.get(Selected))
&& let Some(map) = style.get_nested_map(StyleSelector::Selected.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Selected.to_key());
changed = true;
}

// Hover
if interact_state.is_hovered {
if let Some(map) = style.get_nested_map(StyleSelector::Hover.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Hover.to_key());
changed = true;
}
if interact_state.is_hovered
&& let Some(map) = style.get_nested_map(StyleSelector::Hover.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Hover.to_key());
changed = true;
}

// File Hover
if interact_state.is_file_hover {
if let Some(map) = style.get_nested_map(StyleSelector::FileHover.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::FileHover.to_key());
changed = true;
}
if interact_state.is_file_hover
&& let Some(map) = style.get_nested_map(StyleSelector::FileHover.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::FileHover.to_key());
changed = true;
}

// Focus states
Expand All @@ -2140,25 +2140,26 @@ fn resolve_nested_maps_internal(
changed = true;
}

if interact_state.is_clicking {
if let Some(map) = style.get_nested_map(StyleSelector::Active.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Active.to_key());
changed = true;
}
if interact_state.is_clicking
&& let Some(map) = style.get_nested_map(StyleSelector::Active.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Active.to_key());
changed = true;
}
}
}

// Active (mouse)
if interact_state.is_clicking && !interact_state.using_keyboard_navigation {
if let Some(map) = style.get_nested_map(StyleSelector::Active.to_key()) {
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Active.to_key());
changed = true;
}
if interact_state.is_clicking
&& !interact_state.using_keyboard_navigation
&& let Some(map) = style.get_nested_map(StyleSelector::Active.to_key())
{
classes_applied |= map.any_inherited();
style.apply_mut(map);
style.remove_nested_map(StyleSelector::Active.to_key());
changed = true;
}
}

Expand Down Expand Up @@ -2272,11 +2273,11 @@ impl Style {
self.apply_context_mappings_mut();
}
}
if self.get(Selected) {
if let Some(map) = self.get_nested_map(StyleSelector::Selected.to_key()) {
self.apply_mut(map.apply_selectors(&[StyleSelector::Selected]));
self.apply_context_mappings_mut();
}
if self.get(Selected)
&& let Some(map) = self.get_nested_map(StyleSelector::Selected.to_key())
{
self.apply_mut(map.apply_selectors(&[StyleSelector::Selected]));
self.apply_context_mappings_mut();
}
self
}
Expand Down
Loading