-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order enum settings according to enum values #8784
Conversation
@cinnamon-msft Are all of these in the order you want? Or should I reorder any of them? I could introduce custom ordering, if you want. |
@msftbot make sure @DHowett signs off on this |
Hello @zadjii-msft! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
I'm tagging Dustin here, for the issue we discussed about sorting |
I don't mind this that much. Fortunately we're not stashing a copy. The vector is created, sorted, and then |
std::sort(begin(name##List), end(name##List), EnumEntryComparator<enumType>()); \ | ||
_##name##List = winrt::single_threaded_observable_vector<winrt::Microsoft::Terminal::Settings::Editor::EnumEntry>(std::move(name##List)); | ||
|
||
#define INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(name, enumMappingsName, enumType, resourceSectionAndType, resourceProperty) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure that we could refactor these macros so there was one base macro that could sort either direction, and then INITIALIZE_BINDABLE_ENUM_SETTING
and INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER
would just pass the correct arg to the base macro, but ¯\_(ツ)_/¯
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Sorts the list of `EnumEntry`s that is used to create combo boxes and radio buttons in the Settings UI. `INITIALIZE_BINDABLE_ENUM_SETTING` sorts the list in increasing order of the enum values, whereas `INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER` does so in decreasing order. ## References microsoft#6800 - Settings UI Epic I attempted sorting the `IObservableVector<EnumEntry>` using `std::sort`, but I would get an error in `winrt::Windows::Foundation::swap` (`C2665`). So instead, I did the following approach: - (unchanged) we're converting the `IMap` from EnumMappings into (1) a map of localized strings and (2) the list for XAML controls - instead of storing `EnumEntry`s to the `IObservableVector` directly, store it to a `std::vector` - sort the vector using `std::sort` - _now_ initialize the `IObservableVector` using the sorted `std::vector` This uses the value of the associated enum to determine a sorting order. Since we want the "negative" value (i.e. "none" or "hidden") to be last, I use `EnumEntryComparator` and `EnumEntryReverseComparator` to determine whether we want increasing or decreasing order respectively. `INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER` is a copy of `INITIALIZE_BINDABLE_ENUM_SETTING`, except it uses `EnumEntryReverseComparator` to sort in decreasing order. Closes microsoft#8758
Sorts the list of
EnumEntry
s that is used to create combo boxes andradio buttons in the Settings UI.
INITIALIZE_BINDABLE_ENUM_SETTING
sorts the list in increasing order of the enum values, whereas
INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER
does so in decreasingorder.
References
#6800 - Settings UI Epic
I attempted sorting the
IObservableVector<EnumEntry>
usingstd::sort
, but I would get an error inwinrt::Windows::Foundation::swap
(C2665
). So instead, I did thefollowing approach:
IMap
from EnumMappings into (1) amap of localized strings and (2) the list for XAML controls
EnumEntry
s to theIObservableVector
directly,store it to a
std::vector
std::sort
IObservableVector
using the sortedstd::vector
This uses the value of the associated enum to determine a sorting order.
Since we want the "negative" value (i.e. "none" or "hidden") to be last,
I use
EnumEntryComparator
andEnumEntryReverseComparator
todetermine whether we want increasing or decreasing order respectively.
INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER
is a copy ofINITIALIZE_BINDABLE_ENUM_SETTING
, except it usesEnumEntryReverseComparator
to sort in decreasing order.Closes #8758