Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tab navigation #153

Merged
merged 1 commit into from
Nov 6, 2023
Merged
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
6 changes: 3 additions & 3 deletions examples/counter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn app_view() -> impl View {
.padding(10.0)
.background(Color::WHITE)
.box_shadow_blur(5.0)
.focus_visible(|s| s.border(2.).border_color(Color::BLUE))
.focus_visible(|s| s.outline(2.).outline_color(Color::BLUE))
.hover(|s| s.background(Color::LIGHT_GREEN))
.active(|s| s.color(Color::WHITE).background(Color::DARK_GREEN))
})
Expand All @@ -43,7 +43,7 @@ fn app_view() -> impl View {
.border_radius(10.0)
.padding(10.0)
.margin_left(10.0)
.focus_visible(|s| s.border(2.).border_color(Color::BLUE))
.focus_visible(|s| s.outline(2.).outline_color(Color::BLUE))
.hover(|s| s.background(Color::rgb8(244, 67, 54)))
.active(|s| s.color(Color::WHITE).background(Color::RED))
})
Expand All @@ -61,7 +61,7 @@ fn app_view() -> impl View {
.padding(10.0)
.margin_left(10.0)
.background(Color::LIGHT_BLUE)
.focus_visible(|s| s.border(2.).border_color(Color::BLUE))
.focus_visible(|s| s.outline(2.).outline_color(Color::BLUE))
.disabled(|s| s.background(Color::LIGHT_GRAY))
.hover(|s| s.background(Color::LIGHT_YELLOW))
.active(|s| s.color(Color::WHITE).background(Color::YELLOW_GREEN))
Expand Down
14 changes: 13 additions & 1 deletion examples/themes/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use floem::{
keyboard::{Key, NamedKey},
peniko::Color,
reactive::create_signal,
style::{Background, BorderColor, Style, TextColor, Transition},
style::{Background, BorderColor, Outline, OutlineColor, Style, TextColor, Transition},
style_class,
view::View,
views::{label, stack, text, Decorators},
Expand All @@ -23,6 +23,11 @@ fn app_view() -> impl View {
.transition(TextColor, Transition::linear(0.06))
.transition(BorderColor, Transition::linear(0.06))
.transition(Background, Transition::linear(0.06))
.transition(Outline, Transition::linear(0.1))
.focus_visible(|s| {
s.outline(2.0)
.outline_color(Color::WHITE.with_alpha_factor(0.7))
})
.disabled(|s| {
s.background(Color::DARK_GRAY.with_alpha_factor(0.1))
.border_color(Color::BLACK.with_alpha_factor(0.2))
Expand Down Expand Up @@ -55,6 +60,13 @@ fn app_view() -> impl View {
.transition(TextColor, Transition::linear(0.3))
.transition(BorderColor, Transition::linear(0.3))
.transition(Background, Transition::linear(0.3))
.transition(Outline, Transition::linear(0.2))
.transition(OutlineColor, Transition::linear(0.2))
.outline_color(Color::rgba8(131, 145, 123, 0))
.focus_visible(|s| {
s.outline(10.0)
.outline_color(Color::rgb8(131, 145, 123).with_alpha_factor(0.3))
})
.border_color(Color::rgb8(131, 145, 123))
.hover(|s| s.background(Color::rgb8(204, 209, 201)))
.padding(8.0)
Expand Down
6 changes: 5 additions & 1 deletion examples/widget-gallery/src/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ pub fn checkbox_view() -> impl View {
stack({
(
checkbox(is_checked)
.on_click(move |_| {
set_is_checked.update(|checked| *checked = !*checked);
true
})
.style(|s| s.focus_visible(|s| s.border(2.).border_color(Color::BLUE))),
label(|| "Check me!"),
)
Expand All @@ -36,12 +40,12 @@ pub fn checkbox_view() -> impl View {
stack({
(
checkbox(is_checked)
.disabled(|| true)
.style(|s| s.focus_visible(|s| s.border(2.).border_color(Color::BLUE))),
label(|| "Check me!"),
)
})
.style(|s| s.color(Color::GRAY))
.disabled(|| true)
.on_click(move |_| {
set_is_checked.update(|checked| *checked = !*checked);
true
Expand Down
20 changes: 15 additions & 5 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
responsive::{GridBreakpoints, ScreenSizeBp},
style::{
Background, BorderBottom, BorderColor, BorderLeft, BorderRadius, BorderRight, BorderTop,
BuiltinStyle, CursorStyle, DisplayProp, LayoutProps, Style, StyleClassRef, StyleProp,
StyleSelector, StyleSelectors, ZIndex,
BuiltinStyle, CursorStyle, DisplayProp, LayoutProps, Outline, OutlineColor, Style,
StyleClassRef, StyleProp, StyleSelector, StyleSelectors, ZIndex,
},
unit::PxPct,
view::{paint_bg, paint_border, paint_outline, View},
Expand Down Expand Up @@ -57,19 +57,21 @@
pub border_bottom: BorderBottom,
pub border_radius: BorderRadius,

pub outline: Outline,
pub outline_color: OutlineColor,
pub border_color: BorderColor,
pub background: Background,
}
}

bitflags! {
#[derive(Default, Copy, Clone, Debug)]
#[must_use]
pub(crate) struct ChangeFlags: u8 {
const STYLE = 1;
const LAYOUT = 1 << 1;
}
}

Check warning on line 74 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L67-L74

Added lines #L67 - L74 were not covered by tests

pub struct ViewState {
pub(crate) node: Node,
Expand Down Expand Up @@ -106,7 +108,7 @@
layout_rect: Rect::ZERO,
layout_props: Default::default(),
view_style_props: Default::default(),
requested_changes: ChangeFlags::all(),

Check warning on line 111 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L111

Added line #L111 was not covered by tests
request_style_recursive: false,
has_style_selectors: StyleSelectors::default(),
animation: None,
Expand Down Expand Up @@ -136,8 +138,8 @@
view_class: Option<StyleClassRef>,
classes: &[StyleClassRef],
context: &Style,
) -> bool {
let mut new_frame = false;

Check warning on line 142 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L141-L142

Added lines #L141 - L142 were not covered by tests
let mut computed_style = Style::new();
if let Some(view_style) = view_style {
computed_style.apply_mut(view_style);
Expand All @@ -158,8 +160,8 @@
break 'anim;
}

new_frame = true;

Check warning on line 164 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L163-L164

Added lines #L163 - L164 were not covered by tests
let props = animation.props();

for kind in props.keys() {
Expand Down Expand Up @@ -191,8 +193,8 @@
computed_style.apply_interact_state(&interact_state, screen_size_bp);

self.combined_style = computed_style;

new_frame

Check warning on line 197 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L196-L197

Added lines #L196 - L197 were not covered by tests
}
}

Expand Down Expand Up @@ -266,8 +268,8 @@
stale_view_state: ViewState::new(&mut taffy),
taffy,
view_states: HashMap::new(),
scheduled_updates: Vec::new(),
request_paint: false,

Check warning on line 272 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L271-L272

Added lines #L271 - L272 were not covered by tests
disabled: HashSet::new(),
keyboard_navigable: HashSet::new(),
draggable: HashSet::new(),
Expand Down Expand Up @@ -401,7 +403,7 @@
view_class: Option<StyleClassRef>,
classes: &[StyleClassRef],
context: &Style,
) -> bool {

Check warning on line 406 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L406

Added line #L406 was not covered by tests
let interact_state = self.get_interact_state(&id);
let screen_size_bp = self.screen_size_bp;
let view_state = self.view_state(id);
Expand All @@ -412,7 +414,7 @@
view_class,
classes,
context,
)

Check warning on line 417 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L417

Added line #L417 was not covered by tests
}

pub(crate) fn get_computed_style(&mut self, id: Id) -> &Style {
Expand Down Expand Up @@ -445,51 +447,51 @@

/// Request that this the `id` view be styled, laid out and painted again.
/// This will recursively request this for all parents.
pub fn request_all(&mut self, id: Id) {
self.request_changes(id, ChangeFlags::all());
self.request_paint(id);
}

Check warning on line 453 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L450-L453

Added lines #L450 - L453 were not covered by tests

pub(crate) fn request_changes(&mut self, id: Id, flags: ChangeFlags) {

Check warning on line 455 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L455

Added line #L455 was not covered by tests
let view = self.view_state(id);
if view.requested_changes.contains(flags) {

Check warning on line 457 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L457

Added line #L457 was not covered by tests
return;
}
view.requested_changes.insert(flags);

Check warning on line 460 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L460

Added line #L460 was not covered by tests
if let Some(parent) = id.parent() {
self.request_changes(parent, flags);

Check warning on line 462 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L462

Added line #L462 was not covered by tests
}
}

/// Requests that the style pass will run for `id` on the next frame, and ensures new frame is
/// scheduled to happen.
pub fn schedule_style(&mut self, id: Id) {
self.scheduled_updates.push(FrameUpdate::Style(id));
}

Check warning on line 470 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L468-L470

Added lines #L468 - L470 were not covered by tests

/// Requests that the layout pass will run for `id` on the next frame, and ensures new frame is
/// scheduled to happen.
pub fn schedule_layout(&mut self, id: Id) {
self.scheduled_updates.push(FrameUpdate::Layout(id));
}

Check warning on line 476 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L474-L476

Added lines #L474 - L476 were not covered by tests

/// Requests that the paint pass will run for `id` on the next frame, and ensures new frame is
/// scheduled to happen.
pub fn schedule_paint(&mut self, id: Id) {
self.scheduled_updates.push(FrameUpdate::Paint(id));
}

Check warning on line 482 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L480-L482

Added lines #L480 - L482 were not covered by tests

pub fn request_style(&mut self, id: Id) {
self.request_changes(id, ChangeFlags::STYLE)
}

Check warning on line 486 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L484-L486

Added lines #L484 - L486 were not covered by tests

pub fn request_layout(&mut self, id: Id) {
self.request_changes(id, ChangeFlags::LAYOUT)

Check warning on line 489 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L489

Added line #L489 was not covered by tests
}

// `Id` is unused currently, but could be used to calculate damage regions.
pub fn request_paint(&mut self, _id: Id) {
self.request_paint = true;

Check warning on line 494 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L493-L494

Added lines #L493 - L494 were not covered by tests
}

pub(crate) fn set_viewport(&mut self, id: Id, viewport: Rect) {
Expand Down Expand Up @@ -548,7 +550,9 @@
pub(crate) fn clear_focus(&mut self) {
if let Some(old_id) = self.focus {
// To remove the styles applied by the Focus selector
if self.has_style_for_sel(old_id, StyleSelector::Focus) {
if self.has_style_for_sel(old_id, StyleSelector::Focus)
|| self.has_style_for_sel(old_id, StyleSelector::FocusVisible)
{

Check warning on line 555 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L553-L555

Added lines #L553 - L555 were not covered by tests
self.request_style(old_id);
}
}
Expand All @@ -563,6 +567,12 @@

self.focus = Some(id);
self.keyboard_navigation = keyboard_navigation;

if self.has_style_for_sel(id, StyleSelector::Focus)
|| self.has_style_for_sel(id, StyleSelector::FocusVisible)
{
self.request_style(id);
}

Check warning on line 575 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L570-L575

Added lines #L570 - L575 were not covered by tests
}

pub(crate) fn has_style_for_sel(&mut self, id: Id, selector_kind: StyleSelector) -> bool {
Expand Down Expand Up @@ -674,13 +684,13 @@
self.app_state.request_paint(id);
}

pub fn app_state_mut(&mut self) -> &mut AppState {
self.app_state
}

Check warning on line 689 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L687-L689

Added lines #L687 - L689 were not covered by tests

pub fn app_state(&self) -> &AppState {
self.app_state
}

Check warning on line 693 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L691-L693

Added lines #L691 - L693 were not covered by tests

pub fn update_active(&mut self, id: Id) {
self.app_state.update_active(id);
Expand Down Expand Up @@ -1127,10 +1137,10 @@
self.save();
let id = view.id();
let view_state = self.app_state_mut().view_state(id);
if !view_state.requested_changes.contains(ChangeFlags::STYLE) {

Check warning on line 1140 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1140

Added line #L1140 was not covered by tests
return;
}
view_state.requested_changes.remove(ChangeFlags::STYLE);

Check warning on line 1143 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1143

Added line #L1143 was not covered by tests

let view_style = view.view_style();
let view_class = view.view_class();
Expand All @@ -1149,15 +1159,15 @@
view.for_each_child(&mut |child| {
let state = self.app_state_mut().view_state(child.id());
state.request_style_recursive = true;
state.requested_changes.insert(ChangeFlags::STYLE);

Check warning on line 1162 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1162

Added line #L1162 was not covered by tests
false
});
}

let mut new_frame =
self.app_state
.compute_style(id, view_style, view_class, classes, &self.current);

Check warning on line 1170 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1167-L1170

Added lines #L1167 - L1170 were not covered by tests
let style = self.app_state_mut().get_computed_style(id).clone();
self.direct = style;
Style::apply_only_inherited(&mut self.current, &self.direct);
Expand All @@ -1182,17 +1192,17 @@
&self.direct,
&self.current,
&self.now,
&mut new_frame,

Check warning on line 1195 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1195

Added line #L1195 was not covered by tests
);

view_state.view_style_props.read_explicit(
&self.direct,
&self.current,
&self.now,
&mut new_frame,

Check warning on line 1202 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1202

Added line #L1202 was not covered by tests
);
if new_frame {
self.app_state.schedule_style(id);

Check warning on line 1205 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1204-L1205

Added lines #L1204 - L1205 were not covered by tests
}

view.style(self);
Expand All @@ -1218,9 +1228,9 @@
(*self.current).clone().apply(self.direct.clone())
}

pub fn request_transition(&mut self) {

Check warning on line 1231 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1231

Added line #L1231 was not covered by tests
let id = self.current_view;
self.app_state_mut().schedule_style(id);

Check warning on line 1233 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1233

Added line #L1233 was not covered by tests
}

pub fn app_state_mut(&mut self) -> &mut AppState {
Expand Down Expand Up @@ -1318,10 +1328,10 @@
) -> Node {
let view_state = self.app_state.view_state(id);
let node = view_state.node;
if !view_state.requested_changes.contains(ChangeFlags::LAYOUT) {

Check warning on line 1331 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1331

Added line #L1331 was not covered by tests
return node;
}
view_state.requested_changes.remove(ChangeFlags::LAYOUT);

Check warning on line 1334 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1334

Added line #L1334 was not covered by tests
let style = view_state.combined_style.to_taffy_style();
let _ = self.app_state.taffy.set_style(node, style);

Expand Down Expand Up @@ -1507,7 +1517,7 @@

view.paint(self);
paint_border(self, &view_style_props, size);
paint_outline(self, &style, size)
paint_outline(self, &view_style_props, size)

Check warning on line 1520 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1520

Added line #L1520 was not covered by tests
}

let mut drag_set_to_none = false;
Expand Down Expand Up @@ -1554,7 +1564,7 @@

view.paint(self);
paint_border(self, &view_style_props, size);
paint_outline(self, &style, size);
paint_outline(self, &view_style_props, size);

Check warning on line 1567 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1567

Added line #L1567 was not covered by tests

self.restore();
}
Expand Down Expand Up @@ -1690,7 +1700,7 @@
/// request that this node be styled, laid out and painted again
/// This will recursively request this for all parents.
pub fn request_all(&mut self, id: Id) {
self.app_state.request_all(id);

Check warning on line 1703 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1703

Added line #L1703 was not covered by tests
}

/// request that this node be styled again
Expand All @@ -1705,24 +1715,24 @@
self.app_state.request_layout(id);
}

pub fn app_state_mut(&mut self) -> &mut AppState {
self.app_state
}

Check warning on line 1720 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1718-L1720

Added lines #L1718 - L1720 were not covered by tests

pub fn app_state(&self) -> &AppState {
self.app_state
}

Check warning on line 1724 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1722-L1724

Added lines #L1722 - L1724 were not covered by tests

/// Used internally by Floem to send an update to the correct view based on the `Id` path.
/// It will invoke only once `update` when the correct view is located.
pub fn update_view(&mut self, view: &mut dyn View, id_path: &[Id], state: Box<dyn Any>) {

Check warning on line 1728 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1728

Added line #L1728 was not covered by tests
let id = id_path[0];
let id_path = &id_path[1..];
if id == view.id() {
if id_path.is_empty() {
view.update(self, state);

Check warning on line 1733 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1733

Added line #L1733 was not covered by tests
} else if let Some(child) = view.child_mut(id_path[0]) {
self.update_view(child, id_path, state);

Check warning on line 1735 in src/context.rs

View check run for this annotation

Codecov / codecov/patch

src/context.rs#L1735

Added line #L1735 was not covered by tests
}
}
}
Expand Down
57 changes: 52 additions & 5 deletions src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use crate::style::{Style, StyleMapValue};
use crate::view::{view_children, View};
use crate::views::{
dyn_container, empty, img_dynamic, scroll, stack, static_label, static_list, text, v_stack,
Decorators, Label,
dyn_container, empty, h_stack, img_dynamic, scroll, stack, static_label, static_list, text,
v_stack, Decorators, Label,
};
use crate::window::WindowConfig;
use crate::{new_window, style};
Expand Down Expand Up @@ -34,6 +34,8 @@
children: Vec<Rc<CapturedView>>,
direct_style: Style,
requested_changes: ChangeFlags,
keyboard_navigable: bool,
focused: bool,
}

impl CapturedView {
Expand All @@ -42,8 +44,9 @@
let layout = app_state.get_layout_rect(id);
let taffy = app_state.get_layout(id).unwrap();
let computed_style = app_state.get_computed_style(id).clone();
let keyboard_navigable = app_state.keyboard_navigable.contains(&id);
let focused = app_state.focus == Some(id);

Check warning on line 48 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L47-L48

Added lines #L47 - L48 were not covered by tests
let state = app_state.view_state(id);

let clipped = layout.intersect(clip);
Self {
id,
Expand All @@ -52,7 +55,9 @@
taffy,
clipped,
direct_style: computed_style,
requested_changes: state.requested_changes,
keyboard_navigable,
focused,

Check warning on line 60 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L58-L60

Added lines #L58 - L60 were not covered by tests
children: view_children(view)
.into_iter()
.map(|view| Rc::new(CapturedView::capture(view, app_state, clipped)))
Expand All @@ -79,7 +84,7 @@
}

fn warnings(&self) -> bool {
!self.requested_changes.is_empty() || self.children.iter().any(|child| child.warnings())

Check warning on line 87 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L87

Added line #L87 was not covered by tests
}
}

Expand Down Expand Up @@ -119,6 +124,46 @@
}
}

fn captured_view_name(view: &CapturedView) -> impl View {
let name = static_label(view.name.clone());
let id = text(view.id.to_raw()).style(|s| {
s.margin_right(5.0)
.background(Color::BLACK.with_alpha_factor(0.02))
.border(1.0)
.border_radius(5.0)
.border_color(Color::BLACK.with_alpha_factor(0.07))
.padding(3.0)
.padding_top(0.0)
.padding_bottom(0.0)
.font_size(12.0)
.color(Color::BLACK.with_alpha_factor(0.6))
});
let tab: Box<dyn View> = if view.focused {
Box::new(text("Focus").style(|s| {
s.margin_right(5.0)
.background(Color::rgb8(63, 81, 101).with_alpha_factor(0.6))
.border_radius(5.0)
.padding(1.0)
.font_size(10.0)
.color(Color::WHITE.with_alpha_factor(0.8))
}))
} else if view.keyboard_navigable {
Box::new(text("Tab").style(|s| {
s.margin_right(5.0)
.background(Color::rgb8(204, 217, 221).with_alpha_factor(0.4))
.border(1.0)
.border_radius(5.0)
.border_color(Color::BLACK.with_alpha_factor(0.07))
.padding(1.0)
.font_size(10.0)
.color(Color::BLACK.with_alpha_factor(0.4))
}))

Check warning on line 160 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L127-L160

Added lines #L127 - L160 were not covered by tests
} else {
Box::new(empty())

Check warning on line 162 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L162

Added line #L162 was not covered by tests
};
h_stack((id, tab, name)).style(|s| s.items_center())
}

Check warning on line 165 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L164-L165

Added lines #L164 - L165 were not covered by tests

// Outlined to reduce stack usage.
#[inline(never)]
fn captured_view_no_children(
Expand All @@ -128,7 +173,7 @@
highlighted: RwSignal<Option<Id>>,
) -> Box<dyn View> {
let offset = depth as f64 * 14.0;
let name = static_label(view.name.clone());
let name = captured_view_name(view);

Check warning on line 176 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L176

Added line #L176 was not covered by tests
let height = 20.0;
let id = view.id;

Expand Down Expand Up @@ -174,7 +219,7 @@
children: Vec<Box<dyn View>>,
) -> Box<dyn View> {
let offset = depth as f64 * 14.0;
let name = static_label(view.name.clone());
let name = captured_view_name(view);

Check warning on line 222 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L222

Added line #L222 was not covered by tests
let height = 20.0;
let id = view.id;

Expand Down Expand Up @@ -291,12 +336,12 @@
}

fn info(name: impl Display, value: String) -> impl View {
info_row(name.to_string(), static_label(value))

Check warning on line 339 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L339

Added line #L339 was not covered by tests
}

fn info_row(name: String, view: impl View + 'static) -> impl View {
stack((
stack((static_label(name).style(|s| {

Check warning on line 344 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L344

Added line #L344 was not covered by tests
s.margin_right(5.0)
.color(Color::BLACK.with_alpha_factor(0.6))
}),))
Expand Down Expand Up @@ -354,6 +399,7 @@
move |current| {
if let Some(view) = current.and_then(|id| capture.root.find(id)) {
let name = info("Type", view.name.clone());
let id = info("Id", view.id.to_raw().to_string());

Check warning on line 402 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L402

Added line #L402 was not covered by tests
let count = info("Child Count", format!("{}", view.children.len()));
let beyond = |view: f64, window| {
if view > window {
Expand Down Expand Up @@ -502,11 +548,11 @@
let mut v: Box<dyn View> = match value {
StyleMapValue::Val(v) => {
let v = &*v;
(prop.info.debug_view)(v).unwrap_or_else(|| {
Box::new(static_label((prop.info.debug_any)(v)))
})

Check warning on line 553 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L551-L553

Added lines #L551 - L553 were not covered by tests
}
StyleMapValue::Unset => Box::new(text("Unset")),

Check warning on line 555 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L555

Added line #L555 was not covered by tests
};
if let Some(transition) = style.transitions.get(&prop).cloned() {
let transition = stack((
Expand All @@ -521,7 +567,7 @@
.font_size(10.0)
.color(Color::BLACK.with_alpha_factor(0.4))
}),
static_label(format!("{transition:?}")),

Check warning on line 570 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L570

Added line #L570 was not covered by tests
))
.style(|s| s.items_center());
v = Box::new(v_stack((v, transition)));
Expand All @@ -547,6 +593,7 @@
Box::new(
v_stack((
name,
id,

Check warning on line 596 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L596

Added line #L596 was not covered by tests
count,
x,
y,
Expand All @@ -563,7 +610,7 @@
.style(|s| s.width_full()),
)
} else {
Box::new(text("No selection").style(|s| s.padding(5.0)))

Check warning on line 613 in src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

src/inspector.rs#L613

Added line #L613 was not covered by tests
}
},
)
Expand Down
3 changes: 3 additions & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
fn debug_view(&self) -> Option<Box<dyn View>> {
Some(Box::new(text(format!("{} px", self.0))))
}
fn interpolate(&self, other: &Self, value: f64) -> Option<Self> {
self.0.interpolate(&other.0, value).map(Px)
}

Check warning on line 107 in src/style.rs

View check run for this annotation

Codecov / codecov/patch

src/style.rs#L105-L107

Added lines #L105 - L107 were not covered by tests
}
impl StylePropValue for PxPctAuto {
fn debug_view(&self) -> Option<Box<dyn View>> {
Expand Down
Loading
Loading