public override int CompareTo(FilterCriteria criteria, CarouselItem other) { if (!(other is CarouselBeatmapSet otherSet)) { return(base.CompareTo(criteria, other)); } switch (criteria.Sort) { default: case SortMode.Artist: return(string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase)); case SortMode.Title: return(string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase)); case SortMode.Author: return(string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase)); case SortMode.DateAdded: return(otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded)); case SortMode.BPM: return(compareUsingAggregateMax(otherSet, b => b.BPM)); case SortMode.Length: return(compareUsingAggregateMax(otherSet, b => b.Length)); case SortMode.Difficulty: return(compareUsingAggregateMax(otherSet, b => b.StarDifficulty)); } }
private void attemptSelection() { if (filteringChildren) { return; } // we only perform eager selection if we are a currently selected group. if (State != CarouselItemState.Selected) { return; } // we only perform eager selection if none of our children are in a selected state already. if (Children.Any(i => i.State == CarouselItemState.Selected)) { return; } CarouselItem nextToSelect = Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ?? Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered); if (nextToSelect != null) { nextToSelect.State.Value = CarouselItemState.Selected; } else { updateSelected(null); } }
protected DrawableCarouselItem(CarouselItem item) { Item = item; Height = MAX_HEIGHT; RelativeSizeAxes = Axes.X; Alpha = 0; }
public override void AddChild(CarouselItem i) { base.AddChild(i); if (!addingChildren) { attemptSelection(); } }
public virtual void RemoveChild(CarouselItem i) { InternalChildren.Remove(i); // it's important we do the deselection after removing, so any further actions based on // State.ValueChanged make decisions post-removal. i.State.Value = CarouselItemState.Collapsed; }
private void updateSelected(CarouselItem newSelection) { if (newSelection != null) { LastSelected = newSelection; } updateSelectedIndex(); }
public override void RemoveChild(CarouselItem i) { base.RemoveChild(i); if (i != LastSelected) { updateSelectedIndex(); } }
protected virtual void PerformSelection() { CarouselItem nextToSelect = GetNextToSelect(); if (nextToSelect != null) { nextToSelect.State.Value = CarouselItemState.Selected; } else { updateSelected(null); } }
protected virtual void PerformSelection() { CarouselItem nextToSelect = Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ?? Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value); if (nextToSelect != null) { nextToSelect.State.Value = CarouselItemState.Selected; } else { updateSelected(null); } }
protected override void ChildItemStateChanged(CarouselItem item, CarouselItemState value) { base.ChildItemStateChanged(item, value); switch (value) { case CarouselItemState.Selected: updateSelected(item); break; case CarouselItemState.NotSelected: case CarouselItemState.Collapsed: attemptSelection(); break; } }
protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value) { // ensure we are the only item selected if (value == CarouselItemState.Selected) { foreach (var b in InternalChildren) { if (item == b) { continue; } b.State.Value = CarouselItemState.NotSelected; } State.Value = CarouselItemState.Selected; } }
public override int CompareTo(FilterCriteria criteria, CarouselItem other) { if (!(other is CarouselBeatmap otherBeatmap)) { return(base.CompareTo(criteria, other)); } switch (criteria.Sort) { default: case SortMode.Difficulty: var ruleset = Beatmap.RulesetID.CompareTo(otherBeatmap.Beatmap.RulesetID); if (ruleset != 0) { return(ruleset); } return(Beatmap.StarDifficulty.CompareTo(otherBeatmap.Beatmap.StarDifficulty)); } }
public virtual void AddChild(CarouselItem i) { i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue); i.ChildID = ++currentChildID; if (lastCriteria != null) { i.Filter(lastCriteria); int index = InternalChildren.BinarySearch(i, criteriaComparer); if (index < 0) { index = ~index; // BinarySearch hacks multiple return values with 2's complement. } InternalChildren.Insert(index, i); } else { // criteria may be null for initial population. the filtering will be applied post-add. InternalChildren.Add(i); } }
public override int CompareTo(FilterCriteria criteria, CarouselItem other) { if (!(other is CarouselBeatmapSet otherSet)) { return(base.CompareTo(criteria, other)); } switch (criteria.Sort) { default: case SortMode.Artist: return(string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase)); case SortMode.Title: return(string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase)); case SortMode.Author: return(string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase)); case SortMode.Difficulty: return(BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty)); } }
public virtual void AddChild(CarouselItem i) { i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue); i.ChildID = ++currentChildID; InternalChildren.Add(i); }
public virtual void AddChild(CarouselItem i) { i.State.ValueChanged += v => ChildItemStateChanged(i, v); InternalChildren.Add(i); }
private void updateSelected(CarouselItem newSelection) { LastSelected = newSelection; updateSelectedIndex(); }
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => GetHashCode().CompareTo(other.GetHashCode());
public override void AddChild(CarouselItem i) { base.AddChild(i); attemptSelection(); }