mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:24:24 +00:00
Layers: the row's effects badge is the fx icon
A list row paints a trailing drag handle's icon face as a mark, not an icon button: a handle has no node of its own (the row's description names it), and a button face would add an unnamed button.
This commit is contained in:
@@ -80,7 +80,6 @@ craft_ui::words! {
|
||||
linked: "layersPanel.linked" = "linked";
|
||||
layer_mask: "layersPanel.layerMask" = "layer mask";
|
||||
vector_mask: "layersPanel.vectorMask" = "vector mask";
|
||||
fx: "layersPanel.fx" = "fx";
|
||||
disabled_mask: "layersPanel.disabledMask" = "disabled mask";
|
||||
has_effects: "layersPanel.hasEffects" = "effects";
|
||||
has_smart_filters: "layersPanel.hasSmartFilters" = "Smart Filters";
|
||||
|
||||
@@ -321,7 +321,7 @@ fn layer_row<'r, T: LayerTree>(cx: &'r PanelContext<'r, T>, id: &T::Id) -> ListR
|
||||
// The badge drags every effect of the layer (Photoshop); a click on it is a click on the row.
|
||||
let badge = TrailingPart::new(FX_BADGE);
|
||||
row = row
|
||||
.trailing_part(badge, TrailingFace::Strong(words.fx.clone()), words.has_effects.clone())
|
||||
.trailing_part(badge, TrailingFace::Icon(IconSpec::svg(IconId::new("fx"))), words.has_effects.clone())
|
||||
.part_drag(RowDragSpot::Trailing(badge), LayersDrag::new(cx.list, vec![LayerRowKey::Effects(id.clone(), None)]));
|
||||
}
|
||||
if info.linked {
|
||||
|
||||
@@ -21,6 +21,8 @@ impl ListRow<'_> {
|
||||
pub(super) fn paint_trailing(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>, placed: &Placed) {
|
||||
let side = Vec2::splat(cx.style.sizes.icon);
|
||||
let selected = cx.resolved.selected == Some(true) || cx.env.facts_of(cx.id).is_some_and(|facts| facts.flags.contains(Flags::SELECTED));
|
||||
let drags = &self.drags;
|
||||
let handle = |part: &super::TrailingPart| drags.iter().any(|(spot, _)| *spot == super::RowDragSpot::Trailing(*part));
|
||||
for (at, (trailing, slot)) in self.trailing.iter_mut().zip(&placed.items).enumerate() {
|
||||
let Some(slot) = slot else { continue };
|
||||
let shape = Rect::from_center_size(slot.center(), side);
|
||||
@@ -51,6 +53,12 @@ impl ListRow<'_> {
|
||||
continue;
|
||||
}
|
||||
match face {
|
||||
// A drag handle is no button (`access` names it in the row's description): its icon is a mark.
|
||||
TrailingFace::Icon(icon) if handle(part) => {
|
||||
let mut icon = icon.clone();
|
||||
icon.color.get_or_insert(cx.resolve(&cx.style.trailing_icon.color));
|
||||
ui.draw().icon(shape, &icon);
|
||||
}
|
||||
TrailingFace::Icon(icon) => ui.face(key, IconButton::new(icon.clone()).focusable(false).enabled(*enabled)),
|
||||
TrailingFace::Disclosure { open } => ui.face(key, Disclosure::new(Bind::given(*open)).node(false).enabled(*enabled)),
|
||||
TrailingFace::Strong(text) => {
|
||||
|
||||
Reference in New Issue
Block a user