diff --git a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookGridSettingsManager.cs b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookGridSettingsManager.cs index 96812b756..542a7fc3e 100644 --- a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookGridSettingsManager.cs +++ b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookGridSettingsManager.cs @@ -16,6 +16,9 @@ namespace bts.shell.orderbook { class OrderBookGridSettingsManager : IDisposable, IObserver { public static readonly IReadOnlyDictionary hard_column_flags; + readonly IObserver _core_man_as_observer; + AlgoTreeDisplayMode _algo_tree_display_mode; + static OrderBookGridSettingsManager() { // make font-weight immutable for all columns (the font-weight rule is hard-coded: Regular for root-orders, Light for all others) // TODO: Remove the immutable font-weight flags when cell animation is ready @@ -24,14 +27,12 @@ namespace bts.shell.orderbook { // make font-color immutable for Side, Size, and Filled columns (the font-color rule is hard-coded: MarketData.bid for Buy orders, MarketData.ask for Sells) // TODO: Remove the immutable font-color flags when cell animation is ready foreach (var c in new[] { Columns.Side, Columns.Size, Columns.Filled }) { - col_settings_flags[c.ToString()] = GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableFontWeight; + col_settings_flags[c.ToString()] |= GridColumnSettingsFeatureFlags.ImmutableFontWeight; } + col_settings_flags[Columns.Commit.ToString()] |= GridColumnSettingsFeatureFlags.ImmutableHeader; hard_column_flags = col_settings_flags; } - readonly IObserver _core_man_as_observer; - AlgoTreeDisplayMode _algo_tree_display_mode; - public OrderBookGridSettingsManager( IObservable owner_title, IBus bus, diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index 41d264e22..c8aac5300 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -46,6 +46,7 @@ namespace mbts.spark { HorizontalAlignment _horizontal_alignment = HorizontalAlignment.Left; bool _is_visible, + _can_override_display_name = true, _can_override_font_color = true, _is_font_color_overridden, _can_override_font_weight = true, @@ -63,10 +64,12 @@ namespace mbts.spark { } public string id { get => _id; private set => Set(ref _id, value); } - public string display_name { get => _display_name; set => Set(ref _display_name, value); } public double width { get => _width; set => Set(ref _width, value); } public HorizontalAlignment horizontal_alignment { get => _horizontal_alignment; set => Set(ref _horizontal_alignment, value); } public bool is_visible { get => _is_visible; set => Set(ref _is_visible, value); } + // display name + public bool can_override_display_name { get => _can_override_display_name; private set => Set(ref _can_override_display_name, value); } + public string display_name { get => _display_name; set => Set(ref _display_name, value); } // font color override public bool can_override_font_color { get => _can_override_font_color; private set => Set(ref _can_override_font_color, value); } public bool is_font_color_overridden { get => _is_font_color_overridden; set => Set(ref _is_font_color_overridden, value); } @@ -79,7 +82,10 @@ namespace mbts.spark { public ObservableEditableCollection predicate_animations { get; } public (GridColumnSettings settings, ILookup animations) create() { - var settings = _settings.with(display_name, is_visible, null, + var settings = _settings.with( + can_override_display_name ? display_name : null, + is_visible, + null, is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : default, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : default, width, @@ -113,6 +119,10 @@ namespace mbts.spark { } public void apply_flags(GridColumnSettingsFeatureFlags flags) { + // display name + can_override_display_name = (flags & GridColumnSettingsFeatureFlags.ImmutableHeader) == 0; + if (!can_override_display_name) + display_name = id; // font color can_override_font_color = (flags & GridColumnSettingsFeatureFlags.ImmutableFontColor) == 0; is_font_color_overridden &= can_override_font_color; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml index 88fd35b7f..c76b27847 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml @@ -550,13 +550,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + - + @@ -576,7 +598,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -594,7 +638,7 @@ Header - + Width Horizontal Alignment diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml.cs index d9d1eb004..80f3b0708 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsView.xaml.cs @@ -11,6 +11,10 @@ namespace mbts.ui.spark { /// Interaction logic for GridSettingsView.xaml /// partial class GridSettingsView : UserControl { + public static readonly IValueConverter + DisplayNameVisualStateConverter = ValueConverter.create(can_override => can_override ? VisualStateNames.DisplayName.Active : VisualStateNames.DisplayName.Inactive), + ColumnVisibilityToggleVisualStateConverter = ValueConverter.create(can_override => can_override ? VisualStateNames.ColumnVisibilityToggle.Active : VisualStateNames.ColumnVisibilityToggle.Inactive); + public GridSettingsView() => InitializeComponent(); @@ -38,6 +42,24 @@ namespace mbts.ui.spark { ValueConverter.create((id, header) => id == header ? Visibility.Collapsed : Visibility.Visible); public bool EnableSoundTriggers { get; set; } + + public static class VisualStateNames { + public static class DisplayName { + public const string GroupName = nameof(DisplayName); + + public static readonly string + Active = $"{GroupName}{VisualStates.Active}", + Inactive = $"{GroupName}{VisualStates.Inactive}"; + } + + public static class ColumnVisibilityToggle { + public const string GroupName = nameof(ColumnVisibilityToggle); + + public static readonly string + Active = $"{GroupName}{VisualStates.Active}", + Inactive = $"{GroupName}{VisualStates.Inactive}"; + } + } } static class PredicateTemplateKeys { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs index 6e7b4e4f6..4ab50812d 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/ImmutableColumnSettingsStore.cs @@ -12,6 +12,9 @@ namespace mbts.ui { public static ImmutableColumnSettingStore create(GridColumnSettingsFeatureFlags flags) { var stores_per_flag = new List(); + if ((flags & GridColumnSettingsFeatureFlags.ImmutableHeader) != 0) { + stores_per_flag.Add(new ImmutableHeaderOverrideStore()); + } if ((flags & GridColumnSettingsFeatureFlags.ImmutableFontColor) != 0) { stores_per_flag.Add(new ImmutableFontColorOverrideStore()); } @@ -24,6 +27,19 @@ namespace mbts.ui { public abstract GridColumnSettings apply(GridColumnSettings settings); public abstract void store(GridColumnSettings settings); + class ImmutableHeaderOverrideStore : ImmutableColumnSettingStore { + string _header; + + public ImmutableHeaderOverrideStore() + : base(GridColumnSettingsFeatureFlags.ImmutableHeader) { } + + public override GridColumnSettings apply(GridColumnSettings settings) => + settings.with(display_name: _header); + + public override void store(GridColumnSettings settings) => + _header = settings.display_name; + } + class ImmutableFontColorOverrideStore : ImmutableColumnSettingStore { NullableColorProto _value; @@ -69,4 +85,4 @@ namespace mbts.ui { } } } -} +} \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs index e0a9c2671..407f5b2d4 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridColumnSettingsVM.cs @@ -17,6 +17,7 @@ namespace mbts.spark { HorizontalAlignment _horizontal_alignment = HorizontalAlignment.Left; bool _is_visible, + _can_override_display_name = true, _can_override_font_color = true, _is_font_color_overridden, _can_override_font_weight = true, @@ -28,10 +29,12 @@ namespace mbts.spark { this.owner = owner; public string id { get => _id; private set => Set(ref _id, value); } - public string display_name { get => _display_name; set => Set(ref _display_name, value); } public double width { get => _width; set => Set(ref _width, value); } public HorizontalAlignment horizontal_alignment { get => _horizontal_alignment; set => Set(ref _horizontal_alignment, value); } public bool is_visible { get => _is_visible; set => Set(ref _is_visible, value); } + // display name + public bool can_override_display_name { get => _can_override_display_name; private set => Set(ref _can_override_display_name, value); } + public string display_name { get => _display_name; set => Set(ref _display_name, value); } // font color override public bool can_override_font_color { get => _can_override_font_color; private set => Set(ref _can_override_font_color, value); } public bool is_font_color_overridden { get => _is_font_color_overridden; set => Set(ref _is_font_color_overridden, value); } @@ -42,7 +45,10 @@ namespace mbts.spark { public FontWeight font_weight_override { get => _font_weight_override; set => Set(ref _font_weight_override, value); } public GridColumnSettings create() => - _settings.with(display_name, is_visible, null, + _settings.with( + can_override_display_name ? display_name : null, + is_visible, + null, is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : (NullableFontWeightProto?)null, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : (NullableColorProto?)null, width, @@ -68,6 +74,10 @@ namespace mbts.spark { } public void apply_flags(GridColumnSettingsFeatureFlags flags) { + // display name + can_override_display_name = (flags & GridColumnSettingsFeatureFlags.ImmutableHeader) == 0; + if (!can_override_display_name) + display_name = id; // font color can_override_font_color = (flags & GridColumnSettingsFeatureFlags.ImmutableFontColor) == 0; is_font_color_overridden &= can_override_font_color;