Let a date range be stated, and draw the axis at the scale it deserves
"Limit to range" did nothing, and the reason was not visible from the button. It took its span from the timeline's zoom, which is zero until someone zooms — so `zoomed_span` returned the whole library and the filter narrowed to everything. The chip lit up and the grid did not change. The range has ends now, shown and typed as `YYYY-MM-DD`. Seeding them from the timeline is kept, because zooming to a fortnight and pressing the chip is the fast path; the fields say which fortnight it landed on and let it be corrected. Ends given backwards are swapped rather than refused — there is exactly one range between two days — and the closing day is included, since "to the 5th" means the whole of the 5th and a range ending at its midnight contains none of it. `parse_date` refuses anything that is not a date rather than guessing at an order, because the alternative is a library silently filtered to a span nobody asked for. The axis then follows the range. It used to keep drawing the full extent while a range was on, because it was the only way back out; the typed ends are the way back out now, so it is free to show what was asked about. And bucket size is chosen by how many bars it makes rather than by fixed cut-offs. Each zoom step halves the span, so under thresholds the bar count halved with it until a boundary was crossed: fifteen years went 15 bars, 8, then 46, 23, 11, and finally 6. Zooming in made the picture coarser, which is the opposite of what zooming is for. Aiming at forty bars keeps the count in the same neighbourhood at every level, and the test asserts the property directly — halving a span never coarsens the bucket. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1098,6 +1098,19 @@ export component LibraryGrid inherits Rectangle {
|
||||
/// Whether the grid is narrowed to the timeline's visible span.
|
||||
in property <bool> range-active: false;
|
||||
callback toggle-date-range();
|
||||
/// TRACES: FR-CAT-6
|
||||
/// The ends of the range, as `YYYY-MM-DD`, when one is set.
|
||||
///
|
||||
/// Strings rather than instants because this is what the user types and
|
||||
/// what they read back. Rust parses them and refuses what is not a date;
|
||||
/// `range-invalid` is how that refusal reaches the field, since a filter
|
||||
/// that silently ignored a typo would show an empty grid and no reason.
|
||||
in property <string> range-from;
|
||||
in property <string> range-to;
|
||||
in property <bool> range-invalid: false;
|
||||
/// Both ends at once: they are one range, and applying half of an edit
|
||||
/// would filter to a span the user never asked for.
|
||||
callback range-edited(string, string);
|
||||
|
||||
/// How many images are selected, for the header's count.
|
||||
in property <int> selected-count: 0;
|
||||
@@ -1732,6 +1745,51 @@ export component LibraryGrid inherits Rectangle {
|
||||
clicked => { root.toggle-date-range(); }
|
||||
}
|
||||
|
||||
// The ends, once there is a range to have ends.
|
||||
//
|
||||
// Turning the chip on used to be the whole control, and it
|
||||
// took its span from the timeline's zoom — which is zero until
|
||||
// you zoom, so the range came out as the entire library and
|
||||
// the button appeared to do nothing at all. The span is now
|
||||
// *shown*, and can be typed, so "limit to range" always
|
||||
// narrows to something a person chose.
|
||||
//
|
||||
// Still seeded from the timeline: zooming to a fortnight and
|
||||
// pressing the chip is the fast path, and these fields say
|
||||
// which fortnight it landed on.
|
||||
if root.range-active: HorizontalLayout {
|
||||
spacing: Theme.gap-sm;
|
||||
|
||||
Field {
|
||||
width: 108px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
text: root.range-from;
|
||||
placeholder: "YYYY-MM-DD";
|
||||
accepted(t) => { root.range-edited(t, root.range-to); }
|
||||
}
|
||||
|
||||
Caption {
|
||||
text: "to";
|
||||
vertical-alignment: center;
|
||||
}
|
||||
|
||||
Field {
|
||||
width: 108px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
text: root.range-to;
|
||||
placeholder: "YYYY-MM-DD";
|
||||
accepted(t) => { root.range-edited(root.range-from, t); }
|
||||
}
|
||||
|
||||
// Says which end is wrong is beyond a caption, but saying
|
||||
// that *something* is beats an empty grid with no reason.
|
||||
if root.range-invalid: Caption {
|
||||
text: "not a date";
|
||||
warn: true;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
|
||||
// What the filter is currently hiding. Without this a narrowed
|
||||
|
||||
Reference in New Issue
Block a user