forked from 1b-agent/opencadstudio-upstream
feat(dock): active and dragging rail tab styling
Style the dock rail tab by its panel state: the expanded (active) panel's tab gets a primary-colored highlight and border, and a tab whose panel is being dragged gets a lighter primary tint, so the user can see which panel owns the edge at a glance.
This commit is contained in:
1 parent
577530d2e8
commit
94667f9512
1 file changed
+40
-20
+40
-20
@@ -2293,7 +2293,14 @@ impl OpenCADStudio {
|
|||||||
let tab_strip = (!pinned.is_empty()).then(|| {
|
let tab_strip = (!pinned.is_empty()).then(|| {
|
||||||
let tabs: Vec<Element<'_, Message>> = pinned
|
let tabs: Vec<Element<'_, Message>> = pinned
|
||||||
.iter()
|
.iter()
|
||||||
.map(|id| self.rail_slice(*id, side))
|
.map(|id| {
|
||||||
|
self.rail_slice(
|
||||||
|
*id,
|
||||||
|
side,
|
||||||
|
self.dock_expanded == Some(*id),
|
||||||
|
self.dock_dragging == Some(*id),
|
||||||
|
)
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
column(tabs).width(DOCK_RAIL_W).height(Fill).into()
|
column(tabs).width(DOCK_RAIL_W).height(Fill).into()
|
||||||
});
|
});
|
||||||
@@ -2338,6 +2345,8 @@ impl OpenCADStudio {
|
|||||||
&self,
|
&self,
|
||||||
id: crate::ui::dock::PanelId,
|
id: crate::ui::dock::PanelId,
|
||||||
side: crate::app::config::DockSide,
|
side: crate::app::config::DockSide,
|
||||||
|
is_active: bool,
|
||||||
|
is_dragging: bool,
|
||||||
) -> Element<'_, Message> {
|
) -> Element<'_, Message> {
|
||||||
let label = canvas(VBarLabel {
|
let label = canvas(VBarLabel {
|
||||||
text: id.title().to_string(),
|
text: id.title().to_string(),
|
||||||
@@ -2345,26 +2354,37 @@ impl OpenCADStudio {
|
|||||||
})
|
})
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.height(Fill);
|
.height(Fill);
|
||||||
mouse_area(
|
let bg = move |theme: &Theme| {
|
||||||
container(label)
|
let palette = theme.palette();
|
||||||
.width(Length::Fixed(DOCK_RAIL_W))
|
if is_active {
|
||||||
.height(Fill)
|
palette.primary.weak.color
|
||||||
.style(|theme: &Theme| container::Style {
|
} else if is_dragging {
|
||||||
background: Some(Background::Color(
|
palette.primary.weak.color.scale_alpha(0.55)
|
||||||
theme.palette().background.base.color,
|
} else {
|
||||||
)),
|
palette.background.base.color
|
||||||
border: Border {
|
}
|
||||||
color: theme.palette().background.neutral.color,
|
};
|
||||||
width: 1.0,
|
let tab = container(label)
|
||||||
radius: 0.0.into(),
|
.width(Length::Fixed(DOCK_RAIL_W))
|
||||||
|
.height(Fill)
|
||||||
|
.style(move |theme: &Theme| container::Style {
|
||||||
|
background: Some(Background::Color(bg(theme))),
|
||||||
|
border: Border {
|
||||||
|
color: if is_active {
|
||||||
|
theme.palette().primary.base.color
|
||||||
|
} else {
|
||||||
|
theme.palette().background.neutral.color
|
||||||
},
|
},
|
||||||
..Default::default()
|
width: 1.0,
|
||||||
}),
|
radius: 0.0.into(),
|
||||||
)
|
},
|
||||||
.interaction(iced::mouse::Interaction::Pointer)
|
..Default::default()
|
||||||
.on_press(Message::Dock(crate::ui::dock::DockMsg::DockGrab(id)))
|
});
|
||||||
.on_enter(Message::Dock(crate::ui::dock::DockMsg::Hover(id)))
|
mouse_area(tab)
|
||||||
.into()
|
.interaction(iced::mouse::Interaction::Pointer)
|
||||||
|
.on_press(Message::Dock(crate::ui::dock::DockMsg::DockGrab(id)))
|
||||||
|
.on_enter(Message::Dock(crate::ui::dock::DockMsg::Hover(id)))
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A panel expanded to the full edge column: the panel body plus a
|
/// A panel expanded to the full edge column: the panel body plus a
|
||||||
|
|||||||
Reference in new issue
Block a user