Keep the stars on screen long enough to click one
The rating strip was a sibling of the cell's TouchArea, declared after it so that hit-testing reached the stars first. That half worked: a star click set a rating without also opening the image. The other half did not. Hover is tracked per TouchArea, and Slint sends `Exit` to any item that drops out of the hit path. The strip taking the pointer is exactly that — `cell-touch` left the path, `has-hover` went false, and `show-empty` went with it. On an unrated cell the stars are drawn *only* on hover, so they vanished as the pointer arrived at them; the click then landed on the cell behind and opened the image. Reported as "the star menu disappears when I click on an image", which is precisely what it does. Nesting the strip inside `cell-touch` keeps both halves. Children are hit-tested before the element containing them, so a star still wins the click and still ends the walk before `cell-clicked` runs. And an ancestor stays on the item stack: it gets no `Exit`, and while a child holds the grab it is handed the event filter and never the event. Hover therefore holds for as long as the pointer is anywhere in the cell.
This commit is contained in:
+51
-30
@@ -1907,37 +1907,58 @@ export component LibraryGrid inherits Rectangle {
|
|||||||
// is why the toggling is idempotent-by-union in Rust
|
// is why the toggling is idempotent-by-union in Rust
|
||||||
// rather than this file trying to swallow one of them.
|
// rather than this file trying to swallow one of them.
|
||||||
double-clicked => { root.cell-double-clicked(i); }
|
double-clicked => { root.cell-double-clicked(i); }
|
||||||
}
|
|
||||||
|
|
||||||
// --- the rating strip, ABOVE the cell's own hit area ---
|
// --- the rating strip, INSIDE the cell's hit area ---
|
||||||
//
|
//
|
||||||
// **Declared after `cell-touch` on purpose.** Slint hit-tests
|
// **A child of `cell-touch`, not a sibling of it.** Two
|
||||||
// later siblings first, so a strip nested inside the layout
|
// things have to be true at once here, and only this
|
||||||
// above was underneath the cell-wide TouchArea: the click set
|
// nesting gets both.
|
||||||
// a rating *and* fell through to `cell-clicked`, which threw
|
//
|
||||||
// the user into develop on every star press. Z-order is the
|
// A star must take the click without it also reaching
|
||||||
// whole fix — there is no "handled" flag to set, and adding a
|
// `cell-clicked`, or every rating throws the user into
|
||||||
// travel threshold or a timer would be faking arbitration
|
// develop. Children are hit-tested before the element
|
||||||
// Slint already does correctly once the order is right.
|
// they sit in, and a child that accepts ends the walk
|
||||||
//
|
// before the TouchArea's own handler runs — so the star
|
||||||
// It sits over the foot of the thumbnail rather than below it:
|
// wins, and it wins for the same reason a later sibling
|
||||||
// the caption row is spoken for by the filename, and a third
|
// used to.
|
||||||
// row would cost thumbnail height on every cell to show
|
//
|
||||||
// something that is usually empty.
|
// And the strip must not vanish as the pointer arrives
|
||||||
StarStrip {
|
// at it. As a *sibling* it did: hover is tracked per
|
||||||
x: (parent.width - self.width) / 2;
|
// TouchArea, Slint sends `Exit` to whatever drops out of
|
||||||
// Clear of the caption, which is the cell's last row.
|
// the hit path, and the strip taking the pointer dropped
|
||||||
y: parent.height - self.height - 26px;
|
// `cell-touch` out of it. `has-hover` went false, which
|
||||||
rating: cell.rating;
|
// took `show-empty` with it, which hid the very stars
|
||||||
// Empty stars appear once the pointer is over the cell,
|
// the pointer was travelling towards — on an unrated
|
||||||
// so there is something to aim at without filling the
|
// cell they disappeared, the click landed on the cell
|
||||||
// grid with chrome. On touch there is no hover, so the
|
// behind them, and the image opened. That is the whole
|
||||||
// strip is always present where a rating exists — and a
|
// of the "stars vanish when I click one" report.
|
||||||
// long-press is not needed to discover it.
|
//
|
||||||
show-empty: cell-touch.has-hover;
|
// An *ancestor* stays in the path: it keeps its place on
|
||||||
can-trash: !root.viewing-trash;
|
// the item stack, gets no `Exit`, and during a grab it is
|
||||||
rate(n) => { root.cell-rated(i, n); }
|
// handed only the filter and never the event. So hover
|
||||||
trash() => { root.cell-trashed(i); }
|
// holds for as long as the pointer is anywhere in the
|
||||||
|
// cell, stars included.
|
||||||
|
//
|
||||||
|
// It sits over the foot of the thumbnail rather than
|
||||||
|
// below it: the caption row is spoken for by the
|
||||||
|
// filename, and a third row would cost thumbnail height
|
||||||
|
// on every cell to show something that is usually empty.
|
||||||
|
StarStrip {
|
||||||
|
x: (parent.width - self.width) / 2;
|
||||||
|
// Clear of the caption, which is the cell's last row.
|
||||||
|
y: parent.height - self.height - 26px;
|
||||||
|
rating: cell.rating;
|
||||||
|
// Empty stars appear once the pointer is over the
|
||||||
|
// cell, so there is something to aim at without
|
||||||
|
// filling the grid with chrome. On touch there is no
|
||||||
|
// hover, so the strip is always present where a
|
||||||
|
// rating exists — and a long-press is not needed to
|
||||||
|
// discover it.
|
||||||
|
show-empty: cell-touch.has-hover;
|
||||||
|
can-trash: !root.viewing-trash;
|
||||||
|
rate(n) => { root.cell-rated(i, n); }
|
||||||
|
trash() => { root.cell-trashed(i); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user